praeclarumjj3 commited on
Commit
3430dd6
·
1 Parent(s): aa288e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -21
app.py CHANGED
@@ -183,27 +183,27 @@ def http_bot(state, model_selector, temperature, top_p, max_new_tokens, request:
183
  yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
184
 
185
 
186
- try:
187
  # Stream output
188
- response = chat.generate_stream_gate(pload)
189
- for chunk in response:
190
- if chunk:
191
- data = json.loads(chunk.decode())
192
- if data["error_code"] == 0:
193
- output = data["text"][len(prompt):].strip()
194
- state.messages[-1][-1] = output + "▌"
195
- yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
196
- else:
197
- output = data["text"] + f" (error_code: {data['error_code']})"
198
- state.messages[-1][-1] = output
199
- yield (state, state.to_gradio_chatbot()) + (disable_btn, disable_btn, disable_btn, enable_btn, enable_btn)
200
- return
201
- time.sleep(0.03)
202
- except Exception:
203
- gr.Warning(server_error_msg)
204
- state.messages[-1][-1] = server_error_msg
205
- yield (state, state.to_gradio_chatbot()) + (disable_btn, disable_btn, disable_btn, enable_btn, enable_btn)
206
- return
207
 
208
  state.messages[-1][-1] = state.messages[-1][-1][:-1]
209
  yield (state, state.to_gradio_chatbot()) + (enable_btn,) * 5
@@ -230,7 +230,6 @@ title = "<h1 style='margin-bottom: -10px; text-align: center'>VCoder: Versatile
230
  # style='
231
  description = "<p style='font-size: 16px; margin: 5px; font-weight: w300; text-align: center'> <a href='https://praeclarumjj3.github.io/' style='text-decoration:none' target='_blank'>Jitesh Jain, </a> <a href='https://jwyang.github.io/' style='text-decoration:none' target='_blank'>Jianwei Yang, <a href='https://www.humphreyshi.com/home' style='text-decoration:none' target='_blank'>Humphrey Shi</a></p>" \
232
  + "<p style='font-size: 16px; margin: 5px; font-weight: w600; text-align: center'> <a href='https://praeclarumjj3.github.io/vcoder/' target='_blank'>Project Page</a> | <a href='https://praeclarumjj3.github.io/vcoder/' target='_blank'>Video</a> | <a href='https://arxiv.org/abs/2211.06220' target='_blank'>ArXiv Paper</a> | <a href='https://github.com/SHI-Labs/VCoder' target='_blank'>Github Repo</a></p>" \
233
- + "<p style='text-align: center; font-size: 16px; margin: 5px; font-weight: w300;'> [Note: Please click on Regenerate button if you are unsatisfied with the generated response. You may find screenshots of our demo trials <a href='https://github.com/SHI-Labs/VCoder/blob/main/images/' style='text-decoration:none' target='_blank'>here</a>.]</p>" \
234
  + "<p style='text-align: center; font-size: 16px; margin: 5px; font-weight: w300;'> [Note: You can obtain segmentation maps for your image using the <a href='https://huggingface.co/spaces/shi-labs/OneFormer' style='text-decoration:none' target='_blank'>OneFormer Demo</a>. Please click on Regenerate button if you are unsatisfied with the generated response. You may find screenshots of our demo trials <a href='https://github.com/SHI-Labs/VCoder/blob/main/images/' style='text-decoration:none' target='_blank'>here</a>.]</p>"
235
 
236
  tos_markdown = ("""
 
183
  yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
184
 
185
 
186
+ # try:
187
  # Stream output
188
+ response = chat.generate_stream_gate(pload)
189
+ for chunk in response:
190
+ if chunk:
191
+ data = json.loads(chunk.decode())
192
+ if data["error_code"] == 0:
193
+ output = data["text"][len(prompt):].strip()
194
+ state.messages[-1][-1] = output + "▌"
195
+ yield (state, state.to_gradio_chatbot()) + (disable_btn,) * 5
196
+ else:
197
+ output = data["text"] + f" (error_code: {data['error_code']})"
198
+ state.messages[-1][-1] = output
199
+ yield (state, state.to_gradio_chatbot()) + (disable_btn, disable_btn, disable_btn, enable_btn, enable_btn)
200
+ return
201
+ time.sleep(0.03)
202
+ # except Exception:
203
+ # gr.Warning(server_error_msg)
204
+ # state.messages[-1][-1] = server_error_msg
205
+ # yield (state, state.to_gradio_chatbot()) + (disable_btn, disable_btn, disable_btn, enable_btn, enable_btn)
206
+ # return
207
 
208
  state.messages[-1][-1] = state.messages[-1][-1][:-1]
209
  yield (state, state.to_gradio_chatbot()) + (enable_btn,) * 5
 
230
  # style='
231
  description = "<p style='font-size: 16px; margin: 5px; font-weight: w300; text-align: center'> <a href='https://praeclarumjj3.github.io/' style='text-decoration:none' target='_blank'>Jitesh Jain, </a> <a href='https://jwyang.github.io/' style='text-decoration:none' target='_blank'>Jianwei Yang, <a href='https://www.humphreyshi.com/home' style='text-decoration:none' target='_blank'>Humphrey Shi</a></p>" \
232
  + "<p style='font-size: 16px; margin: 5px; font-weight: w600; text-align: center'> <a href='https://praeclarumjj3.github.io/vcoder/' target='_blank'>Project Page</a> | <a href='https://praeclarumjj3.github.io/vcoder/' target='_blank'>Video</a> | <a href='https://arxiv.org/abs/2211.06220' target='_blank'>ArXiv Paper</a> | <a href='https://github.com/SHI-Labs/VCoder' target='_blank'>Github Repo</a></p>" \
 
233
  + "<p style='text-align: center; font-size: 16px; margin: 5px; font-weight: w300;'> [Note: You can obtain segmentation maps for your image using the <a href='https://huggingface.co/spaces/shi-labs/OneFormer' style='text-decoration:none' target='_blank'>OneFormer Demo</a>. Please click on Regenerate button if you are unsatisfied with the generated response. You may find screenshots of our demo trials <a href='https://github.com/SHI-Labs/VCoder/blob/main/images/' style='text-decoration:none' target='_blank'>here</a>.]</p>"
234
 
235
  tos_markdown = ("""