Spaces:
Sleeping
Sleeping
create basic_agent.py
Browse files- basic_agent.py +21 -0
basic_agent.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from smolagents import (
|
| 3 |
+
CodeAgent,
|
| 4 |
+
LiteLLMModel
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
class BasicAgent:
|
| 8 |
+
def __init__(self):
|
| 9 |
+
model = LiteLLMModel(
|
| 10 |
+
model_id=os.getenv("MODEL_ID"),
|
| 11 |
+
api_key=os.getenv("MODEL_API_KEY")
|
| 12 |
+
)
|
| 13 |
+
self.agent = CodeAgent(
|
| 14 |
+
tools=[],
|
| 15 |
+
model=model,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
def __call__(self, question: str) -> str:
|
| 19 |
+
fixed_answer = self.agent.run(task=question)
|
| 20 |
+
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 21 |
+
return fixed_answer
|