Andrei Nazarov commited on
Commit
b648690
·
1 Parent(s): e7f4f55

final agent

Browse files
Files changed (7) hide show
  1. README.md +1 -1
  2. __pycache__/tools.cpython-310.pyc +0 -0
  3. agent.json +53 -0
  4. app.py +101 -19
  5. prompts.yaml +312 -0
  6. requirements.txt +9 -2
  7. tools.py +132 -0
README.md CHANGED
@@ -12,4 +12,4 @@ hf_oauth: true
12
  hf_oauth_expiration_minutes: 480
13
  ---
14
 
15
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
12
  hf_oauth_expiration_minutes: 480
13
  ---
14
 
15
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
__pycache__/tools.cpython-310.pyc ADDED
Binary file (4.92 kB). View file
 
agent.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tools": [
3
+ "web_search",
4
+ "visit_webpage",
5
+ "final_answer"
6
+ ],
7
+ "model": {
8
+ "class": "HfApiModel",
9
+ "data": {
10
+ "max_tokens": 2096,
11
+ "temperature": 0.5,
12
+ "last_input_token_count": null,
13
+ "last_output_token_count": null,
14
+ "model_id": "Qwen/Qwen2.5-Coder-32B-Instruct",
15
+ "custom_role_conversions": null
16
+ }
17
+ },
18
+ "prompt_templates": {
19
+ "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.",
20
+ "planning": {
21
+ "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.",
22
+ "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.",
23
+ "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:",
24
+ "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.",
25
+ "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.",
26
+ "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."
27
+ },
28
+ "managed_agent": {
29
+ "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.",
30
+ "report": "Here is the final answer from your managed agent '{{name}}':\n{{final_answer}}"
31
+ }
32
+ },
33
+ "max_steps": 6,
34
+ "verbosity_level": 1,
35
+ "grammar": null,
36
+ "planning_interval": null,
37
+ "name": null,
38
+ "description": null,
39
+ "authorized_imports": [
40
+ "unicodedata",
41
+ "stat",
42
+ "datetime",
43
+ "random",
44
+ "pandas",
45
+ "itertools",
46
+ "math",
47
+ "statistics",
48
+ "queue",
49
+ "time",
50
+ "collections",
51
+ "re"
52
+ ]
53
+ }
app.py CHANGED
@@ -3,21 +3,86 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
10
 
11
  # --- Basic Agent Definition ---
