Spaces:
Runtime error
Runtime error
Matt
commited on
Commit
•
aeb84b0
1
Parent(s):
d35cae7
Add PR output
Browse files
app.py
CHANGED
@@ -28,7 +28,14 @@ def apply_chat_template(template, test_conversation, add_generation_prompt, clea
|
|
28 |
tokenizer.chat_template = template
|
29 |
outputs = []
|
30 |
conversation = json.loads(test_conversation)
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
iface = gr.Interface(
|
34 |
description=description_text,
|
@@ -39,5 +46,8 @@ iface = gr.Interface(
|
|
39 |
gr.Checkbox(value=False, label="Add generation prompt"),
|
40 |
gr.Checkbox(value=True, label="Cleanup template whitespace"),
|
41 |
],
|
42 |
-
outputs=
|
|
|
|
|
|
|
43 |
iface.launch()
|
|
|
28 |
tokenizer.chat_template = template
|
29 |
outputs = []
|
30 |
conversation = json.loads(test_conversation)
|
31 |
+
pr_snippet = (
|
32 |
+
"tokenizer = AutoTokenizer.from_pretrained(CHECKPOINT)",
|
33 |
+
f"tokenizer.chat_template = \"{template}\"",
|
34 |
+
tokenizer.push_to_hub(CHECKPOINT, create_pr=True)
|
35 |
+
)
|
36 |
+
pr_snippet = "\n".join(pr_snippet)
|
37 |
+
formatted = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=add_generation_prompt)
|
38 |
+
return formatted, pr_snippet
|
39 |
|
40 |
iface = gr.Interface(
|
41 |
description=description_text,
|
|
|
46 |
gr.Checkbox(value=False, label="Add generation prompt"),
|
47 |
gr.Checkbox(value=True, label="Cleanup template whitespace"),
|
48 |
],
|
49 |
+
outputs=[
|
50 |
+
gr.TextArea(label="Formatted conversation")),
|
51 |
+
gr.TextArea(label="Code snippet to create PR", lines=3, show_copy_button=True))
|
52 |
+
]
|
53 |
iface.launch()
|