Spaces:
Sleeping
Sleeping
rollback changes because wait tool will not work
Browse files
app.py
CHANGED
|
@@ -6,7 +6,6 @@ import requests
|
|
| 6 |
import inspect
|
| 7 |
import pandas as pd
|
| 8 |
from smolagents import (
|
| 9 |
-
tool,
|
| 10 |
Tool,
|
| 11 |
CodeAgent,
|
| 12 |
LiteLLMModel,
|
|
@@ -40,18 +39,7 @@ CUSTOM_PROMPT = """
|
|
| 40 |
When downloading files, try to download them in python code before visiting the website.
|
| 41 |
"""
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
@tool
|
| 46 |
-
def wait(seconds: int = 60) -> None:
|
| 47 |
-
"""
|
| 48 |
-
This tool is used to wait for a certain amount of time.
|
| 49 |
-
Use this tool if you encountered RPM(Requests per minute) or TMP(Tokens per minute) when calling the API.
|
| 50 |
-
|
| 51 |
-
Args:
|
| 52 |
-
seconds (int): How many seconds to wait. Default value is 60.
|
| 53 |
-
"""
|
| 54 |
-
time.sleep(seconds)
|
| 55 |
|
| 56 |
# --- Basic Agent Definition ---
|
| 57 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
@@ -69,10 +57,9 @@ class BasicAgent:
|
|
| 69 |
WikipediaTool(),
|
| 70 |
YoutubeTranscriptTool(),
|
| 71 |
AssemblyAIAudioTranscriptTool(),
|
| 72 |
-
wait,
|
| 73 |
],
|
| 74 |
model=model,
|
| 75 |
-
|
| 76 |
additional_authorized_imports=["pandas", "openpyxl", "requests"],
|
| 77 |
instructions=CUSTOM_PROMPT
|
| 78 |
)
|
|
|
|
| 6 |
import inspect
|
| 7 |
import pandas as pd
|
| 8 |
from smolagents import (
|
|
|
|
| 9 |
Tool,
|
| 10 |
CodeAgent,
|
| 11 |
LiteLLMModel,
|
|
|
|
| 39 |
When downloading files, try to download them in python code before visiting the website.
|
| 40 |
"""
|
| 41 |
|
| 42 |
+
rate_limiter = RateLimiter()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
# --- Basic Agent Definition ---
|
| 45 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
|
|
| 57 |
WikipediaTool(),
|
| 58 |
YoutubeTranscriptTool(),
|
| 59 |
AssemblyAIAudioTranscriptTool(),
|
|
|
|
| 60 |
],
|
| 61 |
model=model,
|
| 62 |
+
step_callbacks=[rate_limiter.increment_and_sleep_if_needed],
|
| 63 |
additional_authorized_imports=["pandas", "openpyxl", "requests"],
|
| 64 |
instructions=CUSTOM_PROMPT
|
| 65 |
)
|