Spaces:
Sleeping
Sleeping
cyberosa
commited on
Commit
·
57800c5
1
Parent(s):
1c5e001
trying single agent again
Browse files
agents.py
CHANGED
@@ -20,7 +20,7 @@ gemini_api_key = os.environ.get("GEMINI_API_KEY", None)
|
|
20 |
open_router_api_key = os.environ.get("OPENROUTER_API_KEY", None)
|
21 |
gemini_model = LiteLLMModel(
|
22 |
# model_id="gemini/gemini-2.0-flash",
|
23 |
-
model_id="gemini/gemini-2.
|
24 |
api_key=gemini_api_key,
|
25 |
tools=[google_search_tool],
|
26 |
)
|
@@ -39,14 +39,14 @@ python_tool = PythonInterpreterTool()
|
|
39 |
visit_webpage_tool = VisitWebpageTool()
|
40 |
my_search_tool = MySearchTool()
|
41 |
|
42 |
-
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
|
51 |
|
52 |
class SkynetMultiAgent:
|
@@ -57,16 +57,9 @@ class SkynetMultiAgent:
|
|
57 |
name="web_search_agent",
|
58 |
description="""
|
59 |
This agent has access to Google Search to search for information about a specific topic.
|
60 |
-
|
61 |
-
IMPORTANT: This agent MUST use the built-in Google Search capability to find accurate and up-to-date information.
|
62 |
-
DO NOT respond that you cannot access external websites or APIs.
|
63 |
-
DO NOT claim you are unable to search the web.
|
64 |
-
This agent is specifically configured with Google Search capability.
|
65 |
-
|
66 |
-
It provides a comprehensive answer based on the search results.
|
67 |
-
Includes relevant facts, figures, and details.
|
68 |
""",
|
69 |
max_steps=2,
|
|
|
70 |
)
|
71 |
self.agent = CodeAgent(
|
72 |
tools=[],
|
@@ -74,7 +67,7 @@ class SkynetMultiAgent:
|
|
74 |
name="manager_agent",
|
75 |
description="Manages the web agents and it runs code.",
|
76 |
managed_agents=[web_agent],
|
77 |
-
|
78 |
max_steps=2,
|
79 |
)
|
80 |
|
@@ -96,10 +89,11 @@ class SkynetMultiAgent:
|
|
96 |
class SkynetSingleAgent:
|
97 |
def __init__(self):
|
98 |
self.agent = ToolCallingAgent(
|
99 |
-
tools=[
|
100 |
model=gemini_model,
|
101 |
name="skynet_agent",
|
102 |
-
description="Agent to answer questions and
|
|
|
103 |
# additional_authorized_imports=[
|
104 |
# "time",
|
105 |
# "numpy",
|
|
|
20 |
open_router_api_key = os.environ.get("OPENROUTER_API_KEY", None)
|
21 |
gemini_model = LiteLLMModel(
|
22 |
# model_id="gemini/gemini-2.0-flash",
|
23 |
+
model_id="gemini/gemini-2.0-flash-001",
|
24 |
api_key=gemini_api_key,
|
25 |
tools=[google_search_tool],
|
26 |
)
|
|
|
39 |
visit_webpage_tool = VisitWebpageTool()
|
40 |
my_search_tool = MySearchTool()
|
41 |
|
42 |
+
with open("prompts.yaml", "r") as stream:
|
43 |
+
prompt_templates = yaml.safe_load(stream)
|
44 |
|
45 |
+
prompt_templates["final_answer"] = {
|
46 |
+
"pre_messages": "",
|
47 |
+
"final_answer": "Here is the final answer from your managed agent '{{name}}':\n{{final_answer}}",
|
48 |
+
"post_messages": "",
|
49 |
+
}
|
50 |
|
51 |
|
52 |
class SkynetMultiAgent:
|
|
|
57 |
name="web_search_agent",
|
58 |
description="""
|
59 |
This agent has access to Google Search to search for information about a specific topic.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
""",
|
61 |
max_steps=2,
|
62 |
+
prompt_templates=prompt_templates,
|
63 |
)
|
64 |
self.agent = CodeAgent(
|
65 |
tools=[],
|
|
|
67 |
name="manager_agent",
|
68 |
description="Manages the web agents and it runs code.",
|
69 |
managed_agents=[web_agent],
|
70 |
+
prompt_templates=prompt_templates,
|
71 |
max_steps=2,
|
72 |
)
|
73 |
|
|
|
89 |
class SkynetSingleAgent:
|
90 |
def __init__(self):
|
91 |
self.agent = ToolCallingAgent(
|
92 |
+
tools=[],
|
93 |
model=gemini_model,
|
94 |
name="skynet_agent",
|
95 |
+
description="Agent to answer questions and to search in the web using google search tool",
|
96 |
+
prompt_templates=prompt_templates,
|
97 |
# additional_authorized_imports=[
|
98 |
# "time",
|
99 |
# "numpy",
|
app.py
CHANGED
@@ -31,8 +31,8 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
31 |
|
32 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
33 |
try:
|
34 |
-
agent = SkynetMultiAgent()
|
35 |
-
|
36 |
print(f"Agent instantiated successfully: {agent}")
|
37 |
except Exception as e:
|
38 |
print(f"Error instantiating agent: {e}")
|
|
|
31 |
|
32 |
# 1. Instantiate Agent ( modify this part to create your agent)
|
33 |
try:
|
34 |
+
# agent = SkynetMultiAgent()
|
35 |
+
agent = SkynetSingleAgent()
|
36 |
print(f"Agent instantiated successfully: {agent}")
|
37 |
except Exception as e:
|
38 |
print(f"Error instantiating agent: {e}")
|