AI UPDATE

This commit is contained in:
2026-03-21 23:50:36 +03:30
parent 292fd88e5a
commit c37b5c8558
15 changed files with 614 additions and 23 deletions
+15 -9
View File
@@ -17,10 +17,18 @@ KB_NAME = "fertilization"
DEFAULT_FERTILIZATION_PROMPT = (
"بر اساس داده‌های خاک (NPK، pH)، مشخصات گیاه، مرحله رشد و پایگاه دانش کودهی، "
"یک توصیه کودهی دقیق بده. "
"پاسخ حتماً به فرمت JSON با فیلدهای زیر باشد:\n"
"fertilizer_needed (bool), fertilizer_type (str), amount_kg_per_hectare (float), "
"reason (str), npk_status (dict با کلیدهای nitrogen, phosphorus, potassium و مقادیر low/normal/high)\n"
"فقط JSON خروجی بده، بدون توضیح اضافی."
"پاسخ حتماً به فرمت JSON با ساختار زیر باشد:\n"
'{\n'
' "plan": {\n'
' "npkRatio": "<str>",\n'
' "amountPerHectare": "<str>",\n'
' "applicationMethod": "<str>",\n'
' "applicationInterval": "<str>",\n'
' "reasoning": "<str>"\n'
' }\n'
'}\n'
"فقط JSON خروجی بده، بدون توضیح اضافی. "
"مقادیر را بر اساس شرایط واقعی خاک و گیاه محاسبه کن."
)
@@ -101,11 +109,9 @@ def get_fertilization_recommendation(
result = json.loads(cleaned)
except (json.JSONDecodeError, ValueError):
result = {
"fertilizer_needed": None,
"fertilizer_type": None,
"amount_kg_per_hectare": None,
"reason": raw,
"npk_status": None,
"plan": {
"reasoning": raw,
},
}
result["raw_response"] = raw