CoolFace
Apppublic

Harikrishnan53/First_agent_template

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py48 linesDownload Raw Back to root
1from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool2import datetime3import requests4import pytz5import yaml6from tools.final_answer import FinalAnswerTool7 8from Gradio_UI import GradioUI9from huggingface_hub import login10import os11login(token=os.environ["hf_token"])12# Below is an example of a tool that does nothing. Amaze us with your creativity !13 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=4096,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 Hub30image_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    35agent = CodeAgent(36    model=model,37    tools=[final_answer,DuckDuckGoSearchTool()], ## add your tools here (don't remove final answer)38    max_steps=6,39    verbosity_level=1,40    grammar=None,41    planning_interval=None,42    name=None,43    description=None,44    prompt_templates=prompt_templates45)46 47 48GradioUI(agent).launch()