Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,9 +4,9 @@ import gradio as gr
|
|
| 4 |
|
| 5 |
# Get API key from environment variable
|
| 6 |
API_KEY = os.environ.get("GROQ_API_KEY")
|
| 7 |
-
API_URL = "https://api.groq.com/
|
| 8 |
|
| 9 |
-
#
|
| 10 |
def query_groq(prompt):
|
| 11 |
headers = {
|
| 12 |
"Authorization": f"Bearer {API_KEY}",
|
|
@@ -18,7 +18,8 @@ def query_groq(prompt):
|
|
| 18 |
"messages": [
|
| 19 |
{"role": "system", "content": "You are an expert Programming Tutor."},
|
| 20 |
{"role": "user", "content": prompt}
|
| 21 |
-
]
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
response = requests.post(API_URL, headers=headers, json=data)
|
|
|
|
| 4 |
|
| 5 |
# Get API key from environment variable
|
| 6 |
API_KEY = os.environ.get("GROQ_API_KEY")
|
| 7 |
+
API_URL = "https://api.groq.com/v1/chat/completions" # <-- FIXED
|
| 8 |
|
| 9 |
+
# Function to call GROQ API
|
| 10 |
def query_groq(prompt):
|
| 11 |
headers = {
|
| 12 |
"Authorization": f"Bearer {API_KEY}",
|
|
|
|
| 18 |
"messages": [
|
| 19 |
{"role": "system", "content": "You are an expert Programming Tutor."},
|
| 20 |
{"role": "user", "content": prompt}
|
| 21 |
+
],
|
| 22 |
+
"temperature": 0.7
|
| 23 |
}
|
| 24 |
|
| 25 |
response = requests.post(API_URL, headers=headers, json=data)
|