marksml commited on
Commit
5a72425
·
1 Parent(s): 96bf2d7

update a few files

Browse files
Files changed (3) hide show
  1. app.py +119 -27
  2. notebook.ipynb +220 -27
  3. tools.py +19 -1
app.py CHANGED
@@ -4,21 +4,106 @@ import requests
4
  import inspect
5
  import pandas as pd
6
  import json
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
10
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  # --- Basic Agent Definition ---
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
  class BasicAgent:
15
  def __init__(self):
16
  print("BasicAgent initialized.")
17
- def __call__(self, question: str) -> str:
 
18
  print(f"Agent received question (first 50 chars): {question[:50]}...")
19
- fixed_answer = "This is a default answer."
20
- print(f"Agent returning fixed answer: {fixed_answer}")
21
- return fixed_answer
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  def run_and_submit_all( profile: gr.OAuthProfile | None):
24
  """
@@ -76,19 +161,23 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
76
  results_log = []
77
  answers_payload = []
78
  print(f"Running agent on {len(questions_data)} questions...")
79
- for item in questions_data:
80
- task_id = item.get("task_id")
81
- question_text = item.get("question")
82
- if not task_id or question_text is None:
83
- print(f"Skipping item with missing task_id or question: {item}")
84
- continue
85
- try:
86
- submitted_answer = agent(question_text)
87
- answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
88
- results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
89
- except Exception as e:
90
- print(f"Error running agent on task {task_id}: {e}")
91
- results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
 
 
 
 
92
 
93
  if not answers_payload:
94
  print("Agent did not produce any answers to submit.")
@@ -102,18 +191,21 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
102
  # 5. Submit
103
  print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
104
  try:
105
- response = requests.post(submit_url, json=submission_data, timeout=60)
106
- response.raise_for_status()
107
- result_data = response.json()
108
- final_status = (
109
- f"Submission Successful!\n"
110
- f"User: {result_data.get('username')}\n"
111
- f"Overall Score: {result_data.get('score', 'N/A')}% "
112
- f"({result_data.get('correct_count', '?')}/{result_data.get('total_attempted', '?')} correct)\n"
113
- f"Message: {result_data.get('message', 'No message received.')}"
114
- )
115
  print("Submission successful.")
116
  results_df = pd.DataFrame(results_log)
 
 
 
117
  return final_status, results_df
118
  except requests.exceptions.HTTPError as e:
119
  error_detail = f"Server responded with status {e.response.status_code}."
 
4
  import inspect
5
  import pandas as pd
6
  import json
7
+ import yaml
8
+
9
+ from smolagents import ToolCallingAgent, Tool, InferenceClientModel, DuckDuckGoSearchTool
10
+ from smolagents import WikipediaSearchTool, PythonInterpreterTool
11
+ from smolagents import OpenAIServerModel
12
+ from tools import fetch_file
13
+
14
+ from phoenix.otel import register
15
+ from openinference.instrumentation.smolagents import SmolagentsInstrumentor
16
+
17
+ register()
18
+ SmolagentsInstrumentor().instrument()
19
 
20
  # (Keep Constants as is)
21
  # --- Constants ---
22
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
23
 
24
+ import os
25
+ token = os.getenv("HF_TOKEN")
26
+
27
+ if token is None:
28
+ raise ValueError('You must set the HF_TOKEN environment variable')
29
+ else:
30
+ print('Token was found')
31
+
32
+
33
+ #model = InferenceClientModel(model_id="Qwen/Qwen3-32B", provider="nscale")
34
+ #model = InferenceClientModel(model_id="deepseek-ai/DeepSeek-R1", provider="nebius")
35
+
36
+ # Set your Gemini API key in the environment variable GEMINI_API_KEY_1
37
+ model = OpenAIServerModel(
38
+ model_id="gemini-2.5-flash",
39
+ api_base="https://generativelanguage.googleapis.com/v1beta",
40
+ api_key=os.getenv("GEMINI_API_KEY_1")
41
+ )
42
+ print('GEMINI_API_KEY_1 was found:', os.getenv("GEMINI_API_KEY_1") is not None)
43
+
44
  # --- Basic Agent Definition ---
45
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
46
  class BasicAgent:
47
  def __init__(self):
48
  print("BasicAgent initialized.")
49
+
50
+ def __call__(self, taskid: str, question: str) -> str:
51
  print(f"Agent received question (first 50 chars): {question[:50]}...")
52
+ #fixed_answer = "This is a default answer."
53
+ #print(f"Agent returning fixed answer: {fixed_answer}")
54
+
55
+ # Define the prompt for the agent
56
+ # Report your thoughts, and finish your answer with the following template:
57
+
58
+ prompt = f"""
59
+
60
+ You are a general AI assistant.
61
+ I will ask you a question and you can use 10 steps to answer the question.
62
+ You can use the tools I provide you to answer my question. Every tool call reduces the number
63
+ of remaining steps available to answer the question.
64
+
65
+ YOUR FINAL ANSWER has be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
66
+ If you are asked for a number, do not use comma to write your number neither use units such as $ or percent sign unless specified otherwise.
67
+ If you are asked for a string, do not use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.
68
+ If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
69
+
70
+ Finish your answer with the following template:
71
+ FINAL ANSWER: [YOUR FINAL ANSWER].
72
+
73
+ The taskid is {taskid}. If you need to download a file that comes with the question then use
74
+ the taskid to fetch the file
75
+ The question is '{question}'.
76
+
77
+ """
78
+
79
+ agent = ToolCallingAgent(
80
+ tools=[
81
+ DuckDuckGoSearchTool(),
82
+ WikipediaSearchTool(),
83
+ fetch_file,
84
+ ],
85
+ model=model,
86
+ max_steps=10,
87
+ #tool_choice="auto",
88
+ )
89
+
90
+ # Run the agent with the prompt
91
+ fixed_answer = agent.run(prompt)
92
+ # Clean the answer
93
+ cleaned_answer = self.clean_answer(fixed_answer)
94
+
95
+ print(f"Agent returned cleaned answer: {cleaned_answer}")
96
+ return cleaned_answer
97
+
98
+ def clean_answer(self, answer: str) -> str:
99
+ # Remove "FINAL ANSWER:" (with or without trailing space)
100
+ answer = answer.replace("FINAL ANSWER:", "").strip()
101
+ # Remove last character if it is a period
102
+ if answer.endswith("."):
103
+ answer = answer[:-1]
104
+ return answer
105
+
106
+
107
 
108
  def run_and_submit_all( profile: gr.OAuthProfile | None):
109
  """
 
161
  results_log = []
162
  answers_payload = []
163
  print(f"Running agent on {len(questions_data)} questions...")
164
+
165
+ item = questions_data[0] if questions_data else None
166
+ #for item in questions_data:
167
+
168
+ task_id = item.get("task_id")
169
+ question_text = item.get("question")
170
+ #if not task_id or question_text is None:
171
+ # print(f"Skipping item with missing task_id or question: {item}")
172
+ # continue
173
+ try:
174
+ submitted_answer = agent(task_id, question_text)
175
+ answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
176
+ print(f"Task ID: {task_id}, Question: {question_text[:50]}..., Submitted Answer: {submitted_answer}")
177
+ results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
178
+ except Exception as e:
179
+ print(f"Error running agent on task {task_id}: {e}")
180
+ results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
181
 
182
  if not answers_payload:
183
  print("Agent did not produce any answers to submit.")
 
191
  # 5. Submit
192
  print(f"Submitting {len(answers_payload)} answers to: {submit_url}")
193
  try:
194
+ #response = requests.post(submit_url, json=submission_data, timeout=60)
195
+ #response.raise_for_status()
196
+ #result_data = response.json()
197
+ #final_status = (
198
+ # f"Submission Successful!\n"
199
+ # f"User: {result_data.get('username')}\n"
200
+ # f"Overall Score: {result_data.get('score', 'N/A')}% "
201
+ # f"({result_data.get('correct_count', '?')}/{result_data.get('total_attempted', '?')} correct)\n"
202
+ # f"Message: {result_data.get('message', 'No message received.')}"
203
+ #)
204
  print("Submission successful.")
205
  results_df = pd.DataFrame(results_log)
206
+ # delete this the next line
207
+ final_status = "Dummy status"
208
+
209
  return final_status, results_df
210
  except requests.exceptions.HTTPError as e:
211
  error_detail = f"Server responded with status {e.response.status_code}."
notebook.ipynb CHANGED
@@ -10,10 +10,18 @@
10
  },
