Spaces:
Sleeping
Sleeping
Switched to using Google gemini-2.0-flash
Browse files
app.py
CHANGED
@@ -34,10 +34,15 @@ class BasicAgent:
|
|
34 |
print("BasicAgent initialized.")
|
35 |
|
36 |
# Initialize the agent with a model and tools
|
|
|
|
|
|
|
|
|
|
|
37 |
model = OpenAIServerModel(
|
38 |
model_id=os.environ["MODEL_ID"],
|
39 |
-
api_base="https://
|
40 |
-
api_key=os.environ["
|
41 |
)
|
42 |
|
43 |
web_agent = ToolCallingAgent(
|
@@ -49,15 +54,6 @@ class BasicAgent:
|
|
49 |
description="This agent can search the web and visit webpages to gather information.",
|
50 |
)
|
51 |
|
52 |
-
python_agent = ToolCallingAgent(
|
53 |
-
verbosity_level=1,
|
54 |
-
tools=[PythonInterpreterTool()],
|
55 |
-
max_steps=5,
|
56 |
-
model=model,
|
57 |
-
name="python_agent",
|
58 |
-
description="This agent can run Python code snippets.",
|
59 |
-
)
|
60 |
-
|
61 |
stt_agent = ToolCallingAgent(
|
62 |
verbosity_level=1,
|
63 |
tools=[SpeechToTextTool()],
|
@@ -70,8 +66,7 @@ class BasicAgent:
|
|
70 |
manager_agent = CodeAgent(
|
71 |
tools=[],
|
72 |
model=model,
|
73 |
-
managed_agents=[web_agent, stt_agent
|
74 |
-
# managed_agents=[web_agent],
|
75 |
additional_authorized_imports=["time", "numpy", "pandas"],
|
76 |
)
|
77 |
|
@@ -92,11 +87,11 @@ class BasicAgent:
|
|
92 |
answer = self.agent.run(system_prompt + question, images=[image_bytes])
|
93 |
elif file_type == "audio":
|
94 |
arguments = {"audio": file_name}
|
95 |
-
answer = self.agent.run(system_prompt + question,
|
96 |
elif file_type == "python":
|
97 |
with open(file_name, "r") as file:
|
98 |
python_code = file.read()
|
99 |
-
answer = self.agent.run(system_prompt + question, code
|
100 |
else:
|
101 |
answer = self.agent.run(system_prompt + question)
|
102 |
|
@@ -169,10 +164,9 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
169 |
question_text = item.get("question")
|
170 |
file_name = item.get("file_name")
|
171 |
file_type = "unknown"
|
172 |
-
print(f"Fetching file content '{file_name}' for task ID: {task_id}")
|
173 |
|
174 |
if file_name:
|
175 |
-
print(f"Fetching file content for task ID: {task_id}")
|
176 |
try:
|
177 |
file_url = f"{api_url}/files/{task_id}"
|
178 |
file_response = requests.get(file_url, timeout=15)
|
|
|
34 |
print("BasicAgent initialized.")
|
35 |
|
36 |
# Initialize the agent with a model and tools
|
37 |
+
# model = OpenAIServerModel(
|
38 |
+
# model_id=os.environ["MODEL_ID"],
|
39 |
+
# api_base="https://api.openai.com/v1",
|
40 |
+
# api_key=os.environ["OPENAI_API_KEY"],
|
41 |
+
# )
|
42 |
model = OpenAIServerModel(
|
43 |
model_id=os.environ["MODEL_ID"],
|
44 |
+
api_base="https://generativelanguage.googleapis.com/v1beta/openai/",
|
45 |
+
api_key=os.environ["GEMINI_API_KEY"],
|
46 |
)
|
47 |
|
48 |
web_agent = ToolCallingAgent(
|
|
|
54 |
description="This agent can search the web and visit webpages to gather information.",
|
55 |
)
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
stt_agent = ToolCallingAgent(
|
58 |
verbosity_level=1,
|
59 |
tools=[SpeechToTextTool()],
|
|
|
66 |
manager_agent = CodeAgent(
|
67 |
tools=[],
|
68 |
model=model,
|
69 |
+
managed_agents=[web_agent, stt_agent],
|
|
|
70 |
additional_authorized_imports=["time", "numpy", "pandas"],
|
71 |
)
|
72 |
|
|
|
87 |
answer = self.agent.run(system_prompt + question, images=[image_bytes])
|
88 |
elif file_type == "audio":
|
89 |
arguments = {"audio": file_name}
|
90 |
+
answer = self.agent.run(system_prompt + question, additional_args=arguments)
|
91 |
elif file_type == "python":
|
92 |
with open(file_name, "r") as file:
|
93 |
python_code = file.read()
|
94 |
+
answer = self.agent.run(system_prompt + question, additional_args={"code": python_code})
|
95 |
else:
|
96 |
answer = self.agent.run(system_prompt + question)
|
97 |
|
|
|
164 |
question_text = item.get("question")
|
165 |
file_name = item.get("file_name")
|
166 |
file_type = "unknown"
|
|
|
167 |
|
168 |
if file_name:
|
169 |
+
print(f"Fetching file content '{file_name}' for task ID: {task_id}")
|
170 |
try:
|
171 |
file_url = f"{api_url}/files/{task_id}"
|
172 |
file_response = requests.get(file_url, timeout=15)
|