Matt commited on
Commit
69460b6
·
1 Parent(s): 3396f08
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -13,6 +13,13 @@ demo_conversation2 = [
13
  {"role": "user", "content": "Hi there!"}
14
  ]
15
 
 
 
 
 
 
 
 
16
  conversations = [demo_conversation1, demo_conversation2]
17
 
18
  def apply_chat_template(template):
@@ -25,5 +32,8 @@ def apply_chat_template(template):
25
  outputs.append(out)
26
  return tuple(outputs)
27
 
28
- iface = gr.Interface(fn=apply_chat_template, inputs="text", outputs=["text"] * len(conversations))
 
 
 
29
  iface.launch()
 
13
  {"role": "user", "content": "Hi there!"}
14
  ]
15
 
16
+ default_template = """{% for message in messages %}
17
+ {{ "<|im_start|>" + message["role"] + \n + message["content"] + "<|im_end|>\n" }}
18
+ {% endfor %}
19
+ {% if add_generation_prompt %}
20
+ {{ "<|im_start|>assistant\n" }}
21
+ {% endif %}"""
22
+
23
  conversations = [demo_conversation1, demo_conversation2]
24
 
25
  def apply_chat_template(template):
 
32
  outputs.append(out)
33
  return tuple(outputs)
34
 
35
+ iface = gr.Interface(
36
+ fn=apply_chat_template,
37
+ inputs=gr.TextArea(value=default_template, lines=10, max_lines=30, label="Chat Template"),
38
+ outputs=["text"] * len(conversations))
39
  iface.launch()