Spaces:
Build error
Build error
cleaning final answer
Browse files- Changelog.md +1 -0
- gemini_model.py +5 -0
Changelog.md
CHANGED
|
@@ -12,6 +12,7 @@
|
|
| 12 |
- Simplified error handling in `run_and_submit_all` by removing redundant try-except block around `instantiate_agent` call.
|
| 13 |
- Updated `run_and_submit_all` to call `fetch_questions` and handle its return values.
|
| 14 |
- Updated `app_dev.py` to import and use `SmolAgent` from `my_agent.py`.
|
|
|
|
| 15 |
|
| 16 |
### Deprecated
|
| 17 |
|
|
|
|
| 12 |
- Simplified error handling in `run_and_submit_all` by removing redundant try-except block around `instantiate_agent` call.
|
| 13 |
- Updated `run_and_submit_all` to call `fetch_questions` and handle its return values.
|
| 14 |
- Updated `app_dev.py` to import and use `SmolAgent` from `my_agent.py`.
|
| 15 |
+
- Added logic to `GeminiApiModel` to extract text after "FINAL ANSWER: " marker in responses.
|
| 16 |
|
| 17 |
### Deprecated
|
| 18 |
|
gemini_model.py
CHANGED
|
@@ -125,6 +125,11 @@ class GeminiApiModel(ApiModel):
|
|
| 125 |
part = response_json["candidates"][0]["content"]["parts"][0]
|
| 126 |
if "text" in part:
|
| 127 |
content = part["text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
# Simulate token counts if available, otherwise default to 0
|
| 129 |
# The basic generateContent API might not return usage directly in the main response
|
| 130 |
# It might be in safetyRatings or other metadata if enabled/available.
|
|
|
|
| 125 |
part = response_json["candidates"][0]["content"]["parts"][0]
|
| 126 |
if "text" in part:
|
| 127 |
content = part["text"]
|
| 128 |
+
# Check for "FINAL ANSWER: " and extract the rest of the string
|
| 129 |
+
final_answer_marker = "FINAL ANSWER: "
|
| 130 |
+
if final_answer_marker in content:
|
| 131 |
+
content = content.split(final_answer_marker)[-1].strip()
|
| 132 |
+
|
| 133 |
# Simulate token counts if available, otherwise default to 0
|
| 134 |
# The basic generateContent API might not return usage directly in the main response
|
| 135 |
# It might be in safetyRatings or other metadata if enabled/available.
|