Spaces:
Sleeping
Sleeping
| from smolagents import CodeAgent, HfApiModel | |
| import yaml | |
| from tools import FinalAnswerTool, VisitWebpageTool, DuckDuckGoSearchTool | |
| from Gradio_UI import GradioUI | |
| # Load prompts | |
| with open("prompts.yaml", 'r') as stream: | |
| prompt_templates = yaml.safe_load(stream) | |
| # Initialize tools | |
| final_answer = FinalAnswerTool() | |
| web_search = DuckDuckGoSearchTool(max_results=5) | |
| visit_webpage = VisitWebpageTool() | |
| # Configure model | |
| model = HfApiModel( | |
| max_tokens=2096, | |
| temperature=0.2, | |
| model_id='Qwen/Qwen2.5-Coder-32B-Instruct' | |
| ) | |
| # Create agent | |
| agent = CodeAgent( | |
| model=model, | |
| tools=[final_answer, web_search, visit_webpage], | |
| max_steps=6, | |
| verbosity_level=1, | |
| grammar=None, | |
| planning_interval=None, | |
| prompt_templates=prompt_templates | |
| ) | |
| # Launch Gradio UI | |
| GradioUI(agent).launch() |