11
  {
12
  "cell_type": "code",
13
- "execution_count": null,
14
  "id": "6cff8644",
15
  "metadata": {},
16
- "outputs": [],
 
 
 
 
 
 
 
 
17
  "source": [
18
  "import os\n",
19
  "token = os.getenv(\"HF_TOKEN\")\n",
@@ -27,19 +35,32 @@
27
  },
28
  {
29
  "cell_type": "code",
30
- "execution_count": null,
31
  "id": "a414cce1",
32
  "metadata": {},
33
- "outputs": [],
 
 
 
 
 
 
 
 
34
  "source": [
 
 
 
 
 
35
  "import yaml\n",
36
  "\n",
37
- "from smolagents import CodeAgent, Tool, InferenceClientModel, DuckDuckGoSearchTool, WikipediaSearchTool\n",
38
  "from smolagents import OpenAIServerModel\n",
39
  "from tools import fetch_file\n",
40
  "\n",
41
  "#model = InferenceClientModel(model_id=\"Qwen/Qwen3-32B\", provider=\"nscale\")\n",
42
- "model = InferenceClientModel(model_id=\"deepseek-ai/DeepSeek-R1-Distill-Llama-70B\", provider=\"nscale\")\n",
43
  "\n",
44
  "# Set your Gemini API key in the environment variable GEMINI_API_KEY_1\n",
45
  "#model = OpenAIServerModel(\n",
@@ -49,25 +70,53 @@
49
  "# ) \n",
50
  "#print('API key was found:', os.getenv(\"GEMINI_API_KEY_1\") is not None)\n",
51
  "\n",
52
- "#from app import BasicAgent\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  "\n",
54
- "system_prompt = \"\"\"You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: \n",
55
- "FINAL ANSWER: [YOUR FINAL ANSWER]. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.\n",
56
- "If you are asked for a number, don’t use comma to write your number neither use units such as $ or percent sign unless specified otherwise.\n",
57
- "If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.\n",
58
- "If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string. \n",
 
 
 
 
59
  "\n",
60
- "Here is the question: {question}\n",
61
- "\"\"\"\n",
62
  "\n",
63
- "agent = CodeAgent(\n",
64
- " model=model, \n",
65
- " tools=[fetch_file, DuckDuckGoSearchTool(), WikipediaSearchTool()], \n",
66
- " add_base_tools=True,\n",
67
- " additional_authorized_imports=['requests', 'bs4'] \n",
68
- " )\n",
69
  "\n",
70
- "\n"
71
  ]
72
  },
73
  {
@@ -80,10 +129,155 @@
80
  },
81
  {
82
  "cell_type": "code",
83
- "execution_count": null,
84
  "id": "09b50aa1",
85
  "metadata": {},
86
- "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  "source": [
88
  "item = {\n",
89
  " \"task_id\": \"8e867cd7-cff9-4e6c-867a-ff5ddc2550be\",\n",
@@ -93,12 +287,11 @@
93
  " }\n",
94
  "\n",
95
  "question_text = item[\"question\"]\n",
96
- "prompt_with_question = system_prompt.format(question=question_text)\n",
97
  "\n",
98
- "print(f\"Question: {prompt_with_question}\")\n",
99
  "\n",
100
- "#task_id = item[\"task_id\"]\n",
101
- "submitted_answer = agent(prompt_with_question)\n"
102
  ]
103
  }
104
  ],
 
10
  },
11
  {
12
  "cell_type": "code",
13
+ "execution_count": 19,
14
  "id": "6cff8644",
15
  "metadata": {},
16
+ "outputs": [
17
+ {
18
+ "name": "stdout",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "Token was found\n"
22
+ ]
23
+ }
24
+ ],
25
  "source": [
26
  "import os\n",
27
  "token = os.getenv(\"HF_TOKEN\")\n",
 
35
  },
