Slaiwala commited on
Commit
65dcf65
·
verified ·
1 Parent(s): c934e2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -32
app.py CHANGED
@@ -1013,48 +1013,49 @@ with gr.Blocks(theme="soft") as demo:
1013
  feedback_grp = gr.Group(visible=False)
1014
  with feedback_grp:
1015
  gr.Markdown("### How helpful was this answer?")
1016
- rating = gr.Radio(choices=[1,2,3,4,5], label="Rating (1=poor, 5=great)")
1017
  comment = gr.Textbox(label="Optional comment", placeholder="What was good or missing?")
1018
  submit_fb = gr.Button("Submit feedback")
1019
  fb_status = gr.Markdown("")
1020
 
1021
- # Wiring
1022
- enter_btn.click(
1023
- fn=enter_app,
1024
- inputs=[first_tb, last_tb, state],
1025
- outputs=[gate, app, state, gate_msg],
1026
- )
1027
 
1028
- send_btn.click(
1029
- fn=predict,
1030
- inputs=[user_in, chat, state],
1031
- outputs=[chat, user_in, feedback_grp, rating, comment, state],
1032
- concurrency_limit=1, # serialize LLM calls
1033
- )
1034
 
1035
- user_in.submit(
1036
- fn=predict,
1037
- inputs=[user_in, chat, state],
1038
- outputs=[chat, user_in, feedback_grp, rating, comment, state],
1039
- concurrency_limit=1, # serialize LLM calls
1040
- )
1041
 
1042
- clear_btn.click(
1043
- fn=lambda: ([], "", gr.update(visible=False), None, "", init_session()),
1044
- inputs=None,
1045
- outputs=[chat, user_in, feedback_grp, rating, comment, state],
1046
- concurrency_limit=4,
1047
- )
1048
 
1049
- submit_fb.click(
1050
- fn=save_feedback,
1051
- inputs=[rating, comment, state],
1052
- outputs=[fb_status, feedback_grp],
1053
- concurrency_limit=4,
1054
- )
1055
 
1056
- # Queue (true concurrency = 1 to prevent OOM/restarts)
1057
  demo.queue(concurrency_count=1, max_size=64)
 
1058
 
1059
 
1060
 
 
1013
  feedback_grp = gr.Group(visible=False)
1014
  with feedback_grp:
1015
  gr.Markdown("### How helpful was this answer?")
1016
+ rating = gr.Radio(choices=[1, 2, 3, 4, 5], label="Rating (1=poor, 5=great)")
1017
  comment = gr.Textbox(label="Optional comment", placeholder="What was good or missing?")
1018
  submit_fb = gr.Button("Submit feedback")
1019
  fb_status = gr.Markdown("")
1020
 
1021
+ # ---- Wiring (MUST stay inside the Blocks context) ----
1022
+ enter_btn.click(
1023
+ fn=enter_app,
1024
+ inputs=[first_tb, last_tb, state],
1025
+ outputs=[gate, app, state, gate_msg],
1026
+ )
1027
 
1028
+ send_btn.click(
1029
+ fn=predict,
1030
+ inputs=[user_in, chat, state],
1031
+ outputs=[chat, user_in, feedback_grp, rating, comment, state],
1032
+ concurrency_limit=1, # serialize LLM calls
1033
+ )
1034
 
1035
+ user_in.submit(
1036
+ fn=predict,
1037
+ inputs=[user_in, chat, state],
1038
+ outputs=[chat, user_in, feedback_grp, rating, comment, state],
1039
+ concurrency_limit=1, # serialize LLM calls
1040
+ )
1041
 
1042
+ clear_btn.click(
1043
+ fn=lambda: ([], "", gr.update(visible=False), None, "", init_session()),
1044
+ inputs=None,
1045
+ outputs=[chat, user_in, feedback_grp, rating, comment, state],
1046
+ concurrency_limit=4,
1047
+ )
1048
 
1049
+ submit_fb.click(
1050
+ fn=save_feedback,
1051
+ inputs=[rating, comment, state],
1052
+ outputs=[fb_status, feedback_grp],
1053
+ concurrency_limit=4,
1054
+ )
1055
 
1056
+ # Queue & launch (outside the Blocks)
1057
  demo.queue(concurrency_count=1, max_size=64)
1058
+ demo.launch(max_threads=8)
1059
 
1060
 
1061