Implement fluent cli demo

This commit is contained in:
duzx16 2023-06-27 09:51:05 +08:00
parent 8a0f57b1da
commit 761db39c1b

View File

@ -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__":