hodfa840 commited on
Commit
36ff0bd
Β·
1 Parent(s): a1edf08

fix: add api_name=False to all event handlers to bypass Gradio schema crash

Browse files

Gradio's api_info route throws TypeError when serializing ChatMessage
Pydantic schema (additionalProperties is bool, not dict). Adding
api_name=False skips schema generation for all handlers. Also pins
gradio>=5.23.0 where this is resolved.

Files changed (2) hide show
  1. app.py +4 -1
  2. requirements.txt +1 -0
app.py CHANGED
@@ -440,7 +440,7 @@ with gr.Blocks(title="RetailMind β€” Self-Healing AI", css=css, theme=gr.themes.
440
  with gr.Accordion(scenario_name, open=False):
441
  for q in queries:
442
  btn = gr.Button(q, size="sm", variant="secondary")
443
- btn.click(fn=load_example, inputs=btn, outputs=msg)
444
 
445
  # ── MIDDLE: Product Feed ─────────────────────────────────
446
  with gr.Column(scale=4, elem_classes=["glass-panel"]):
@@ -488,16 +488,19 @@ with gr.Blocks(title="RetailMind β€” Self-Healing AI", css=css, theme=gr.themes.
488
  process_query,
489
  inputs=[msg, chatbot],
490
  outputs=[msg, chatbot, drift_plot, explanation_box, current_phase, retrieved_box],
 
491
  )
492
  msg.submit(
493
  process_query,
494
  inputs=[msg, chatbot],
495
  outputs=[msg, chatbot, drift_plot, explanation_box, current_phase, retrieved_box],
 
496
  )
497
  reset_btn.click(
498
  reset_chat,
499
  inputs=None,
500
  outputs=[msg, chatbot, drift_plot, explanation_box, current_phase, retrieved_box],
 
501
  )
502
 
503
 
 
440
  with gr.Accordion(scenario_name, open=False):
441
  for q in queries:
442
  btn = gr.Button(q, size="sm", variant="secondary")
443
+ btn.click(fn=load_example, inputs=btn, outputs=msg, api_name=False)
444
 
445
  # ── MIDDLE: Product Feed ─────────────────────────────────
446
  with gr.Column(scale=4, elem_classes=["glass-panel"]):
 
488
  process_query,
489
  inputs=[msg, chatbot],
490
  outputs=[msg, chatbot, drift_plot, explanation_box, current_phase, retrieved_box],
491
+ api_name=False,
492
  )
493
  msg.submit(
494
  process_query,
495
  inputs=[msg, chatbot],
496
  outputs=[msg, chatbot, drift_plot, explanation_box, current_phase, retrieved_box],
497
+ api_name=False,
498
  )
499
  reset_btn.click(
500
  reset_chat,
501
  inputs=None,
502
  outputs=[msg, chatbot, drift_plot, explanation_box, current_phase, retrieved_box],
503
+ api_name=False,
504
  )
505
 
506
 
requirements.txt CHANGED
@@ -1,3 +1,4 @@
 
1
  transformers
2
  torch
3
  sentence-transformers
 
1
+ gradio>=5.23.0
2
  transformers
3
  torch
4
  sentence-transformers