Spaces:
Sleeping
Sleeping
First batch of a minimal agent
Browse files
agent.py
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, tool, InferenceClientModel
|
| 2 |
+
|
| 3 |
+
class QAgent:
|
| 4 |
+
def __init__(self):
|
| 5 |
+
print("BasicAgent initialized.")
|
| 6 |
+
def __call__(self, question: str) -> str:
|
| 7 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 8 |
+
# provider = "nebius"
|
| 9 |
+
model = "Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 10 |
+
api_key = SP_HF_TOK
|
| 11 |
+
|
| 12 |
+
agent = CodeAgent(tools=[DuckDuckGoSearchTool, VisitWebpageTool],
|
| 13 |
+
model=InferenceClientModel(
|
| 14 |
+
model=model,
|
| 15 |
+
# provider=provider,
|
| 16 |
+
api_key=api_key),
|
| 17 |
+
add_base_tools=True)
|
| 18 |
+
|
| 19 |
+
fixed_answer = agent.run(question)
|
| 20 |
+
print(f"Agent returning fixed answer: {fixed_answer}")
|
| 21 |
+
return fixed_answer
|