Spaces:
Sleeping
Sleeping
clearer prompts
Browse files- gemini_agent.py +25 -43
gemini_agent.py
CHANGED
|
@@ -166,59 +166,41 @@ Provide only the direct answer. If it's a quote, give just the quoted text. If i
|
|
| 166 |
# Handle attached file questions with enhanced prompts
|
| 167 |
if 'attached' in question.lower():
|
| 168 |
if 'python code' in question.lower():
|
| 169 |
-
prompt = f"""This question refers to attached Python code. Based on typical code execution patterns, provide the most likely numeric output:
|
| 170 |
-
|
| 171 |
-
{question}
|
| 172 |
-
|
| 173 |
-
Answer:"""
|
| 174 |
elif '.mp3' in question.lower():
|
| 175 |
-
prompt = f"""This question refers to an attached audio file. Provide the most likely answer based on the context:
|
| 176 |
-
|
| 177 |
-
{question}
|
| 178 |
-
|
| 179 |
-
Answer:"""
|
| 180 |
else:
|
| 181 |
-
prompt = f"""This question refers to an attached file. Provide the most likely answer:
|
| 182 |
-
|
| 183 |
-
{question}
|
| 184 |
-
|
| 185 |
-
Answer:"""
|
| 186 |
# Handle chess position question
|
| 187 |
elif 'chess position' in question.lower() and 'image' in question.lower():
|
| 188 |
-
prompt = f"""This is a chess question with an attached image. Provide the best chess move in algebraic notation:
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
# Create enhanced prompt based on question type
|
| 195 |
-
|
| 196 |
-
prompt = f"""Provide only the exact answer to this question. No explanations, just the specific number, name, or fact requested:
|
| 197 |
-
|
| 198 |
-
{question}
|
| 199 |
-
|
| 200 |
-
Answer:"""
|
| 201 |
elif 'who' in question.lower():
|
| 202 |
-
prompt = f"""Provide only the name requested. No explanations or additional context:
|
| 203 |
-
|
| 204 |
-
{question}
|
| 205 |
-
|
| 206 |
-
Answer:"""
|
| 207 |
elif 'where' in question.lower():
|
| 208 |
-
prompt = f"""Provide only the location requested. No explanations:
|
| 209 |
-
|
| 210 |
-
{question}
|
| 211 |
-
|
| 212 |
-
Answer:"""
|
| 213 |
else:
|
| 214 |
-
prompt = f"""Answer this question with only the essential information requested:
|
| 215 |
-
|
| 216 |
-
{question}
|
| 217 |
-
|
| 218 |
-
Answer:"""
|
| 219 |
|
| 220 |
# Use the constructed prompt for all cases
|
| 221 |
-
|
| 222 |
await self._rate_limit()
|
| 223 |
response = self.model.generate_content(
|
| 224 |
prompt,
|
|
|
|
| 166 |
# Handle attached file questions with enhanced prompts
|
| 167 |
if 'attached' in question.lower():
|
| 168 |
if 'python code' in question.lower():
|
| 169 |
+
prompt = f"""This question refers to attached Python code. Based on typical code execution patterns, provide the most likely numeric output:\n\n{question}\n\nAnswer:"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
elif '.mp3' in question.lower():
|
| 171 |
+
prompt = f"""This question refers to an attached audio file. Provide the most likely answer based on the context:\n\n{question}\n\nAnswer:"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
else:
|
| 173 |
+
prompt = f"""This question refers to an attached file. Provide the most likely answer:\n\n{question}\n\nAnswer:"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
# Handle chess position question
|
| 175 |
elif 'chess position' in question.lower() and 'image' in question.lower():
|
| 176 |
+
prompt = f"""This is a chess question with an attached image. Provide the best chess move in algebraic notation:\n\n{question}\n\nAnswer:"""
|
| 177 |
+
# Handle list extraction and formatting
|
| 178 |
+
elif (
|
| 179 |
+
'alphabetize' in question.lower() or
|
| 180 |
+
'comma separated' in question.lower() or
|
| 181 |
+
'list' in question.lower() or
|
| 182 |
+
'ingredients' in question.lower() or
|
| 183 |
+
'page numbers' in question.lower() or
|
| 184 |
+
'vegetables' in question.lower()
|
| 185 |
+
):
|
| 186 |
+
# Add domain definition for botanical vegetables
|
| 187 |
+
if 'vegetable' in question.lower() and ('botany' in question.lower() or 'botanical' in question.lower()):
|
| 188 |
+
definition = ("In botany, a vegetable is any edible part of a plant that is not a fruit or seed. "
|
| 189 |
+
"Fruits contain seeds and develop from the ovary of a flower. Use this definition.")
|
| 190 |
+
prompt = f"{definition}\n\n{question}\n\nList only the requested items, alphabetized, comma separated, and do not include any explanations or extra words."
|
| 191 |
+
else:
|
| 192 |
+
prompt = f"{question}\n\nList only the requested items, alphabetized, comma separated, and do not include any explanations or extra words."
|
| 193 |
# Create enhanced prompt based on question type
|
| 194 |
+
elif 'how many' in question.lower() or 'what is the' in question.lower():
|
| 195 |
+
prompt = f"""Provide only the exact answer to this question. No explanations, just the specific number, name, or fact requested:\n\n{question}\n\nAnswer:"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
elif 'who' in question.lower():
|
| 197 |
+
prompt = f"""Provide only the name requested. No explanations or additional context:\n\n{question}\n\nAnswer:"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
elif 'where' in question.lower():
|
| 199 |
+
prompt = f"""Provide only the location requested. No explanations:\n\n{question}\n\nAnswer:"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
else:
|
| 201 |
+
prompt = f"""Answer this question with only the essential information requested:\n\n{question}\n\nAnswer:"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
# Use the constructed prompt for all cases
|
|
|
|
| 204 |
await self._rate_limit()
|
| 205 |
response = self.model.generate_content(
|
| 206 |
prompt,
|