Spaces:
Sleeping
Sleeping
File size: 849 Bytes
b5d1e65 c46e32c b5d1e65 3434345 b5d1e65 c46e32c b5d1e65 3434345 b5d1e65 2c5b49a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import os
from smolagents import (
CodeAgent,
LiteLLMModel,
PythonInterpreterTool,
DuckDuckGoSearchTool,
VisitWebpageTool,
)
from rate_limiter import RateLimiter
class BasicAgent:
def __init__(self):
model = LiteLLMModel(
model_id=os.getenv("MODEL_ID"),
api_key=os.getenv("MODEL_API_KEY")
)
self.agent = CodeAgent(
tools=[
PythonInterpreterTool(),
DuckDuckGoSearchTool(),
VisitWebpageTool(),
],
model=model,
step_callbacks=[RateLimiter().increment_and_sleep_if_needed]
)
def __call__(self, question: str) -> str:
final_answer = self.agent.run(task=question)
print(f"Agent returning final answer: {final_answer}")
return final_answer |