Update app.py
Browse files
app.py
CHANGED
@@ -35,15 +35,13 @@ def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetit
|
|
35 |
history = history or []
|
36 |
|
37 |
if system_message.strip():
|
38 |
-
# if system_message is not None or empty
|
39 |
messages = "<|im_start|> "+"system\n" + system_message.strip() + "<|im_end|>\n" + \
|
40 |
"\n".join(["\n".join(["<|im_start|> "+"user\n"+item[0]+"<|im_end|>", "<|im_start|> assistant\n"+item[1]+"<|im_end|>"])
|
41 |
-
|
42 |
else:
|
43 |
-
# if system_message is None or empty, use BASE_SYSTEM_MESSAGE
|
44 |
messages = "<|im_start|> "+"system\n" + BASE_SYSTEM_MESSAGE + "<|im_end|>\n" + \
|
45 |
"\n".join(["\n".join(["<|im_start|> "+"user\n"+item[0]+"<|im_end|>", "<|im_start|> assistant\n"+item[1]+"<|im_end|>"])
|
46 |
-
|
47 |
# strip the last `<|end_of_turn|>` from the messages
|
48 |
messages = messages.rstrip("<|im_end|>")
|
49 |
# remove last space from assistant, some models output a ZWSP if you leave a space
|
|
|
35 |
history = history or []
|
36 |
|
37 |
if system_message.strip():
|
|
|
38 |
messages = "<|im_start|> "+"system\n" + system_message.strip() + "<|im_end|>\n" + \
|
39 |
"\n".join(["\n".join(["<|im_start|> "+"user\n"+item[0]+"<|im_end|>", "<|im_start|> assistant\n"+item[1]+"<|im_end|>"])
|
40 |
+
for item in history])
|
41 |
else:
|
|
|
42 |
messages = "<|im_start|> "+"system\n" + BASE_SYSTEM_MESSAGE + "<|im_end|>\n" + \
|
43 |
"\n".join(["\n".join(["<|im_start|> "+"user\n"+item[0]+"<|im_end|>", "<|im_start|> assistant\n"+item[1]+"<|im_end|>"])
|
44 |
+
for item in history])
|
45 |
# strip the last `<|end_of_turn|>` from the messages
|
46 |
messages = messages.rstrip("<|im_end|>")
|
47 |
# remove last space from assistant, some models output a ZWSP if you leave a space
|