PeterPinetree commited on
Commit
b235111
·
verified ·
1 Parent(s): b078faf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
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: [{"role": "user", "content": str(x)}], # Format as message dict
266
  inputs=[starter_button],
267
  outputs=[chatbot],
268
  queue=False
269
- ).then(
270
- fn=respond,
271
- inputs=[starter_button, chatbot, genre, full_memory],
272
- outputs=[chatbot],
 
 
 
 
 
 
 
 
 
 
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