Kackle commited on
Commit
e2d15d4
·
verified ·
1 Parent(s): 1943f3b

Update gemini_agent.py

Browse files
Files changed (1) hide show
  1. 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
- # Extract the first number, word, or phrase (tweak regex as needed)
269
- match = re.search(r'^[A-Za-z0-9 ,+-]+', answer)
270
- if match:
271
- answer = match.group(0).strip()
 
 
 
 
 
 
 
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():