Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
]
|
239 |
-
|
240 |
-
|
|
|
|
|
|
|
|
|
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:
|