Skip to content

Commit

Permalink
fix: 优化控制台闪烁的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
潕量 committed May 18, 2023
1 parent 163f94e commit 95f4b23
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions cli_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,12 @@ def main():
os.system(clear_command)
print("欢迎使用 ChatGLM-6B 模型,输入内容即可进行对话,clear 清空对话历史,stop 终止程序")
continue
count = 0
prev_response = ""
print("ChatGLM-6B:", end="", flush=True)
for response, history in model.stream_chat(tokenizer, query, history=history):
if stop_stream:
stop_stream = False
break
else:
count += 1
if count % 8 == 0:
os.system(clear_command)
print(build_prompt(history), flush=True)
signal.signal(signal.SIGINT, signal_handler)
os.system(clear_command)
print(build_prompt(history), flush=True)

print(response[len(prev_response):], end="", flush=True)
prev_response = response
print("\n", end="", flush=True)

if __name__ == "__main__":
main()

0 comments on commit 95f4b23

Please sign in to comment.