Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,27 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
import os
|
4 |
from groq import Groq
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
#
|
7 |
-
groq_api_key = os.getenv("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") #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Initialize the GROQ client
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
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
|
|
|
1 |
+
import os
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
|
|
4 |
from groq import Groq
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
|
7 |
+
# Load environment variables from .env file (optional)
|
8 |
+
load_dotenv()
|
9 |
|
10 |
+
# Get the API key from environment variable or set directly
|
11 |
+
groq_api_key = os.getenv("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") # First try from environment variable
|
12 |
+
if not groq_api_key:
|
13 |
+
# Optionally, set the API key directly for testing
|
14 |
+
groq_api_key = "your_actual_groq_api_key_here"
|
15 |
+
|
16 |
+
if not groq_api_key:
|
17 |
+
st.error("GROQ_API_KEY is not set. Please provide a valid API key.")
|
18 |
+
st.stop()
|
19 |
|
20 |
# Initialize the GROQ client
|
21 |
+
groq_client = Groq(api_key=groq_api_key)
|
22 |
+
|
23 |
+
if not groq_client:
|
24 |
+
st.error("Failed to initialize the GROQ client. Please check your API key.")
|
|
|
|
|
|
|
25 |
st.stop()
|
26 |
|
27 |
# Function to load and preprocess data
|