Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,8 +4,8 @@ import requests
|
|
| 4 |
# Groq API Key (Replace with your actual key)
|
| 5 |
GROQ_API_KEY = "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"
|
| 6 |
|
| 7 |
-
# Groq API URL for chat completion
|
| 8 |
-
GROQ_API_URL = "https://
|
| 9 |
|
| 10 |
# Function to interact with Groq API
|
| 11 |
def chat_with_groq(prompt, history):
|
|
@@ -34,7 +34,7 @@ def chat_with_groq(prompt, history):
|
|
| 34 |
return response_data["choices"][0]["message"]["content"]
|
| 35 |
else:
|
| 36 |
return f"API Error: {response_data.get('error', {}).get('message', 'Unknown error')}"
|
| 37 |
-
|
| 38 |
except Exception as e:
|
| 39 |
return f"Exception Error: {str(e)}"
|
| 40 |
|
|
|
|
| 4 |
# Groq API Key (Replace with your actual key)
|
| 5 |
GROQ_API_KEY = "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"
|
| 6 |
|
| 7 |
+
# Correct Groq API URL for chat completion
|
| 8 |
+
GROQ_API_URL = "https://api.groq.com/openai/v1/chat/completions"
|
| 9 |
|
| 10 |
# Function to interact with Groq API
|
| 11 |
def chat_with_groq(prompt, history):
|
|
|
|
| 34 |
return response_data["choices"][0]["message"]["content"]
|
| 35 |
else:
|
| 36 |
return f"API Error: {response_data.get('error', {}).get('message', 'Unknown error')}"
|
| 37 |
+
|
| 38 |
except Exception as e:
|
| 39 |
return f"Exception Error: {str(e)}"
|
| 40 |
|