aynot's picture
fix int answer
1a6dacb
raw
history blame
973 Bytes
from smolagents import CodeAgent, LiteLLMModel
import os
from cloudpathlib import AnyPath
from tools import initialize_all_available_tools
class MyAgent:
def __init__(self, verbosity_level=0):
model = LiteLLMModel(
model_id="gemini/gemini-2.0-flash-lite",
api_key=os.environ.get('GOOGLE_API_KEY')
)
tools = initialize_all_available_tools()
self.agent = CodeAgent(
tools=tools,
model=model,
max_steps=10,
verbosity_level=verbosity_level
)
with AnyPath("gaia_prompt.txt").open("r", encoding='utf-8') as f:
self.gaia_prompt = f.read()
def get_answer(self, question):
answer = self.agent.run(self.gaia_prompt + '\n' + question)
answer = str(answer)
fa_tmlp = "FINAL ANSWER:"
if answer.startswith(fa_tmlp):
answer = answer[len(fa_tmlp):]
return answer.strip()