Spaces:
Runtime error
Runtime error
Fix singleton and add limits to tool outputs
Browse files- src/agent.py +6 -4
src/agent.py
CHANGED
|
@@ -23,15 +23,15 @@ class GaiaAgent(BaseAgent):
|
|
| 23 |
)
|
| 24 |
self.agent = ToolCallingAgent(
|
| 25 |
tools=[
|
| 26 |
-
DuckDuckGoSearchTool(),
|
| 27 |
FinalAnswerTool(),
|
| 28 |
-
VisitWebpageTool(),
|
| 29 |
DownloadAndParseFileTool(),
|
| 30 |
PythonInterpreterTool(),
|
| 31 |
# TODO: Image interpretation, MP3 interpretation
|
| 32 |
],
|
| 33 |
max_steps=10,
|
| 34 |
-
planning_interval=
|
| 35 |
model=self.model,
|
| 36 |
)
|
| 37 |
self.token_rate_limiter = InputTokenRateLimiter()
|
|
@@ -92,7 +92,9 @@ class InputTokenRateLimiter:
|
|
| 92 |
|
| 93 |
def __init__(self, max_tpm=50000):
|
| 94 |
self.max_tpm = max_tpm
|
| 95 |
-
|
|
|
|
|
|
|
| 96 |
|
| 97 |
def _update_queue(self, time_now):
|
| 98 |
while self.token_window and time_now - self.token_window[0][0] > SECONDS_IN_MINUTE:
|
|
|
|
| 23 |
)
|
| 24 |
self.agent = ToolCallingAgent(
|
| 25 |
tools=[
|
| 26 |
+
DuckDuckGoSearchTool(max_results=3),
|
| 27 |
FinalAnswerTool(),
|
| 28 |
+
VisitWebpageTool(max_output_length=20000),
|
| 29 |
DownloadAndParseFileTool(),
|
| 30 |
PythonInterpreterTool(),
|
| 31 |
# TODO: Image interpretation, MP3 interpretation
|
| 32 |
],
|
| 33 |
max_steps=10,
|
| 34 |
+
planning_interval=5,
|
| 35 |
model=self.model,
|
| 36 |
)
|
| 37 |
self.token_rate_limiter = InputTokenRateLimiter()
|
|
|
|
| 92 |
|
| 93 |
def __init__(self, max_tpm=50000):
|
| 94 |
self.max_tpm = max_tpm
|
| 95 |
+
if not hasattr(self, "_initialized"):
|
| 96 |
+
self.token_window = deque() # stores (timestamp, tokens_used)
|
| 97 |
+
self._initialized = True
|
| 98 |
|
| 99 |
def _update_queue(self, time_now):
|
| 100 |
while self.token_window and time_now - self.token_window[0][0] > SECONDS_IN_MINUTE:
|