Kackle commited on
Commit
b6a607a
·
verified ·
1 Parent(s): f60e375

small prompt change

Browse files
Files changed (1) hide show
  1. gemini_agent.py +20 -0
gemini_agent.py CHANGED
@@ -229,6 +229,26 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
229
  if match:
230
  answer = match.group(0).strip()
231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  return answer
233
 
234
  async def _generate_video_answer_from_question(self, question: str, video_id: str) -> str:
 
229
  if match:
230
  answer = match.group(0).strip()
231
 
232
+ # Post-processing for chess move extraction
233
+ if 'chess position' in question.lower() and 'image' in question.lower():
234
+ move_match = re.search(r'([KQRBN]?[a-h]?[1-8]?x?[a-h][1-8](=[QRBN])?[+#]?)', answer)
235
+ if move_match:
236
+ answer = move_match.group(1)
237
+
238
+ # Post-processing for strict list extraction
239
+ if any(kw in question.lower() for kw in ["alphabetize", "comma separated", "list", "ingredients", "page numbers", "vegetables"]):
240
+ # Extract only a comma-separated list of words (allowing spaces)
241
+ list_match = re.findall(r'[A-Za-z][A-Za-z ]*', answer)
242
+ if list_match:
243
+ answer = ', '.join([item.strip() for item in list_match if item.strip()])
244
+
245
+ # Wikipedia tool integration (simple version)
246
+ if 'wikipedia' in question.lower() or 'according to wikipedia' in question.lower():
247
+ # Add a Wikipedia search instruction to the prompt if not already present
248
+ if 'wikipedia' not in prompt.lower():
249
+ prompt += "\nIf you do not know the answer, search the latest English Wikipedia and use only information from there."
250
+ # Optionally, you could call a real Wikipedia API here for retrieval-augmented generation
251
+
252
  return answer
253
 
254
  async def _generate_video_answer_from_question(self, question: str, video_id: str) -> str: