Skip to content

Commit

Permalink
Upload the demo
Browse files Browse the repository at this point in the history
  • Loading branch information
YerongLi committed Jul 11, 2023
1 parent a2ab5a3 commit 9cee0b4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cli_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import argparse
from fastllm_pytools import llm

def args_parser():
parser = argparse.ArgumentParser(description = 'fastllm_chat_demo')
parser.add_argument('-p', '--path', type = str, required = True, default = '', help = '模型文件的路径')
args = parser.parse_args()
return args

if __name__ == "__main__":
args = args_parser()
model = llm.model(args.path)

history = []
print("输入内容即可进行对话,clear 清空对话历史,stop 终止程序")
while True:
query = input("\n用户:")
if query.strip() == "stop":
break
if query.strip() == "clear":
history = []
print("输入内容即可进行对话,clear 清空对话历史,stop 终止程序")
continue
print("AI:", end = "");
curResponse = "";
for response in model.stream_response(query, history = history):
curResponse += response;
print(response, flush = True, end = "")
history.append((query, curResponse))

0 comments on commit 9cee0b4

Please sign in to comment.