Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,9 +38,9 @@ if TAVILY_API_KEY:
|
|
| 38 |
else:
|
| 39 |
print("Warning: TAVILY_API_KEY not found in .env file. TavilySearchResults tool will not be available.")
|
| 40 |
|
| 41 |
-
wikipedia_tool = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper(top_k_results=
|
| 42 |
tools.append(wikipedia_tool)
|
| 43 |
-
arxiv_tool = ArxivQueryRun(api_wrapper=ArxivAPIWrapper(top_k_results=
|
| 44 |
tools.append(arxiv_tool)
|
| 45 |
|
| 46 |
# --- LangGraph Agent Definition ---
|
|
@@ -127,7 +127,7 @@ class LangGraphAgent:
|
|
| 127 |
return {"messages": tool_messages}
|
| 128 |
|
| 129 |
def __call__(self, question: str) -> str:
|
| 130 |
-
print(f"Agent received question (first 50 chars): {question[:
|
| 131 |
initial_state = {"messages": [HumanMessage(content=question)]}
|
| 132 |
|
| 133 |
# The GAIA prompt example suggests not including "FINAL ANSWER" and just replying with the answer.
|
|
@@ -137,7 +137,7 @@ class LangGraphAgent:
|
|
| 137 |
|
| 138 |
final_graph_state = None
|
| 139 |
try:
|
| 140 |
-
for event in self.graph.stream(initial_state, {"recursion_limit":
|
| 141 |
# print(f"Graph event: {event}") # For debugging stream
|
| 142 |
if END in event:
|
| 143 |
final_graph_state = event[END]
|
|
|
|
| 38 |
else:
|
| 39 |
print("Warning: TAVILY_API_KEY not found in .env file. TavilySearchResults tool will not be available.")
|
| 40 |
|
| 41 |
+
wikipedia_tool = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper(top_k_results=10, doc_content_chars_max=2000))
|
| 42 |
tools.append(wikipedia_tool)
|
| 43 |
+
arxiv_tool = ArxivQueryRun(api_wrapper=ArxivAPIWrapper(top_k_results=10, doc_content_chars_max=2000))
|
| 44 |
tools.append(arxiv_tool)
|
| 45 |
|
| 46 |
# --- LangGraph Agent Definition ---
|
|
|
|
| 127 |
return {"messages": tool_messages}
|
| 128 |
|
| 129 |
def __call__(self, question: str) -> str:
|
| 130 |
+
print(f"Agent received question (first 50 chars): {question[:100]}...")
|
| 131 |
initial_state = {"messages": [HumanMessage(content=question)]}
|
| 132 |
|
| 133 |
# The GAIA prompt example suggests not including "FINAL ANSWER" and just replying with the answer.
|
|
|
|
| 137 |
|
| 138 |
final_graph_state = None
|
| 139 |
try:
|
| 140 |
+
for event in self.graph.stream(initial_state, {"recursion_limit": 100}): # Added recursion limit
|
| 141 |
# print(f"Graph event: {event}") # For debugging stream
|
| 142 |
if END in event:
|
| 143 |
final_graph_state = event[END]
|