Spaces:
Running
Running
File size: 1,269 Bytes
edc5f9e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | from smolagents import (
CodeAgent,
InferenceClientModel,
DuckDuckGoSearchTool,
VisitWebpageTool,
)
class BasicAgent:
def __init__(self):
model = InferenceClientModel()
self.agent = CodeAgent(
tools=[
DuckDuckGoSearchTool(max_results=10),
VisitWebpageTool(),
],
model=model,
max_steps=15,
planning_interval=4,
)
def __call__(self, question: str) -> str:
prompt = f"""
Solve the following GAIA benchmark question accurately.
Use web search and webpage browsing whenever useful.
Reason carefully and verify facts when possible.
Your response will be checked using EXACT MATCH.
Return ONLY the final answer.
Do not provide an explanation.
Do not write "FINAL ANSWER".
Do not add introductory or concluding text.
If the answer is a list, follow the exact formatting requested
by the question.
Question:
{question}
"""
result = self.agent.run(prompt)
return str(result).strip()
if __name__ == "__main__":
agent = BasicAgent()
test_question = (
'.rewsna eht sa "tfel" drow eht fo etisoppo eht etirw ,'
'ecnetnes siht dnatsrednu uoy fI'
)
print(agent(test_question)) |