Yingxu He
commited on
Update handler.py
Browse files- handler.py +14 -3
handler.py
CHANGED
@@ -21,13 +21,24 @@ class EndpointHandler:
|
|
21 |
parameters = data.pop("parameters", None)
|
22 |
|
23 |
str_messages = inputs.split(TURN_BREAKER)
|
24 |
-
cpp_messages = [chatglm_cpp.ChatMessage(
|
|
|
|
|
|
|
25 |
|
26 |
for msg in str_messages[1:]:
|
27 |
if USER_SYMBOL in msg:
|
28 |
-
cpp_messages.append(
|
|
|
|
|
|
|
|
|
29 |
else:
|
30 |
-
cpp_messages.append(
|
|
|
|
|
|
|
|
|
31 |
|
32 |
# pass inputs with all kwargs in data
|
33 |
if parameters is not None:
|
|
|
21 |
parameters = data.pop("parameters", None)
|
22 |
|
23 |
str_messages = inputs.split(TURN_BREAKER)
|
24 |
+
cpp_messages = [chatglm_cpp.ChatMessage(
|
25 |
+
role="system",
|
26 |
+
content=str_messages[0].replace(SYSTEM_SYMBOL, "")
|
27 |
+
)]
|
28 |
|
29 |
for msg in str_messages[1:]:
|
30 |
if USER_SYMBOL in msg:
|
31 |
+
cpp_messages.append(
|
32 |
+
chatglm_cpp.ChatMessage(
|
33 |
+
role="user",
|
34 |
+
content=msg.replace(USER_SYMBOL, "")
|
35 |
+
))
|
36 |
else:
|
37 |
+
cpp_messages.append(
|
38 |
+
chatglm_cpp.ChatMessage(
|
39 |
+
role="assistant",
|
40 |
+
content=msg.replace(ASSISTANT_SYMBOL, "")
|
41 |
+
))
|
42 |
|
43 |
# pass inputs with all kwargs in data
|
44 |
if parameters is not None:
|