import yaml import os from smolagents import GradioUI, CodeAgent, TransformersModel # Get current directory path CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) from tools.web_search import DuckDuckGoSearchTool as WebSearch from tools.visit_webpage import VisitWebpageTool as VisitWebpage from tools.final_answer import FinalAnswerTool as FinalAnswer model = TransformersModel( max_new_tokens=5000, model_id='sbintuitions/sarashina2.2-3b-instruct-v0.1', ) web_search = WebSearch() visit_webpage = VisitWebpage() final_answer = FinalAnswer() with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream: prompt_templates = yaml.safe_load(stream) agent_simple_data_analyst = CodeAgent( model=model, tools=[web_search, visit_webpage], managed_agents=[], max_steps=10, verbosity_level=1, grammar=None, planning_interval=None, name='simple_data_analyst', description='A simple agent that can search the web and analyze data with Python.', prompt_templates=prompt_templates ) if __name__ == "__main__": GradioUI(agent_simple_data_analyst).launch()