Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,26 +17,27 @@ print("Groq Client Ready 🚀")
|
|
| 17 |
# ---------------------------
|
| 18 |
def chat_with_groq(message, history):
|
| 19 |
try:
|
| 20 |
-
# Convert Gradio history into Groq message format
|
| 21 |
messages = []
|
| 22 |
for human, assistant in history:
|
| 23 |
messages.append({"role": "user", "content": human})
|
| 24 |
messages.append({"role": "assistant", "content": assistant})
|
| 25 |
messages.append({"role": "user", "content": message})
|
| 26 |
|
| 27 |
-
print("Sending messages to Groq:", messages)
|
| 28 |
|
| 29 |
-
#
|
| 30 |
chat_completion = client.chat.completions.create(
|
| 31 |
messages=messages,
|
| 32 |
-
model="mixtral-8x7b-32768", #
|
| 33 |
)
|
| 34 |
|
| 35 |
reply = chat_completion.choices[0].message.content
|
| 36 |
return reply
|
| 37 |
except Exception as e:
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
| 40 |
|
| 41 |
# ---------------------------
|
| 42 |
# Gradio UI (adjusted for Gradio 6.x)
|
|
|
|
| 17 |
# ---------------------------
|
| 18 |
def chat_with_groq(message, history):
|
| 19 |
try:
|
|
|
|
| 20 |
messages = []
|
| 21 |
for human, assistant in history:
|
| 22 |
messages.append({"role": "user", "content": human})
|
| 23 |
messages.append({"role": "assistant", "content": assistant})
|
| 24 |
messages.append({"role": "user", "content": message})
|
| 25 |
|
| 26 |
+
print("Sending messages to Groq:", messages)
|
| 27 |
|
| 28 |
+
# Try a standard Groq model to rule out model issues
|
| 29 |
chat_completion = client.chat.completions.create(
|
| 30 |
messages=messages,
|
| 31 |
+
model="mixtral-8x7b-32768", # 👈 change to this known working model
|
| 32 |
)
|
| 33 |
|
| 34 |
reply = chat_completion.choices[0].message.content
|
| 35 |
return reply
|
| 36 |
except Exception as e:
|
| 37 |
+
# Print full exception details
|
| 38 |
+
import traceback
|
| 39 |
+
traceback.print_exc()
|
| 40 |
+
return f"❌ Error: {str(e)}"
|
| 41 |
|
| 42 |
# ---------------------------
|
| 43 |
# Gradio UI (adjusted for Gradio 6.x)
|