vwxyzjn commited on
Commit
25cd81a
1 Parent(s): 3550d0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -23
app.py CHANGED
@@ -207,37 +207,41 @@ def generate(
207
  response_idx = output[generation_start_idx:].find("<response>")
208
 
209
  # if `<request>` is in the output, highlight it, if `<call>` is in the output, highlight it
210
- # print(generation_start_idx, request_idx, call_idx, response_idx)
211
  highlighted_output = [
212
  (prompt, ""),
213
  (output[generation_start_idx:generation_start_idx+request_idx], ""),
214
  (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "request"),
215
  (output[generation_start_idx+call_idx:-1], "call"),
216
  ]
217
- print(i, highlighted_output, output)
218
  yield highlighted_output
219
 
220
- call_output = copy.deepcopy(output)
221
- # response phase
222
- generate_kwargs["stop_sequences"] = ["<submit>"]
223
- stream = client.generate_stream(output, **generate_kwargs)
224
- for response in stream:
225
- if response.token.text == "<|endoftext|>":
226
- return output
227
- else:
228
- output += response.token.text
229
- if submit_idx == -1:
230
- submit_idx = output[generation_start_idx:].find("<submit>")
231
- # print(generation_start_idx, request_idx, call_idx, response_idx, submit_idx)
232
- highlighted_output = [
233
- (prompt, ""),
234
- (output[generation_start_idx:generation_start_idx+request_idx], ""),
235
- (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "request"),
236
- (output[generation_start_idx+call_idx:generation_start_idx+response_idx], "call"),
237
- (output[generation_start_idx+response_idx:-1], "submit"),
238
- ]
239
- print(highlighted_output, output)
240
- yield highlighted_output
 
 
 
 
241
 
242
  return highlighted_output
243
  except Exception as e:
 
207
  response_idx = output[generation_start_idx:].find("<response>")
208
 
209
  # if `<request>` is in the output, highlight it, if `<call>` is in the output, highlight it
210
+ # print("-------", generation_start_idx, request_idx, call_idx, response_idx)
211
  highlighted_output = [
212
  (prompt, ""),
213
  (output[generation_start_idx:generation_start_idx+request_idx], ""),
214
  (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "request"),
215
  (output[generation_start_idx+call_idx:-1], "call"),
216
  ]
217
+ # print(i, highlighted_output, output)
218
  yield highlighted_output
219
 
220
+ # breakpoint()
221
+ call_output = copy.deepcopy(output)
222
+ print("start submit output")
223
+ # response phase
224
+ generate_kwargs["stop_sequences"] = ["<submit>"]
225
+ stream = client.generate_stream(output, **generate_kwargs)
226
+ for response in stream:
227
+ if response.token.text == "<|endoftext|>":
228
+ return output
229
+ else:
230
+ output += response.token.text
231
+ if submit_idx == -1:
232
+ submit_idx = output[generation_start_idx:].find("<submit>")
233
+ # print("-------", generation_start_idx, request_idx, call_idx, response_idx, submit_idx)
234
+ highlighted_output = [
235
+ (prompt, ""),
236
+ (output[generation_start_idx:generation_start_idx+request_idx], ""),
237
+ (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "request"),
238
+ (output[generation_start_idx+call_idx:generation_start_idx+response_idx], "call"),
239
+ (output[generation_start_idx+response_idx:-1], "submit"),
240
+ ]
241
+ # print(highlighted_output, output)
242
+ yield highlighted_output
243
+ print("-------", generation_start_idx, request_idx, call_idx, response_idx, submit_idx)
244
+ print(highlighted_output, output)
245
 
246
  return highlighted_output
247
  except Exception as e: