Spaces:
Sleeping
Sleeping
| from smolagents import CodeAgent, InferenceClientModel | |
| from smolagents import VisitWebpageTool, WebSearchTool, WikipediaSearchTool, PythonInterpreterTool,FinalAnswerTool | |
| import os | |
| token=os.getenv("HF_API_TOKEN") | |
| class GaiaAgent: | |
| def __init__(self): | |
| import os | |
| token = os.getenv("HF_API_TOKEN") | |
| print("DEBUG: HF_API_TOKEN is", token[:6]+ "...") | |
| self.model = InferenceClientModel( | |
| max_tokens = 1024, | |
| temperature = 0.5, | |
| model_id = 'meta-llama/Llama-3.1-8B-Instruct', | |
| #custom_role_conversions=None, | |
| provider="hf-inference", | |
| token=token | |
| ) | |
| #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}" | |