Update server.py
Browse files
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:
|