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)
|
os.system(clear_command)
|
||||||
print("欢迎使用 ChatGLM2-6B 模型,输入内容即可进行对话,clear 清空对话历史,stop 终止程序")
|
print("欢迎使用 ChatGLM2-6B 模型,输入内容即可进行对话,clear 清空对话历史,stop 终止程序")
|
||||||
continue
|
continue
|
||||||
count = 0
|
print("\nChatGLM:", end="")
|
||||||
|
current_length = 0
|
||||||
for response, history, past_key_values in model.stream_chat(tokenizer, query, history=history,
|
for response, history, past_key_values in model.stream_chat(tokenizer, query, history=history,
|
||||||
past_key_values=past_key_values,
|
past_key_values=past_key_values,
|
||||||
return_past_key_values=True):
|
return_past_key_values=True):
|
||||||
@ -47,13 +48,9 @@ def main():
|
|||||||
stop_stream = False
|
stop_stream = False
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
count += 1
|
print(response[current_length:], end="", flush=True)
|
||||||
if count % 8 == 0:
|
current_length = len(response)
|
||||||
os.system(clear_command)
|
print("")
|
||||||
print(build_prompt(history), flush=True)
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
|
||||||
os.system(clear_command)
|
|
||||||
print(build_prompt(history), flush=True)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user