UPDATE
This commit is contained in:
@@ -4,7 +4,7 @@ import json
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from farm_data.services import get_farm_details
|
||||
from farm_data.services import build_ai_farm_snapshot, get_ai_snapshot_metric, get_ai_snapshot_weather
|
||||
from rag.api_provider import get_chat_client
|
||||
from rag.chat import (
|
||||
_complete_audit_log,
|
||||
@@ -71,7 +71,7 @@ def _clean_json(raw: str) -> dict[str, Any]:
|
||||
|
||||
|
||||
def _load_farm_or_error(farm_uuid: str) -> dict[str, Any]:
|
||||
farm_details = get_farm_details(farm_uuid)
|
||||
farm_details = build_ai_farm_snapshot(farm_uuid)
|
||||
if farm_details is None:
|
||||
raise RAGServiceError(
|
||||
error_code="farm_not_found",
|
||||
@@ -158,6 +158,16 @@ def get_water_need_prediction_insight(
|
||||
structured_context = {
|
||||
"farm_uuid": farm_uuid,
|
||||
"prediction_payload": prediction_payload,
|
||||
"source_metadata": {
|
||||
"agronomic_metrics": {
|
||||
"source": "build_ai_farm_snapshot",
|
||||
"policy": "cluster_block_farm_aggregated",
|
||||
},
|
||||
"weather": {
|
||||
"source": "center_location_forecast",
|
||||
"policy": "center_location_latest_forecast",
|
||||
},
|
||||
},
|
||||
}
|
||||
rag_context = build_rag_context(
|
||||
query=user_query,
|
||||
@@ -208,4 +218,14 @@ def get_water_need_prediction_insight(
|
||||
parsed["source"] = "llm"
|
||||
parsed["farm_uuid"] = farm_uuid
|
||||
parsed["raw_response"] = raw
|
||||
parsed["source_metadata"] = {
|
||||
"agronomic_metrics": {
|
||||
"source": "build_ai_farm_snapshot",
|
||||
"policy": "cluster_block_farm_aggregated",
|
||||
},
|
||||
"weather": {
|
||||
"source": "center_location_forecast",
|
||||
"policy": "center_location_latest_forecast",
|
||||
},
|
||||
}
|
||||
return parsed
|
||||
|
||||
Reference in New Issue
Block a user