| from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool |
| import requests |
| import yaml |
| from tools.final_answer import FinalAnswerTool |
|
|
| from Gradio_UI import GradioUI |
|
|
| |
| @tool |
| def get_the_weather_forecast(city_name:str) -> str: |
| """ |
| Get the weather forecast for a given city. |
| Args: |
| city_name (str): The name of the city to get the weather forecast for. |
| Returns: |
| str: The weather forecast for the city. |
| """ |
|
|
| url = 'https://wttr.in/{}'.format(city_name) |
| try: |
| data = requests.get(url) |
| weather_forecast = data.text |
| except: |
| weather_forecast = "Error Occurred" |
| return(weather_forecast) |
|
|
| @tool |
| def get_clothes_pieces_url()-> list: |
| """ |
| Get a list of URLs related to different types of clothing pieces. |
| Args: |
| None |
| Returns: |
| list: A list of URLs related to clothing pieces. |
| """ |
| return [ |
| "https://dico-petitbac.com/vetements/", |
| "https://kizoshop.com/blogs/infos/quelles-sont-les-differents-types-de-vetements" |
| ] |
|
|
| @tool |
| def get_outfits_ideas_url()-> list: |
| """ |
| Get a list of URLs related to outfit ideas. |
| Args: |
| None |
| Returns: |
| list: A list of URLs related to outfit ideas. |
| """ |
| return [ |
| "https://www.votrejournal.net/types-de-vetements-les-differents-a-connaitre-pour-bien-shabiller/", |
| "https://mode-homme-tendance.fr/look-masculin/10-idees-de-tenues-tendance-pour-homme/" |
| ] |
|
|
|
|
|
|
| finalanswer = FinalAnswerTool() |
| ducksearch = DuckDuckGoSearchTool() |
|
|
| |
| |
|
|
| model = HfApiModel( |
| max_tokens=2096, |
| temperature=0.5, |
| model_id='Qwen/Qwen2.5-Coder-32B-Instruct', |
| custom_role_conversions=None, |
| ) |
|
|
| |
| |
|
|
| with open("prompts.yaml", 'r') as stream: |
| prompt_templates = yaml.safe_load(stream) |
| |
| agent = CodeAgent( |
| model=model, |
| tools=[finalanswer, ducksearch, get_the_weather_forecast, get_clothes_pieces_url, get_outfits_ideas_url], |
| max_steps=15, |
| verbosity_level=1, |
| grammar=None, |
| planning_interval=None, |
| name="mapmarker", |
| description="An agent that create a map on which it add multiple markers", |
| prompt_templates=prompt_templates |
| ) |
|
|
|
|
| GradioUI(agent).launch() |