Spaces:
Sleeping
Sleeping
File size: 1,479 Bytes
cb43752 efbf494 237f4e6 efbf494 2d69eb1 4337336 9d9535b 9d83242 f280b77 8e91062 cb43752 a0cc714 9d9535b aad1e32 a0cc714 3e7fa24 2d69eb1 9d9535b 7c09eaf 9d9535b c33b606 9d9535b 9d83242 9d9535b 4337336 f280b77 7c09eaf 4337336 | 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 | 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}"
|