Abbas0786 commited on
Commit
a323f6c
·
verified ·
1 Parent(s): f1193f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -20
app.py CHANGED
@@ -30,9 +30,6 @@ if city:
30
  response = requests.get(openweather_api_url, params=params)
31
  response.raise_for_status() # Will raise an HTTPError for bad responses
32
 
33
- # Print raw response for debugging
34
- st.write(f"Raw response: {response.text}")
35
-
36
  weather_data = response.json()
37
 
38
  if weather_data.get("cod") != 200:
@@ -40,6 +37,7 @@ if city:
40
  else:
41
  # Display weather data
42
  st.write("Current Weather:")
 
43
  st.write(f"Temperature: {weather_data['main']['temp']}°C")
44
  st.write(f"Weather: {weather_data['weather'][0]['description'].capitalize()}")
45
  st.write(f"Humidity: {weather_data['main']['humidity']}%")
@@ -48,21 +46,19 @@ if city:
48
  except requests.exceptions.RequestException as e:
49
  st.write(f"Error fetching weather data: {e}")
50
 
51
- # Groq API request
52
- try:
53
- chat_completion = client.chat.completions.create(
54
- messages=[
55
- {
56
- "role": "user",
57
- "content": "Explain the importance of fast language models",
58
- }
59
- ],
60
- model="llama3-8b-8192",
61
- )
62
- st.write("Groq AI Response:")
63
- st.write(chat_completion.choices[0].message.content)
64
 
65
- except Exception as e:
66
- st.write(f"Error fetching Groq data: {e}")
67
-
68
- # Note: Make sure to replace "YOUR_OPENWEATHERMAP_API_KEY" with your actual OpenWeatherMap API key.
 
30
  response = requests.get(openweather_api_url, params=params)
31
  response.raise_for_status() # Will raise an HTTPError for bad responses
32
 
 
 
 
33
  weather_data = response.json()
34
 
35
  if weather_data.get("cod") != 200:
 
37
  else:
38
  # Display weather data
39
  st.write("Current Weather:")
40
+ st.write(f"City: {weather_data['name']}, {weather_data['sys']['country']}")
41
  st.write(f"Temperature: {weather_data['main']['temp']}°C")
42
  st.write(f"Weather: {weather_data['weather'][0]['description'].capitalize()}")
43
  st.write(f"Humidity: {weather_data['main']['humidity']}%")
 
46
  except requests.exceptions.RequestException as e:
47
  st.write(f"Error fetching weather data: {e}")
48
 
49
+ # Remove Groq API request and response handling
50
+ # try:
51
+ # chat_completion = client.chat.completions.create(
52
+ # messages=[
53
+ # {
54
+ # "role": "user",
55
+ # "content": "Explain the importance of fast language models",
56
+ # }
57
+ # ],
58
+ # model="llama3-8b-8192",
59
+ # )
60
+ # st.write("Groq AI Response:")
61
+ # st.write(chat_completion.choices[0].message.content)
62
 
63
+ # except Exception as e:
64
+ # st.write(f"Error fetching Groq data: {e}")