UPDATE
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
from farm_data.models import SensorData
|
||||
from rag.api_provider import get_chat_client
|
||||
from rag.chat import (
|
||||
_complete_audit_log,
|
||||
@@ -78,13 +79,24 @@ def get_fertilization_recommendation(
|
||||
|
||||
user_query = query or "توصیه کودهی برای مزرعه من چیست؟"
|
||||
|
||||
sensor = (
|
||||
SensorData.objects.prefetch_related("plants")
|
||||
.filter(farm_uuid=sensor_uuid)
|
||||
.first()
|
||||
)
|
||||
resolved_plant_name = plant_name
|
||||
if not resolved_plant_name and sensor is not None:
|
||||
plant = sensor.plants.first()
|
||||
if plant is not None:
|
||||
resolved_plant_name = plant.name
|
||||
|
||||
context = build_rag_context(
|
||||
user_query, sensor_uuid, config=cfg, limit=limit, kb_name=KB_NAME, service_id=SERVICE_ID,
|
||||
)
|
||||
|
||||
extra_parts: list[str] = []
|
||||
if plant_name and growth_stage:
|
||||
plant_text = build_plant_text(plant_name, growth_stage)
|
||||
if resolved_plant_name and growth_stage:
|
||||
plant_text = build_plant_text(resolved_plant_name, growth_stage)
|
||||
if plant_text:
|
||||
extra_parts.append("[اطلاعات گیاه]\n" + plant_text)
|
||||
if extra_parts:
|
||||
|
||||
Reference in New Issue
Block a user