mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 21:37:20 +08:00
## 🛠 新增功能 - 支持百川在线模型 (@hzg0601 @liunux4odoo in #1623) - 支持 Azure OpenAI 与 claude 等 Langchain 自带模型 (@zRzRzRzRzRzRzR in #1808) - Agent 功能大量更新,支持更多的工具、更换提示词、检索知识库 (@zRzRzRzRzRzRzR in #1626 #1666 #1785) - 加长 32k 模型的历史记录 (@zRzRzRzRzRzRzR in #1629 #1630) - *_chat 接口支持 max_tokens 参数 (@liunux4odoo in #1744) - 实现 API 和 WebUI 的前后端分离 (@liunux4odoo in #1772) - 支持 zlilliz 向量库 (@zRzRzRzRzRzRzR in #1785) - 支持 metaphor 搜索引擎 (@liunux4odoo in #1792) - 支持 p-tuning 模型 (@hzg0601 in #1810) - 更新完善文档和 Wiki (@imClumsyPanda @zRzRzRzRzRzRzR @glide-the in #1680 #1811) ## 🐞 问题修复 - 修复 bge-* 模型匹配超过 1 的问题 (@zRzRzRzRzRzRzR in #1652) - 修复系统代理为空的问题 (@glide-the in #1654) - 修复重建知识库时 `d == self.d assert error` (@liunux4odoo in #1766) - 修复对话历史消息错误 (@liunux4odoo in #1801) - 修复 OpenAI 无法调用的 bug (@zRzRzRzRzRzRzR in #1808) - 修复 windows下 BIND_HOST=0.0.0.0 时对话出错的问题 (@hzg0601 in #1810)
95 lines
3.0 KiB
Python
95 lines
3.0 KiB
Python
import sys
|
|
sys.path.append(".")
|
|
from server.knowledge_base.migrate import create_tables, reset_tables, folder2db, prune_db_docs, prune_folder_files
|
|
from configs.model_config import NLTK_DATA_PATH
|
|
import nltk
|
|
nltk.data.path = [NLTK_DATA_PATH] + nltk.data.path
|
|
from datetime import datetime
|
|
import sys
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(description="please specify only one operate method once time.")
|
|
|
|
parser.add_argument(
|
|
"-r",
|
|
"--recreate-vs",
|
|
action="store_true",
|
|
help=('''
|
|
recreate vector store.
|
|
use this option if you have copied document files to the content folder, but vector store has not been populated or DEFAUL_VS_TYPE/EMBEDDING_MODEL changed.
|
|
'''
|
|
)
|
|
)
|
|
parser.add_argument(
|
|
"-u",
|
|
"--update-in-db",
|
|
action="store_true",
|
|
help=('''
|
|
update vector store for files exist in database.
|
|
use this option if you want to recreate vectors for files exist in db and skip files exist in local folder only.
|
|
'''
|
|
)
|
|
)
|
|
parser.add_argument(
|
|
"-i",
|
|
"--increament",
|
|
action="store_true",
|
|
help=('''
|
|
update vector store for files exist in local folder and not exist in database.
|
|
use this option if you want to create vectors increamentally.
|
|
'''
|
|
)
|
|
)
|
|
parser.add_argument(
|
|
"--prune-db",
|
|
action="store_true",
|
|
help=('''
|
|
delete docs in database that not existed in local folder.
|
|
it is used to delete database docs after user deleted some doc files in file browser
|
|
'''
|
|
)
|
|
)
|
|
parser.add_argument(
|
|
"--prune-folder",
|
|
action="store_true",
|
|
help=('''
|
|
delete doc files in local folder that not existed in database.
|
|
is is used to free local disk space by delete unused doc files.
|
|
'''
|
|
)
|
|
)
|
|
parser.add_argument(
|
|
"--kb-name",
|
|
type=str,
|
|
nargs="+",
|
|
default=[],
|
|
help=("specify knowledge base names to operate on. default is all folders exist in KB_ROOT_PATH.")
|
|
)
|
|
|
|
if len(sys.argv) <= 1:
|
|
parser.print_help()
|
|
else:
|
|
args = parser.parse_args()
|
|
start_time = datetime.now()
|
|
|
|
create_tables() # confirm tables exist
|
|
if args.recreate_vs:
|
|
reset_tables()
|
|
print("database talbes reseted")
|
|
print("recreating all vector stores")
|
|
folder2db(kb_names=args.kb_name, mode="recreate_vs")
|
|
elif args.update_in_db:
|
|
folder2db(kb_names=args.kb_name, mode="update_in_db")
|
|
elif args.increament:
|
|
folder2db(kb_names=args.kb_name, mode="increament")
|
|
elif args.prune_db:
|
|
prune_db_docs(args.kb_name)
|
|
elif args.prune_folder:
|
|
prune_folder_files(args.kb_name)
|
|
|
|
end_time = datetime.now()
|
|
print(f"总计用时: {end_time-start_time}")
|