Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,9 +2,10 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
import requests
|
4 |
from groq import Groq
|
5 |
-
|
6 |
-
from
|
7 |
-
|
|
|
8 |
# Initialize the Groq client with the API key
|
9 |
client = Groq(api_key=api_key)
|
10 |
|
@@ -55,10 +56,11 @@ def get_health_articles(query):
|
|
55 |
articles = []
|
56 |
return articles
|
57 |
except requests.exceptions.HTTPError as http_err:
|
58 |
-
st.error(f"HTTP error occurred: {http_err}")
|
|
|
59 |
return []
|
60 |
except requests.exceptions.RequestException as err:
|
61 |
-
st.error(f"Error fetching articles: {err}")
|
62 |
return []
|
63 |
|
64 |
# Streamlit app layout
|
|
|
2 |
import pandas as pd
|
3 |
import requests
|
4 |
from groq import Groq
|
5 |
+
|
6 |
+
# Set the API key directly or from environment variable
|
7 |
+
api_key = "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" # Replace with your actual demo API key
|
8 |
+
|
9 |
# Initialize the Groq client with the API key
|
10 |
client = Groq(api_key=api_key)
|
11 |
|
|
|
56 |
articles = []
|
57 |
return articles
|
58 |
except requests.exceptions.HTTPError as http_err:
|
59 |
+
st.error(f"HTTP error occurred: {http_err}. Please check your API key and the endpoint.")
|
60 |
+
st.error(f"Response content: {response.text}")
|
61 |
return []
|
62 |
except requests.exceptions.RequestException as err:
|
63 |
+
st.error(f"Error fetching articles: {err}. Please check your internet connection.")
|
64 |
return []
|
65 |
|
66 |
# Streamlit app layout
|