agent_course_final / agent.py
George Sergia
Update HF_TOKEN ref
7626150
raw
history blame contribute delete
830 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)
model = HfApiModel(model_id="Qwen/Qwen3-235B-A22B")
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