UPDATE
This commit is contained in:
@@ -13,7 +13,12 @@ from typing import Any
|
||||
from django.apps import apps
|
||||
|
||||
from farm_data.models import SensorData
|
||||
from farm_data.services import clone_snapshot_as_runtime_plant, get_farm_plant_snapshot_by_name
|
||||
from farm_data.services import (
|
||||
build_ai_farm_snapshot,
|
||||
clone_snapshot_as_runtime_plant,
|
||||
get_ai_snapshot_weather,
|
||||
get_farm_plant_snapshot_by_name,
|
||||
)
|
||||
from rag.api_provider import get_chat_client
|
||||
from rag.chat import (
|
||||
_complete_audit_log,
|
||||
@@ -628,6 +633,7 @@ def get_fertilization_recommendation(
|
||||
.filter(farm_uuid=resolved_farm_uuid)
|
||||
.first()
|
||||
)
|
||||
ai_snapshot = build_ai_farm_snapshot(resolved_farm_uuid)
|
||||
|
||||
plant_config = apps.get_app_config("plant")
|
||||
resolved_plant_name = plant_config.resolve_plant_name(plant_name)
|
||||
@@ -662,6 +668,7 @@ def get_fertilization_recommendation(
|
||||
plant=plant,
|
||||
forecasts=forecasts,
|
||||
growth_stage=resolved_growth_stage,
|
||||
ai_snapshot=ai_snapshot,
|
||||
)
|
||||
|
||||
context = build_rag_context(
|
||||
@@ -727,6 +734,9 @@ def get_fertilization_recommendation(
|
||||
growth_stage=resolved_growth_stage,
|
||||
forecasts=forecasts,
|
||||
)
|
||||
result.setdefault("source_metadata", {})
|
||||
result["source_metadata"]["farm_metrics"] = (ai_snapshot or {}).get("source_metadata", {}).get("farm_metrics", {})
|
||||
result["source_metadata"]["weather"] = {"source": "center_location_forecast", "policy": "center_location_latest_forecast"}
|
||||
result = _validate_fertilization_response(result)
|
||||
result["raw_response"] = raw
|
||||
result["simulation_optimizer"] = optimized_result
|
||||
|
||||
Reference in New Issue
Block a user