gemini
Browse files
agent.py
CHANGED
@@ -4,7 +4,6 @@ import json
|
|
4 |
import requests
|
5 |
import pandas as pd
|
6 |
from huggingface_hub import InferenceClient
|
7 |
-
from openai import OpenAI
|
8 |
|
9 |
class GetFileTool(Tool):
|
10 |
name = "get_file_tool"
|
@@ -127,38 +126,6 @@ class ImageAnalysisTool(Tool):
|
|
127 |
|
128 |
return completion.choices[0].message.content
|
129 |
|
130 |
-
class WebSearchPerplexityTool(Tool):
|
131 |
-
name = "web_search_perplexity_tool"
|
132 |
-
description = """This tool searches the web for information using Perplexity, try first to forward the entire question"""
|
133 |
-
inputs = {
|
134 |
-
"question": {"type": "string", "description": "Use the entire question at first and then iterate with follow-up questions"}
|
135 |
-
}
|
136 |
-
output_type = "string"
|
137 |
-
|
138 |
-
def forward(self, question: str) -> str:
|
139 |
-
messages = [
|
140 |
-
{
|
141 |
-
"role": "system",
|
142 |
-
"content": (
|
143 |
-
"Answer the question based on the information provided and following the instructions"
|
144 |
-
),
|
145 |
-
},
|
146 |
-
{
|
147 |
-
"role": "user",
|
148 |
-
"content": question,
|
149 |
-
},
|
150 |
-
]
|
151 |
-
|
152 |
-
client = OpenAI(api_key=os.getenv("PERPLEXITY_API_KEY"), base_url="https://api.perplexity.ai")
|
153 |
-
|
154 |
-
# chat completion without streaming
|
155 |
-
response = client.chat.completions.create(
|
156 |
-
model="sonar-pro",
|
157 |
-
messages=messages,
|
158 |
-
)
|
159 |
-
|
160 |
-
return response.choices[0].message.content
|
161 |
-
|
162 |
|
163 |
def final_answer_formatting(answer, question):
|
164 |
model = LiteLLMModel(
|
@@ -167,14 +134,7 @@ def final_answer_formatting(answer, question):
|
|
167 |
)
|
168 |
|
169 |
prompt = f"""
|
170 |
-
You are an AI assistant specialized in the GAIA benchmark. For the question provided, generate the answer in the exact format requested by the question. Do not include any other text
|
171 |
-
|
172 |
-
For example:
|
173 |
-
Question: "what is the capital of France ?"
|
174 |
-
Answer: "The capital of France is Paris. It is the largest city in France and serves as the country's political, cultural, and economic center. Paris has been the capital since its liberation in 1944, although it has held this status intermittently throughout French history"
|
175 |
-
Return: "Paris"
|
176 |
-
|
177 |
-
Your turn:
|
178 |
Question: {question}
|
179 |
Answer: {answer}
|
180 |
"""
|
@@ -223,15 +183,15 @@ audio_agent = CodeAgent(
|
|
223 |
manager_agent = CodeAgent(
|
224 |
name="manager_agent",
|
225 |
model=LiteLLMModel(
|
226 |
-
model_id="gemini/gemini-2.
|
227 |
api_key=os.getenv("GOOGLE_API_KEY"),
|
228 |
),
|
229 |
-
tools=[GetFileTool(), LoadXlsxFileTool(), LoadTextFileTool(), ImageAnalysisTool()
|
230 |
-
managed_agents=[audio_agent],
|
231 |
additional_authorized_imports=[
|
232 |
"pandas"
|
233 |
],
|
234 |
planning_interval=5,
|
235 |
verbosity_level=1,
|
236 |
max_steps=10,
|
237 |
-
)
|
|
|
4 |
import requests
|
5 |
import pandas as pd
|
6 |
from huggingface_hub import InferenceClient
|
|
|
7 |
|
8 |
class GetFileTool(Tool):
|
9 |
name = "get_file_tool"
|
|
|
126 |
|
127 |
return completion.choices[0].message.content
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
def final_answer_formatting(answer, question):
|
131 |
model = LiteLLMModel(
|
|
|
134 |
)
|
135 |
|
136 |
prompt = f"""
|
137 |
+
You are an AI assistant specialized in the GAIA benchmark. For the question provided, generate the answer in the exact format requested by the question. Do not include any other text or creative additions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
Question: {question}
|
139 |
Answer: {answer}
|
140 |
"""
|
|
|
183 |
manager_agent = CodeAgent(
|
184 |
name="manager_agent",
|
185 |
model=LiteLLMModel(
|
186 |
+
model_id="gemini/gemini-2.5-flash-preview-04-17",
|
187 |
api_key=os.getenv("GOOGLE_API_KEY"),
|
188 |
),
|
189 |
+
tools=[GetFileTool(), LoadXlsxFileTool(), LoadTextFileTool(), ImageAnalysisTool()],
|
190 |
+
managed_agents=[web_agent, audio_agent],
|
191 |
additional_authorized_imports=[
|
192 |
"pandas"
|
193 |
],
|
194 |
planning_interval=5,
|
195 |
verbosity_level=1,
|
196 |
max_steps=10,
|
197 |
+
)
|