UPDATE
This commit is contained in:
@@ -8,8 +8,8 @@ from typing import Any
|
||||
from django.apps import apps
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
|
||||
from farm_data.services import get_farm_details
|
||||
from farm_data.context import load_farm_context
|
||||
from farm_data.services import build_ai_farm_snapshot
|
||||
from rag.api_provider import get_chat_client
|
||||
from rag.chat import (
|
||||
_complete_audit_log,
|
||||
@@ -156,12 +156,18 @@ def _build_structured_context(
|
||||
if context is None:
|
||||
raise ValueError("farm_uuid نامعتبر است یا اطلاعات هشدار مزرعه پیدا نشد.")
|
||||
|
||||
tracker = build_farm_alerts_tracker(sensor_id=farm_uuid, context=context, ai_bundle=None)
|
||||
ai_snapshot = build_ai_farm_snapshot(farm_uuid)
|
||||
tracker = build_farm_alerts_tracker(
|
||||
sensor_id=farm_uuid,
|
||||
context=context,
|
||||
ai_bundle={"ai_snapshot": ai_snapshot},
|
||||
)
|
||||
structured = {
|
||||
"farm_profile": _farm_profile(context, farm_uuid),
|
||||
"tracker": tracker,
|
||||
"forecasts": _forecast_summary(context),
|
||||
"incoming_alerts": _normalize_incoming_alerts(incoming_alerts),
|
||||
"ai_snapshot_source_metadata": (ai_snapshot or {}).get("source_metadata", {}),
|
||||
}
|
||||
return context, structured
|
||||
|
||||
@@ -321,7 +327,7 @@ def _llm_response(
|
||||
) -> tuple[dict[str, Any], str, str]:
|
||||
cfg = load_rag_config()
|
||||
service, service_cfg, model, client = _build_service_config(cfg, service_id)
|
||||
farm_details = get_farm_details(farm_uuid)
|
||||
farm_details = build_ai_farm_snapshot(farm_uuid)
|
||||
rag_context = build_rag_context(
|
||||
query=query,
|
||||
sensor_uuid=farm_uuid,
|
||||
|
||||
Reference in New Issue
Block a user