agent_course_final / agent.py
George Sergia
Add HF token
b216a70
raw
history blame
888 Bytes
from smolagents import DuckDuckGoSearchTool, CodeAgent, HfApiModel
import os
import yaml
class BasicAgent:
def __init__(self):
print("BasicAgent initialized.")
def __call__(self, question: str) -> str:
print(f"Agent received question (first 50 chars): {question[:50]}...")
with open("prompts.yaml", 'r') as stream:
prompt_templates = yaml.safe_load(stream)
HF_TOKEN = os.getenv("HF_TOKEN")
model = HfApiModel(model_id="Qwen/Qwen3-235B-A22B", token=HF_TOKEN)
search_tool = DuckDuckGoSearchTool()
agent = CodeAgent(
tools=[search_tool],
model=model,
add_base_tools = True,
prompt_templates=prompt_templates
)
fixed_answer = agent.run(question)
print(f"Agent returning fixed answer: {fixed_answer}")
return fixed_answer