Commit
·
8f43b5e
1
Parent(s):
6de65a0
model modification
Browse files- __pycache__/agent.cpython-310.pyc +0 -0
- agent.py +25 -18
- f918266a-b3e0-4914-865d-4faa564f1aef.py +35 -0
- requirements.txt +3 -1
__pycache__/agent.cpython-310.pyc
ADDED
|
Binary file (5.25 kB). View file
|
|
|
agent.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent, LiteLLMModel, DuckDuckGoSearchTool, WikipediaSearchTool, Tool, VisitWebpageTool
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
import requests
|
|
@@ -128,9 +128,9 @@ class ImageAnalysisTool(Tool):
|
|
| 128 |
|
| 129 |
|
| 130 |
def final_answer_formatting(answer, question):
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
api_key=os.getenv("
|
| 134 |
)
|
| 135 |
|
| 136 |
prompt = f"""
|
|
@@ -140,18 +140,27 @@ def final_answer_formatting(answer, question):
|
|
| 140 |
Answer: {answer}
|
| 141 |
"""
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
|
| 147 |
-
|
| 148 |
-
return output
|
| 149 |
|
| 150 |
|
| 151 |
web_agent = CodeAgent(
|
| 152 |
-
model=
|
| 153 |
-
model_id=
|
| 154 |
-
api_key=os.getenv("GOOGLE_API_KEY"),
|
| 155 |
),
|
| 156 |
tools=[
|
| 157 |
WikipediaSearchTool(),
|
|
@@ -169,9 +178,8 @@ web_agent = CodeAgent(
|
|
| 169 |
)
|
| 170 |
|
| 171 |
audio_agent = CodeAgent(
|
| 172 |
-
model=
|
| 173 |
-
model_id=
|
| 174 |
-
api_key=os.getenv("GOOGLE_API_KEY"),
|
| 175 |
),
|
| 176 |
tools=[AudioToTextTool()],
|
| 177 |
add_base_tools=False,
|
|
@@ -183,9 +191,8 @@ audio_agent = CodeAgent(
|
|
| 183 |
|
| 184 |
manager_agent = CodeAgent(
|
| 185 |
name="manager_agent",
|
| 186 |
-
model=
|
| 187 |
-
model_id=
|
| 188 |
-
api_key=os.getenv("GOOGLE_API_KEY"),
|
| 189 |
),
|
| 190 |
tools=[getFile(), LoadXlsxFileTool(), LoadTextFileTool(), ImageAnalysisTool()],
|
| 191 |
managed_agents=[web_agent, audio_agent],
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, LiteLLMModel, DuckDuckGoSearchTool, WikipediaSearchTool, Tool, VisitWebpageTool, HfApiModel
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
import requests
|
|
|
|
| 128 |
|
| 129 |
|
| 130 |
def final_answer_formatting(answer, question):
|
| 131 |
+
client = InferenceClient(
|
| 132 |
+
provider="nebius",
|
| 133 |
+
api_key=os.getenv("HF_API_KEY"),
|
| 134 |
)
|
| 135 |
|
| 136 |
prompt = f"""
|
|
|
|
| 140 |
Answer: {answer}
|
| 141 |
"""
|
| 142 |
|
| 143 |
+
completion = client.chat.completions.create(
|
| 144 |
+
model="mistralai/Mistral-Small-3.1-24B-Instruct-2503",
|
| 145 |
+
messages=[
|
| 146 |
+
{
|
| 147 |
+
"role": "user",
|
| 148 |
+
"content": [
|
| 149 |
+
{
|
| 150 |
+
"type": "text",
|
| 151 |
+
"text": prompt
|
| 152 |
+
}
|
| 153 |
+
]
|
| 154 |
+
}
|
| 155 |
+
],
|
| 156 |
+
)
|
| 157 |
|
| 158 |
+
return completion.choices[0].message.content
|
|
|
|
| 159 |
|
| 160 |
|
| 161 |
web_agent = CodeAgent(
|
| 162 |
+
model=HfApiModel(
|
| 163 |
+
model_id='Qwen/Qwen3-32B'
|
|
|
|
| 164 |
),
|
| 165 |
tools=[
|
| 166 |
WikipediaSearchTool(),
|
|
|
|
| 178 |
)
|
| 179 |
|
| 180 |
audio_agent = CodeAgent(
|
| 181 |
+
model=HfApiModel(
|
| 182 |
+
model_id='Qwen/Qwen3-32B'
|
|
|
|
| 183 |
),
|
| 184 |
tools=[AudioToTextTool()],
|
| 185 |
add_base_tools=False,
|
|
|
|
| 191 |
|
| 192 |
manager_agent = CodeAgent(
|
| 193 |
name="manager_agent",
|
| 194 |
+
model=HfApiModel(
|
| 195 |
+
model_id='Qwen/Qwen3-235B-A22B'
|
|
|
|
| 196 |
),
|
| 197 |
tools=[getFile(), LoadXlsxFileTool(), LoadTextFileTool(), ImageAnalysisTool()],
|
| 198 |
managed_agents=[web_agent, audio_agent],
|
f918266a-b3e0-4914-865d-4faa564f1aef.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from random import randint
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
class UhOh(Exception):
|
| 5 |
+
pass
|
| 6 |
+
|
| 7 |
+
class Hmm:
|
| 8 |
+
def __init__(self):
|
| 9 |
+
self.value = randint(-100, 100)
|
| 10 |
+
|
| 11 |
+
def Yeah(self):
|
| 12 |
+
if self.value == 0:
|
| 13 |
+
return True
|
| 14 |
+
else:
|
| 15 |
+
raise UhOh()
|
| 16 |
+
|
| 17 |
+
def Okay():
|
| 18 |
+
while True:
|
| 19 |
+
yield Hmm()
|
| 20 |
+
|
| 21 |
+
def keep_trying(go, first_try=True):
|
| 22 |
+
maybe = next(go)
|
| 23 |
+
try:
|
| 24 |
+
if maybe.Yeah():
|
| 25 |
+
return maybe.value
|
| 26 |
+
except UhOh:
|
| 27 |
+
if first_try:
|
| 28 |
+
print("Working...")
|
| 29 |
+
print("Please wait patiently...")
|
| 30 |
+
time.sleep(0.1)
|
| 31 |
+
return keep_trying(go, first_try=False)
|
| 32 |
+
|
| 33 |
+
if __name__ == "__main__":
|
| 34 |
+
go = Okay()
|
| 35 |
+
print(f"{keep_trying(go)}")
|
requirements.txt
CHANGED
|
@@ -4,4 +4,6 @@ pandas
|
|
| 4 |
openpyxl
|
| 5 |
huggingface-hub
|
| 6 |
smolagents
|
| 7 |
-
python-dotenv
|
|
|
|
|
|
|
|
|
| 4 |
openpyxl
|
| 5 |
huggingface-hub
|
| 6 |
smolagents
|
| 7 |
+
python-dotenv
|
| 8 |
+
litellm
|
| 9 |
+
wikipedia-api
|