Spaces:
Sleeping
Sleeping
Update gemini_agent.py
Browse files- gemini_agent.py +7 -0
gemini_agent.py
CHANGED
|
@@ -228,6 +228,13 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
|
|
| 228 |
sentences = answer.split('. ')
|
| 229 |
answer = sentences[0] + '.'
|
| 230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
return answer
|
| 232 |
|
| 233 |
async def _generate_video_answer_from_question(self, question: str, video_id: str) -> str:
|
|
|
|
| 228 |
sentences = answer.split('. ')
|
| 229 |
answer = sentences[0] + '.'
|
| 230 |
|
| 231 |
+
# If the question expects a single value, extract it
|
| 232 |
+
if any(kw in question.lower() for kw in ["how many", "what is the", "who", "where", "give only", "provide only"]):
|
| 233 |
+
# Extract the first number, word, or phrase (tweak regex as needed)
|
| 234 |
+
match = re.search(r'^[A-Za-z0-9 ,+-]+', answer)
|
| 235 |
+
if match:
|
| 236 |
+
answer = match.group(0).strip()
|
| 237 |
+
|
| 238 |
return answer
|
| 239 |
|
| 240 |
async def _generate_video_answer_from_question(self, question: str, video_id: str) -> str:
|