ArceusInception commited on
Commit
01faf32
·
verified ·
1 Parent(s): 09399df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -18,9 +18,9 @@ def get_weather_and_insight(city):
18
  temp = data.get('main', {}).get('temp')
19
  description = data.get('weather', [{}])[0].get('description')
20
 
21
- # Generating a creative weather summary using LangChain LLM
22
  groq_api_key = os.getenv("GROQ_API_KEY")
23
- system = f"Today in {city}, it feels like {temp}°C with {humidity}% humidity. The sky is {description}. Can you share a fun fact about {city}?"
24
  human = "{text}"
25
  prompt = ChatPromptTemplate.from_messages(
26
  [("system", system), ("human", human)]
@@ -29,11 +29,11 @@ def get_weather_and_insight(city):
29
  chain = prompt | chat | StrOutputParser()
30
  output = chain.invoke({"text": city})
31
 
32
- # Adding emojis for visual flair
33
  weather_emoji = "☀️" if "clear" in description else "☁️" if "cloud" in description else "🌧️" if "rain" in description else "❄️" if "snow" in description else "🌫️"
34
 
35
- # Creating the final response string
36
- final_response = f"📍 {city.upper()} Update: {output} {weather_emoji}"
37
 
38
  return final_response
39
 
@@ -43,7 +43,7 @@ iface = gr.Interface(
43
  inputs=gr.Textbox(label="Enter City Name", placeholder="Type city here..."),
44
  outputs=gr.Textbox(label="Weather Report and Insight"),
45
  title="WeatherAssistantApp",
46
- description="Enter a city name to get a concise weather report with an engaging AI-generated city insight."
47
  )
48
 
49
  iface.launch()
 
18
  temp = data.get('main', {}).get('temp')
19
  description = data.get('weather', [{}])[0].get('description')
20
 
21
+ # Generate a creative weather summary using LangChain LLM
22
  groq_api_key = os.getenv("GROQ_API_KEY")
23
+ system = f"Local weather update for {city}: {temp}°C, {description}. Provide a fun fact about {city}."
24
  human = "{text}"
25
  prompt = ChatPromptTemplate.from_messages(
26
  [("system", system), ("human", human)]
 
29
  chain = prompt | chat | StrOutputParser()
30
  output = chain.invoke({"text": city})
31
 
32
+ # Add emojis for visual flair
33
  weather_emoji = "☀️" if "clear" in description else "☁️" if "cloud" in description else "🌧️" if "rain" in description else "❄️" if "snow" in description else "🌫️"
34
 
35
+ # Create the final response string, avoiding repetition
36
+ final_response = f"🌍 Weather Update for {city}: {temp}°C, {humidity}% humidity, described as {description} {weather_emoji}. Insight: {output}"
37
 
38
  return final_response
39
 
 
43
  inputs=gr.Textbox(label="Enter City Name", placeholder="Type city here..."),
44
  outputs=gr.Textbox(label="Weather Report and Insight"),
45
  title="WeatherAssistantApp",
46
+ description="Enter a city name to get a concise weather report with an AI-generated insight."
47
  )
48
 
49
  iface.launch()