elliemci commited on
Commit
fdffbe8
·
verified ·
1 Parent(s): 3e1a1f0

Upload 9 files

Browse files

Party planning agent with tools to come up with a party theme, menu and music, able to estimate the time required to prepare it.

agent.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tools": [
3
+ "web_search",
4
+ "visit_webpage",
5
+ "suggest_menu",
6
+ "catering_service_tool",
7
+ "superhero_party_theme_generator",
8
+ "final_answer"
9
+ ],
10
+ "model": {
11
+ "class": "HfApiModel",
12
+ "data": {
13
+ "last_input_token_count": 3527,
14
+ "last_output_token_count": 83,
15
+ "model_id": "Qwen/Qwen2.5-Coder-32B-Instruct",
16
+ "provider": null
17
+ }
18
+ },
19
+ "managed_agents": {},
20
+ "prompt_templates": {
21
+ "system_prompt": "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.\nTo do so, you have been given access to a list of tools: these tools are basically Python functions which you can call with code.\nTo solve the task, you must plan forward to proceed in a series of steps, in a cycle of 'Thought:', 'Code:', and 'Observation:' sequences.\n\nAt each step, in the 'Thought:' sequence, you should first explain your reasoning towards solving the task and the tools that you want to use.\nThen in the 'Code:' sequence, you should write the code in simple Python. The code sequence must end with '<end_code>' sequence.\nDuring each intermediate step, you can use 'print()' to save whatever important information you will then need.\nThese print outputs will then appear in the 'Observation:' field, which will be available as input for the next step.\nIn the end you have to return a final answer using the `final_answer` tool.\n\nHere are a few examples using notional tools:\n---\nTask: \"Generate an image of the oldest person in this document.\"\n\nThought: 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.\nCode:\n```py\nanswer = document_qa(document=document, question=\"Who is the oldest person mentioned?\")\nprint(answer)\n```<end_code>\nObservation: \"The oldest person in the document is John Doe, a 55 year old lumberjack living in Newfoundland.\"\n\nThought: I will now generate an image showcasing the oldest person.\nCode:\n```py\nimage = image_generator(\"A portrait of John Doe, a 55-year-old man living in Canada.\")\nfinal_answer(image)\n```<end_code>\n\n---\nTask: \"What is the result of the following operation: 5 + 3 + 1294.678?\"\n\nThought: I will use python code to compute the result of the operation and then return the final answer using the `final_answer` tool\nCode:\n```py\nresult = 5 + 3 + 1294.678\nfinal_answer(result)\n```<end_code>\n\n---\nTask:\n\"Answer the question in the variable `question` about the image stored in the variable `image`. The question is in French.\nYou have been provided with these additional arguments, that you can access using the keys as variables in your python code:\n{'question': 'Quel est l'animal sur l'image?', 'image': 'path/to/image.jpg'}\"\n\nThought: 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.\nCode:\n```py\ntranslated_question = translator(question=question, src_lang=\"French\", tgt_lang=\"English\")\nprint(f\"The translated question is {translated_question}.\")\nanswer = image_qa(image=image, question=translated_question)\nfinal_answer(f\"The answer is {answer}\")\n```<end_code>\n\n---\nTask:\nIn a 1979 interview, Stanislaus Ulam discusses with Martin Sherwin about other great physicists of his time, including Oppenheimer.\nWhat does he say was the consequence of Einstein learning too much math on his creativity, in one word?\n\nThought: I need to find and read the 1979 interview of Stanislaus Ulam with Martin Sherwin.\nCode:\n```py\npages = search(query=\"1979 interview Stanislaus Ulam Martin Sherwin physicists Einstein\")\nprint(pages)\n```<end_code>\nObservation:\nNo result found for query \"1979 interview Stanislaus Ulam Martin Sherwin physicists Einstein\".\n\nThought: The query was maybe too restrictive and did not find any results. Let's try again with a broader query.\nCode:\n```py\npages = search(query=\"1979 interview Stanislaus Ulam\")\nprint(pages)\n```<end_code>\nObservation:\nFound 6 pages:\n[Stanislaus Ulam 1979 interview](https://ahf.nuclearmuseum.org/voices/oral-histories/stanislaus-ulams-interview-1979/)\n\n[Ulam discusses Manhattan Project](https://ahf.nuclearmuseum.org/manhattan-project/ulam-manhattan-project/)\n\n(truncated)\n\nThought: I will read the first 2 pages to know more.\nCode:\n```py\nfor url in [\"https://ahf.nuclearmuseum.org/voices/oral-histories/stanislaus-ulams-interview-1979/\", \"https://ahf.nuclearmuseum.org/manhattan-project/ulam-manhattan-project/\"]:\n whole_page = visit_webpage(url)\n print(whole_page)\n print(\"\\n\" + \"=\"*80 + \"\\n\") # Print separator between pages\n```<end_code>\nObservation:\nManhattan Project Locations:\nLos Alamos, NM\nStanislaus 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\n(truncated)\n\nThought: 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.\nCode:\n```py\nfinal_answer(\"diminished\")\n```<end_code>\n\n---\nTask: \"Which city has the highest population: Guangzhou or Shanghai?\"\n\nThought: 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.\nCode:\n```py\nfor city in [\"Guangzhou\", \"Shanghai\"]:\n print(f\"Population {city}:\", search(f\"{city} population\")\n```<end_code>\nObservation:\nPopulation Guangzhou: ['Guangzhou has a population of 15 million inhabitants as of 2021.']\nPopulation Shanghai: '26 million (2019)'\n\nThought: Now I know that Shanghai has the highest population.\nCode:\n```py\nfinal_answer(\"Shanghai\")\n```<end_code>\n\n---\nTask: \"What is the current age of the pope, raised to the power 0.36?\"\n\nThought: I will use the tool `wiki` to get the age of the pope, and confirm that with a web search.\nCode:\n```py\npope_age_wiki = wiki(query=\"current pope age\")\nprint(\"Pope age as per wikipedia:\", pope_age_wiki)\npope_age_search = web_search(query=\"current pope age\")\nprint(\"Pope age as per google search:\", pope_age_search)\n```<end_code>\nObservation:\nPope age: \"The pope Francis is currently 88 years old.\"\n\nThought: I know that the pope is 88 years old. Let's compute the result using python code.\nCode:\n```py\npope_current_age = 88 ** 0.36\nfinal_answer(pope_current_age)\n```<end_code>\n\nAbove 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:\n{%- for tool in tools.values() %}\n- {{ tool.name }}: {{ tool.description }}\n Takes inputs: {{tool.inputs}}\n Returns an output of type: {{tool.output_type}}\n{%- endfor %}\n\n{%- if managed_agents and managed_agents.values() | list %}\nYou can also give tasks to team members.\nCalling 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.\nGiven that this team member is a real human, you should be very verbose in your task.\nHere is a list of the team members that you can call:\n{%- for agent in managed_agents.values() %}\n- {{ agent.name }}: {{ agent.description }}\n{%- endfor %}\n{%- else %}\n{%- endif %}\n\nHere are the rules you should always follow to solve your task:\n1. Always provide a 'Thought:' sequence, and a 'Code:\\n```py' sequence ending with '```<end_code>' sequence, else you will fail.\n2. Use only variables that you have defined!\n3. 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?\")'.\n4. 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.\n5. Call a tool only when needed, and never re-do a tool call that you previously did with the exact same parameters.\n6. Don't name any new variable with the same name as a tool: for instance don't name a variable 'final_answer'.\n7. Never create any notional variables in our code, as having these in your logs will derail you from the true variables.\n8. You can use imports in your code, but only from the following list of modules: {{authorized_imports}}\n9. The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.\n10. Don't give up! You're in charge of solving the task, not providing directions to solve it.\n\nNow Begin! If you solve the task correctly, you will receive a reward of $1,000,000.",
22
+ "planning": {
23
+ "initial_facts": "Below I will present you a task.\n\nYou will now build a comprehensive preparatory survey of which facts we have at our disposal and which ones we still need.\nTo do so, you will have to read the task and identify things that must be discovered in order to successfully complete it.\nDon't make any assumptions. For each item, provide a thorough reasoning. Here is how you will structure this survey:\n\n---\n### 1. Facts given in the task\nList here the specific facts given in the task that could help you (there might be nothing here).\n\n### 2. Facts to look up\nList here any facts that we may need to look up.\nAlso 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.\n\n### 3. Facts to derive\nList here anything that we want to derive from the above by logical reasoning, for instance computation or simulation.\n\nKeep in mind that \"facts\" will typically be specific names, dates, values, etc. Your answer should use the below headings:\n### 1. Facts given in the task\n### 2. Facts to look up\n### 3. Facts to derive\nDo not add anything else.\n\nHere is the task:\n```\n{{task}}\n```\nNow begin!",
24
+ "initial_plan": "You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.\n\nNow for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.\nThis plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.\nDo not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.\nAfter writing the final step of the plan, write the '\\n<end_plan>' tag and stop there.\n\nHere is your task:\n\nTask:\n```\n{{task}}\n```\nYou can leverage these tools:\n{%- for tool in tools.values() %}\n- {{ tool.name }}: {{ tool.description }}\n Takes inputs: {{tool.inputs}}\n Returns an output of type: {{tool.output_type}}\n{%- endfor %}\n\n{%- if managed_agents and managed_agents.values() | list %}\nYou can also give tasks to team members.\nCalling 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.\nGiven that this team member is a real human, you should be very verbose in your request.\nHere is a list of the team members that you can call:\n{%- for agent in managed_agents.values() %}\n- {{ agent.name }}: {{ agent.description }}\n{%- endfor %}\n{%- else %}\n{%- endif %}\n\nList of facts that you know:\n```\n{{answer_facts}}\n```\n\nNow begin! Write your plan below.",
25
+ "update_facts_pre_messages": "You are a world expert at gathering known and unknown facts based on a conversation.\nBelow you will find a task, and a history of attempts made to solve the task. You will have to produce a list of these:\n### 1. Facts given in the task\n### 2. Facts that we have learned\n### 3. Facts still to look up\n### 4. Facts still to derive\nFind the task and history below:",
26
+ "update_facts_post_messages": "Earlier we've built a list of facts.\nBut since in your previous steps you may have learned useful new facts or invalidated some false ones.\nPlease update your list of facts based on the previous history, and provide these headings:\n### 1. Facts given in the task\n### 2. Facts that we have learned\n### 3. Facts still to look up\n### 4. Facts still to derive\n\nNow write your new list of facts below.",
27
+ "update_plan_pre_messages": "You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.\n\nYou have been given a task:\n```\n{{task}}\n```\n\nFind 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.\nIf the previous tries so far have met some success, you can make an updated plan based on these actions.\nIf you are stalled, you can make a completely new plan starting from scratch.",
28
+ "update_plan_post_messages": "You're still working towards solving this task:\n```\n{{task}}\n```\n\nYou can leverage these tools:\n{%- for tool in tools.values() %}\n- {{ tool.name }}: {{ tool.description }}\n Takes inputs: {{tool.inputs}}\n Returns an output of type: {{tool.output_type}}\n{%- endfor %}\n\n{%- if managed_agents and managed_agents.values() | list %}\nYou can also give tasks to team members.\nCalling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task'.\nGiven 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.\nHere is a list of the team members that you can call:\n{%- for agent in managed_agents.values() %}\n- {{ agent.name }}: {{ agent.description }}\n{%- endfor %}\n{%- else %}\n{%- endif %}\n\nHere is the up to date list of facts that you know:\n```\n{{facts_update}}\n```\n\nNow for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.\nThis plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.\nBeware that you have {remaining_steps} steps remaining.\nDo not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.\nAfter writing the final step of the plan, write the '\\n<end_plan>' tag and stop there.\n\nNow write your new plan below."
29
+ },
30
+ "managed_agent": {
31
+ "task": "You're a helpful agent named '{{name}}'.\nYou have been submitted this task by your manager.\n---\nTask:\n{{task}}\n---\nYou'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.\n\nYour final_answer WILL HAVE to contain these parts:\n### 1. Task outcome (short version):\n### 2. Task outcome (extremely detailed version):\n### 3. Additional context (if relevant):\n\nPut all these in your final_answer tool, everything that you do not pass as an argument to final_answer will be lost.\nAnd even if your task resolution is not successful, please return as much context as possible, so that your manager can act upon this feedback.",
32
+ "report": "Here is the final answer from your managed agent '{{name}}':\n{{final_answer}}"
33
+ },
34
+ "final_answer": {
35
+ "pre_messages": "An agent tried to answer a user query but it got stuck and failed to do so. You are tasked with providing an answer instead. Here is the agent's memory:",
36
+ "post_messages": "Based on the above, please provide an answer to the following user request:\n{{task}}"
37
+ }
38
+ },
39
+ "max_steps": 10,
40
+ "verbosity_level": 2,
41
+ "grammar": null,
42
+ "planning_interval": null,
43
+ "name": null,
44
+ "description": null,
45
+ "requirements": [
46
+ "requests",
47
+ "duckduckgo_search",
48
+ "markdownify",
49
+ "smolagents"
50
+ ],
51
+ "authorized_imports": [
52
+ "queue",
53
+ "collections",
54
+ "time",
55
+ "statistics",
56
+ "stat",
57
+ "math",
58
+ "unicodedata",
59
+ "random",
60
+ "itertools",
61
+ "re",
62
+ "datetime"
63
+ ]
64
+ }
app.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
prompts.yaml ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
196
+ Here is the task:
197
+ ```
198
+ {{task}}
199
+ ```
200
+ Now begin!
201
+ "initial_plan": |-
202
+ You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
203
+ Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
204
+ This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
205
+ Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
206
+ After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
207
+
208
+ Here is your task:
209
+
210
+ Task:
211
+ ```
212
+ {{task}}
213
+ ```
214
+ You can leverage these tools:
215
+ {%- for tool in tools.values() %}
216
+ - {{ tool.name }}: {{ tool.description }}
217
+ Takes inputs: {{tool.inputs}}
218
+ Returns an output of type: {{tool.output_type}}
219
+ {%- endfor %}
220
+
221
+ {%- if managed_agents and managed_agents.values() | list %}
222
+ You can also give tasks to team members.
223
+ 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.
224
+ Given that this team member is a real human, you should be very verbose in your request.
225
+ Here is a list of the team members that you can call:
226
+ {%- for agent in managed_agents.values() %}
227
+ - {{ agent.name }}: {{ agent.description }}
228
+ {%- endfor %}
229
+ {%- else %}
230
+ {%- endif %}
231
+
232
+ List of facts that you know:
233
+ ```
234
+ {{answer_facts}}
235
+ ```
236
+
237
+ Now begin! Write your plan below.
238
+ "update_facts_pre_messages": |-
239
+ You are a world expert at gathering known and unknown facts based on a conversation.
240
+ 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:
241
+ ### 1. Facts given in the task
242
+ ### 2. Facts that we have learned
243
+ ### 3. Facts still to look up
244
+ ### 4. Facts still to derive
245
+ Find the task and history below:
246
+ "update_facts_post_messages": |-
247
+ Earlier we've built a list of facts.
248
+ But since in your previous steps you may have learned useful new facts or invalidated some false ones.
249
+ Please update your list of facts based on the previous history, and provide these headings:
250
+ ### 1. Facts given in the task
251
+ ### 2. Facts that we have learned
252
+ ### 3. Facts still to look up
253
+ ### 4. Facts still to derive
254
+ Now write your new list of facts below.
255
+ "update_plan_pre_messages": |-
256
+ You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
257
+ You have been given a task:
258
+ ```
259
+ {{task}}
260
+ ```
261
+
262
+ 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.
263
+ If the previous tries so far have met some success, you can make an updated plan based on these actions.
264
+ If you are stalled, you can make a completely new plan starting from scratch.
265
+ "update_plan_post_messages": |-
266
+ You're still working towards solving this task:
267
+ ```
268
+ {{task}}
269
+ ```
270
+ You can leverage these tools:
271
+ {%- for tool in tools.values() %}
272
+ - {{ tool.name }}: {{ tool.description }}
273
+ Takes inputs: {{tool.inputs}}
274
+ Returns an output of type: {{tool.output_type}}
275
+ {%- endfor %}
276
+
277
+ {%- if managed_agents and managed_agents.values() | list %}
278
+ You can also give tasks to team members.
279
+ Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task'.
280
+ 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.
281
+ Here is a list of the team members that you can call:
282
+ {%- for agent in managed_agents.values() %}
283
+ - {{ agent.name }}: {{ agent.description }}
284
+ {%- endfor %}
285
+ {%- else %}
286
+ {%- endif %}
287
+
288
+ Here is the up to date list of facts that you know:
289
+ ```
290
+ {{facts_update}}
291
+ ```
292
+
293
+ Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
294
+ This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
295
+ Beware that you have {remaining_steps} steps remaining.
296
+ Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
297
+ After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
298
+
299
+ Now write your new plan below.
300
+ "managed_agent":
301
+ "task": |-
302
+ You're a helpful agent named '{{name}}'.
303
+ You have been submitted this task by your manager.
304
+ ---
305
+ Task:
306
+ {{task}}
307
+ ---
308
+ 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.
309
+ Your final_answer WILL HAVE to contain these parts:
310
+ ### 1. Task outcome (short version):
311
+ ### 2. Task outcome (extremely detailed version):
312
+ ### 3. Additional context (if relevant):
313
+
314
+ Put all these in your final_answer tool, everything that you do not pass as an argument to final_answer will be lost.
315
+ 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.
316
+ "report": |-
317
+ Here is the final answer from your managed agent '{{name}}':
318
+ {{final_answer}}
319
+ "final_answer":
320
+ "pre_messages": |-
321
+ An agent tried to answer a user query but it got stuck and failed to do so. You are tasked with providing an answer instead. Here is the agent's memory:
322
+ "post_messages": |-
323
+ Based on the above, please provide an answer to the following user request:
324
+ {{task}}
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ requests
2
+ smolagents
3
+ yaml
tools/.DS_Store ADDED
Binary file (6.15 kB). View file
 
