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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -18
app.py CHANGED
@@ -618,9 +618,17 @@ def weather_agent_tool(query: str) -> str:
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}
@@ -629,15 +637,16 @@ 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)
@@ -726,9 +735,17 @@ def weather_tool(query: str) -> str:
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}
@@ -737,15 +754,16 @@ 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)
 
618
  hour_str = closest_hour["time"].split(" ")[1]
619
 
620
  summary_prompt = f"""
621
+ You are a helpful weather reasoning assistant.
622
 
623
+ Based on the following weather data and the user's question, think step-by-step to extract the most relevant information, and give a natural, friendly, and cautious answer in British English.
624
+
625
+ Avoid being overly confident — never say "Yes, it will..." or "Definitely." Instead, use expressions like:
626
+ - "It is very likely that..."
627
+ - "There is a high chance of..."
628
+ - "Based on the current data, it seems that..."
629
+ - "There may be..."
630
+
631
+ Also, after answering the question, include a short weather summary and a useful suggestion (e.g., bring an umbrella, wear sunscreen, avoid outdoor activities).
632
 
633
  --- Weather Data ---
634
  Location: {location}
 
637
  Temperature: {temp}°C (Feels like {feels}°C)
638
  Humidity: {humidity}%
639
  Chance of rain: {chance_rain}%
640
+ Chance of snow: {closest_hour.get("chance_of_snow", "N/A")}%
641
+ Wind speed: {closest_hour.get("wind_kph", "N/A")} kph
642
+ UV index: {closest_hour.get("uv", "N/A")}
643
+ Cloud cover: {closest_hour.get("cloud", "N/A")}%
644
+ Visibility: {closest_hour.get("vis_km", "N/A")} km
645
 
646
+ --- User Question ---
647
+ {query}
648
 
649
+ --- Final Answer ---
650
  """
651
  response = llm_gpt4.invoke(summary_prompt)
652
  return response.content.strip() if isinstance(response, AIMessage) else str(response)
 
735
  hour_str = closest_hour["time"].split(" ")[1]
736
 
737
  summary_prompt = f"""
738
+ You are a helpful weather reasoning assistant.
739
+
740
+ Based on the following weather data and the user's question, think step-by-step to extract the most relevant information, and give a natural, friendly, and cautious answer in British English.
741
+
742
+ Avoid being overly confident — never say "Yes, it will..." or "Definitely." Instead, use expressions like:
743
+ - "It is very likely that..."
744
+ - "There is a high chance of..."
745
+ - "Based on the current data, it seems that..."
746
+ - "There may be..."
747
 
748
+ Also, after answering the question, include a short weather summary and a useful suggestion (e.g., bring an umbrella, wear sunscreen, avoid outdoor activities).
749
 
750
  --- Weather Data ---
751
  Location: {location}
 
754
  Temperature: {temp}°C (Feels like {feels}°C)
755
  Humidity: {humidity}%
756
  Chance of rain: {chance_rain}%
757
+ Chance of snow: {closest_hour.get("chance_of_snow", "N/A")}%
758
+ Wind speed: {closest_hour.get("wind_kph", "N/A")} kph
759
+ UV index: {closest_hour.get("uv", "N/A")}
760
+ Cloud cover: {closest_hour.get("cloud", "N/A")}%
761
+ Visibility: {closest_hour.get("vis_km", "N/A")} km
762
 
763
+ --- User Question ---
764
+ {query}
765
 
766
+ --- Final Answer ---
767
  """
768
  response = llm_gpt4.invoke(summary_prompt)
769
  return response.content.strip() if isinstance(response, AIMessage) else str(response)