HudaQamber commited on
Commit
2cc4eba
·
verified ·
1 Parent(s): 223d9e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -2,12 +2,14 @@ import os
2
  import gradio as gr
3
  from groq import Groq
4
 
5
- # Get GROQ API key from environment variable
6
- GROQ_API_KEY = os.getenv("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") # Ensure the correct environment variable name is used
7
 
8
- # Check if the API key is found
9
- if not GROQ_API_KEY:
10
- raise ValueError("API key is missing. Please set the GROQ_API_KEY environment variable.")
 
 
11
 
12
  # Initialize the Groq client
13
  client = Groq(api_key=GROQ_API_KEY)
@@ -27,7 +29,7 @@ def chat_with_groq(message, history):
27
 
28
  # Call Groq API
29
  response = client.chat.completions.create(
30
- model="llama3-70b-8192", # ✅ Updated to active supported model
31
  messages=messages,
32
  temperature=0.7,
33
  max_tokens=500,
@@ -62,4 +64,3 @@ with gr.Blocks() as demo:
62
  # Launch the Gradio app
63
  demo.launch()
64
 
65
-
 
2
  import gradio as gr
3
  from groq import Groq
4
 
5
+ # ========== Option 1: Directly set your API key (quick testing) ==========
6
+ GROQ_API_KEY = "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"
7
 
8
+ # ========== Option 2: Read from environment variable ==========
9
+ # Uncomment below two lines if you prefer reading from environment
10
+ # GROQ_API_KEY = os.getenv("GROQ_API_KEY")
11
+ # if not GROQ_API_KEY:
12
+ # raise ValueError("API key is missing. Please set the GROQ_API_KEY environment variable.")
13
 
14
  # Initialize the Groq client
15
  client = Groq(api_key=GROQ_API_KEY)
 
29
 
30
  # Call Groq API
31
  response = client.chat.completions.create(
32
+ model="llama3-70b-8192", # ✅ Active supported model
33
  messages=messages,
34
  temperature=0.7,
35
  max_tokens=500,
 
64
  # Launch the Gradio app
65
  demo.launch()
66