GameTheory commited on
Commit
760da16
·
verified ·
1 Parent(s): ea8b9c4

Sync from GitHub

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -575,11 +575,19 @@ def build_demo():
575
  def chip_turn(label, hist):
576
  return "", (hist or []) + [{"role": "user", "content": label}], *hide3()
577
 
 
 
 
 
 
 
 
 
578
  def bot_turn(hist):
579
  if not hist or hist[-1]["role"] != "user":
580
  yield hist, *hide3()
581
  return
582
- msg = hist[-1]["content"]
583
  hist = hist + [{"role": "assistant", "content": ""}]
584
  final_chips = []
585
  for text, ch in respond(msg, hist[:-1]):
 
575
  def chip_turn(label, hist):
576
  return "", (hist or []) + [{"role": "user", "content": label}], *hide3()
577
 
578
+ def msg_text(content):
579
+ # Gradio 6 Chatbot returns content as a list of blocks
580
+ # ([{"text": ..., "type": "text"}]) rather than a plain string.
581
+ if isinstance(content, list):
582
+ return " ".join(b.get("text", "") for b in content
583
+ if isinstance(b, dict)).strip()
584
+ return content or ""
585
+
586
  def bot_turn(hist):
587
  if not hist or hist[-1]["role"] != "user":
588
  yield hist, *hide3()
589
  return
590
+ msg = msg_text(hist[-1]["content"])
591
  hist = hist + [{"role": "assistant", "content": ""}]
592
  final_chips = []
593
  for text, ch in respond(msg, hist[:-1]):