tools/categorize_occasion.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import tool
2
+
3
+
4
+ @tool
5
+ def categorize_occasion(description: str) -> str:
6
+ """
7
+ Categorizes the occasion based on the description.
8
+
9
+ Args:
10
+ description: a str which is the description of the occasion.
11
+
12
+ Returns:
13
+ a str which is the category of the occasion.
14
+ """
15
+ keywords = {
16
+ "casual dining": ["casual", "relaxed", "comfort", "everyday", "homestyle"],
17
+ "formal dining": ["formal", "elegant", "gourmet", "sophisticated", "luxurious"],
18
+ "kids’ birthday party": [
19
+ "kids",
20
+ "birthday",
21
+ "fun",
22
+ "playful",
23
+ "sweet",
24
+ "colorful",
25
+ ],
26
+ "brunch": ["brunch", "sunny", "fresh", "laid-back", "morning"],
27
+ "wedding reception": [
28
+ "wedding",
29
+ "romantic",
30
+ "celebratory",
31
+ "lavish",
32
+ "classic",
33
+ ],
34
+ "cocktail party": ["cocktail", "chic", "trendy", "bite-sized", "elegant"],
35
+ "holiday feast": ["holiday", "festive", "traditional", "hearty", "seasonal"],
36
+ "BBQ cookout": ["bbq", "smoky", "rustic", "bold", "outdoor"],
37
+ "picnic": ["picnic", "light", "fresh", "portable", "easy"],
38
+ "game day": ["game day", "bold", "cheesy", "crispy", "finger-food"],
39
+ "afternoon tea": ["tea", "delicate", "floral", "light", "elegant"],
40
+ "business luncheon": [
41
+ "business",
42
+ "professional",
43
+ "refined",
44
+ "efficient",
45
+ "executive",
46
+ ],
47
+ "farm-to-table": ["farm", "organic", "fresh", "sustainable", "wholesome"],
48
+ "tasting menu": ["tasting", "experimental", "artisanal", "gourmet", "curated"],
49
+ "street food festival": ["street food", "global", "bold", "spicy", "handheld"],
50
+ "healthy & wellness": [
51
+ "healthy",
52
+ "clean",
53
+ "nutrient-rich",
54
+ "energizing",
55
+ "balanced",
56
+ ],
57
+ "late-night bites": [
58
+ "late-night",
59
+ "indulgent",
60
+ "savory",
61
+ "comforting",
62
+ "satisfying",
63
+ ],
64
+ "buffet": ["buffet", "grand", "varied", "abundant", "diverse"],
65
+ "family-style": ["family", "generous", "homely", "comforting", "shared"],
66
+ "vegan feast": ["vegan", "plant-based", "colorful", "wholesome", "conscious"],
67
+ "superhero": ["high-energy", "healthy", "superfood"],
68
+ }
69
+
70
+ for category, words in keywords.items():
71
+ if any(keyword in description for keyword in words):
72
+ return category
73
+
74
+ return "casual dining"
tools/estimate_preparation_time.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+ from smolagents import tool
3
+ from tools.search import search
4
+
5
+
6
+ @tool
7
+ def estimate_preparation_time(task: str) -> str:
8
+ """Estimates the time needed to complete a preparation task using web search and determines complexity based on similar tasks.
9
+
10
+ Args:
11
+ task: A preparation task like "music playlist", "dinner", "drinks", "decoration setup"
12
+
13
+ Returns:
14
+ An estimated time in HH:MM format.
15
+ """
16
+ complexity_query = f"What is the complexity level of preparing {task}?"
17
+ complexity_result = search(complexity_query)
18
+
19
+ if not complexity_result:
20
+ complexity = "medium" # default complexity if not found
21
+ else:
22
+ complexity = complexity_result
23
+
24
+ time_query = f"How long does it take to prepare {task} at {complexity} complexity?"
25
+ time_result = search(time_query)
26
+
27
+ if time_result:
28
+ return f"Approximate time: {time_result}"
29
+ else:
30
+ return "Could not retrieve an estimate. Try again later."
tools/party_theme_tool.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+
3
+
4
+ class PartyThemeTool(Tool):
5
+ name = "party_theme_generator"
6
+ description = """
7
+ This tool suggests creative party themes based on a menu category.
8
+ It returns a unique party theme idea.
9
+ """
10
+
11
+ inputs = {
12
+ "category": {
13
+ "type": "string",
14
+ "description": "The type of occasion categorized by categorize_menu().",
15
+ }
16
+ }
17
+
18
+ output_type = "string"
19
+
20
+ themes = {
21
+ "casual dining": "Backyard Bash: A relaxed and fun gathering with BBQ, picnic-style seating, and outdoor games.",
22
+ "formal dining": "Black Tie Soirée: An elegant dinner party with gourmet dishes, fine wines, and sophisticated decor.",
23
+ "kids’ birthday party": "Magical Wonderland: A colorful and playful party with themed decorations, fun activities, and a candy buffet.",
24
+ "brunch": "Sunny Garden Brunch: A fresh and delightful morning gathering with pastries, mimosas, and floral decor.",
25
+ "wedding reception": "Fairy Tale Wedding: A romantic and celebratory event with elegant decor, live music, and exquisite dining.",
26
+ "cocktail party": "Gatsby Glam: A chic 1920s-inspired cocktail party with jazz music, fancy drinks, and dazzling outfits.",
27
+ "holiday feast": "Winter Wonderland: A festive holiday dinner with seasonal dishes, twinkling lights, and cozy ambiance.",
28
+ "BBQ cookout": "Texas-Style BBQ: A bold and smoky feast featuring grilled meats, country music, and rustic decor.",
29
+ "picnic": "Spring Picnic: A laid-back outdoor meal with fresh sandwiches, fruit baskets, and checkered blankets.",
30
+ "game day": "Sports Fan Frenzy: A high-energy gathering with big screens, wings, and team spirit decorations.",
31
+ "afternoon tea": "Royal Tea Party: An elegant affair with fine china, delicate pastries, and a selection of gourmet teas.",
32
+ "business luncheon": "Executive Networking Lunch: A professional yet refined meal with business-friendly dishes and a sleek ambiance.",
33
+ "farm-to-table": "Organic Harvest Feast: A sustainable and wholesome dining experience with locally sourced ingredients.",
34
+ "tasting menu": "Chef’s Special Tasting: A curated multi-course experience with artisanal flavors and expertly paired wines.",
35
+ "street food festival": "Global Street Feast: A lively festival with food trucks, international flavors, and a bustling atmosphere.",
36
+ "healthy & wellness": "Zen Wellness Retreat: A health-conscious event featuring nutritious meals, yoga, and detox drinks.",
37
+ "late-night bites": "Midnight Munchies: A cozy gathering with comfort food, neon lights, and a relaxed, late-night vibe.",
38
+ "buffet": "Grand Buffet Extravaganza: A diverse dining experience with an endless selection of dishes from around the world.",
39
+ "family-style": "Sunday Family Feast: A warm and generous meal shared with loved ones around a big communal table.",
40
+ "vegan feast": "Green Gourmet Gala: A plant-based celebration with vibrant, wholesome dishes and eco-friendly decor.",
41
+ "fine dining": "Michelin Star Experience: A sophisticated evening inspired by world-class restaurants, featuring gourmet multi-course meals, expertly paired wines and candlelit ambiance.",
42
+ "super healthy food": "Pure Vitality Retreat: A rejuvenating event focused on nutrient-rich superfoods, fresh organic produce, and plant-based dishes with herbal infusions.",
43
+ }
44
+
45
+ def forward(self, category: str):
46
+ return self.themes.get(
47
+ category.lower(),
48
+ "Casual Gathering: A relaxed get-together with easygoing vibes and good food.",
49
+ )
tools/search.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import tool, DuckDuckGoSearchTool
2
+
3
+
4
+ @tool
5
+ def search(query: str) -> str:
6
+ """Perrforms a web serach using DuckDuckGo and returns the most relevant information fo the search term.
7
+ Args:
8
+ query: a str that specifies the information to retrieve.
9
+
10
+ Returns:
11
+ str: The first relevant result snippet or title from the search results.
12
+ """
13
+ search_tool = DuckDuckGoSearchTool()
14
+ results = search_tool.search(query)
15
+
16
+ if results:
17
+ return results[0]["snippet"] if "snippet" in results[0] else results[0]["title"]
18
+ return None