zRzRzRzRzRzRzR Alexyo commited on
Commit
340a2eb
1 Parent(s): e46a148

fix issue https://github.com/THUDM/ChatGLM3/issues/227 (#9)

Browse files

- fix issue https://github.com/THUDM/ChatGLM3/issues/227 (9c01557f168549c2f022b96904335f0e21ecb11d)


Co-authored-by: y A n g <Alexyo@users.noreply.huggingface.co>

Files changed (1) hide show
  1. modeling_chatglm.py +4 -1
modeling_chatglm.py CHANGED
@@ -1000,7 +1000,10 @@ class ChatGLMForConditionalGeneration(ChatGLMPreTrainedModel):
1000
  content = ""
1001
  history = deepcopy(history)
1002
  for response in output.split("<|assistant|>"):
1003
- metadata, content = response.split("\n", maxsplit=1)
 
 
 
1004
  if not metadata.strip():
1005
  content = content.strip()
1006
  history.append({"role": "assistant", "metadata": metadata, "content": content})
 
1000
  content = ""
1001
  history = deepcopy(history)
1002
  for response in output.split("<|assistant|>"):
1003
+ if "\n" in response:
1004
+ metadata, content = response.split("\n", maxsplit=1)
1005
+ else:
1006
+ metadata, content = "", response
1007
  if not metadata.strip():
1008
  content = content.strip()
1009
  history.append({"role": "assistant", "metadata": metadata, "content": content})