Matt commited on
Commit
9512d4d
1 Parent(s): 93451f9
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -17,12 +17,13 @@ conversations = [demo_conversation1, demo_conversation2]
17
 
18
  def apply_chat_template(template):
19
  tokenizer.chat_template = template
20
- out = ""
21
  for i, conversation in enumerate(conversations):
22
  without_gen = tokenizer.apply_chat_template(conversation, tokenize=False)
23
  with_gen = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
24
- out += f"Conversation {i} without generation prompt:\n\n{without_gen}\n\nConversation {i} with generation prompt:\n\n{with_gen}\n\n"
25
- return out
 
26
 
27
- iface = gr.Interface(fn=apply_chat_template, inputs="text", outputs="text")
28
  iface.launch()
 
17
 
18
  def apply_chat_template(template):
19
  tokenizer.chat_template = template
20
+ outputs = []
21
  for i, conversation in enumerate(conversations):
22
  without_gen = tokenizer.apply_chat_template(conversation, tokenize=False)
23
  with_gen = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=True)
24
+ out = f"Conversation {i} without generation prompt:\n\n{without_gen}\n\nConversation {i} with generation prompt:\n\n{with_gen}\n\n"
25
+ outputs.append(out)
26
+ return *outputs
27
 
28
+ iface = gr.Interface(fn=apply_chat_template, inputs="text", outputs=["text"] * len(conversations))
29
  iface.launch()