Implement fluent cli demo
This commit is contained in:
parent
8a0f57b1da
commit
761db39c1b
13
cli_demo.py
13
cli_demo.py
@ -39,7 +39,8 @@ def main():
|
||||
os.system(clear_command)
|
||||
print("欢迎使用 ChatGLM2-6B 模型,输入内容即可进行对话,clear 清空对话历史,stop 终止程序")
|
||||
continue
|
||||
count = 0
|
||||
print("\nChatGLM:", end="")
|
||||
current_length = 0
|
||||
for response, history, past_key_values in model.stream_chat(tokenizer, query, history=history,
|
||||
past_key_values=past_key_values,
|
||||
return_past_key_values=True):
|
||||
@ -47,13 +48,9 @@ def main():
|
||||
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[current_length:], end="", flush=True)
|
||||
current_length = len(response)
|
||||
print("")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user