Ë
    @hà  ã                   ó€   — d dl mZmZmZ d dlmZmZ d dlmZm	Z	  e«       Z
e
j                  ded¬«      defd„«       Zy	)
é    )Ú	APIRouterÚDependsÚHTTPException)Ú
YieldInputÚYieldPredictionResponse)Úpredict_yieldÚget_weather_dataz/predictéÈ   )Úresponse_modelÚstatus_codeÚyield_inputc              ƒ   óÂ  K  — 	 | j                   r| j                  s| j                   | _        d}t        | d«      rDt        | d«      r8| j                  r,| j                  r t        | j                  | j                  «      }t        | «      \  }}}d|||dœ}|r||d<   t        di |¤ŽS # t        $ r,}t        d|› �«       t        dd	t        |«      › �¬
«      ‚d}~ww xY w­w)zT
    Receives farm details and returns a yield prediction with recommendations.
    NÚlatitudeÚ	longitudeT)ÚsuccessÚyield_Úestimated_productionÚrecommendationsÚweather_dataz'Unexpected error in /predict endpoint: iô  zIAn internal server error occurred while generating the yield prediction: )r   Údetail© )Ú	crop_typeÚcropÚhasattrr   r   r	   r   r   Ú	ExceptionÚprintr   Ústr)r   r   Úyield_per_hectareÚtotal_productionr   Úresponse_dataÚes          úOC:\Users\aadil\OneDrive\Desktop\404\backend\app\api\endpoints\yield_endpoint.pyÚpredict_farm_yieldr#      s  è ø€ ðJà× Ò ¨×)9Ò)9Ø*×4Ñ4ˆKÔð ˆÜ�; 
Ô+´¸À[Ô0QØ×Ò K×$9Ò$9Ü+¨K×,@Ñ,@À+×BWÑBWÓXˆLô @MÈ[Ó?YÑ<ÐÐ+¨_ð Ø'Ø$4Ø.ñ	
ˆñ Ø,8ˆM˜.Ñ)ô 'Ñ7¨Ñ7Ð7øÜò JäÐ7¸°sÐ;Ô<Ü¨Ð6ô  ADð  EFó  AGð  @Hð  5Iô  Jð  	JûðJüs)   ‚C„B"B' Â&CÂ'	CÂ0'CÃCÃCN)Úfastapir   r   r   Úapp.models.yield_modelr   r   Ú%app.services.yield_prediction_servicer   r	   ÚrouterÚpostr#   r   ó    r"   Ú<module>r*      sF   ðß 5Ñ 5ß Fß Qá	‹€à‡�ˆZÐ(?ÈS€ÓQð%JØò%Jó Rñ%Jr)   