3 Star 21 Fork 3

r yon/langchain-ChatGLM pdf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cli_demo.py 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
imClumsyPanda 提交于 2023-04-14 00:06 . update cli_demo.py
from configs.model_config import *
from chains.local_doc_qa import LocalDocQA
# return top-k text chunk from vector store
VECTOR_SEARCH_TOP_K = 10
# LLM input history length
LLM_HISTORY_LEN = 3
# Show reply with source text from input document
REPLY_WITH_SOURCE = True
if __name__ == "__main__":
local_doc_qa = LocalDocQA()
local_doc_qa.init_cfg(llm_model=LLM_MODEL,
embedding_model=EMBEDDING_MODEL,
embedding_device=EMBEDDING_DEVICE,
llm_history_len=LLM_HISTORY_LEN,
top_k=VECTOR_SEARCH_TOP_K)
vs_path = None
while not vs_path:
filepath = input("Input your local knowledge file path 请输入本地知识文件路径:")
vs_path = local_doc_qa.init_knowledge_vector_store(filepath)
history = []
while True:
query = input("Input your question 请输入问题:")
resp, history = local_doc_qa.get_knowledge_based_answer(query=query,
vs_path=vs_path,
chat_history=history)
if REPLY_WITH_SOURCE:
print(resp)
else:
print(resp["result"])
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wjyrjy/langchain-chat-glm-pdf.git
git@gitee.com:wjyrjy/langchain-chat-glm-pdf.git
wjyrjy
langchain-chat-glm-pdf
langchain-ChatGLM pdf
master

搜索帮助