CoolFace
Apppublic

IALATAM/First_agent_template

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py50 linesDownload Raw Back to root
1import os2from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool3import datetime4import requests5import pytz6import yaml7from tools.final_answer import FinalAnswerTool8from tools.obtener_transcripcion import wikipedia_summary9 10from Gradio_UI import GradioUI11 12# Load HF API key from HF Space Secrets13hf_api_key = os.getenv("HF_API_KEY")14 15 16final_answer = FinalAnswerTool()17 18# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:19# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud' 20 21model = HfApiModel(22max_tokens=2096,23temperature=0.5,24model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded25custom_role_conversions=None,26)27 28 29# Import tool from Hub30##image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)31 32with open("prompts.yaml", 'r') as stream:33    prompt_templates = yaml.safe_load(stream)34 35 36 37agent = CodeAgent(38    model=model,39    tools=[final_answer, wikipedia_summary], ## add your tools here (don't remove final answer)40    max_steps=6,41    verbosity_level=1,42    grammar=None,43    planning_interval=None,44    name=None,45    description=None,46    prompt_templates=prompt_templates47)48 49 50GradioUI(agent).launch()