lvwerra HF staff commited on
Commit
4e2c35f
·
1 Parent(s): 7389f5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -172,18 +172,20 @@ def generate(
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 submit_idx == -1:
176
  submit_idx = output[generation_start_idx:].find("<submit>")
177
  # I am sorry about the code
178
  print("-------", generation_start_idx, request_idx, call_idx, response_idx)
179
  highlighted_output = [
180
- (prompt, ""),
181
- (output[generation_start_idx:], "") if request_idx == -1 else ("", ""),
182
- (output[generation_start_idx:generation_start_idx+request_idx], ""),
183
- (output[generation_start_idx+request_idx:], "") if call_idx == -1 else ("", ""),
184
- (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "request"),
185
- (output[generation_start_idx+call_idx:generation_start_idx+response_idx], "call"),
186
- (output[generation_start_idx+response_idx:], "submit") if submit_idx != -1 else ("", ""),
187
  # (output[generation_start_idx:generation_start_idx+request_idx], ""),
188
  # (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "request"),
189
  # (output[generation_start_idx+call_idx:], "call"),
@@ -288,7 +290,7 @@ with gr.Blocks(theme=theme, analytics_enabled=False, css=css) as demo:
288
 
289
  output = gr.HighlightedText(
290
  label="Output",
291
- color_map={"query": "red", "call": "green", "response": "blue", "submit": "yellow", "model": "pink"},
292
  )
293
 
294
  gr_examples = gr.Examples(
 
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:
176
+ response_idx += len("<response>")
177
  if submit_idx == -1:
178
  submit_idx = output[generation_start_idx:].find("<submit>")
179
  # I am sorry about the code
180
  print("-------", generation_start_idx, request_idx, call_idx, response_idx)
181
  highlighted_output = [
182
+ (prompt, "query"),
183
+ (output[generation_start_idx:], "model") if request_idx == -1 else ("", ""),
184
+ (output[generation_start_idx:generation_start_idx+request_idx], "model"),
185
+ (output[generation_start_idx+request_idx:], "model") if call_idx == -1 else ("", ""),
186
+ (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "tool request"),
187
+ (output[generation_start_idx+call_idx:generation_start_idx+response_idx], "tool call"),
188
+ (output[generation_start_idx+response_idx:], "model") if submit_idx != -1 else ("", ""),
189
  # (output[generation_start_idx:generation_start_idx+request_idx], ""),
190
  # (output[generation_start_idx+request_idx:generation_start_idx+call_idx], "request"),
191
  # (output[generation_start_idx+call_idx:], "call"),
 
290
 
291
  output = gr.HighlightedText(
292
  label="Output",
293
+ color_map={"query": "red", "tool call": "green", "tool response": "blue", "model": "pink"},
294
  )
295
 
296
  gr_examples = gr.Examples(