Spaces:
Runtime error
Runtime error
| from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool | |
| from smolagents.default_tools import FinalAnswerTool, VisitWebpageTool | |
| from Gradio_UI import GradioUI | |
| import datetime | |
| import yaml | |
| from typing import Optional | |
| from my_tools import * | |
| # Free Distill-R1 Model: | |
| # `deepseek-ai/DeepSeek-R1-Distill-Qwen-32B` | |
| # If the agent does not answer, the model is overloaded, please use another model or the original Hugging Face Endpoint for contains qwen2.5 coder: | |
| # 'Qwen/Qwen2.5-Coder-32B-Instruct' | |
| model = HfApiModel( | |
| max_tokens=10000, | |
| temperature=0.5, | |
| model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud', # Endpoint with 'Qwen/Qwen2.5-Coder-32B-Instruct' | |
| custom_role_conversions=None, | |
| ) | |
| # Init tools | |
| final_answer = FinalAnswerTool() | |
| image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True) | |
| search_tool = DuckDuckGoSearchTool() | |
| visit_webpage_tool = VisitWebpageTool() | |
| with open("prompts.yaml", 'r') as stream: | |
| prompt_templates = yaml.safe_load(stream) | |
| agent = CodeAgent( | |
| model=model, | |
| tools=[ | |
| final_answer, | |
| search_tool, | |
| image_generation_tool, | |
| convert_currency, | |
| get_weather, | |
| get_news_headlines, | |
| get_joke, | |
| get_random_fact, | |
| search_wikipedia, | |
| get_current_time_in_timezone, | |
| visit_webpage_tool | |
| ], | |
| max_steps=10, | |
| verbosity_level=0, | |
| grammar=None, | |
| planning_interval=3, | |
| name=None, | |
| description=None, | |
| prompt_templates=prompt_templates | |
| ) | |
| GradioUI(agent).launch() |