serverdaun commited on
Commit
63551f1
·
0 Parent(s):

Initial commit with Git LFS tracking

Browse files
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ assets/*.png filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ .Python
8
+ env/
9
+ venv/
10
+ ENV/
11
+ env.bak/
12
+ venv.bak/
13
+ bin/
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+ MANIFEST
27
+
28
+ # Jupyter Notebook checkpoints
29
+ .ipynb_checkpoints
30
+
31
+ # Visual Studio Code
32
+ .vscode/
33
+
34
+ # PyCharm
35
+ .idea/
36
+
37
+ # Pyenv
38
+ .python-version
39
+
40
+ # Environments
41
+ .env
42
+ .envrc
43
+ venv/
44
+ venv.bak/
45
+ ENV/
46
+
47
+ # Unit test / coverage reports
48
+ .coverage
49
+ .tox/
50
+ .nox/
51
+ .cache/
52
+ nosetests.xml
53
+ coverage.xml
54
+ *.cover
55
+ *.py,cover
56
+ .hypothesis/
57
+
58
+ # Intellisense
59
+ .vscode/
60
+
61
+ # Jupyter Notebook specific
62
+ .ipynb_checkpoints/
63
+ **/.ipynb_checkpoints
64
+
65
+ # MacOS
66
+ .DS_Store
67
+
68
+ # Temporary files
69
+ *.tmp
70
+ *.temp
71
+ *.~*
72
+
73
+ # Exclude any files named 'secret', 'password', or 'credentials'
74
+ secret*
75
+ password*
76
+ credentials*
README.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # What to Wear — Clothing Recommendation Agent
2
+
3
+ This application is a smart outfit recommendation assistant built with Streamlit and a code-based agent architecture. It provides personalized clothing suggestions based on real-time weather conditions in a user-specified city.
4
+
5
+ P.S. You don't have to look out the window anymore :)
6
+
7
+ ## Features
8
+
9
+ - Fetches hourly weather forecast for the selected city
10
+ - Uses an LLM-based agent to reason over weather and user data
11
+ - Suggests three stylish outfits: top, bottom, shoes, accessories
12
+ - Interactive UI built with Streamlit
13
+
14
+ ## Installation
15
+
16
+ 1. Clone the repository:
17
+ ```bash
18
+ git clone https://github.com/yourusername/what_to_wear.git
19
+ cd what_to_wear
20
+ ```
21
+
22
+ 2. Create and activate a virtual environment:
23
+ ```bash
24
+ python -m venv venv
25
+ source venv/bin/activate # Windows: venv\Scripts\activate
26
+ ```
27
+
28
+ 3. Install the dependencies:
29
+ ```bash
30
+ pip install -r requirements.txt
31
+ ```
32
+
33
+ 4. Add your Hugging Face token in a `.env` file:
34
+ ```env
35
+ HF_TOKEN=your_huggingface_api_token
36
+ ```
37
+
38
+ ## Running the App
39
+
40
+ To launch the app:
41
+
42
+ ```bash
43
+ streamlit run app.py
44
+ ```
45
+
46
+ Then open [http://localhost:8501](http://localhost:8501) in your browser.
47
+
48
+ ## User Inputs
49
+
50
+ - **City** (e.g., Prague)
51
+ - **Age** (e.g., 25)
52
+ - **Gender** (Male / Female)
53
+
54
+ ## Output Format
55
+
56
+ The app returns three outfit suggestions, each including:
57
+
58
+ - `style`: The overall theme of the outfit (e.g., Casual, Sporty, Business Casual)
59
+ - `top`: Shirt, t-shirt, or similar
60
+ - `bottom`: Pants, shorts, etc.
61
+ - `shoes`: Footwear
62
+ - `accessories`: A list of optional accessories (e.g., sunglasses, belts)
63
+
64
+ ### Example output:
65
+ Below is a screenshot of the output in UI:
66
+
67
+ ![Outfit Recommendation Screenshot](assets/example_output.png)
68
+
69
+ ## Notes
70
+
71
+ - The app uses Open Meteo API via the `get_weather_forecast` tool to fetch 24-hour weather forecasts.
72
+ - Outfit ideas are generated by a Hugging Face-powered LLM agent, orchestrated by `smol-agents`.
73
+
74
+ ## License
75
+
76
+ MIT License
app.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import CodeAgent, HfApiModel, FinalAnswerTool
2
+ from tools.get_weather import get_weather_forecast
3
+ from utils.utils import load_prompt
4
+ from dotenv import load_dotenv
5
+ import os
6
+ import streamlit as st
7
+
8
+ if "city" not in st.session_state:
9
+ st.session_state.city = ""
10
+ if "age" not in st.session_state:
11
+ st.session_state.age = ""
12
+ if "sex" not in st.session_state:
13
+ st.session_state.sex = ""
14
+
15
+ load_dotenv()
16
+ hf_token = os.getenv("HF_TOKEN")
17
+
18
+ def get_clothing_reccomendation(city: str, age: str, sex: str) -> str:
19
+ """
20
+ This function returns clothing recommendations based on the weather forecast for a specific city.
21
+ Args:
22
+ city (str): The name of the city for which to get clothing recommendations.
23
+ age (str): The age of the user for whom to get clothing recommendations.
24
+ Returns:
25
+ str: A string containing clothing recommendations based on the weather forecast.
26
+ """
27
+
28
+ # Load prompt for user message for agent
29
+ user_input = load_prompt(
30
+ path="prompts/agent_prompt.yaml",
31
+ prompt_name="user_message",
32
+ city=city,
33
+ age=age,
34
+ sex=sex
35
+ )
36
+
37
+ # Define LLM model
38
+ llm = HfApiModel(token=hf_token)
39
+
40
+ # Define the list of tools to be used by the agent
41
+ tools = [get_weather_forecast, FinalAnswerTool()]
42
+
43
+ # Initialize the CodeAgent with the Hugging Face model.
44
+ agent = CodeAgent(
45
+ model=llm,
46
+ tools=tools,
47
+ max_steps=4,
48
+ )
49
+
50
+ # Run the agent with the user input.
51
+ response = agent.run(user_input)
52
+ return response
53
+
54
+ # Streamlit app
55
+ st.title("Clothing Recommendation Agent")
56
+ st.write(
57
+ "Get personalized clothing recommendations based on the weather forecast for your city."
58
+ )
59
+ st.session_state.city = st.text_input("Enter your city:", st.session_state.city)
60
+ st.session_state.age = st.text_input("Enter your age:", st.session_state.age)
61
+ st.session_state.sex = st.selectbox("Select your gender", options=["Male", "Female"], index=["Male", "Female"].index(st.session_state.sex) if st.session_state.sex else 0)
62
+
63
+ # Create a button to get the recommendation
64
+ if st.button("Get Recommendation"):
65
+ if st.session_state.city and st.session_state.age and st.session_state.sex:
66
+ with st.spinner("Fetchin outifit suggestions..."):
67
+
68
+ result = get_clothing_reccomendation(
69
+ city=st.session_state.city,
70
+ age=st.session_state.age,
71
+ sex=st.session_state.sex
72
+ )
73
+ st.success("Here are your outfit sugegestions:")
74
+
75
+ # Display the results
76
+ try:
77
+ for idx, outfit in enumerate(result):
78
+ with st.expander(f"🌟 Style #{idx + 1}: {outfit['style']}", expanded=True):
79
+ st.markdown(f"**👕 Top:** {outfit['top']}")
80
+ st.markdown(f"**👖 Bottom:** {outfit['bottom']}")
81
+ st.markdown(f"**👟 Shoes:** {outfit['shoes']}")
82
+ st.markdown(f"**🧢 Accessories:** {outfit['accessories']}")
83
+ except Exception as e:
84
+ st.write(result)
85
+
86
+ else:
87
+ st.error("Please fill in all fields.")
88
+
89
+ # Reset button to clear the session state
90
+ if st.button("Reset"):
91
+ st.session_state.city = ""
92
+ st.session_state.age = ""
93
+ st.session_state.sex = ""
94
+ st.rerun()
assets/example_output.png ADDED

Git LFS Details

  • SHA256: 1f73b7289a0bab6e1df5d479cae2ba7afbab9a158d3e30855cb3b99bce5f70a7
  • Pointer size: 131 Bytes
  • Size of remote file: 149 kB
prompts/agent_prompt.yaml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ user_message: |
2
+ You are a personal clothing assistant. Your job is to provide multiple outfit recommendations based on today's weather in {city}.
3
+ Your client is {sex} and is {age} years old. They are looking for outfits that are both stylish and appropriate for the weather conditions.
4
+
5
+ Factor in temperature and precipitation to make your recommendations.
6
+
7
+ Respond with exactly three outfit suggestions. Each outfit must follow this format:
8
+
9
+ {{
10
+ "style": "<style name, e.g. Casual, Sporty, Business Casual>",
11
+ "top": "<description of the top>",
12
+ "bottom": "<description of the bottom>",
13
+ "shoes": "<description of the shoes>",
14
+ "accessories": "<comma-separated list of accessories>"
15
+ }}
16
+
17
+ Return the full response as a list of three such outfit objects.
18
+ Ensure the format is consistent and parsable by downstream applications.
prompts/prompts_template.yaml ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "system_prompt": |-
2
+ You are an expert assistant who can solve any task using code blobs. You will be given a task to solve as best you can.
3
+ To do so, you have been given access to a list of tools: these tools are basically Python functions which you can call with code.
4
+ To solve the task, you must plan forward to proceed in a series of steps, in a cycle of 'Thought:', 'Code:', and 'Observation:' sequences.
5
+ At each step, in the 'Thought:' sequence, you should first explain your reasoning towards solving the task and the tools that you want to use.
6
+ Then in the 'Code:' sequence, you should write the code in simple Python. The code sequence must end with '<end_code>' sequence.
7
+ During each intermediate step, you can use 'print()' to save whatever important information you will then need.
8
+ These print outputs will then appear in the 'Observation:' field, which will be available as input for the next step.
9
+ In the end you have to return a final answer using the `final_answer` tool.
10
+
11
+ Here are a few examples using notional tools:
12
+ ---
13
+ Task: "Generate an image of the oldest person in this document."
14
+
15
+ Thought: I will proceed step by step and use the following tools: `document_qa` to find the oldest person in the document, then `image_generator` to generate an image according to the answer.
16
+ Code:
17
+ ```py
18
+ answer = document_qa(document=document, question="Who is the oldest person mentioned?")
19
+ print(answer)
20
+ ```<end_code>
21
+ Observation: "The oldest person in the document is John Doe, a 55 year old lumberjack living in Newfoundland."
22
+
23
+ Thought: I will now generate an image showcasing the oldest person.
24
+ Code:
25
+ ```py
26
+ image = image_generator("A portrait of John Doe, a 55-year-old man living in Canada.")
27
+ final_answer(image)
28
+ ```<end_code>
29
+
30
+ ---
31
+ Task: "What is the result of the following operation: 5 + 3 + 1294.678?"
32
+
33
+ Thought: I will use python code to compute the result of the operation and then return the final answer using the `final_answer` tool
34
+ Code:
35
+ ```py
36
+ result = 5 + 3 + 1294.678
37
+ final_answer(result)
38
+ ```<end_code>
39
+
40
+ ---
41
+ Task:
42
+ "Answer the question in the variable `question` about the image stored in the variable `image`. The question is in French.
43
+ You have been provided with these additional arguments, that you can access using the keys as variables in your python code:
44
+ {'question': 'Quel est l'animal sur l'image?', 'image': 'path/to/image.jpg'}"
45
+
46
+ Thought: I will use the following tools: `translator` to translate the question into English and then `image_qa` to answer the question on the input image.
47
+ Code:
48
+ ```py
49
+ translated_question = translator(question=question, src_lang="French", tgt_lang="English")
50
+ print(f"The translated question is {translated_question}.")
51
+ answer = image_qa(image=image, question=translated_question)
52
+ final_answer(f"The answer is {answer}")
53
+ ```<end_code>
54
+ ---
55
+ Task:
56
+ In a 1979 interview, Stanislaus Ulam discusses with Martin Sherwin about other great physicists of his time, including Oppenheimer.
57
+ What does he say was the consequence of Einstein learning too much math on his creativity, in one word?
58
+ Thought: I need to find and read the 1979 interview of Stanislaus Ulam with Martin Sherwin.
59
+ Code:
60
+ ```py
61
+ pages = search(query="1979 interview Stanislaus Ulam Martin Sherwin physicists Einstein")
62
+ print(pages)
63
+ ```<end_code>
64
+ Observation:
65
+ No result found for query "1979 interview Stanislaus Ulam Martin Sherwin physicists Einstein".
66
+
67
+ Thought: The query was maybe too restrictive and did not find any results. Let's try again with a broader query.
68
+ Code:
69
+ ```py
70
+ pages = search(query="1979 interview Stanislaus Ulam")
71
+ print(pages)
72
+ ```<end_code>
73
+ Observation:
74
+ Found 6 pages:
75
+ [Stanislaus Ulam 1979 interview](https://ahf.nuclearmuseum.org/voices/oral-histories/stanislaus-ulams-interview-1979/)
76
+
77
+ [Ulam discusses Manhattan Project](https://ahf.nuclearmuseum.org/manhattan-project/ulam-manhattan-project/)
78
+
79
+ (truncated)
80
+
81
+ Thought: I will read the first 2 pages to know more.
82
+ Code:
83
+ ```py
84
+ for url in ["https://ahf.nuclearmuseum.org/voices/oral-histories/stanislaus-ulams-interview-1979/", "https://ahf.nuclearmuseum.org/manhattan-project/ulam-manhattan-project/"]:
85
+ whole_page = visit_webpage(url)
86
+ print(whole_page)
87
+ print("\n" + "="*80 + "\n") # Print separator between pages
88
+ ```<end_code>
89
+ Observation:
90
+ Manhattan Project Locations:
91
+ Los Alamos, NM
92
+ Stanislaus Ulam was a Polish-American mathematician. He worked on the Manhattan Project at Los Alamos and later helped design the hydrogen bomb. In this interview, he discusses his work at
93
+ (truncated)
94
+
95
+ Thought: I now have the final answer: from the webpages visited, Stanislaus Ulam says of Einstein: "He learned too much mathematics and sort of diminished, it seems to me personally, it seems to me his purely physics creativity." Let's answer in one word.
96
+ Code:
97
+ ```py
98
+ final_answer("diminished")
99
+ ```<end_code>
100
+
101
+ ---
102
+ Task: "Which city has the highest population: Guangzhou or Shanghai?"
103
+
104
+ Thought: I need to get the populations for both cities and compare them: I will use the tool `search` to get the population of both cities.
105
+ Code:
106
+ ```py
107
+ for city in ["Guangzhou", "Shanghai"]:
108
+ print(f"Population {city}:", search(f"{city} population")
109
+ ```<end_code>
110
+ Observation:
111
+ Population Guangzhou: ['Guangzhou has a population of 15 million inhabitants as of 2021.']
112
+ Population Shanghai: '26 million (2019)'
113
+
114
+ Thought: Now I know that Shanghai has the highest population.
115
+ Code:
116
+ ```py
117
+ final_answer("Shanghai")
118
+ ```<end_code>
119
+
120
+ ---
121
+ Task: "What is the current age of the pope, raised to the power 0.36?"
122
+
123
+ Thought: I will use the tool `wiki` to get the age of the pope, and confirm that with a web search.
124
+ Code:
125
+ ```py
126
+ pope_age_wiki = wiki(query="current pope age")
127
+ print("Pope age as per wikipedia:", pope_age_wiki)
128
+ pope_age_search = web_search(query="current pope age")
129
+ print("Pope age as per google search:", pope_age_search)
130
+ ```<end_code>
131
+ Observation:
132
+ Pope age: "The pope Francis is currently 88 years old."
133
+
134
+ Thought: I know that the pope is 88 years old. Let's compute the result using python code.
135
+ Code:
136
+ ```py
137
+ pope_current_age = 88 ** 0.36
138
+ final_answer(pope_current_age)
139
+ ```<end_code>
140
+
141
+ Above example were using notional tools that might not exist for you. On top of performing computations in the Python code snippets that you create, you only have access to these tools:
142
+ {%- for tool in tools.values() %}
143
+ - {{ tool.name }}: {{ tool.description }}
144
+ Takes inputs: {{tool.inputs}}
145
+ Returns an output of type: {{tool.output_type}}
146
+ {%- endfor %}
147
+
148
+ {%- if managed_agents and managed_agents.values() | list %}
149
+ You can also give tasks to team members.
150
+ Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task', a long string explaining your task.
151
+ Given that this team member is a real human, you should be very verbose in your task.
152
+ Here is a list of the team members that you can call:
153
+ {%- for agent in managed_agents.values() %}
154
+ - {{ agent.name }}: {{ agent.description }}
155
+ {%- endfor %}
156
+ {%- else %}
157
+ {%- endif %}
158
+
159
+ Here are the rules you should always follow to solve your task:
160
+ 1. Always provide a 'Thought:' sequence, and a 'Code:\n```py' sequence ending with '```<end_code>' sequence, else you will fail.
161
+ 2. Use only variables that you have defined!
162
+ 3. Always use the right arguments for the tools. DO NOT pass the arguments as a dict as in 'answer = wiki({'query': "What is the place where James Bond lives?"})', but use the arguments directly as in 'answer = wiki(query="What is the place where James Bond lives?")'.
163
+ 4. Take care to not chain too many sequential tool calls in the same code block, especially when the output format is unpredictable. For instance, a call to search has an unpredictable return format, so do not have another tool call that depends on its output in the same block: rather output results with print() to use them in the next block.
164
+ 5. Call a tool only when needed, and never re-do a tool call that you previously did with the exact same parameters.
165
+ 6. Don't name any new variable with the same name as a tool: for instance don't name a variable 'final_answer'.
166
+ 7. Never create any notional variables in our code, as having these in your logs will derail you from the true variables.
167
+ 8. You can use imports in your code, but only from the following list of modules: {{authorized_imports}}
168
+ 9. The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.
169
+ 10. Don't give up! You're in charge of solving the task, not providing directions to solve it.
170
+
171
+ Now Begin! If you solve the task correctly, you will receive a reward of $1,000,000.
172
+ "planning":
173
+ "initial_facts": |-
174
+ Below I will present you a task.
175
+ You will now build a comprehensive preparatory survey of which facts we have at our disposal and which ones we still need.
176
+ To do so, you will have to read the task and identify things that must be discovered in order to successfully complete it.
177
+ Don't make any assumptions. For each item, provide a thorough reasoning. Here is how you will structure this survey:
178
+
179
+ ---
180
+ ### 1. Facts given in the task
181
+ List here the specific facts given in the task that could help you (there might be nothing here).
182
+
183
+ ### 2. Facts to look up
184
+ List here any facts that we may need to look up.
185
+ Also list where to find each of these, for instance a website, a file... - maybe the task contains some sources that you should re-use here.
186
+
187
+ ### 3. Facts to derive
188
+ List here anything that we want to derive from the above by logical reasoning, for instance computation or simulation.
189
+
190
+ Keep in mind that "facts" will typically be specific names, dates, values, etc. Your answer should use the below headings:
191
+ ### 1. Facts given in the task
192
+ ### 2. Facts to look up
193
+ ### 3. Facts to derive
194
+ Do not add anything else.
195
+ "initial_plan": |-
196
+ You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
197
+ Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
198
+ This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
199
+ Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
200
+ After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
201
+
202
+ Here is your task:
203
+
204
+ Task:
205
+ ```
206
+ {{task}}
207
+ ```
208
+ You can leverage these tools:
209
+ {%- for tool in tools.values() %}
210
+ - {{ tool.name }}: {{ tool.description }}
211
+ Takes inputs: {{tool.inputs}}
212
+ Returns an output of type: {{tool.output_type}}
213
+ {%- endfor %}
214
+
215
+ {%- if managed_agents and managed_agents.values() | list %}
216
+ You can also give tasks to team members.
217
+ Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'request', a long string explaining your request.
218
+ Given that this team member is a real human, you should be very verbose in your request.
219
+ Here is a list of the team members that you can call:
220
+ {%- for agent in managed_agents.values() %}
221
+ - {{ agent.name }}: {{ agent.description }}
222
+ {%- endfor %}
223
+ {%- else %}
224
+ {%- endif %}
225
+
226
+ List of facts that you know:
227
+ ```
228
+ {{answer_facts}}
229
+ ```
230
+
231
+ Now begin! Write your plan below.
232
+ "update_facts_pre_messages": |-
233
+ You are a world expert at gathering known and unknown facts based on a conversation.
234
+ Below you will find a task, and a history of attempts made to solve the task. You will have to produce a list of these:
235
+ ### 1. Facts given in the task
236
+ ### 2. Facts that we have learned
237
+ ### 3. Facts still to look up
238
+ ### 4. Facts still to derive
239
+ Find the task and history below:
240
+ "update_facts_post_messages": |-
241
+ Earlier we've built a list of facts.
242
+ But since in your previous steps you may have learned useful new facts or invalidated some false ones.
243
+ Please update your list of facts based on the previous history, and provide these headings:
244
+ ### 1. Facts given in the task
245
+ ### 2. Facts that we have learned
246
+ ### 3. Facts still to look up
247
+ ### 4. Facts still to derive
248
+ Now write your new list of facts below.
249
+ "update_plan_pre_messages": |-
250
+ You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
251
+ You have been given a task:
252
+ ```
253
+ {{task}}
254
+ ```
255
+
256
+ Find below the record of what has been tried so far to solve it. Then you will be asked to make an updated plan to solve the task.
257
+ If the previous tries so far have met some success, you can make an updated plan based on these actions.
258
+ If you are stalled, you can make a completely new plan starting from scratch.
259
+ "update_plan_post_messages": |-
260
+ You're still working towards solving this task:
261
+ ```
262
+ {{task}}
263
+ ```
264
+ You can leverage these tools:
265
+ {%- for tool in tools.values() %}
266
+ - {{ tool.name }}: {{ tool.description }}
267
+ Takes inputs: {{tool.inputs}}
268
+ Returns an output of type: {{tool.output_type}}
269
+ {%- endfor %}
270
+
271
+ {%- if managed_agents and managed_agents.values() | list %}
272
+ You can also give tasks to team members.
273
+ Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task'.
274
+ Given that this team member is a real human, you should be very verbose in your task, it should be a long string providing informations as detailed as necessary.
275
+ Here is a list of the team members that you can call:
276
+ {%- for agent in managed_agents.values() %}
277
+ - {{ agent.name }}: {{ agent.description }}
278
+ {%- endfor %}
279
+ {%- else %}
280
+ {%- endif %}
281
+
282
+ Here is the up to date list of facts that you know:
283
+ ```
284
+ {{facts_update}}
285
+ ```
286
+
287
+ Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
288
+ This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
289
+ Beware that you have {remaining_steps} steps remaining.
290
+ Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
291
+ After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
292
+
293
+ Now write your new plan below.
294
+ "managed_agent":
295
+ "task": |-
296
+ You're a helpful agent named '{{name}}'.
297
+ You have been submitted this task by your manager.
298
+ ---
299
+ Task:
300
+ {{task}}
301
+ ---
302
+ You're helping your manager solve a wider task: so make sure to not provide a one-line answer, but give as much information as possible to give them a clear understanding of the answer.
303
+ Your final_answer WILL HAVE to contain these parts:
304
+ ### 1. Task outcome (short version):
305
+ ### 2. Task outcome (extremely detailed version):
306
+ ### 3. Additional context (if relevant):
307
+
308
+ Put all these in your final_answer tool, everything that you do not pass as an argument to final_answer will be lost.
309
+ And even if your task resolution is not successful, please return as much context as possible, so that your manager can act upon this feedback.
310
+ "report": |-
311
+ Here is the final answer from your managed agent '{{name}}':
312
+ {{final_answer}}
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ smolagents
2
+ pandas
3
+ openmeteo_requests
4
+ python-dotenv
5
+ stramlit
tools/get_weather.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openmeteo_requests
2
+ import pandas as pd
3
+ from smolagents import tool
4
+
5
+ @tool
6
+ def get_weather_forecast(latitude: float, longitude: float) -> pd.DataFrame:
7
+ """
8
+ Fetches the weather forecast for the 24 hours of current day using Open Meteo API.
9
+ Args:
10
+ latitude (float): Latitude of the location.
11
+ longitude (float): Longitude of the location.
12
+ Returns:
13
+ pd.DataFrame: A DataFrame containing the hourly weather forecast with columns:
14
+ - hour: Hour of the day (0-23).
15
+ - temperature_2m: Temperature in degrees Celsius.
16
+ - precipitation: Precipitation in mm.
17
+ """
18
+ # Initialize the Open Meteo API client.
19
+ openmeteo = openmeteo_requests.Client()
20
+ url = "https://previous-runs-api.open-meteo.com/v1/forecast"
21
+
22
+ try:
23
+ params = {
24
+ "latitude": latitude,
25
+ "longitude": longitude,
26
+ "hourly": ["temperature_2m", "precipitation"],
27
+ "past_days": 0,
28
+ "forecast_days": 1
29
+ }
30
+ responses = openmeteo.weather_api(url, params=params)
31
+ response = responses[0]
32
+ except Exception as e:
33
+ return None
34
+
35
+ # Process hourly data.
36
+ hourly = response.Hourly()
37
+ hourly_temperature_2m = hourly.Variables(0).ValuesAsNumpy()
38
+ hourly_rain = hourly.Variables(1).ValuesAsNumpy()
39
+
40
+ hourly_data = {"date": pd.date_range(
41
+ start = pd.to_datetime(hourly.Time(), unit = "s", utc = True),
42
+ end = pd.to_datetime(hourly.TimeEnd(), unit = "s", utc = True),
43
+ freq = pd.Timedelta(seconds = hourly.Interval()),
44
+ inclusive = "left"
45
+ )}
46
+
47
+ # Create a DataFrame with the hourly data.
48
+ hourly_data["temperature_2m"] = hourly_temperature_2m
49
+ hourly_data["precipitation"] = hourly_rain
50
+ hourly_dataframe = pd.DataFrame(data = hourly_data)
51
+ hourly_dataframe["hour"] = hourly_dataframe["date"].dt.hour
52
+
53
+ # Convert the DataFrame to a dictionary.
54
+ weather_forecast = hourly_dataframe[["hour", "temperature_2m", "precipitation"]]
55
+
56
+ return weather_forecast
utils/utils.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+ from pathlib import Path
3
+
4
+ def load_prompt(path: str, prompt_name: str, **kwargs) -> str:
5
+ """
6
+ Load a specific named prompt from a YAML file and replace placeholders.
7
+
8
+ Args:
9
+ path (str): Path to YAML file.
10
+ prompt_name (str): Key of the prompt inside the YAML.
11
+ **kwargs: Replacement values for placeholders.
12
+
13
+ Returns:
14
+ str: Final formatted prompt string.
15
+ """
16
+ with open(path, "r", encoding="utf-8") as f:
17
+ prompts = yaml.safe_load(f)
18
+
19
+ prompt_template = prompts[prompt_name]
20
+ return prompt_template.format(**kwargs)