Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -262,14 +262,24 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 262 |
# 4) Connect each starter button:
|
| 263 |
for starter_button in starter_buttons:
|
| 264 |
starter_button.click(
|
| 265 |
-
fn=lambda x: [
|
| 266 |
inputs=[starter_button],
|
| 267 |
outputs=[chatbot],
|
| 268 |
queue=False
|
| 269 |
-
).then
|
| 270 |
-
fn=respond
|
| 271 |
-
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
queue=True
|
| 274 |
)
|
| 275 |
|
|
|
|
| 262 |
# 4) Connect each starter button:
|
| 263 |
for starter_button in starter_buttons:
|
| 264 |
starter_button.click(
|
| 265 |
+
fn=lambda x: [(x, "")], # Simple tuple for chat history
|
| 266 |
inputs=[starter_button],
|
| 267 |
outputs=[chatbot],
|
| 268 |
queue=False
|
| 269 |
+
).success( # Use success instead of then for better flow control
|
| 270 |
+
fn=lambda x, h, g, m: respond(
|
| 271 |
+
message=x,
|
| 272 |
+
chat_history=h if h else [],
|
| 273 |
+
genre=g,
|
| 274 |
+
use_full_memory=m
|
| 275 |
+
),
|
| 276 |
+
inputs=[
|
| 277 |
+
starter_button, # The starter text
|
| 278 |
+
chatbot, # Current chat history
|
| 279 |
+
genre, # Selected genre
|
| 280 |
+
full_memory # Memory flag
|
| 281 |
+
],
|
| 282 |
+
outputs=chatbot,
|
| 283 |
queue=True
|
| 284 |
)
|
| 285 |
|