VyLala commited on
Commit
f739d5d
·
verified ·
1 Parent(s): 4e7035b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -14
app.py CHANGED
@@ -73,12 +73,12 @@ with gr.Blocks() as interface:
73
 
74
  status = gr.Markdown(visible=False)
75
 
76
- with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
77
- with gr.Column(elem_id="nps-box"):
78
- gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
79
- nps_slider = gr.Slider(minimum=0, maximum=10, step=1, label="Select score: 0-10 (0-6: not likely or low; 7-8: neutral; 9-10: likely or highly)")
80
- nps_submit = gr.Button("Submit")
81
- nps_output = gr.Textbox(label="", interactive=False, visible=True) # Start empty
82
 
83
  with gr.Group(visible=False) as results_group:
84
  # with gr.Accordion("Open to See the Result", open=False) as results:
@@ -104,12 +104,20 @@ with gr.Blocks() as interface:
104
  submit_report_button = gr.Button("Submit", visible=False)
105
  status_report = gr.Markdown(visible=False)
106
 
107
- # nps_question = gr.Markdown("### How likely are you to recommend this tool to a colleague or peer (0 = Not at all, 10 = Definitely)?")
108
- # nps_slider = gr.Slider(minimum=0, maximum=10, step=1, label="Your NPS Score (0-10)")
109
- # nps_button = gr.Button("Submit")
110
- # nps_output = gr.Textbox(label="", interactive=False, visible=True) # Start empty
111
-
112
- download_file = gr.File(label="Download File Here", visible=False, interactive=True)
 
 
 
 
 
 
 
 
113
  progress_box = gr.Textbox(label="Live Processing Log", lines=20, interactive=False)
114
 
115
  gr.Markdown("---")
@@ -1164,8 +1172,10 @@ with gr.Blocks() as interface:
1164
  inputs=[raw_text, q1, q2, contact],
1165
  outputs=[feedback_status]
1166
  )
1167
- nps_submit.click(fn=submit_nps, inputs=[user_email, nps_slider], outputs=[nps_output])
1168
-
 
 
1169
 
1170
  gr.HTML("""
1171
  <style>
 
73
 
74
  status = gr.Markdown(visible=False)
75
 
76
+ # with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
77
+ # with gr.Column(elem_id="nps-box"):
78
+ # gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
79
+ # nps_slider = gr.Slider(minimum=0, maximum=10, step=1, label="Select score: 0-10 (0-6: not likely or low; 7-8: neutral; 9-10: likely or highly)")
80
+ # nps_submit = gr.Button("Submit")
81
+ # nps_output = gr.Textbox(label="", interactive=False, visible=True) # Start empty
82
 
83
  with gr.Group(visible=False) as results_group:
84
  # with gr.Accordion("Open to See the Result", open=False) as results:
 
104
  submit_report_button = gr.Button("Submit", visible=False)
105
  status_report = gr.Markdown(visible=False)
106
 
107
+ with gr.Group(visible=False, elem_id="nps-overlay") as nps_modal:
108
+ with gr.Column(elem_id="nps-box"):
109
+ gr.Markdown("### How likely are you to recommend this tool to a colleague or peer?")
110
+
111
+ # Create 11 buttons (0–10)
112
+ with gr.Row():
113
+ nps_buttons = []
114
+ for i in range(0, 11):
115
+ btn = gr.Button(str(i), elem_id=f"nps-btn-{i}")
116
+ nps_buttons.append(btn)
117
+
118
+ nps_output = gr.Textbox(label="", interactive=False, visible=True)
119
+
120
+ download_file = gr.File(label="Download File Here", visible=False, interactive=True)
121
  progress_box = gr.Textbox(label="Live Processing Log", lines=20, interactive=False)
122
 
123
  gr.Markdown("---")
 
1172
  inputs=[raw_text, q1, q2, contact],
1173
  outputs=[feedback_status]
1174
  )
1175
+ #nps_submit.click(fn=submit_nps, inputs=[user_email, nps_slider], outputs=[nps_output])
1176
+ # Link each button to submit function
1177
+ for i, btn in enumerate(nps_buttons):
1178
+ btn.click(fn=submit_nps, inputs=[user_email, gr.State(i)], outputs=nps_output)
1179
 
1180
  gr.HTML("""
1181
  <style>