Matt commited on
Commit
19568e8
·
1 Parent(s): 71364cd

Proper output formats

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -28,12 +28,11 @@ def apply_chat_template(template, test_conversation1, test_conversation2):
28
  outputs = []
29
  for i, conversation_str in enumerate((test_conversation1, test_conversation2)):
30
  conversation = json.loads(conversation_str)
31
- without_gen = tokenizer.apply_chat_template(conversation, tokenize=False)
32
- with_gen = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
33
- out = f"Conversation {i}:\n\n{conversation_str}\n\nOutput without generation prompt:\n\n{without_gen}\n\nOutput with generation prompt:\n\n{with_gen}\n\n"
34
- outputs.append(out)
35
  return tuple(outputs)
36
 
 
37
  iface = gr.Interface(
38
  fn=apply_chat_template,
39
  inputs=[
@@ -41,5 +40,5 @@ iface = gr.Interface(
41
  gr.TextArea(value=str(demo_conversation1), lines=5, label="Conversation 1"),
42
  gr.TextArea(value=str(demo_conversation2), lines=5, label="Conversation 2")
43
  ],
44
- outputs=["text", "text"])
45
  iface.launch()
 
28
  outputs = []
29
  for i, conversation_str in enumerate((test_conversation1, test_conversation2)):
30
  conversation = json.loads(conversation_str)
31
+ outputs.append(tokenizer.apply_chat_template(conversation, tokenize=False))
32
+ outputs.append(with_gen = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True))
 
 
33
  return tuple(outputs)
34
 
35
+ output_names = ["Conversation 1 without generation prompt", "Conversation 1 with generation prompt", "Conversation 2 without generation prompt", "Conversation 2 with generation prompt"]
36
  iface = gr.Interface(
37
  fn=apply_chat_template,
38
  inputs=[
 
40
  gr.TextArea(value=str(demo_conversation1), lines=5, label="Conversation 1"),
41
  gr.TextArea(value=str(demo_conversation2), lines=5, label="Conversation 2")
42
  ],
43
+ outputs=[gr.TextArea, label=output_name for output_name in output_names])
44
  iface.launch()