mohAhmad commited on
Commit
73fc345
1 Parent(s): 1e05159

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -4,11 +4,15 @@ import pdfplumber
4
  import os
5
  import gc
6
 
7
- # Set your Groq API key (make sure to set this in your environment variables)
8
- os.environ["GROQ_API_KEY"] = "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" # Set your API key here
9
 
10
- # Initialize the Groq client
11
- client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
 
 
 
 
12
 
13
  def generate_response_groq(context, query):
14
  """Generate response using Groq API."""
 
4
  import os
5
  import gc
6
 
7
+ # No need for load_dotenv() since Hugging Face automatically loads secrets as environment variables
8
+ api_key = os.getenv("GROQ_API_KEY")
9
 
10
+ if not api_key:
11
+ st.error("Groq API key not found. Please check your environment variables.")
12
+ st.stop() # Stop execution if API key is missing
13
+
14
+ # Initialize the Groq client with the API key
15
+ client = Groq(api_key=api_key)
16
 
17
  def generate_response_groq(context, query):
18
  """Generate response using Groq API."""