Spaces:
Sleeping
Sleeping
Update gemini_agent.py
Browse files- gemini_agent.py +11 -4
gemini_agent.py
CHANGED
|
@@ -265,10 +265,17 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
|
|
| 265 |
|
| 266 |
# If the question expects a single value, extract it
|
| 267 |
if any(kw in question.lower() for kw in ["how many", "what is the", "who", "where", "give only", "provide only"]):
|
| 268 |
-
#
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
|
| 273 |
# Post-processing for chess move extraction
|
| 274 |
if 'chess position' in question.lower() and 'image' in question.lower():
|
|
|
|
| 265 |
|
| 266 |
# If the question expects a single value, extract it
|
| 267 |
if any(kw in question.lower() for kw in ["how many", "what is the", "who", "where", "give only", "provide only"]):
|
| 268 |
+
# Special handling for "give only the first name"
|
| 269 |
+
if "give only the first name" in question.lower() or "first name" in question.lower():
|
| 270 |
+
# Extract first name from full name
|
| 271 |
+
name_match = re.search(r'\b([A-ZĄĆĘŁŃÓŚŹŻ][a-ząćęłńóśźż]+)', answer)
|
| 272 |
+
if name_match:
|
| 273 |
+
answer = name_match.group(1)
|
| 274 |
+
else:
|
| 275 |
+
# Extract the first number, word, or phrase (tweak regex as needed)
|
| 276 |
+
match = re.search(r'^[A-Za-z0-9 ,+-]+', answer)
|
| 277 |
+
if match:
|
| 278 |
+
answer = match.group(0).strip()
|
| 279 |
|
| 280 |
# Post-processing for chess move extraction
|
| 281 |
if 'chess position' in question.lower() and 'image' in question.lower():
|