Spaces:
Sleeping
Sleeping
08.09.2025
Browse files- statefulagent.py +6 -12
statefulagent.py
CHANGED
|
@@ -2,17 +2,6 @@ import os
|
|
| 2 |
from smolagents import CodeAgent, InferenceClientModel
|
| 3 |
from a_tools import search_tool, final_answer, image_generation_tool
|
| 4 |
|
| 5 |
-
extra_instructions = """
|
| 6 |
-
|
| 7 |
-
For your final answer, always use:
|
| 8 |
-
final_answer(<answer>)
|
| 9 |
-
Do NOT include any HTML tags. Return only Python code in your final output.
|
| 10 |
-
|
| 11 |
-
Example:
|
| 12 |
-
city_name = "St. Petersburg"
|
| 13 |
-
final_answer(city_name)
|
| 14 |
-
"""
|
| 15 |
-
|
| 16 |
class AG_Agent:
|
| 17 |
def __init__(self):
|
| 18 |
a_model = InferenceClientModel(
|
|
@@ -22,7 +11,12 @@ class AG_Agent:
|
|
| 22 |
)
|
| 23 |
self.model = a_model
|
| 24 |
self.tools = [search_tool, final_answer, image_generation_tool]
|
| 25 |
-
self.agent = CodeAgent(tools=self.tools,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
self.context = []
|
| 27 |
self.max_context_len = 20
|
| 28 |
self.max_steps = 15
|
|
|
|
| 2 |
from smolagents import CodeAgent, InferenceClientModel
|
| 3 |
from a_tools import search_tool, final_answer, image_generation_tool
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
class AG_Agent:
|
| 6 |
def __init__(self):
|
| 7 |
a_model = InferenceClientModel(
|
|
|
|
| 11 |
)
|
| 12 |
self.model = a_model
|
| 13 |
self.tools = [search_tool, final_answer, image_generation_tool]
|
| 14 |
+
self.agent = CodeAgent(tools=self.tools,
|
| 15 |
+
model=self.model,
|
| 16 |
+
stream_outputs=True,
|
| 17 |
+
code_block_tags="markdown",
|
| 18 |
+
additional_authorized_imports=['requests', 'bs4','pandas','numpy',
|
| 19 |
+
'json','datetime','geopandas','shapely'])
|
| 20 |
self.context = []
|
| 21 |
self.max_context_len = 20
|
| 22 |
self.max_steps = 15
|