Spaces:
Running
on
Zero
Running
on
Zero
fix template
Browse files
app.py
CHANGED
@@ -72,13 +72,16 @@ def predict(message, history, system_prompt, temperature, max_new_tokens, top_k,
|
|
72 |
elif CHAT_TEMPLATE == "Bielik":
|
73 |
stop_tokens = ["</s>"]
|
74 |
prompt_builder = ["<s>"]
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
82 |
instruction = ''.join(prompt_builder)
|
83 |
else:
|
84 |
raise Exception("Incorrect chat template, select 'ChatML' or 'Mistral Instruct'")
|
|
|
72 |
elif CHAT_TEMPLATE == "Bielik":
|
73 |
stop_tokens = ["</s>"]
|
74 |
prompt_builder = ["<s>"]
|
75 |
+
if history:
|
76 |
+
for human, assistant in history:
|
77 |
+
if system_prompt:
|
78 |
+
prompt_builder.append(f"[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n{human} [/INST] {assistant}</s>")
|
79 |
+
system_prompt = None
|
80 |
+
else:
|
81 |
+
prompt_builder.append(f"[INST] {human} [/INST] {assistant}</s>")
|
82 |
+
prompt_builder.append(f"[INST] {message} [/INST]")
|
83 |
+
else:
|
84 |
+
prompt_builder.append(f"[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n{message} [/INST]")
|
85 |
instruction = ''.join(prompt_builder)
|
86 |
else:
|
87 |
raise Exception("Incorrect chat template, select 'ChatML' or 'Mistral Instruct'")
|