update cli_demo.py
This commit is contained in:
parent
144d9a8ca3
commit
621a0fe686
|
|
@ -39,7 +39,11 @@ def load_file(filepath, sentence_size=SENTENCE_SIZE):
|
||||||
|
|
||||||
|
|
||||||
def write_check_file(filepath, docs):
|
def write_check_file(filepath, docs):
|
||||||
fout = open('load_file.txt', 'a')
|
folder_path = os.path.join(os.path.dirname(filepath), "tmp_files")
|
||||||
|
if not os.path.exists(folder_path):
|
||||||
|
os.makedirs(folder_path)
|
||||||
|
fp = os.path.join(folder_path, 'load_file.txt')
|
||||||
|
fout = open(fp, 'a')
|
||||||
fout.write("filepath=%s,len=%s" % (filepath, len(docs)))
|
fout.write("filepath=%s,len=%s" % (filepath, len(docs)))
|
||||||
fout.write('\n')
|
fout.write('\n')
|
||||||
for i in docs:
|
for i in docs:
|
||||||
|
|
|
||||||
|
|
@ -31,13 +31,13 @@ if __name__ == "__main__":
|
||||||
chat_history=history,
|
chat_history=history,
|
||||||
streaming=STREAMING):
|
streaming=STREAMING):
|
||||||
if STREAMING:
|
if STREAMING:
|
||||||
logger.info(resp["result"][last_print_len:])
|
print(resp["result"][last_print_len:], end="", flush=True)
|
||||||
last_print_len = len(resp["result"])
|
last_print_len = len(resp["result"])
|
||||||
else:
|
else:
|
||||||
logger.info(resp["result"])
|
print(resp["result"])
|
||||||
if REPLY_WITH_SOURCE:
|
if REPLY_WITH_SOURCE:
|
||||||
source_text = [f"""出处 [{inum + 1}] {os.path.split(doc.metadata['source'])[-1]}:\n\n{doc.page_content}\n\n"""
|
source_text = [f"""出处 [{inum + 1}] {os.path.split(doc.metadata['source'])[-1]}:\n\n{doc.page_content}\n\n"""
|
||||||
# f"""相关度:{doc.metadata['score']}\n\n"""
|
# f"""相关度:{doc.metadata['score']}\n\n"""
|
||||||
for inum, doc in
|
for inum, doc in
|
||||||
enumerate(resp["source_documents"])]
|
enumerate(resp["source_documents"])]
|
||||||
logger.info("\n\n" + "\n\n".join(source_text))
|
print("\n\n" + "\n\n".join(source_text))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue