ABVM's picture
Update agent.py
237f4e6 verified
Raw
History Blame
1.43 kB
from smolagents import CodeAgent, InferenceClientModel
from smolagents import VisitWebpageTool, WebSearchTool, WikipediaSearchTool, PythonInterpreterTool,FinalAnswerTool
import os
os.getenv("hf_token")
class GaiaAgent:
def __init__(self):
import os
token = os.getenv("hf_token")
print("DEBUG: hf_token is", token[:6]+ "...")
self.model = InferenceClientModel(
max_tokens = 1024,
temperature = 0.5,
model_id = "meta-llama/Llama-2-7b-chat-hf",
#custom_role_conversions=None,
provider="hf-inference"
)
#Creating the agent
self.agent = CodeAgent(
model=self.model,
tools=[
VisitWebpageTool(),
WebSearchTool(),
WikipediaSearchTool(),
PythonInterpreterTool(),
FinalAnswerTool(),
],
max_steps=10,
verbosity_level = 2, #or other parameter
grammar = None,
planning_interval=None,
#name="web_agent",
#description="Brows the web to find information",
#additional_autorized_imports = ["pandas"],
)
def __call__(self, question: str) -> str:
try:
return self.agent.run(question)
except Exception as e:
return f"ERROR: {e}"