Spaces:
Sleeping
Sleeping
| import os | |
| from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, InferenceClientModel, LiteLLMModel | |
| class BasicAgent: | |
| def __init__(self): | |
| print("BasicAgent initialized.") | |
| def __call__(self, question: str) -> str: | |
| print(f"Agent received question (first 50 chars): {question[:50]}...") | |
| model = LiteLLMModel(model_id="groq/deepseek-r1-distill-llama-70b", | |
| api_key=os.getenv("GROQ_API_KEY")) | |
| agent = ToolCallingAgent( | |
| tools=[DuckDuckGoSearchTool()], | |
| model=model, | |
| max_steps=5, | |
| name="web_agent", | |
| description="Web Search Agent", | |
| verbosity_level=2 | |
| ) | |
| answer = agent.run( | |
| f""" | |
| Answer the question using the tools provided. If you need to search the web, use the DuckDuckGoSearchTool. | |
| If you find relevant information, use it to answer the question. Do not make up answers. | |
| If you cannot find an answer, respond with 'I don't know'. Provide only the final answer, not the steps taken. | |
| Question: {question} | |
| """ | |
| ) | |
| print(f"Agent returning answer: {answer}") | |
| return answer | |