srikol commited on
Commit
952ac40
·
verified ·
1 Parent(s): 20da24e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -137,6 +137,7 @@ with gr.Blocks(theme="soft") as demo:
137
  chat = gr.Chatbot(type="messages", label="Résumé Bot", height=520)
138
  inp = gr.Textbox(placeholder="Ask about my résumé…", show_label=False)
139
  state = gr.State([])
 
140
 
141
  # ENTER
142
  def user_submit(msg, hist):
@@ -154,8 +155,16 @@ with gr.Blocks(theme="soft") as demo:
154
  {"role":"assistant","content":ans}]
155
  return hist, hist
156
 
 
157
  for b, q in zip(btns, quick):
158
- b.click(quick_send, [state, q], [chat, state])
 
 
 
 
 
 
 
159
 
160
  if __name__ == "__main__":
161
  # When running in HF Spaces, share=True is ignored; safe to leave as-is.
 
137
  chat = gr.Chatbot(type="messages", label="Résumé Bot", height=520)
138
  inp = gr.Textbox(placeholder="Ask about my résumé…", show_label=False)
139
  state = gr.State([])
140
+ quick_q = gr.Textbox(visible=False) # Hidden textbox for quick button input
141
 
142
  # ENTER
143
  def user_submit(msg, hist):
 
155
  {"role":"assistant","content":ans}]
156
  return hist, hist
157
 
158
+ # This block handles button clicks using a hidden textbox to store the question value
159
  for b, q in zip(btns, quick):
160
+ b.click(
161
+ fn=None,
162
+ inputs=None,
163
+ outputs=quick_q,
164
+ _js=f"() => '{q}'"
165
+ ).then(
166
+ quick_send, [state, quick_q], [chat, state]
167
+ )
168
 
169
  if __name__ == "__main__":
170
  # When running in HF Spaces, share=True is ignored; safe to leave as-is.