ChienChung commited on
Commit
a3fbf9b
·
verified ·
1 Parent(s): 1e9e3b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -20
app.py CHANGED
@@ -618,16 +618,27 @@ def weather_agent_tool(query: str) -> str:
618
  hour_str = closest_hour["time"].split(" ")[1]
619
 
620
  summary_prompt = f"""
621
- Summarise this weather forecast naturally:
622
- Location: {location}
623
- Time: {target_dt.strftime('%Y-%m-%d')} at {hour_str}
624
- Condition: {condition}
625
- Temp: {temp}°C (Feels like {feels}°C)
626
- Humidity: {humidity}%
627
- Chance of rain: {chance_rain}%
628
-
629
- Make it short, friendly, and human-style.
630
- """
 
 
 
 
 
 
 
 
 
 
 
631
  response = llm_gpt4.invoke(summary_prompt)
632
  return response.content.strip() if isinstance(response, AIMessage) else str(response)
633
 
@@ -715,16 +726,27 @@ def weather_tool(query: str) -> str:
715
  hour_str = closest_hour["time"].split(" ")[1]
716
 
717
  summary_prompt = f"""
718
- Summarise this weather forecast naturally:
719
- Location: {location}
720
- Time: {target_dt.strftime('%Y-%m-%d')} at {hour_str}
721
- Condition: {condition}
722
- Temp: {temp}°C (Feels like {feels}°C)
723
- Humidity: {humidity}%
724
- Chance of rain: {chance_rain}%
725
-
726
- Make it short, friendly, and human-style.
727
- """
 
 
 
 
 
 
 
 
 
 
 
728
  response = llm_gpt4.invoke(summary_prompt)
729
  return response.content.strip() if isinstance(response, AIMessage) else str(response)
730
 
 
618
  hour_str = closest_hour["time"].split(" ")[1]
619
 
620
  summary_prompt = f"""
621
+ You are a weather analyst. Below is detailed weather data for a specific time and location.
622
+
623
+ Your task: Based on the user's question, **reason step-by-step** which information is most relevant, then provide a concise, human-readable answer in British English.
624
+
625
+ --- Weather Data ---
626
+ Location: {location}
627
+ Time: {target_dt.strftime('%Y-%m-%d')} at {hour_str}
628
+ Condition: {condition}
629
+ Temperature: {temp}°C (Feels like {feels}°C)
630
+ Humidity: {humidity}%
631
+ Chance of rain: {chance_rain}%
632
+ Chance of snow: {closest_hour.get("chance_of_snow", 0)}%
633
+ Wind speed: {closest_hour.get("wind_kph", 'N/A')} kph
634
+ UV index: {closest_hour.get("uv", 'N/A')}
635
+ Cloud cover: {closest_hour.get("cloud", 'N/A')}%
636
+
637
+ --- User Query ---
638
+ "{query}"
639
+
640
+ Step-by-step reasoning and final answer:
641
+ """
642
  response = llm_gpt4.invoke(summary_prompt)
643
  return response.content.strip() if isinstance(response, AIMessage) else str(response)
644
 
 
726
  hour_str = closest_hour["time"].split(" ")[1]
727
 
728
  summary_prompt = f"""
729
+ You are a weather analyst. Below is detailed weather data for a specific time and location.
730
+
731
+ Your task: Based on the user's question, **reason step-by-step** which information is most relevant, then provide a concise, human-readable answer in British English.
732
+
733
+ --- Weather Data ---
734
+ Location: {location}
735
+ Time: {target_dt.strftime('%Y-%m-%d')} at {hour_str}
736
+ Condition: {condition}
737
+ Temperature: {temp}°C (Feels like {feels}°C)
738
+ Humidity: {humidity}%
739
+ Chance of rain: {chance_rain}%
740
+ Chance of snow: {closest_hour.get("chance_of_snow", 0)}%
741
+ Wind speed: {closest_hour.get("wind_kph", 'N/A')} kph
742
+ UV index: {closest_hour.get("uv", 'N/A')}
743
+ Cloud cover: {closest_hour.get("cloud", 'N/A')}%
744
+
745
+ --- User Query ---
746
+ "{query}"
747
+
748
+ Step-by-step reasoning and final answer:
749
+ """
750
  response = llm_gpt4.invoke(summary_prompt)
751
  return response.content.strip() if isinstance(response, AIMessage) else str(response)
752