Update app.py
Browse filesfixed api key issues
app.py
CHANGED
@@ -25,12 +25,21 @@ class GaiaLangGraphAgent:
|
|
25 |
print("Initializing GaiaLangGraphAgent...")
|
26 |
load_dotenv()
|
27 |
|
|
|
|
|
|
|
|
|
28 |
class AgentState(TypedDict):
|
29 |
question: str
|
30 |
intermediate_steps: Annotated[List[BaseMessage], operator.add]
|
31 |
self.AgentState = AgentState
|
32 |
|
33 |
-
web_search_tool = TavilySearchResults(
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
@tool
|
36 |
def calculator(expression: str) -> str:
|
@@ -40,7 +49,7 @@ class GaiaLangGraphAgent:
|
|
40 |
return str(numexpr.evaluate(expression).item())
|
41 |
except Exception as e: return f"Error: {e}"
|
42 |
|
43 |
-
llm_vision = ChatGoogleGenerativeAI(model="gemini-
|
44 |
|
45 |
def get_file_path(file_name: str) -> str:
|
46 |
if not os.path.exists("task_files"): os.makedirs("task_files")
|
|
|
25 |
print("Initializing GaiaLangGraphAgent...")
|
26 |
load_dotenv()
|
27 |
|
28 |
+
google_api_key = os.getenv("GOOGLE_API_KEY")
|
29 |
+
if not google_api_key:
|
30 |
+
raise ValueError("GOOGLE_API_KEY secret not found. Please set it in your Hugging Face Space settings.")
|
31 |
+
|
32 |
class AgentState(TypedDict):
|
33 |
question: str
|
34 |
intermediate_steps: Annotated[List[BaseMessage], operator.add]
|
35 |
self.AgentState = AgentState
|
36 |
|
37 |
+
web_search_tool = TavilySearchResults(
|
38 |
+
tavily_api_key=os.getenv("TAVILY_API_KEY"),
|
39 |
+
search_engine="google",
|
40 |
+
max_results=3,
|
41 |
+
return_direct=True,
|
42 |
+
)
|
43 |
|
44 |
@tool
|
45 |
def calculator(expression: str) -> str:
|
|
|
49 |
return str(numexpr.evaluate(expression).item())
|
50 |
except Exception as e: return f"Error: {e}"
|
51 |
|
52 |
+
llm_vision = ChatGoogleGenerativeAI(model="gemini-2.5-pro-preview-06-05", google_api_key=google_api_key)
|
53 |
|
54 |
def get_file_path(file_name: str) -> str:
|
55 |
if not os.path.exists("task_files"): os.makedirs("task_files")
|