lvwerra HF staff commited on
Commit
5384f91
1 Parent(s): 4e2c35f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -147,7 +147,7 @@ def generate(
147
  output = system_prompt + prompt
148
  generation_start_idx = len(output)
149
  highlighted_output = [
150
- (prompt, ""),
151
  ]
152
  yield highlighted_output, output[generation_start_idx:]
153
  for response in stream:
@@ -170,6 +170,8 @@ def generate(
170
  request_idx = output[generation_start_idx:].find("<request>")
171
  if call_idx == -1:
172
  call_idx = output[generation_start_idx:].find("<call>")
 
 
173
  if response_idx == -1:
174
  response_idx = output[generation_start_idx:].find("<response>")
175
  if response_idx != -1:
@@ -205,11 +207,11 @@ def generate(
205
  submit_idx = output[generation_start_idx:].find("<submit>")
206
  # print("-------", generation_start_idx, request_idx, call_idx, response_idx)
207
  highlighted_output = [
208
- (prompt, ""),
209
- (output[generation_start_idx:generation_start_idx+request_idx], ""),
210
  (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "request"),
211
  (output[generation_start_idx+call_idx:generation_start_idx+response_idx], "call"),
212
- (output[generation_start_idx+response_idx:], "submit") if submit_idx != -1 else ("", ""),
213
  ]
214
  # print(highlighted_output, output[generation_start_idx:])
215
  yield highlighted_output, output[generation_start_idx:]
@@ -282,9 +284,8 @@ with gr.Blocks(theme=theme, analytics_enabled=False, css=css) as demo:
282
  instruction = gr.Textbox(
283
  value="Q: In which country is Oberhofen situated?",
284
  # placeholder="Enter your question here. E.g., Q: In which country is Oberhofen situated?",
285
- lines=5,
286
  label="Input",
287
- elem_id="q-input",
288
  )
289
  submit = gr.Button("Generate", variant="primary")
290
 
 
147
  output = system_prompt + prompt
148
  generation_start_idx = len(output)
149
  highlighted_output = [
150
+ (prompt, "query"),
151
  ]
152
  yield highlighted_output, output[generation_start_idx:]
153
  for response in stream:
 
170
  request_idx = output[generation_start_idx:].find("<request>")
171
  if call_idx == -1:
172
  call_idx = output[generation_start_idx:].find("<call>")
173
+ if call_idx != -1:
174
+ call_idx += len("<call>")
175
  if response_idx == -1:
176
  response_idx = output[generation_start_idx:].find("<response>")
177
  if response_idx != -1:
 
207
  submit_idx = output[generation_start_idx:].find("<submit>")
208
  # print("-------", generation_start_idx, request_idx, call_idx, response_idx)
209
  highlighted_output = [
210
+ (prompt, "query"),
211
+ (output[generation_start_idx:generation_start_idx+request_idx], "model"),
212
  (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "request"),
213
  (output[generation_start_idx+call_idx:generation_start_idx+response_idx], "call"),
214
+ (output[generation_start_idx+response_idx:], "model") if submit_idx != -1 else ("", ""),
215
  ]
216
  # print(highlighted_output, output[generation_start_idx:])
217
  yield highlighted_output, output[generation_start_idx:]
 
284
  instruction = gr.Textbox(
285
  value="Q: In which country is Oberhofen situated?",
286
  # placeholder="Enter your question here. E.g., Q: In which country is Oberhofen situated?",
287
+ lines=2,
288
  label="Input",
 
289
  )
290
  submit = gr.Button("Generate", variant="primary")
291