Commit Graph

12 Commits

Author SHA1 Message Date
liunux4odoo 3b3d948d27
添加文件对话模式 (#2071)
开发者:
- 添加 /chat/file_chat, /knowledge_base/upload_temp_docs API 接口
- 添加 CACHED_MEMO_VS_NUM, BASE_TEMP_DIR 配置项
2023-11-16 07:39:27 +08:00
hzg0601 c1440c2609 增加ElasticSearch支持 2023-11-10 16:04:41 +08:00
liunux4odoo 55e417a263 升级注意
数据库表发生变化,需要重建知识库

 新功能
- 增加FileDocModel库表,存储知识文件与向量库Document ID对应关系以及元数据,便于检索向量库
- 增加FileDocModel对应的数据库操作函数(这些函数主要是给KBService调用,用户一般无需使用):
  - list_docs_from_db: 根据知识库名称、文件名称、元数据检索对应的Document IDs
  - delete_docs_from_db: 根据知识库名称、文件名称删除对应的file-doc映射
  - add_docs_to_db: 添加对应的file-doc映射
- KBService增加list_docs方法,可以根据文件名、元数据检索Document。当前仅支持FAISS,待milvus/pg实现get_doc_by_id方法后即自动支持。
- 去除server.utils对torch的依赖

 待完善
- milvus/pg kb_service需要实现get_doc_by_id方法
2023-09-01 22:54:57 +08:00
liunux4odoo 3acbf4d5d1
增加数据库字段,重建知识库使用多线程 (#1280)
* close #1172: 给webui_page/utils添加一些log信息,方便定位错误

* 修复:重建知识库时页面未实时显示进度

* skip model_worker running when using online model api such as chatgpt

* 修改知识库管理相关内容:
1.KnowledgeFileModel增加3个字段:file_mtime(文件修改时间),file_size(文件大小),custom_docs(是否使用自定义docs)。为后面比对上传文件做准备。
2.给所有String字段加上长度,防止mysql建表错误(pr#1177)
3.统一[faiss/milvus/pgvector]_kb_service.add_doc接口,使其支持自定义docs
4.为faiss_kb_service增加一些方法,便于调用
5.为KnowledgeFile增加一些方法,便于获取文件信息,缓存file2text的结果。

* 修复/chat/fastchat无法流式输出的问题

* 新增功能:
1、KnowledgeFileModel增加"docs_count"字段,代表该文件加载到向量库中的Document数量,并在WEBUI中进行展示。
2、重建知识库`python init_database.py --recreate-vs`支持多线程。

其它:
统一代码中知识库相关函数用词:file代表一个文件名称或路径,doc代表langchain加载后的Document。部分与API接口有关或含义重叠的函数暂未修改。

---------

Co-authored-by: liunux4odoo <liunux@qq.com>, hongkong9771
2023-08-28 13:50:35 +08:00
liunux4odoo a47240e871 fix KnowledgeFile: set text_splitter_name in database to SpacyTextSplitter if it is not set 2023-08-16 10:14:47 +08:00
liunux4odoo ec984205ae fix knowledge base management:
1. docs in database were note deleted when clear vector store
2. diable buttons when local doc file not exist.
2023-08-14 19:09:02 +08:00
liunux4odoo 17ddee38a4 fix conflict between def_fastchat and pr1037 2023-08-10 15:02:41 +08:00
zqt d4f728dfa2 添加向量数据库pg支持,和向量库docker-compose.ym环境文件 2023-08-10 11:16:52 +08:00
liunux4odoo 532ed81ecf add functions to get kb and doc details from db 2023-08-08 23:57:39 +08:00
liunux4odoo 135af5f3ff update knowledge base db orm:
1. set default values for file_count, file_version, create_time.
2. fix bug: add_doc_to_db
3. make add_kb_to_db more flexiable with existing kb
2023-08-08 21:47:20 +08:00
liunux4odoo 444e1afad5 remove server/knowledge_base/knowledge_file.py 2023-08-08 16:51:37 +08:00
zqt b61e0772c9 使用orm操作数据库 2023-08-08 14:25:55 +08:00