Spaces:
Paused
Paused
Arturo Jiménez de los Galanes Reguillos
commited on
Commit
·
cc63cd7
1
Parent(s):
7a4427a
Apply a found chat template
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ system_message = "You are a computer programmer that can translate python code t
|
|
10 |
|
11 |
def user_prompt_for(python):
|
12 |
return f"Rewrite this python code to C++. You must search for the maximum performance. \
|
13 |
-
Format your response in Markdown. This is the python Code, between triple
|
14 |
\n\n\
|
15 |
```{python}```"
|
16 |
|
@@ -21,15 +21,17 @@ def messages_for(python):
|
|
21 |
]
|
22 |
|
23 |
def apply_chat_template(messages):
|
24 |
-
bos_token = "<|
|
25 |
-
|
|
|
26 |
for message in messages:
|
27 |
-
if message['role'] == '
|
28 |
-
result += f"
|
29 |
-
elif message['role'] == '
|
30 |
-
result += f"
|
31 |
else:
|
32 |
-
result += f"
|
|
|
33 |
return result
|
34 |
|
35 |
|
|
|
10 |
|
11 |
def user_prompt_for(python):
|
12 |
return f"Rewrite this python code to C++. You must search for the maximum performance. \
|
13 |
+
Format your response in Markdown. This is the python Code, between triple backticks: \
|
14 |
\n\n\
|
15 |
```{python}```"
|
16 |
|
|
|
21 |
]
|
22 |
|
23 |
def apply_chat_template(messages):
|
24 |
+
bos_token = "<|begin▁of▁sentence|>"
|
25 |
+
|
26 |
+
result = ""
|
27 |
for message in messages:
|
28 |
+
if message['role'] == 'system':
|
29 |
+
result += f"{message['content']}\n"
|
30 |
+
elif message['role'] == 'user':
|
31 |
+
result += f"### Instruction:\n{message['content']}\n"
|
32 |
else:
|
33 |
+
result += f"### Response:\n{message['content']}\n<|EOT|>\n"
|
34 |
+
|
35 |
return result
|
36 |
|
37 |
|