chansung commited on
Commit
9aac618
·
1 Parent(s): cc8498b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -13
app.py CHANGED
@@ -122,7 +122,9 @@ with gr.Blocks(css=PARENT_BLOCK_CSS) as demo:
122
 
123
  chatbot = gr.Chatbot(elem_id='chatbot', label="Alpaca-LoRA")
124
  instruction_txtbox = gr.Textbox(placeholder="What do you want to say to AI?", label="Instruction")
125
- send_prompt_btn = gr.Button(value="Send Prompt")
 
 
126
 
127
  with gr.Accordion("Helper Buttons", open=False):
128
  gr.Markdown(f"`Continue` lets AI to complete the previous incomplete answers. `Summarize` lets AI to summarize the conversations so far.")
@@ -158,38 +160,52 @@ with gr.Blocks(css=PARENT_BLOCK_CSS) as demo:
158
 
159
  gr.Markdown(f"{BOTTOM_LINE}")
160
 
161
- send_prompt_btn.click(
162
- chat_stream,
 
163
  [context_txtbox, instruction_txtbox, state_chatbot],
164
  [state_chatbot, chatbot, context_txtbox],
 
 
165
  )
166
- send_prompt_btn.click(
167
  reset_textbox,
168
  [],
169
  [instruction_txtbox],
170
  )
171
-
172
- continue_btn.click(
173
- chat_stream,
174
  [context_txtbox, continue_txtbox, state_chatbot],
175
  [state_chatbot, chatbot, context_txtbox],
 
 
176
  )
177
- continue_btn.click(
178
  reset_textbox,
179
  [],
180
  [instruction_txtbox],
181
  )
182
-
183
- summarize_btn.click(
184
- chat_stream,
185
  [context_txtbox, summrize_txtbox, state_chatbot],
186
  [state_chatbot, chatbot, context_txtbox],
 
 
187
  )
188
- summarize_btn.click(
189
  reset_textbox,
190
  [],
191
  [instruction_txtbox],
192
- )
 
 
 
 
 
 
 
193
 
194
  demo.queue(
195
  concurrency_count=1,
 
122
 
123
  chatbot = gr.Chatbot(elem_id='chatbot', label="Alpaca-LoRA")
124
  instruction_txtbox = gr.Textbox(placeholder="What do you want to say to AI?", label="Instruction")
125
+ with gr.Row():
126
+ send_prompt_btn = gr.Button(value="Send Prompt")
127
+ cancel_btn = gr.Button(value="Cancel")
128
 
129
  with gr.Accordion("Helper Buttons", open=False):
130
  gr.Markdown(f"`Continue` lets AI to complete the previous incomplete answers. `Summarize` lets AI to summarize the conversations so far.")
 
160
 
161
  gr.Markdown(f"{BOTTOM_LINE}")
162
 
163
+
164
+ send_event = send_prompt_btn.click(
165
+ chat_batch if batch_enabled else chat_stream,
166
  [context_txtbox, instruction_txtbox, state_chatbot],
167
  [state_chatbot, chatbot, context_txtbox],
168
+ batch=batch_enabled,
169
+ max_batch_size=args.batch_size,
170
  )
171
+ reset_event = send_prompt_btn.click(
172
  reset_textbox,
173
  [],
174
  [instruction_txtbox],
175
  )
176
+
177
+ continue_event = continue_btn.click(
178
+ chat_batch if batch_enabled else chat_stream,
179
  [context_txtbox, continue_txtbox, state_chatbot],
180
  [state_chatbot, chatbot, context_txtbox],
181
+ batch=batch_enabled,
182
+ max_batch_size=args.batch_size,
183
  )
184
+ reset_continue_event = continue_btn.click(
185
  reset_textbox,
186
  [],
187
  [instruction_txtbox],
188
  )
189
+
190
+ summarize_event = summarize_btn.click(
191
+ chat_batch if batch_enabled else chat_stream,
192
  [context_txtbox, summrize_txtbox, state_chatbot],
193
  [state_chatbot, chatbot, context_txtbox],
194
+ batch=batch_enabled,
195
+ max_batch_size=args.batch_size,
196
  )
197
+ summarize_reset_event = summarize_btn.click(
198
  reset_textbox,
199
  [],
200
  [instruction_txtbox],
201
+ )
202
+
203
+ cancel_btn.click(
204
+ None, None, None,
205
+ cancels=[
206
+ send_event, continue_event, summarize_event
207
+ ]
208
+ )
209
 
210
  demo.queue(
211
  concurrency_count=1,