36
  {
37
  "cell_type": "code",
38
+ "execution_count": 21,
39
  "id": "a414cce1",
40
  "metadata": {},
41
+ "outputs": [
42
+ {
43
+ "name": "stdout",
44
+ "output_type": "stream",
45
+ "text": [
46
+ "BasicAgent initialized.\n"
47
+ ]
48
+ }
49
+ ],
50
  "source": [
51
+ "import os\n",
52
+ "import requests\n",
53
+ "import inspect\n",
54
+ "import pandas as pd\n",
55
+ "import json\n",
56
  "import yaml\n",
57
  "\n",
58
+ "from smolagents import ToolCallingAgent, Tool, InferenceClientModel, DuckDuckGoSearchTool, WikipediaSearchTool\n",
59
  "from smolagents import OpenAIServerModel\n",
60
  "from tools import fetch_file\n",
61
  "\n",
62
  "#model = InferenceClientModel(model_id=\"Qwen/Qwen3-32B\", provider=\"nscale\")\n",
63
+ "model = InferenceClientModel(model_id=\"deepseek-ai/DeepSeek-R1\", provider=\"nebius\")\n",
64
  "\n",
65
  "# Set your Gemini API key in the environment variable GEMINI_API_KEY_1\n",
66
  "#model = OpenAIServerModel(\n",
 
70
  "# ) \n",
71
  "#print('API key was found:', os.getenv(\"GEMINI_API_KEY_1\") is not None)\n",
72
  "\n",
73
+ "# --- Basic Agent Definition ---\n",
74
+ "# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------\n",
75
+ "class BasicAgent:\n",
76
+ " def __init__(self):\n",
77
+ " print(\"BasicAgent initialized.\")\n",
78
+ " def __call__(self, taskid: str, question: str) -> str:\n",
79
+ " print(f\"Agent received question (first 50 chars): {question[:50]}...\")\n",
80
+ " #fixed_answer = \"This is a default answer.\"\n",
81
+ " #print(f\"Agent returning fixed answer: {fixed_answer}\")\n",
82
+ "\n",
83
+ " prompt = f\"\"\"\n",
84
+ " \n",
85
+ " You are a general AI assistant. \n",
86
+ " I will ask you a question and you can use 9 steps to answer the question.\n",
87
+ " You can use the tools I provide you to answer my question. Every tool call reduces the number \n",
88
+ " of remaining steps available to answer the question. \n",
89
+ " Report your thoughts, and finish your answer with the following template: \n",
90
+ " FINAL ANSWER: [YOUR FINAL ANSWER]. \n",
91
+ " \n",
92
+ " YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.\n",
93
+ " If you are asked for a number, don’t use comma to write your number neither use units such as $ or percent sign unless specified otherwise.\n",
94
+ " If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.\n",
95
+ " If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string. \n",
96
+ "\n",
97
+ " The taskid is {taskid}. If you need to download a file that comes with the question then use the taskid to fetch the file\n",
98
+ " The question is '{question}'.\n",
99
+ "\n",
100
+ " You have 9 steps to answer the question.\n",
101
+ "\n",
102
+ " \"\"\"\n",
103
  "\n",
104
+ " agent = ToolCallingAgent(\n",
105
+ " tools=[\n",
106
+ " fetch_file, \n",
107
+ " DuckDuckGoSearchTool(), \n",
108
+ " WikipediaSearchTool()\n",
109
+ " ], \n",
110
+ " model=model, \n",
111
+ " max_steps=9,\n",
112
+ " )\n",
113
  "\n",
114
+ " # Run the agent with the prompt\n",
115
+ " fixed_answer = agent.run(prompt)\n",
116
  "\n",
117
+ " return fixed_answer\n",
 
 
 
 
 
118
  "\n",
119
+ "agent = BasicAgent()\n"
120
  ]
121
  },
122
  {
 
129
  },
