Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -189,12 +189,14 @@ ANSWER:"""
|
|
| 189 |
|
| 190 |
# =========================
|
| 191 |
# 💬 CHAT FUNCTION
|
|
|
|
| 192 |
# =========================
|
| 193 |
def chat(message, history):
|
| 194 |
if not message.strip():
|
| 195 |
return "", history
|
| 196 |
reply = generate(message)
|
| 197 |
-
history.append(
|
|
|
|
| 198 |
return "", history
|
| 199 |
|
| 200 |
# =========================
|
|
@@ -225,7 +227,8 @@ with gr.Blocks(title="Groq RAG Assistant") as app:
|
|
| 225 |
|
| 226 |
with gr.Column(scale=2):
|
| 227 |
gr.Markdown("### 💬 Ask Your Documents")
|
| 228 |
-
|
|
|
|
| 229 |
msg = gr.Textbox(
|
| 230 |
placeholder="Ask a question about your documents…",
|
| 231 |
label="Your question",
|
|
|
|
| 189 |
|
| 190 |
# =========================
|
| 191 |
# 💬 CHAT FUNCTION
|
| 192 |
+
# Gradio 5 uses {"role": ..., "content": ...} dicts, not tuples
|
| 193 |
# =========================
|
| 194 |
def chat(message, history):
|
| 195 |
if not message.strip():
|
| 196 |
return "", history
|
| 197 |
reply = generate(message)
|
| 198 |
+
history.append({"role": "user", "content": message})
|
| 199 |
+
history.append({"role": "assistant", "content": reply})
|
| 200 |
return "", history
|
| 201 |
|
| 202 |
# =========================
|
|
|
|
| 227 |
|
| 228 |
with gr.Column(scale=2):
|
| 229 |
gr.Markdown("### 💬 Ask Your Documents")
|
| 230 |
+
# Gradio 5: type="messages" uses the new dict format
|
| 231 |
+
chatbot = gr.Chatbot(height=480, type="messages")
|
| 232 |
msg = gr.Textbox(
|
| 233 |
placeholder="Ask a question about your documents…",
|
| 234 |
label="Your question",
|