12
- # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
- class BasicAgent:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  def __init__(self):
15
- print("BasicAgent initialized.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  def __call__(self, question: str) -> str:
17
- print(f"Agent received question (first 50 chars): {question[:50]}...")
18
- fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
20
- return fixed_answer
21
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
@@ -40,7 +105,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
40
 
41
  # 1. Instantiate Agent ( modify this part to create your agent)
42
  try:
43
- agent = BasicAgent()
44
  except Exception as e:
45
  print(f"Error instantiating agent: {e}")
46
  return f"Error initializing agent: {e}", None
@@ -139,6 +204,12 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
139
  results_df = pd.DataFrame(results_log)
140
  return status_message, results_df
141
 
 
 
 
 
 
 
142
 
143
  # --- Build Gradio Interface using Blocks ---
144
  with gr.Blocks() as demo:
@@ -158,18 +229,29 @@ with gr.Blocks() as demo:
158
  """
159
  )
160
 
161
- gr.LoginButton()
162
-
163
- run_button = gr.Button("Run Evaluation & Submit All Answers")
164
-
165
- status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
166
- # Removed max_rows=10 from DataFrame constructor
167
- results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
 
 
168
 
169
- run_button.click(
170
- fn=run_and_submit_all,
171
- outputs=[status_output, results_table]
172
- )
 
 
 
 
 
 
 
 
 
173
 
174
  if __name__ == "__main__":
175
  print("\n" + "-"*30 + " App Starting " + "-"*30)
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
7
+ from tools import FinalAnswerTool, convert_currency, handle_currency_error
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
11
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
 
13
  # --- Basic Agent Definition ---
14
+
15
+ # System prompt for the agent
16
+ SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question.
17
+ Report your thoughts, and finish your answer with just the answer — no prefixes like "FINAL ANSWER:".
18
+ Your answer should be a number OR as few words as possible OR a comma-separated list of numbers and/or strings.
19
+
20
+ Tool Use Guidelines:
21
+ 1. Do **not** use any tools outside of the provided tools list.
22
+ 2. Always use **only one tool at a time** in each step of your execution.
23
+ 3. Even for complex tasks, assume a solution exists. If one method fails, try another approach using different tools.
24
+
25
+ Currency Conversion Guidelines:
26
+ 1. Always use standard three-letter currency codes in UPPERCASE (USD, EUR, GBP, JPY, etc.)
27
+ 2. If you get an error from convert_currency, use handle_currency_error to get help
28
+ 3. Common supported currencies are: USD, EUR, GBP, JPY, AUD, CAD, CHF, CNY, INR
29
+ 4. Always check the error message and use handle_currency_error to get specific guidance
30
+ 5. If you get "not found in available rates" error, try a different currency pair from the common list
31
+ 6. Always convert the user currency input to the standard three-letter currency code in UPPERCASE (e.g. "usd" -> "USD", "us dollars" -> "USD", "russian ruble" -> "RUB")
32
+ 7. When giving the final answer, always use the standard three-letter currency code in UPPERCASE and not the user input.
33
+
34
+ Example workflow:
35
+ 1. First, normalize the currency inputs:
36
+ - "us dollars" -> "USD"
37
+ - "euro" -> "EUR"
38
+ - "pound" -> "GBP"
39
+ 2. Then try the conversion with the normalized codes
40
+ 3. If it fails, use handle_currency_error to understand why
41
+ 4. Based on the error message, either:
42
+ - Try a different currency pair
43
+ - Use an intermediate currency
44
+ - Suggest supported alternatives
45
+
46
+ Common currency mappings:
47
+ - USD: "us dollar", "us dollars", "dollar", "dollars"
48
+ - EUR: "euro", "euros"
49
+ - GBP: "pound", "pounds", "sterling"
50
+ - JPY: "yen", "japanese yen"
51
+ - AUD: "australian dollar"
52
+ - CAD: "canadian dollar"
53
+ - CHF: "swiss franc"
54
+ - CNY: "yuan", "renminbi"
55
+ - INR: "rupee", "indian rupee"
56
+ """
57
+
58
+ final_answer = FinalAnswerTool()
59
+
60
+ model = HfApiModel(model_id="gemini/gemini-2.0-flash-lite", api_key=os.getenv("GEMINI_API_KEY"))
61
+
62
+ class MyAgent:
63
  def __init__(self):
64
+ gemini_api_key = os.getenv("GEMINI_API_KEY")
65
+ if not gemini_api_key:
66
+ raise ValueError("GEMINI_API_KEY not set in environment variables.")
67
+
68
+ self.model = HfApiModel(
69
+ model_id="gemini/gemini-2.0-flash-lite",
70
+ api_key=gemini_api_key,
71
+ system_prompt=SYSTEM_PROMPT
72
+ )
73
+
74
+ self.agent = CodeAgent(
75
+ tools=[
76
+ FinalAnswerTool(),
77
+ DuckDuckGoSearchTool(),
78
+ convert_currency,
79
+ handle_currency_error
80
+ ],
81
+ model=self.model,
82
+ )
83
+
84
  def __call__(self, question: str) -> str:
85
+ return self.agent.run(question)
 
 
 
86
 
87
  def run_and_submit_all( profile: gr.OAuthProfile | None):
88
  """
 
105
 
106
  # 1. Instantiate Agent ( modify this part to create your agent)
107
  try:
108
+ agent = MyAgent()
109
  except Exception as e:
110
  print(f"Error instantiating agent: {e}")
111
  return f"Error initializing agent: {e}", None
 
204
  results_df = pd.DataFrame(results_log)
205
  return status_message, results_df
206
 
207
+ def test_currency_conversion(amount: float, from_currency: str, to_currency: str) -> str:
208
+ """Test function for currency conversion."""
209
+ try:
210
+ return convert_currency(from_currency, to_currency, int(amount))
211
+ except Exception as e:
212
+ return f"Error: {str(e)}"
213
 
214
  # --- Build Gradio Interface using Blocks ---
215
  with gr.Blocks() as demo:
 
229
  """
230
  )
