File size: 2,760 Bytes
1787bf2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
import requests
import yaml
from tools.final_answer import FinalAnswerTool

from Gradio_UI import GradioUI

# Below is an example of a tool that does nothing. Amaze us with your creativity !
@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()

# 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:
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud' 

model = HfApiModel(
    max_tokens=2096,
    temperature=0.5,
    model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
    custom_role_conversions=None,
)

# Import tool from Hub
# image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)

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], ## add your tools here (don't remove final answer)
    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()