Student3331 commited on
Commit
7fc8aa2
·
verified ·
1 Parent(s): 16905b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
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("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") # Make sure to use your actual API key
 
 
 
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