Spaces:
Sleeping
Sleeping
parsing final answer
Browse files- custom_agent.py +20 -2
custom_agent.py
CHANGED
|
@@ -182,8 +182,20 @@ class CustomAgent:
|
|
| 182 |
}
|
| 183 |
)
|
| 184 |
result = answer["messages"][-1].content
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
except Exception as e:
|
| 188 |
print(f"Error in CustomAgent: {e}")
|
| 189 |
return f"Error: {e}"
|
|
@@ -194,3 +206,9 @@ if __name__ == "__main__":
|
|
| 194 |
agent(
|
| 195 |
"How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia."
|
| 196 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
}
|
| 183 |
)
|
| 184 |
result = answer["messages"][-1].content
|
| 185 |
+
|
| 186 |
+
if "FINAL ANSWER: " in result:
|
| 187 |
+
final_answer_start = result.find("FINAL ANSWER: ") + len(
|
| 188 |
+
"FINAL ANSWER: "
|
| 189 |
+
)
|
| 190 |
+
extracted_answer = result[final_answer_start:].strip()
|
| 191 |
+
print(f"CustomAgent extracted answer: {extracted_answer}")
|
| 192 |
+
return extracted_answer
|
| 193 |
+
else:
|
| 194 |
+
print(
|
| 195 |
+
f"CustomAgent returning full answer (no FINAL ANSWER found): {result}"
|
| 196 |
+
)
|
| 197 |
+
return result
|
| 198 |
+
|
| 199 |
except Exception as e:
|
| 200 |
print(f"Error in CustomAgent: {e}")
|
| 201 |
return f"Error: {e}"
|
|
|
|
| 206 |
agent(
|
| 207 |
"How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia."
|
| 208 |
)
|
| 209 |
+
agent(
|
| 210 |
+
"How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?"
|
| 211 |
+
)
|
| 212 |
+
agent(
|
| 213 |
+
"In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?"
|
| 214 |
+
)
|