Update check_format function to enable nested list detection and adjust planning interval in Agent class
Browse files
app.py
CHANGED
@@ -50,13 +50,13 @@ def load_file(path: str) -> list | dict:
|
|
50 |
|
51 |
def check_format(answer: str | list, *args, **kwargs) -> list:
|
52 |
"""Check if the answer is a list and not a nested list."""
|
53 |
-
|
54 |
if isinstance(answer, list):
|
55 |
for item in answer:
|
56 |
if isinstance(item, list):
|
57 |
print("Nested list detected")
|
58 |
raise TypeError("Nested lists are not allowed in the final answer.")
|
59 |
-
print("Final answer is a list:"
|
60 |
return answer
|
61 |
elif isinstance(answer, str):
|
62 |
return [answer]
|
@@ -178,7 +178,7 @@ class Agent:
|
|
178 |
model=client,
|
179 |
tools=[DuckDuckGoSearchTool(max_results=5), VisitWebpageTool(max_output_length=20000), generate_image, download_images, transcribe_audio],
|
180 |
additional_authorized_imports=["pandas", "PIL", "io"],
|
181 |
-
planning_interval=
|
182 |
max_steps=5,
|
183 |
stream_outputs=False,
|
184 |
final_answer_checks=[check_format]
|
|
|
50 |
|
51 |
def check_format(answer: str | list, *args, **kwargs) -> list:
|
52 |
"""Check if the answer is a list and not a nested list."""
|
53 |
+
print("Checking format of the answer:", answer)
|
54 |
if isinstance(answer, list):
|
55 |
for item in answer:
|
56 |
if isinstance(item, list):
|
57 |
print("Nested list detected")
|
58 |
raise TypeError("Nested lists are not allowed in the final answer.")
|
59 |
+
print("Final answer is a list:")
|
60 |
return answer
|
61 |
elif isinstance(answer, str):
|
62 |
return [answer]
|
|
|
178 |
model=client,
|
179 |
tools=[DuckDuckGoSearchTool(max_results=5), VisitWebpageTool(max_output_length=20000), generate_image, download_images, transcribe_audio],
|
180 |
additional_authorized_imports=["pandas", "PIL", "io"],
|
181 |
+
planning_interval=2,
|
182 |
max_steps=5,
|
183 |
stream_outputs=False,
|
184 |
final_answer_checks=[check_format]
|