Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,16 @@ from groq import Groq
|
|
6 |
# Set the GROQ API key from environment variable
|
7 |
groq_api_key = os.getenv("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") # Make sure the GROQ API key is set in your environment
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Function to load and preprocess data
|
10 |
@st.cache_data
|
11 |
def load_data(file):
|
@@ -42,7 +52,7 @@ def provide_observed_advice(data):
|
|
42 |
def get_health_advice_from_groq(query):
|
43 |
try:
|
44 |
# Sending request to GROQ API
|
45 |
-
chat_completion =
|
46 |
messages=[{
|
47 |
"role": "user",
|
48 |
"content": query
|
|
|
6 |
# Set the GROQ API key from environment variable
|
7 |
groq_api_key = os.getenv("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") # Make sure the GROQ API key is set in your environment
|
8 |
|
9 |
+
# Initialize the GROQ client
|
10 |
+
try:
|
11 |
+
groq_client = Groq(api_key=groq_api_key)
|
12 |
+
|
13 |
+
if not groq_client:
|
14 |
+
raise ValueError("Failed to initialize the GROQ client. Please check your API key.")
|
15 |
+
except Exception as e:
|
16 |
+
st.error(f"Error initializing GROQ client: {e}")
|
17 |
+
st.stop()
|
18 |
+
|
19 |
# Function to load and preprocess data
|
20 |
@st.cache_data
|
21 |
def load_data(file):
|
|
|
52 |
def get_health_advice_from_groq(query):
|
53 |
try:
|
54 |
# Sending request to GROQ API
|
55 |
+
chat_completion = groq_client.chat.completions.create(
|
56 |
messages=[{
|
57 |
"role": "user",
|
58 |
"content": query
|