diff --git a/models/chatglm/__init__.py b/models/chatglm/__init__.py index 0440751..3fa7661 100644 --- a/models/chatglm/__init__.py +++ b/models/chatglm/__init__.py @@ -33,8 +33,10 @@ def chat(self) -> str: history = [] while True: text = input("用户输入:") + last_response = "" for response, history in self.model.stream_chat(self.tokenizer, text, history=history): - print(response, end='\r') + print(response[len(last_response):], end='') + last_response = response print(flush=True) def run_web_demo(self, input_text, history=[]): @@ -45,4 +47,4 @@ def run(self, text, history=[]): return self.model.chat(self.tokenizer, text, history=history) def get_model(args): - return ChatGLMMdoel(args) \ No newline at end of file + return ChatGLMMdoel(args)