Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,14 @@ import os
|
|
2 |
import gradio as gr
|
3 |
from groq import Groq
|
4 |
|
5 |
-
#
|
6 |
-
GROQ_API_KEY =
|
7 |
|
8 |
-
#
|
9 |
-
if
|
10 |
-
|
|
|
|
|
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", # ✅
|
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 |
|
|