Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
# Fetch the Groq API key from environment variable
|
| 6 |
-
GROQ_API_KEY = os.getenv("
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Correct API URL for Groq Chat Completions
|
| 9 |
GROQ_API_URL = 'https://api.groq.com/openai/v1/chat/completions' # Correct Groq endpoint
|
|
|
|
| 1 |
import os
|
| 2 |
import requests
|
| 3 |
import streamlit as st
|
| 4 |
+
from dotenv import load_dotenv # Import to load environment variables from .env file
|
| 5 |
+
|
| 6 |
+
# Load environment variables from a .env file (if you have one)
|
| 7 |
+
load_dotenv()
|
| 8 |
|
| 9 |
# Fetch the Groq API key from environment variable
|
| 10 |
+
GROQ_API_KEY = os.getenv("GROQ_API_KEY") # Make sure this matches the key in your .env or environment
|
| 11 |
+
|
| 12 |
+
if not GROQ_API_KEY:
|
| 13 |
+
st.error("API Key not found! Please set your GROQ_API_KEY in the environment.")
|
| 14 |
|
| 15 |
# Correct API URL for Groq Chat Completions
|
| 16 |
GROQ_API_URL = 'https://api.groq.com/openai/v1/chat/completions' # Correct Groq endpoint
|