added final check in check_answer
Browse files
app.py
CHANGED
@@ -58,6 +58,7 @@ def load_file(path: str) -> dict:
|
|
58 |
|
59 |
def check_format(answer: str | list, *args, **kwargs) -> list:
|
60 |
"""Check if the answer is a list and not a nested list."""
|
|
|
61 |
print("Checking format of the answer:", answer)
|
62 |
if isinstance(answer, list):
|
63 |
for item in answer:
|
@@ -69,7 +70,9 @@ def check_format(answer: str | list, *args, **kwargs) -> list:
|
|
69 |
elif isinstance(answer, str):
|
70 |
return [answer]
|
71 |
elif isinstance(answer, dict):
|
72 |
-
raise TypeError(
|
|
|
|
|
73 |
|
74 |
|
75 |
## tools definition
|
|
|
58 |
|
59 |
def check_format(answer: str | list, *args, **kwargs) -> list:
|
60 |
"""Check if the answer is a list and not a nested list."""
|
61 |
+
# other args are ignored on purpose, they are there just for compatibility
|
62 |
print("Checking format of the answer:", answer)
|
63 |
if isinstance(answer, list):
|
64 |
for item in answer:
|
|
|
70 |
elif isinstance(answer, str):
|
71 |
return [answer]
|
72 |
elif isinstance(answer, dict):
|
73 |
+
raise TypeError("Final answer must be a list, not a dict. Please check the answer format.")
|
74 |
+
else:
|
75 |
+
raise TypeError("Answer format not recognized. The answer must be either a list or a string.")
|
76 |
|
77 |
|
78 |
## tools definition
|