231
 
232
+ with gr.Tab("Main Evaluation"):
233
+ gr.LoginButton()
234
+ run_button = gr.Button("Run Evaluation & Submit All Answers")
235
+ status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
236
+ results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
237
+ run_button.click(
238
+ fn=run_and_submit_all,
239
+ outputs=[status_output, results_table]
240
+ )
241
 
242
+ with gr.Tab("Currency Converter Test"):
243
+ gr.Markdown("## Test Currency Conversion")
244
+ amount_input = gr.Number(label="Amount", value=100)
245
+ from_currency = gr.Textbox(label="From Currency (e.g., USD)", value="USD")
246
+ to_currency = gr.Textbox(label="To Currency (e.g., EUR)", value="EUR")
247
+ convert_button = gr.Button("Convert")
248
+ result = gr.Textbox(label="Result")
249
+
250
+ convert_button.click(
251
+ fn=test_currency_conversion,
252
+ inputs=[amount_input, from_currency, to_currency],
253
+ outputs=result
254
+ )
255
 
256
  if __name__ == "__main__":
257
  print("\n" + "-"*30 + " App Starting " + "-"*30)
prompts.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 CHANGED
@@ -1,2 +1,9 @@
1
- gradio
2
- requests
 
 
 
 
 
 
 
 
1
+ gradio[oauth]>=4.0.0
2
+ requests>=2.31.0
3
+ pandas>=2.0.0
4
+ forex-python>=1.8
5
+ pyyaml>=6.0.1
6
+ typing-extensions>=4.5.0
7
+ markdownify
8
+ litellm>=1.0.0
9
+ git+https://github.com/huggingface/smolagents.git
tools.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, Optional, Union
2
+ from forex_python.converter import CurrencyRates, RatesNotAvailableError
3
+ import requests
4
+ from smolagents import tool, Tool
5
+
6
+ # Common currency mappings
7
+ CURRENCY_MAPPINGS = {
8
+ 'USD': ['usd', 'dollar', 'dollars', 'us dollar', 'us dollars'],
9
+ 'EUR': ['eur', 'euro', 'euros'],
10
+ 'GBP': ['gbp', 'pound', 'pounds', 'sterling'],
11
+ 'JPY': ['jpy', 'yen', 'japanese yen'],
12
+ 'AUD': ['aud', 'australian dollar'],
13
+ 'CAD': ['cad', 'canadian dollar'],
14
+ 'CHF': ['chf', 'swiss franc'],
15
+ 'CNY': ['cny', 'yuan', 'renminbi'],
16
+ 'INR': ['inr', 'rupee', 'indian rupee']
17
+ }
18
+
19
+ def normalize_currency(currency: str) -> str:
20
+ """Normalize currency input to standard three-letter code."""
21
+ currency = currency.strip().lower()
22
+
23
+ # Check if it's already a valid code
24
+ if currency.upper() in CURRENCY_MAPPINGS:
25
+ return currency.upper()
26
+
27
+ # Check if it's a known variation
28
+ for code, variations in CURRENCY_MAPPINGS.items():
29
+ if currency in variations:
30
+ return code
31
+
32
+ # If not found, return the original (will be caught by validation)
33
+ return currency.upper()
34
+
35
+ class FinalAnswerTool(Tool):
36
+ name = "final_answer"
37
+ description = "Provides a final answer to the given problem."
38
+ inputs = {'answer': {'type': 'any', 'description': 'The final answer to the problem'}}
39
+ output_type = "any"
40
+
41
+ def forward(self, answer: Any) -> Any:
42
+ return answer
43
+
44
+ def __init__(self, *args, **kwargs):
45
+ self.is_initialized = False
46
+
47
+ def get_exchange_rate_fallback(curr1: str, curr2: str) -> float:
48
+ """Fallback method to get exchange rates using a free API."""
49
+ try:
50
+ # Normalize currency codes
51
+ curr1 = normalize_currency(curr1)
52
+ curr2 = normalize_currency(curr2)
53
+
54
+ # Using a different free API endpoint
55
+ url = f"https://open.er-api.com/v6/latest/{curr1}"
56
+ response = requests.get(url, timeout=5)
57
+ response.raise_for_status()
58
+ data = response.json()
59
+
60
+ if data.get('result') != 'success':
61
+ raise Exception(f"API returned error: {data.get('error-type', 'Unknown error')}")
62
+
63
+ rates = data.get('rates', {})
64
+ if curr2 not in rates:
65
+ raise Exception(f"Exchange rate for {curr2} is not available. Please try a different currency pair.")
66
+
67
+ return rates[curr2]
68
+ except requests.exceptions.RequestException as e:
69
+ raise Exception(f"Network error while fetching exchange rate: {str(e)}")
70
+ except Exception as e:
71
+ raise Exception(f"Failed to fetch exchange rate from fallback API: {str(e)}")
72
+
73
+ @tool
74
+ def handle_currency_error(error: str, currency: str) -> str:
75
+ """A tool to handle currency conversion errors and suggest solutions.
76
+ Args:
77
+ error: The error message from the currency conversion attempt
78
+ currency: The currency code that caused the error
79
+ """
80
+ currency = currency.upper()
81
+ common_currencies = {
82
+ 'USD': 'US Dollar',
83
+ 'EUR': 'Euro',
84
+ 'GBP': 'British Pound',
85
+ 'JPY': 'Japanese Yen',
86
+ 'AUD': 'Australian Dollar',
87
+ 'CAD': 'Canadian Dollar',
88
+ 'CHF': 'Swiss Franc',
89
+ 'CNY': 'Chinese Yuan',
90
+ 'INR': 'Indian Rupee'
91
+ }
92
+
93
+ if 'not found in available rates' in error.lower():
94
+ return f"""Currency {currency} is not available for direct conversion.
95
+ Please try one of these approaches:
96
+ 1. Use a different currency pair from the supported list: {', '.join(common_currencies.keys())}
97
+ 2. Convert through USD or EUR as an intermediate currency
98
+ 3. If you need to convert {currency}, try converting to USD first, then to your target currency"""
99
+
100
+ if 'not found' in error.lower() or 'not available' in error.lower():
101
+ if currency in common_currencies:
102
+ return f"Currency {currency} ({common_currencies[currency]}) is not available for conversion. Please try a different currency pair from: {', '.join(common_currencies.keys())}"
103
+ else:
104
+ return f"Currency {currency} is not supported. Please use one of these common currencies: {', '.join(common_currencies.keys())}"
105
+
106
+ return f"Error with currency {currency}: {error}. Please try again with a different currency pair from: {', '.join(common_currencies.keys())}"
107
+
108
+ @tool
109
+ def convert_currency(curr1: str, curr2: str, amount: float) -> str:
110
+ """ A tool that converts one currency into another.
111
+ Args:
112
+ curr1: Currency 1, the initial currency that needs to be converted into another one (e.g. EUR, euro, usd).
113
+ curr2: Currency 2, the currency the first one needs to be converted into (e.g. RUB, dollar, gbp).
114
+ amount: The amount of currency 1 that needs to be converted (can be integer or decimal).
115
+ """
116
+ try:
117
+ # Normalize currency codes
118
+ curr1 = normalize_currency(curr1)
119
+ curr2 = normalize_currency(curr2)
120
+
121
+ # Try the primary method first
122
+ try:
123
+ cr = CurrencyRates()
124
+ converted_amount = cr.convert(curr1, curr2, amount)
125
+ except (RatesNotAvailableError, Exception) as e:
126
+ # If primary method fails, use fallback
127
+ rate = get_exchange_rate_fallback(curr1, curr2)
128
+ converted_amount = amount * rate
129
+
130
+ return f"{amount} {curr1} is {converted_amount:.2f} {curr2}"
131
+ except Exception as e:
132
+ return f"Error converting {curr1} to {curr2}: {str(e)}"