Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,8 @@ import gradio as gr
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
-
|
|
|
7 |
|
8 |
# (Keep Constants as is)
|
9 |
# --- Constants ---
|
@@ -20,16 +21,26 @@ class BasicAgent:
|
|
20 |
)
|
21 |
self.agent = CodeAgent(
|
22 |
model = model,
|
23 |
-
tools=[GoogleSearchTool()],
|
24 |
add_base_tools=True, # Add any additional base tools
|
25 |
max_steps=15,
|
26 |
planning_interval=3 # Enable planning every 3 steps
|
27 |
)
|
28 |
-
def __call__(self, question: str) -> str:
|
29 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
30 |
-
fixed_answer = self.agent.run(question)
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
35 |
"""
|
|
|
3 |
import requests
|
4 |
import inspect
|
5 |
import pandas as pd
|
6 |
+
import asyncio
|
7 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, LiteLLMModel, GoogleSearchTool, WikipediaSearchTool
|
8 |
|
9 |
# (Keep Constants as is)
|
10 |
# --- Constants ---
|
|
|
21 |
)
|
22 |
self.agent = CodeAgent(
|
23 |
model = model,
|
24 |
+
tools=[GoogleSearchTool(), WikipediaSearchTool() ],
|
25 |
add_base_tools=True, # Add any additional base tools
|
26 |
max_steps=15,
|
27 |
planning_interval=3 # Enable planning every 3 steps
|
28 |
)
|
29 |
+
async def __call__(self, question: str) -> str:
|
30 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
31 |
+
# fixed_answer = self.agent.run(question)
|
32 |
+
response = await asyncio.to_thread(
|
33 |
+
self.agent.run,
|
34 |
+
question=question
|
35 |
+
)
|
36 |
+
|
37 |
+
# Ensure response is a string, fixing the integer error
|
38 |
+
response = str(response)
|
39 |
+
if response is None:
|
40 |
+
print(f"No answer found.")
|
41 |
+
|
42 |
+
print(f"Agent returning fixed answer: {response}")
|
43 |
+
return response
|
44 |
|
45 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
46 |
"""
|