elanuk commited on
Commit
7348e8b
Β·
verified Β·
1 Parent(s): fa5e508

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +31 -0
server.py CHANGED
@@ -932,6 +932,37 @@ def format_agent_responses(agent_responses):
932
  formatted = [str(item) for item in formatted]
933
  return '\n'.join(formatted)
934
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
935
  def run_workflow_ui(district):
936
  """Run workflow directly using internal functions"""
937
  if not district:
 
932
  formatted = [str(item) for item in formatted]
933
  return '\n'.join(formatted)
934
 
935
+ def format_alert_summary(raw_data):
936
+ """Format alert summary"""
937
+ if not raw_data or 'alert_data' not in raw_data:
938
+ return "No alert data available"
939
+
940
+ alert_data = raw_data['alert_data']
941
+
942
+ summary = f"""
943
+ ## 🚨 Alert Summary
944
+ **πŸ“ Location:** {alert_data['location']['village']}, {alert_data['location']['district']}, {alert_data['location']['state']}
945
+ **🌾 Crop Information:**
946
+ - **Crop:** {alert_data['crop']['name'].title()}
947
+ - **Growth Stage:** {alert_data['crop']['stage']}
948
+ - **Season:** {alert_data['crop']['season'].title()}
949
+ **🌀️ Weather Conditions:**
950
+ - **Temperature:** {alert_data['weather']['temperature']}
951
+ - **Expected Rainfall:** {alert_data['weather']['expected_rainfall']}
952
+ - **Wind Speed:** {alert_data['weather']['wind_speed']}
953
+ - **Rain Probability:** {alert_data['weather']['rain_probability']}%
954
+ **⚠️ Alert Details:**
955
+ - **Type:** {alert_data['alert']['type'].replace('_', ' ').title()}
956
+ - **Urgency:** {alert_data['alert']['urgency'].upper()}
957
+ - **AI Enhanced:** {'βœ… Yes' if alert_data['alert']['ai_generated'] else '❌ No'}
958
+ **πŸ“¨ Alert Message:**
959
+ {alert_data['alert']['message']}
960
+ **🎯 Action Items:**
961
+ {chr(10).join([f"- {item.replace('_', ' ').title()}" for item in alert_data['alert']['action_items']])}
962
+ """
963
+ return summary
964
+
965
+
966
  def run_workflow_ui(district):
967
  """Run workflow directly using internal functions"""
968
  if not district: