Spaces:
Runtime error
Runtime error
harivarshannn commited on
Commit ·
11d1217
1
Parent(s): 30c23a2
fix: improve Tamil/Malayalam bilingual prompt reliability in ask and image analysis routes
Browse files
app.py
CHANGED
|
@@ -218,16 +218,16 @@ def ask_question():
|
|
| 218 |
|
| 219 |
try:
|
| 220 |
# Construct prompt
|
|
|
|
| 221 |
full_prompt = (
|
| 222 |
"You are AgroGPT, an expert agriculture assistant. "
|
| 223 |
"Answer the following question clearly and concisely in plain text. "
|
| 224 |
-
"
|
| 225 |
-
"
|
| 226 |
-
"
|
| 227 |
-
"
|
| 228 |
-
"Do
|
| 229 |
-
f"{
|
| 230 |
-
f"Question: {question}\nAnswer:"
|
| 231 |
)
|
| 232 |
|
| 233 |
print(f"Asking Ollama: {question}", flush=True)
|
|
|
|
| 218 |
|
| 219 |
try:
|
| 220 |
# Construct prompt
|
| 221 |
+
weather_section = f"\n\n[Weather Context]: {weather_context.strip()}" if weather_context.strip() else ""
|
| 222 |
full_prompt = (
|
| 223 |
"You are AgroGPT, an expert agriculture assistant. "
|
| 224 |
"Answer the following question clearly and concisely in plain text. "
|
| 225 |
+
"Structure your response EXACTLY as follows:\n"
|
| 226 |
+
"1. Provide a helpful answer in English.\n"
|
| 227 |
+
"2. Then write the header 'Malayalam Summary:' followed by the FULL answer translated into native Malayalam script (മലയാളം). Do NOT use English/Latin letters for Malayalam.\n"
|
| 228 |
+
"3. Then write the header 'Tamil Summary:' followed by the FULL answer translated into native Tamil script (தமிழ்). Do NOT use English/Latin letters for Tamil.\n"
|
| 229 |
+
"Use double line breaks between each section. Do NOT use markdown, asterisks, or bullet points.\n\n"
|
| 230 |
+
f"Question: {question}{weather_section}\n\nAnswer:"
|
|
|
|
| 231 |
)
|
| 232 |
|
| 233 |
print(f"Asking Ollama: {question}", flush=True)
|
model.py
CHANGED
|
@@ -123,15 +123,11 @@ def analyze_image_for_disease(image_path: str) -> str:
|
|
| 123 |
f"You are an expert plant pathologist. An image analysis system has detected "
|
| 124 |
f"'{disease_name}' with {confidence*100:.1f}% confidence. "
|
| 125 |
f"{'Note: This was a simulated detection based on color analysis.' if is_simulated else ''}\n\n"
|
| 126 |
-
f"Provide detailed advice for the farmer
|
| 127 |
-
f"1.
|
| 128 |
-
f"2.
|
| 129 |
-
f"3.
|
| 130 |
-
f"
|
| 131 |
-
f"Priority for summary: 1. English, 2. Malayalam (native script), 3. Tamil (native script).\n"
|
| 132 |
-
f"Layout Instructions: Provide the advice in English first, then add a header 'Malayalam Summary:' followed by the Malayalam text, then 'Tamil Summary:' followed by the Tamil text. Use double line breaks between sections.\n"
|
| 133 |
-
f"CRITICAL: Use native UTF-8 characters for Malayalam and Tamil. Do NOT transliterate into English alphabets.\n"
|
| 134 |
-
f"Note: Use plain text only. Do not use markdown formatting, bolding, or any asterisks (*).\n"
|
| 135 |
f"Keep the tone helpful and professional."
|
| 136 |
)
|
| 137 |
|
|
|
|
| 123 |
f"You are an expert plant pathologist. An image analysis system has detected "
|
| 124 |
f"'{disease_name}' with {confidence*100:.1f}% confidence. "
|
| 125 |
f"{'Note: This was a simulated detection based on color analysis.' if is_simulated else ''}\n\n"
|
| 126 |
+
f"Provide detailed advice for the farmer. Structure your response EXACTLY as follows:\n"
|
| 127 |
+
f"1. English Section: Describe the symptoms, then recommended treatments (organic and chemical), then preventive measures.\n"
|
| 128 |
+
f"2. Write the header 'Malayalam Summary:' followed by a FULL translation of the above advice in native Malayalam script (മലയാളം). Do NOT use English/Latin letters for Malayalam.\n"
|
| 129 |
+
f"3. Write the header 'Tamil Summary:' followed by a FULL translation of the above advice in native Tamil script (தமிழ்). Do NOT use English/Latin letters for Tamil.\n\n"
|
| 130 |
+
f"Use double line breaks between sections. Do NOT use markdown formatting, bolding, or any asterisks (*).\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
f"Keep the tone helpful and professional."
|
| 132 |
)
|
| 133 |
|