Spaces:
Sleeping
Sleeping
post processing
Browse files- gemini_agent.py +11 -6
gemini_agent.py
CHANGED
|
@@ -272,12 +272,17 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
|
|
| 272 |
if move_match:
|
| 273 |
answer = move_match.group(1)
|
| 274 |
|
| 275 |
-
# Post-processing for
|
| 276 |
-
if
|
| 277 |
-
# Extract
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
return answer
|
| 283 |
|
|
|
|
| 272 |
if move_match:
|
| 273 |
answer = move_match.group(1)
|
| 274 |
|
| 275 |
+
# Post-processing for sorted, deduplicated lists
|
| 276 |
+
if 'page numbers' in question.lower() or 'comma-delimited list' in question.lower():
|
| 277 |
+
# Extract numbers, deduplicate, sort, and join
|
| 278 |
+
nums = re.findall(r'\d+', answer)
|
| 279 |
+
nums = sorted(set(int(n) for n in nums))
|
| 280 |
+
answer = ', '.join(str(n) for n in nums)
|
| 281 |
+
elif 'alphabetize' in question.lower() or 'alphabetized' in question.lower() or 'ingredients' in question.lower() or 'vegetables' in question.lower():
|
| 282 |
+
# Extract words/phrases, deduplicate, sort, and join
|
| 283 |
+
items = [item.strip() for item in answer.split(',') if item.strip()]
|
| 284 |
+
items = sorted(set(items), key=lambda x: x.lower())
|
| 285 |
+
answer = ', '.join(items)
|
| 286 |
|
| 287 |
return answer
|
| 288 |
|