130
  {
131
  "cell_type": "code",
132
+ "execution_count": 22,
133
  "id": "09b50aa1",
134
  "metadata": {},
135
+ "outputs": [
136
+ {
137
+ "name": "stdout",
138
+ "output_type": "stream",
139
+ "text": [
140
+ "Agent received question (first 50 chars): How many studio albums were published by Mercedes ...\n"
141
+ ]
142
+ },
143
+ {
144
+ "data": {
145
+ "text/html": [
146
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702\">╭──────────────────────────────────────────────────── </span><span style=\"color: #d4b702; text-decoration-color: #d4b702; font-weight: bold\">New run</span><span style=\"color: #d4b702; text-decoration-color: #d4b702\"> ────────────────────────────────────────────────────╮</span>\n",
147
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
148
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">You are a general AI assistant. </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
149
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> I will ask you a question and you can use 9 steps to answer the question.</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
150
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> You can use the tools I provide you to answer my question. Every tool call reduces the number </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
151
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> of remaining steps available to answer the question. </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
152
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> Report your thoughts, and finish your answer with the following template: </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
153
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> FINAL ANSWER: [YOUR FINAL ANSWER\\]. </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
154
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
155
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
156
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">and/or strings.</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
157
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> If you are asked for a number, don’t use comma to write your number neither use units such as $ or </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
158
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">percent sign unless specified otherwise.</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
159
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
160
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">the digits in plain text unless specified otherwise.</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
161
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> If you are asked for a comma separated list, apply the above rules depending of whether the element to </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
162
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">be put in the list is a number or a string. </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
163
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
164
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> The taskid is 8e867cd7-cff9-4e6c-867a-ff5ddc2550be. If you need to download a file that comes with the </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
165
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">question then use the taskid to fetch the file</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
166
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> The question is 'How many studio albums were published by Mercedes Sosa between 2000 and 2009 </span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
167
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">(included)? You can use the latest 2022 version of english wikipedia.'.</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
168
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
169
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\"> You have 9 steps to answer the question.</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
170
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n",
171
+ "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">╰─ InferenceClientModel - deepseek-ai/DeepSeek-R1 ────────────────────────────────────────────────────────────────╯</span>\n",
172
+ "</pre>\n"
173
+ ],
174
+ "text/plain": [
175
+ "\u001b[38;2;212;183;2m╭─\u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[1;38;2;212;183;2mNew run\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╮\u001b[0m\n",
176
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
177
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mYou are a general AI assistant. \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
178
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m I will ask you a question and you can use 9 steps to answer the question.\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
179
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m You can use the tools I provide you to answer my question. Every tool call reduces the number \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
180
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m of remaining steps available to answer the question. \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
181
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m Report your thoughts, and finish your answer with the following template: \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
182
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m FINAL ANSWER: [YOUR FINAL ANSWER\\]. \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
183
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
184
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
185
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mand/or strings.\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
186
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m If you are asked for a number, don’t use comma to write your number neither use units such as $ or \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
187
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mpercent sign unless specified otherwise.\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
188
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
189
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mthe digits in plain text unless specified otherwise.\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
190
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m If you are asked for a comma separated list, apply the above rules depending of whether the element to \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
191
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mbe put in the list is a number or a string. \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
192
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
193
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m The taskid is 8e867cd7-cff9-4e6c-867a-ff5ddc2550be. If you need to download a file that comes with the \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
194
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mquestion then use the taskid to fetch the file\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
195
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m The question is 'How many studio albums were published by Mercedes Sosa between 2000 and 2009 \u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
196
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m(included)? You can use the latest 2022 version of english wikipedia.'.\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
197
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
198
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1m You have 9 steps to answer the question.\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
199
+ "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n",
200
+ "\u001b[38;2;212;183;2m╰─\u001b[0m\u001b[38;2;212;183;2m InferenceClientModel - deepseek-ai/DeepSeek-R1 \u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n"
201
+ ]
202
+ },
203
+ "metadata": {},
204
+ "output_type": "display_data"
205
+ },
206
+ {
207
+ "data": {
208
+ "text/html": [
209
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #d4b702; text-decoration-color: #d4b702\">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ </span><span style=\"font-weight: bold\">Step </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #d4b702; text-decoration-color: #d4b702\"> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span>\n",
210
+ "</pre>\n"
211
+ ],
212
+ "text/plain": [
213
+ "\u001b[38;2;212;183;2m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \u001b[0m\u001b[1mStep \u001b[0m\u001b[1;36m1\u001b[0m\u001b[38;2;212;183;2m ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m\n"
214
+ ]
215
+ },
216
+ "metadata": {},
217
+ "output_type": "display_data"
218
+ },
219
+ {
220
+ "data": {
221
+ "text/html": [
222
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Error while generating output:</span>\n",
223
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">(Request ID: </span><span style=\"color: #808000; text-decoration-color: #808000; font-weight: bold\">Root</span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">=</span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1</span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">-686d606c-1f8bffb50e7ac4b077a26fe0;</span><span style=\"color: #ffff00; text-decoration-color: #ffff00\">2128d2d1-4e56-4788-a9eb-3015f54f1e44</span><span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">)</span>\n",
224
+ "\n",
225
+ "<span style=\"color: #800000; text-decoration-color: #800000; font-weight: bold\">Bad request:</span>\n",
226
+ "</pre>\n"
227
+ ],
228
+ "text/plain": [
229
+ "\u001b[1;31mError while generating output:\u001b[0m\n",
230
+ "\u001b[1;31m(\u001b[0m\u001b[1;31mRequest ID: \u001b[0m\u001b[1;33mRoot\u001b[0m\u001b[1;31m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;31m-686d606c-1f8bffb50e7ac4b077a26fe0;\u001b[0m\u001b[93m2128d2d1-4e56-4788-a9eb-3015f54f1e44\u001b[0m\u001b[1;31m)\u001b[0m\n",
231
+ "\n",
232
+ "\u001b[1;31mBad request:\u001b[0m\n"
233
+ ]
234
+ },
235
+ "metadata": {},
236
+ "output_type": "display_data"
237
+ },
238
+ {
239
+ "data": {
240
+ "text/html": [
241
+ "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">[Step 1: Duration 0.80 seconds]</span>\n",
242
+ "</pre>\n"
243
+ ],
244
+ "text/plain": [
245
+ "\u001b[2m[Step 1: Duration 0.80 seconds]\u001b[0m\n"
246
+ ]
247
+ },
248
+ "metadata": {},
249
+ "output_type": "display_data"
250
+ },
251
+ {
252
+ "ename": "AgentGenerationError",
253
+ "evalue": "Error while generating output:\n(Request ID: Root=1-686d606c-1f8bffb50e7ac4b077a26fe0;2128d2d1-4e56-4788-a9eb-3015f54f1e44)\n\nBad request:",
254
+ "output_type": "error",
255
+ "traceback": [
256
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
257
+ "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)",
258
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\huggingface_hub\\utils\\_http.py:409\u001b[0m, in \u001b[0;36mhf_raise_for_status\u001b[1;34m(response, endpoint_name)\u001b[0m\n\u001b[0;32m 408\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 409\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 410\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m HTTPError \u001b[38;5;28;01mas\u001b[39;00m e:\n",
259
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\requests\\models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n",
260
+ "\u001b[1;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://router.huggingface.co/nebius/v1/chat/completions",
261
+ "\nThe above exception was the direct cause of the following exception:\n",
262
+ "\u001b[1;31mBadRequestError\u001b[0m Traceback (most recent call last)",
263
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\smolagents\\agents.py:1272\u001b[0m, in \u001b[0;36mToolCallingAgent._step_stream\u001b[1;34m(self, memory_step)\u001b[0m\n\u001b[0;32m 1271\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m-> 1272\u001b[0m chat_message: ChatMessage \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mgenerate\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1273\u001b[0m \u001b[43m \u001b[49m\u001b[43minput_messages\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1274\u001b[0m \u001b[43m \u001b[49m\u001b[43mstop_sequences\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mObservation:\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mCalling tools:\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1275\u001b[0m \u001b[43m \u001b[49m\u001b[43mtools_to_call_from\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtools_and_managed_agents\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m 1276\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1278\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlogger\u001b[38;5;241m.\u001b[39mlog_markdown(\n\u001b[0;32m 1279\u001b[0m content\u001b[38;5;241m=\u001b[39mchat_message\u001b[38;5;241m.\u001b[39mcontent \u001b[38;5;28;01mif\u001b[39;00m chat_message\u001b[38;5;241m.\u001b[39mcontent \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28mstr\u001b[39m(chat_message\u001b[38;5;241m.\u001b[39mraw),\n\u001b[0;32m 1280\u001b[0m title\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mOutput message of the LLM:\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m 1281\u001b[0m level\u001b[38;5;241m=\u001b[39mLogLevel\u001b[38;5;241m.\u001b[39mDEBUG,\n\u001b[0;32m 1282\u001b[0m )\n",
264
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\smolagents\\models.py:1408\u001b[0m, in \u001b[0;36mInferenceClientModel.generate\u001b[1;34m(self, messages, stop_sequences, response_format, tools_to_call_from, **kwargs)\u001b[0m\n\u001b[0;32m 1399\u001b[0m completion_kwargs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_prepare_completion_kwargs(\n\u001b[0;32m 1400\u001b[0m messages\u001b[38;5;241m=\u001b[39mmessages,\n\u001b[0;32m 1401\u001b[0m stop_sequences\u001b[38;5;241m=\u001b[39mstop_sequences,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 1406\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[0;32m 1407\u001b[0m )\n\u001b[1;32m-> 1408\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mclient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mchat_completion\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mcompletion_kwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1410\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_last_input_token_count \u001b[38;5;241m=\u001b[39m response\u001b[38;5;241m.\u001b[39musage\u001b[38;5;241m.\u001b[39mprompt_tokens\n",
265
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\huggingface_hub\\inference\\_client.py:924\u001b[0m, in \u001b[0;36mInferenceClient.chat_completion\u001b[1;34m(self, messages, model, stream, frequency_penalty, logit_bias, logprobs, max_tokens, n, presence_penalty, response_format, seed, stop, stream_options, temperature, tool_choice, tool_prompt, tools, top_logprobs, top_p, extra_body)\u001b[0m\n\u001b[0;32m 917\u001b[0m request_parameters \u001b[38;5;241m=\u001b[39m provider_helper\u001b[38;5;241m.\u001b[39mprepare_request(\n\u001b[0;32m 918\u001b[0m inputs\u001b[38;5;241m=\u001b[39mmessages,\n\u001b[0;32m 919\u001b[0m parameters\u001b[38;5;241m=\u001b[39mparameters,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 922\u001b[0m api_key\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtoken,\n\u001b[0;32m 923\u001b[0m )\n\u001b[1;32m--> 924\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_inner_post\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest_parameters\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstream\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 926\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m stream:\n",
266
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\huggingface_hub\\inference\\_client.py:280\u001b[0m, in \u001b[0;36mInferenceClient._inner_post\u001b[1;34m(self, request_parameters, stream)\u001b[0m\n\u001b[0;32m 279\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 280\u001b[0m \u001b[43mhf_raise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43mresponse\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 281\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\u001b[38;5;241m.\u001b[39miter_lines() \u001b[38;5;28;01mif\u001b[39;00m stream \u001b[38;5;28;01melse\u001b[39;00m response\u001b[38;5;241m.\u001b[39mcontent\n",
267
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\huggingface_hub\\utils\\_http.py:465\u001b[0m, in \u001b[0;36mhf_raise_for_status\u001b[1;34m(response, endpoint_name)\u001b[0m\n\u001b[0;32m 462\u001b[0m message \u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m 463\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mBad request for \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mendpoint_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m endpoint:\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m endpoint_name \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mBad request:\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 464\u001b[0m )\n\u001b[1;32m--> 465\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m _format(BadRequestError, message, response) \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01me\u001b[39;00m\n\u001b[0;32m 467\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m response\u001b[38;5;241m.\u001b[39mstatus_code \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m403\u001b[39m:\n",
268
+ "\u001b[1;31mBadRequestError\u001b[0m: (Request ID: Root=1-686d606c-1f8bffb50e7ac4b077a26fe0;2128d2d1-4e56-4788-a9eb-3015f54f1e44)\n\nBad request:",
269
+ "\nThe above exception was the direct cause of the following exception:\n",
270
+ "\u001b[1;31mAgentGenerationError\u001b[0m Traceback (most recent call last)",
271
+ "Cell \u001b[1;32mIn[22], line 11\u001b[0m\n\u001b[0;32m 8\u001b[0m question_text \u001b[38;5;241m=\u001b[39m item[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mquestion\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[0;32m 9\u001b[0m task_id \u001b[38;5;241m=\u001b[39m item[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtask_id\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n\u001b[1;32m---> 11\u001b[0m submitted_answer \u001b[38;5;241m=\u001b[39m \u001b[43magent\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtask_id\u001b[49m\u001b[43m,\u001b[49m\u001b[43mquestion_text\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 13\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSubmitted answer:\u001b[39m\u001b[38;5;124m\"\u001b[39m, submitted_answer)\n",
272
+ "Cell \u001b[1;32mIn[21], line 65\u001b[0m, in \u001b[0;36mBasicAgent.__call__\u001b[1;34m(self, taskid, question)\u001b[0m\n\u001b[0;32m 54\u001b[0m agent \u001b[38;5;241m=\u001b[39m ToolCallingAgent(\n\u001b[0;32m 55\u001b[0m tools\u001b[38;5;241m=\u001b[39m[\n\u001b[0;32m 56\u001b[0m fetch_file, \n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 61\u001b[0m max_steps\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m9\u001b[39m,\n\u001b[0;32m 62\u001b[0m )\n\u001b[0;32m 64\u001b[0m \u001b[38;5;66;03m# Run the agent with the prompt\u001b[39;00m\n\u001b[1;32m---> 65\u001b[0m fixed_answer \u001b[38;5;241m=\u001b[39m \u001b[43magent\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mprompt\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 67\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m fixed_answer\n",
273
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\smolagents\\agents.py:442\u001b[0m, in \u001b[0;36mMultiStepAgent.run\u001b[1;34m(self, task, stream, reset, images, additional_args, max_steps)\u001b[0m\n\u001b[0;32m 439\u001b[0m run_start_time \u001b[38;5;241m=\u001b[39m time\u001b[38;5;241m.\u001b[39mtime()\n\u001b[0;32m 440\u001b[0m \u001b[38;5;66;03m# Outputs are returned only at the end. We only look at the last step.\u001b[39;00m\n\u001b[1;32m--> 442\u001b[0m steps \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mlist\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_run_stream\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtask\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtask\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmax_steps\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmax_steps\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mimages\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mimages\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 443\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(steps[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m], FinalAnswerStep)\n\u001b[0;32m 444\u001b[0m output \u001b[38;5;241m=\u001b[39m steps[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\u001b[38;5;241m.\u001b[39moutput\n",
274
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\smolagents\\agents.py:530\u001b[0m, in \u001b[0;36mMultiStepAgent._run_stream\u001b[1;34m(self, task, max_steps, images)\u001b[0m\n\u001b[0;32m 527\u001b[0m final_answer \u001b[38;5;241m=\u001b[39m output\u001b[38;5;241m.\u001b[39moutput\n\u001b[0;32m 528\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m AgentGenerationError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 529\u001b[0m \u001b[38;5;66;03m# Agent generation errors are not caused by a Model error but an implementation error: so we should raise them and exit.\u001b[39;00m\n\u001b[1;32m--> 530\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[0;32m 531\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m AgentError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 532\u001b[0m \u001b[38;5;66;03m# Other AgentError types are caused by the Model, so we should log them and iterate.\u001b[39;00m\n\u001b[0;32m 533\u001b[0m action_step\u001b[38;5;241m.\u001b[39merror \u001b[38;5;241m=\u001b[39m e\n",
275
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\smolagents\\agents.py:517\u001b[0m, in \u001b[0;36mMultiStepAgent._run_stream\u001b[1;34m(self, task, max_steps, images)\u001b[0m\n\u001b[0;32m 515\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlogger\u001b[38;5;241m.\u001b[39mlog_rule(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mStep \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstep_number\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m, level\u001b[38;5;241m=\u001b[39mLogLevel\u001b[38;5;241m.\u001b[39mINFO)\n\u001b[0;32m 516\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 517\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43moutput\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_step_stream\u001b[49m\u001b[43m(\u001b[49m\u001b[43maction_step\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[0;32m 518\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;66;43;03m# Yield streaming deltas\u001b[39;49;00m\n\u001b[0;32m 519\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mnot\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43misinstance\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43moutput\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43mActionOutput\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mToolOutput\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[0;32m 520\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43moutput\u001b[49m\n",
276
+ "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python313\\site-packages\\smolagents\\agents.py:1289\u001b[0m, in \u001b[0;36mToolCallingAgent._step_stream\u001b[1;34m(self, memory_step)\u001b[0m\n\u001b[0;32m 1287\u001b[0m memory_step\u001b[38;5;241m.\u001b[39mtoken_usage \u001b[38;5;241m=\u001b[39m chat_message\u001b[38;5;241m.\u001b[39mtoken_usage\n\u001b[0;32m 1288\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m-> 1289\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m AgentGenerationError(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mError while generating output:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlogger) \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01me\u001b[39;00m\n\u001b[0;32m 1291\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m chat_message\u001b[38;5;241m.\u001b[39mtool_calls \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(chat_message\u001b[38;5;241m.\u001b[39mtool_calls) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[0;32m 1292\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
277
+ "\u001b[1;31mAgentGenerationError\u001b[0m: Error while generating output:\n(Request ID: Root=1-686d606c-1f8bffb50e7ac4b077a26fe0;2128d2d1-4e56-4788-a9eb-3015f54f1e44)\n\nBad request:"
278
+ ]
279
+ }
280
+ ],
281
  "source": [
282
  "item = {\n",
283
  " \"task_id\": \"8e867cd7-cff9-4e6c-867a-ff5ddc2550be\",\n",
 
287
  " }\n",
288
  "\n",
289
  "question_text = item[\"question\"]\n",
290
+ "task_id = item[\"task_id\"]\n",
291
  "\n",
292
+ "submitted_answer = agent(task_id,question_text)\n",
293
  "\n",
294
+ "print(\"Submitted answer:\", submitted_answer)\n"
 
295
  ]
296
  }
297
  ],
tools.py CHANGED
@@ -1,7 +1,25 @@
1
- from smolagents import tool
2
  import requests
3
  import json
4
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  @tool
7
  def fetch_questions(api_url: str) -> dict | None:
 
 
1
  import requests
2
  import json
3
  import os
4
+ from smolagents import tool
5
+ from typing import Any, Optional
6
+ from smolagents.tools import Tool
7
+
8
+ class FinalAnswerTool(Tool):
9
+ name = "final_answer"
10
+ description = "Provides a final answer to the given problem."
11
+ inputs = {'answer': {'type': 'any', 'description': 'The final answer to the problem'}}
12
+ output_type = "any"
13
+
14
+ def forward(self, answer: Any) -> Any:
15
+
16
+ # Returns the final answer provided by the agent.
17
+ # FINAL ANSWER: [YOUR FINAL ANSWER].
18
+
19
+ return answer
20
+
21
+ def __init__(self, *args, **kwargs):
22
+ self.is_initialized = False
23
 
24
  @tool
25
  def fetch_questions(api_url: str) -> dict | None: