mriusero commited on
Commit
7674639
·
1 Parent(s): 3aa49cb

core: refacto

Browse files
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import os
2
- from src.gradio_ui import user_interface
3
 
4
  if __name__ == "__main__":
5
  print("\n" + "-"*30 + " App Starting " + "-"*30)
 
1
  import os
2
+ from src.utils import user_interface
3
 
4
  if __name__ == "__main__":
5
  print("\n" + "-"*30 + " App Starting " + "-"*30)
prompts/final_answer.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ "final_answer":
2
+ "pre_messages": ""
3
+ "post_messages": ""
prompts/managed_agent.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "managed_agent":
2
+ "task": |-
3
+ You are a general AI assistant. I will ask you a question. Report your thoughts, and finish
4
+ your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
5
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of
6
+ numbers and/or strings.
7
+ If you are asked for a number, don’t use comma to write your number neither use units such as $ or percent
8
+ sign unless specified otherwise.
9
+ If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write the digits in
10
+ plain text unless specified otherwise.
11
+ If you are asked for a comma separated list, apply the above rules depending of whether the element to be put
12
+ in the list is a number or a string.
13
+ "report": |-
14
+ Here is the final answer from your managed agent '{{name}}':
15
+ {{final_answer}}
prompts/planning.yaml ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "planning":
2
+ "initial_facts": |-
3
+ Below I will present you a task.
4
+
5
+ You will now build a comprehensive preparatory survey of which facts we have at our disposal and which ones we still need.
6
+ To do so, you will have to read the task and identify things that must be discovered in order to successfully complete it.
7
+ Don't make any assumptions. For each item, provide a thorough reasoning. Here is how you will structure this survey:
8
+
9
+ ---
10
+ ### 1. Facts given in the task
11
+ List here the specific facts given in the task that could help you (there might be nothing here).
12
+
13
+ ### 2. Facts to look up
14
+ List here any facts that we may need to look up.
15
+ 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.
16
+
17
+ ### 3. Facts to derive
18
+ List here anything that we want to derive from the above by logical reasoning, for instance computation or simulation.
19
+
20
+ Keep in mind that "facts" will typically be specific names, dates, values, etc. Your answer should use the below headings:
21
+ ### 1. Facts given in the task
22
+ ### 2. Facts to look up
23
+ ### 3. Facts to derive
24
+ Do not add anything else.
25
+ "initial_plan": |-
26
+ You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
27
+
28
+ Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
29
+ This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
30
+ Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
31
+ After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
32
+
33
+ Here is your task:
34
+
35
+ Task:
36
+ ```
37
+ {{task}}
38
+ ```
39
+ You can leverage these tools:
40
+ {%- for tool in tools.values() %}
41
+ - {{ tool.name }}: {{ tool.description }}
42
+ Takes inputs: {{tool.inputs}}
43
+ Returns an output of type: {{tool.output_type}}
44
+ {%- endfor %}
45
+
46
+ {%- if managed_agents and managed_agents.values() | list %}
47
+ You can also give tasks to team members.
48
+ 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.
49
+ Given that this team member is a real human, you should be very verbose in your request.
50
+ Here is a list of the team members that you can call:
51
+ {%- for agent in managed_agents.values() %}
52
+ - {{ agent.name }}: {{ agent.description }}
53
+ {%- endfor %}
54
+ {%- else %}
55
+ {%- endif %}
56
+
57
+ List of facts that you know:
58
+ ```
59
+ {{answer_facts}}
60
+ ```
61
+
62
+ Now begin! Write your plan below.
63
+ "update_facts_pre_messages": |-
64
+ You are a world expert at gathering known and unknown facts based on a conversation.
65
+ 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:
66
+ ### 1. Facts given in the task
67
+ ### 2. Facts that we have learned
68
+ ### 3. Facts still to look up
69
+ ### 4. Facts still to derive
70
+ Find the task and history below:
71
+ "update_facts_post_messages": |-
72
+ Earlier we've built a list of facts.
73
+ But since in your previous steps you may have learned useful new facts or invalidated some false ones.
74
+ Please update your list of facts based on the previous history, and provide these headings:
75
+ ### 1. Facts given in the task
76
+ ### 2. Facts that we have learned
77
+ ### 3. Facts still to look up
78
+ ### 4. Facts still to derive
79
+
80
+ Now write your new list of facts below.
81
+ "update_plan_pre_messages": |-
82
+ You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
83
+
84
+ You have been given a task:
85
+ ```
86
+ {{task}}
87
+ ```
88
+
89
+ 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.
90
+ If the previous tries so far have met some success, you can make an updated plan based on these actions.
91
+ If you are stalled, you can make a completely new plan starting from scratch.
92
+ "update_plan_post_messages": |-
93
+ You're still working towards solving this task:
94
+ ```
95
+ {{task}}
96
+ ```
97
+
98
+ You can leverage these tools:
99
+ {%- for tool in tools.values() %}
100
+ - {{ tool.name }}: {{ tool.description }}
101
+ Takes inputs: {{tool.inputs}}
102
+ Returns an output of type: {{tool.output_type}}
103
+ {%- endfor %}
104
+
105
+ {%- if managed_agents and managed_agents.values() | list %}
106
+ You can also give tasks to team members.
107
+ Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task'.
108
+ 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.
109
+ Here is a list of the team members that you can call:
110
+ {%- for agent in managed_agents.values() %}
111
+ - {{ agent.name }}: {{ agent.description }}
112
+ {%- endfor %}
113
+ {%- else %}
114
+ {%- endif %}
115
+
116
+ Here is the up to date list of facts that you know:
117
+ ```
118
+ {{facts_update}}
119
+ ```
120
+
121
+ Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
122
+ This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
123
+ Beware that you have {remaining_steps} steps remaining.
124
+ Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
125
+ After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
126
+
127
+ Now write your new plan below.
prompt.yaml → prompts/system_prompt.yaml RENAMED
@@ -13,7 +13,7 @@
13
  ---
14
  Task: "Generate an image of the oldest person in this document."
15
 
16
- 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.
17
  Code:
18
  ```py
19
  answer = document_qa(document=document, question="Who is the oldest person mentioned?")
@@ -31,7 +31,7 @@
31
  ---
32
  Task: "What is the result of the following operation: 5 + 3 + 1294.678?"
33
 
34
- Thought: I will use python code to compute the result of the operation and then return the final answer using the `final_answer` tool.
35
  Code:
36
  ```py
37
  result = 5 + 3 + 1294.678
@@ -44,7 +44,7 @@
44
  You have been provided with these additional arguments, that you can access using the keys as variables in your python code:
45
  {'question': 'Quel est l'animal sur l'image?', 'image': 'path/to/image.jpg'}"
46
 
47
- 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.
48
  Code:
49
  ```py
50
  translated_question = translator(question=question, src_lang="French", tgt_lang="English")
@@ -58,7 +58,7 @@
58
  In a 1979 interview, Stanislaus Ulam discusses with Martin Sherwin about other great physicists of his time, including Oppenheimer.
59
  What does he say was the consequence of Einstein learning too much math on his creativity, in one word?
60
 
61
- Thought: I need to find and read the 1979 interview of Stanislaus Ulam with Martin Sherwin.
62
  Code:
63
  ```py
64
  pages = search(query="1979 interview Stanislaus Ulam Martin Sherwin physicists Einstein")
@@ -104,7 +104,7 @@
104
  ---
105
  Task: "Which city has the highest population: Guangzhou or Shanghai?"
106
 
107
- 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.
108
  Code:
109
  ```py
110
  for city in ["Guangzhou", "Shanghai"]:
@@ -123,7 +123,7 @@
123
  ---
124
  Task: "What is the current age of the pope, raised to the power 0.36?"
125
 
126
- Thought: I will use the tool `wiki` to get the age of the pope, and confirm that with a web search.
127
  Code:
128
  ```py
129
  pope_age_wiki = wiki(query="current pope age")
@@ -171,149 +171,4 @@
171
  9. The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.
172
  10. Don't give up! You're in charge of solving the task, not providing directions to solve it.
173
 
174
- Now Begin! If you solve the task correctly, you will receive a reward of $1,000,000.
175
- "planning":
176
- "initial_facts": |-
177
- Below I will present you a task.
178
-
179
- You will now build a comprehensive preparatory survey of which facts we have at our disposal and which ones we still need.
180
- To do so, you will have to read the task and identify things that must be discovered in order to successfully complete it.
181
- Don't make any assumptions. For each item, provide a thorough reasoning. Here is how you will structure this survey:
182
-
183
- ---
184
- ### 1. Facts given in the task
185
- List here the specific facts given in the task that could help you (there might be nothing here).
186
-
187
- ### 2. Facts to look up
188
- List here any facts that we may need to look up.
189
- 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.
190
-
191
- ### 3. Facts to derive
192
- List here anything that we want to derive from the above by logical reasoning, for instance computation or simulation.
193
-
194
- Keep in mind that "facts" will typically be specific names, dates, values, etc. Your answer should use the below headings:
195
- ### 1. Facts given in the task
196
- ### 2. Facts to look up
197
- ### 3. Facts to derive
198
- Do not add anything else.
199
- "initial_plan": |-
200
- You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
201
-
202
- Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
203
- This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
204
- Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
205
- After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
206
-
207
- Here is your task:
208
-
209
- Task:
210
- ```
211
- {{task}}
212
- ```
213
- You can leverage these tools:
214
- {%- for tool in tools.values() %}
215
- - {{ tool.name }}: {{ tool.description }}
216
- Takes inputs: {{tool.inputs}}
217
- Returns an output of type: {{tool.output_type}}
218
- {%- endfor %}
219
-
220
- {%- if managed_agents and managed_agents.values() | list %}
221
- You can also give tasks to team members.
222
- 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.
223
- Given that this team member is a real human, you should be very verbose in your request.
224
- Here is a list of the team members that you can call:
225
- {%- for agent in managed_agents.values() %}
226
- - {{ agent.name }}: {{ agent.description }}
227
- {%- endfor %}
228
- {%- else %}
229
- {%- endif %}
230
-
231
- List of facts that you know:
232
- ```
233
- {{answer_facts}}
234
- ```
235
-
236
- Now begin! Write your plan below.
237
- "update_facts_pre_messages": |-
238
- You are a world expert at gathering known and unknown facts based on a conversation.
239
- 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:
240
- ### 1. Facts given in the task
241
- ### 2. Facts that we have learned
242
- ### 3. Facts still to look up
243
- ### 4. Facts still to derive
244
- Find the task and history below:
245
- "update_facts_post_messages": |-
246
- Earlier we've built a list of facts.
247
- But since in your previous steps you may have learned useful new facts or invalidated some false ones.
248
- Please update your list of facts based on the previous history, and provide these headings:
249
- ### 1. Facts given in the task
250
- ### 2. Facts that we have learned
251
- ### 3. Facts still to look up
252
- ### 4. Facts still to derive
253
-
254
- Now write your new list of facts below.
255
- "update_plan_pre_messages": |-
256
- You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
257
-
258
- You have been given a task:
259
- ```
260
- {{task}}
261
- ```
262
-
263
- 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.
264
- If the previous tries so far have met some success, you can make an updated plan based on these actions.
265
- If you are stalled, you can make a completely new plan starting from scratch.
266
- "update_plan_post_messages": |-
267
- You're still working towards solving this task:
268
- ```
269
- {{task}}
270
- ```
271
-
272
- You can leverage these tools:
273
- {%- for tool in tools.values() %}
274
- - {{ tool.name }}: {{ tool.description }}
275
- Takes inputs: {{tool.inputs}}
276
- Returns an output of type: {{tool.output_type}}
277
- {%- endfor %}
278
-
279
- {%- if managed_agents and managed_agents.values() | list %}
280
- You can also give tasks to team members.
281
- Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task'.
282
- 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.
283
- Here is a list of the team members that you can call:
284
- {%- for agent in managed_agents.values() %}
285
- - {{ agent.name }}: {{ agent.description }}
286
- {%- endfor %}
287
- {%- else %}
288
- {%- endif %}
289
-
290
- Here is the up to date list of facts that you know:
291
- ```
292
- {{facts_update}}
293
- ```
294
-
295
- Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
296
- This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
297
- Beware that you have {remaining_steps} steps remaining.
298
- Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
299
- After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
300
-
301
- Now write your new plan below.
302
- "managed_agent":
303
- "task": |-
304
- You are a general AI assistant. I will ask you a question. Report your thoughts, and finish
305
- your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
306
- YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of
307
- numbers and/or strings.
308
- If you are asked for a number, don’t use comma to write your number neither use units such as $ or percent
309
- sign unless specified otherwise.
310
- If you are asked for a string, don’t use articles, neither abbreviations (e.g. for cities), and write the digits in
311
- plain text unless specified otherwise.
312
- If you are asked for a comma separated list, apply the above rules depending of whether the element to be put
313
- in the list is a number or a string.
314
- "report": |-
315
- Here is the final answer from your managed agent '{{name}}':
316
- {{final_answer}}
317
- "final_answer":
318
- "pre_messages": ""
319
- "post_messages": ""
 
13
  ---
14
  Task: "Generate an image of the oldest person in this document."
15
 
16
+ Thought: Let's tackle this problem, 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.
17
  Code:
18
  ```py
19
  answer = document_qa(document=document, question="Who is the oldest person mentioned?")
 
31
  ---
32
  Task: "What is the result of the following operation: 5 + 3 + 1294.678?"
33
 
34
+ Thought: Let's tackle this problem, I will use python code to compute the result of the operation and then return the final answer using the `final_answer` tool.
35
  Code:
36
  ```py
37
  result = 5 + 3 + 1294.678
 
44
  You have been provided with these additional arguments, that you can access using the keys as variables in your python code:
45
  {'question': 'Quel est l'animal sur l'image?', 'image': 'path/to/image.jpg'}"
46
 
47
+ Thought: Let's tackle this problem,, 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.
48
  Code:
49
  ```py
50
  translated_question = translator(question=question, src_lang="French", tgt_lang="English")
 
58
  In a 1979 interview, Stanislaus Ulam discusses with Martin Sherwin about other great physicists of his time, including Oppenheimer.
59
  What does he say was the consequence of Einstein learning too much math on his creativity, in one word?
60
 
61
+ Thought: Let's tackle this problem, I need to find and read the 1979 interview of Stanislaus Ulam with Martin Sherwin.
62
  Code:
63
  ```py
64
  pages = search(query="1979 interview Stanislaus Ulam Martin Sherwin physicists Einstein")
 
104
  ---
105
  Task: "Which city has the highest population: Guangzhou or Shanghai?"
106
 
107
+ Thought: Let's tackle this problem, 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.
108
  Code:
109
  ```py
110
  for city in ["Guangzhou", "Shanghai"]:
 
123
  ---
124
  Task: "What is the current age of the pope, raised to the power 0.36?"
125
 
126
+ Thought: Let's tackle this problem, I will use the tool `wiki` to get the age of the pope, and confirm that with a web search.
127
  Code:
128
  ```py
129
  pope_age_wiki = wiki(query="current pope age")
 
171
  9. The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.
172
  10. Don't give up! You're in charge of solving the task, not providing directions to solve it.
173
 
174
+ Now Begin! If you solve the task correctly, you will receive a reward of $1,000,000.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
  gradio
2
  requests
3
  gradio[oauth]
4
- smolagents
 
 
1
  gradio
2
  requests
3
  gradio[oauth]
4
+ smolagents
5
+ wikipedia
src/utils/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ from .gradio_ui import user_interface
2
+ from .api import fetch_questions, submit_answers
3
+ from .final_check import validate_answer
4
+ from .prompt import load_prompt
src/{api.py → utils/api.py} RENAMED
File without changes
src/{final_check.py → utils/final_check.py} RENAMED
File without changes
src/{gradio_ui.py → utils/gradio_ui.py} RENAMED
File without changes
src/utils/prompt.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+
3
+ def load_prompt():
4
+ """
5
+ Load the prompt templates from YAML files.
6
+ """
7
+ file_paths = {
8
+ "system_prompt": "./prompts/system_prompt.yaml",
9
+ "planning": "./prompts/planning.yaml",
10
+ "managed_agent": "./prompts/managed_agent.yaml",
11
+ "final_answer": "./prompts/final_answer.yaml"
12
+ }
13
+ prompt_template = {}
14
+ for key, path in file_paths.items():
15
+ with open(path, 'r') as stream:
16
+ prompt_template[key] = yaml.safe_load(stream)[key]
17
+ return prompt_template
src/workflow.py CHANGED
@@ -2,12 +2,12 @@ import gradio as gr
2
  import pandas as pd
3
  import os
4
  import yaml
 
5
 
6
- from smolagents import CodeAgent, MLXModel, DuckDuckGoSearchTool, load_tool, tool
7
 
8
- from src.api import fetch_questions, submit_answers
9
  from src.tools import WikipediaSearchTool, VisitWebpageTool, FinalAnswerTool
10
- from src.final_check import validate_answer
11
 
12
 
13
  def run_and_submit_all(profile: gr.OAuthProfile | None):
@@ -19,8 +19,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
19
  print("User not logged in.")
20
  return "Please Login to Hugging Face with the button.", None
21
 
22
- with open("./prompt.yaml", 'r') as stream:
23
- prompt_template = yaml.safe_load(stream)
24
 
25
  # Load the model
26
  # mlx_model = MLXModel("./Qwen2.5-Coder-32B-Instruct-4bit") too large for local inference
@@ -33,8 +32,6 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
33
  visit_webpage = VisitWebpageTool()
34
  final_answer = FinalAnswerTool()
35
 
36
-
37
-
38
  agent = CodeAgent(
39
  model=mlx_model,
40
  tools=[
@@ -44,7 +41,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
44
  final_answer,
45
  ],
46
  add_base_tools=True,
47
- max_steps=6,
48
  verbosity_level=2,
49
  grammar=None,
50
  planning_interval=None,
@@ -75,6 +72,8 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
75
  except Exception as e:
76
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
77
 
 
 
78
  if not answers_payload:
79
  return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
80
 
 
2
  import pandas as pd
3
  import os
4
  import yaml
5
+ import time
6
 
7
+ from smolagents import CodeAgent, MLXModel, DuckDuckGoSearchTool
8
 
9
+ from src.utils import fetch_questions, submit_answers, validate_answer, load_prompt
10
  from src.tools import WikipediaSearchTool, VisitWebpageTool, FinalAnswerTool
 
11
 
12
 
13
  def run_and_submit_all(profile: gr.OAuthProfile | None):
 
19
  print("User not logged in.")
20
  return "Please Login to Hugging Face with the button.", None
21
 
22
+ prompt_template = load_prompt()
 
23
 
24
  # Load the model
25
  # mlx_model = MLXModel("./Qwen2.5-Coder-32B-Instruct-4bit") too large for local inference
 
32
  visit_webpage = VisitWebpageTool()
33
  final_answer = FinalAnswerTool()
34
 
 
 
35
  agent = CodeAgent(
36
  model=mlx_model,
37
  tools=[
 
41
  final_answer,
42
  ],
43
  add_base_tools=True,
44
+ max_steps=30,
45
  verbosity_level=2,
46
  grammar=None,
47
  planning_interval=None,
 
72
  except Exception as e:
73
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"})
74
 
75
+ time.sleep(10) # Tempo to avoid throttling
76
+
77
  if not answers_payload:
78
  return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
79