Commit Graph

52 Commits

Author SHA1 Message Date
wvivi2023 565a94c1bb customize word loader 2024-01-10 10:45:47 +08:00
wvivi2023 9fc4793b79 enahnce 2024-01-05 09:58:29 +08:00
wvivi2023 df348e96a5 add log 2024-01-02 15:22:35 +08:00
liunux4odoo 9ff7bef2c2
新功能:知识库管理界面支持查看、编辑、删除向量库文档 (#2471)
* 新功能:
- 知识库管理界面支持查看、编辑、删除向量库文档。暂不支持增加(aggrid添加新行比较麻烦,需要另外实现)
- 去除知识库管理界面中重建知识库和删除知识库按钮,建议用户到终端命令操作

修复:
- 所有与知识库名称、文件名称有关的数据库操作函数都改成大小写不敏感,所有路径统一为 posix 风格,避免因路径文本不一致导致数据重复和操作失效 (close #2232)

开发者:
- 添加 update_docs_by_id 函数与 API 接口。当前仅支持 FAISS,暂时未用到,未将来对知识库做更细致的修改做准备
- 统一 DocumentWithScore 与 DocumentWithVsId
- FAISS 返回的 Document.metadata 中包含 ID, 方便后续查找比对
- /knowledge_base/search_docs 接口支持 file_name, metadata 参数,可以据此检索文档

* fix bug
2023-12-26 13:44:36 +08:00
liunux4odoo 472a97a616 所有 chat 接口都改为 EventSourceResponse;ApiRequest 作对应修改 2023-12-13 16:53:24 +08:00
liunux4odoo aae4144476
数据库和向量库中文档 metadata["source"] 改为相对路径,便于向量库迁移 (#2153)
修复:
- 上传知识库文件名称包括子目录时,自动创建子目录
2023-11-23 19:54:00 +08:00
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
imClumsyPanda fb32c31a70 reformat kb_doc_api.py 2023-11-06 22:44:50 +08:00
zR 57612d5232
修复一些bug (#1965)
* 修改一些bug

* 更新掉了一部分之前的bug
2023-11-03 18:56:27 +08:00
zR 24d1e28a07
一些细节优化 (#1891)
Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-27 11:52:44 +08:00
zR 69e5da4e7a
北京黑客松更新 (#1785)
* 北京黑客松更新

知识库支持:
支持zilliz数据库
Agent支持:
支持以下工具调用
1. 支持互联网Agent调用
2. 支持知识库Agent调用
3. 支持旅游助手工具(未上传)

知识库更新
1. 支持知识库简介,用于Agent选择
2. UI对应知识库简介

提示词选择
1. UI 和模板支持提示词模板更换选择
2023-10-18 15:19:02 +08:00
liunux4odoo 94977c7ab1
修复:切换embed_model时,FAISS向量库未正确释放,导致`d == self.d assert (#1766)
修复:
- 切换embed_model时,FAISS向量库未正确释放,导致d == self.d assert error (close [求助] 初始化知识库发生错误 #1657 )
- ApiRequest中chat接口增加max_tokens参数
- FileDocModel模型字段错误(字段错误 #1691)
2023-10-16 21:02:07 +08:00
liunux4odoo 818cb1a491 update kb_doc_api: use Form instead of Body when upload file 2023-09-21 09:57:36 +08:00
glide-the bd0164ea62 处理序列化至磁盘的逻辑 2023-09-20 21:35:23 +08:00
liunux4odoo f7c73b842a
优化configs (#1474)
* remove llm_model_dict

* optimize configs

* fix get_model_path

* 更改一些默认参数,添加千帆的默认配置

* Update server_config.py.example
2023-09-15 17:52:22 +08:00
liunux4odoo 16d8809c9a
api和webui知识库操作支持chunk_size/overlap_size/zh_title_enhance参数 (#1459) 2023-09-13 11:19:47 +08:00
liunux4odoo 22ff073309
修改Embeddings和FAISS缓存加载方式,知识库相关API接口支持多线程并发 (#1434)
* 修改Embeddings和FAISS缓存加载方式,支持多线程,支持内存FAISS

* 知识库相关API接口支持多线程并发

* 根据新的API接口调整ApiRequest和测试用例

* 删除webui.py失效的启动说明
2023-09-11 20:41:41 +08:00
glide-the 5550e3c1a9 增加显示详细日志开关 2023-09-08 20:48:31 +08:00
liunux4odoo 775870a516
改变api视图函数的sync/async,提高api并发能力: (#1414)
1. 4个chat类接口改为async
2. 知识库操作,涉及向量库修改的使用async,避免FAISS写入错误;涉及向量库读取的改为sync,提高并发
2023-09-08 12:25:02 +08:00
liunux4odoo 661a0e9d72 新功能:
- 知识库管理中的add_docs/delete_docs/update_docs均支持批量操作,并利用多线程提高效率
- API的重建知识库接口支持多线程
- add_docs可提供参数控制上传文件后是否继续进行向量化
- add_docs/update_docs支持传入自定义docs(以json形式)。后续考虑区分完整或补充式自定义docs
- download_doc接口添加`preview`参数,支持下载或预览
- kb_service增加`save_vector_store`方法,便于保存向量库(仅FAISS,其它无操作)
- 将document_loader & text_splitter逻辑从KnowledgeFile中抽离出来,为后续对内存文件进行向量化做准备
- KowledgeFile支持docs & splitted_docs的缓存,方便在中间过程做一些自定义

其它:
- 将部分错误输出由print改为logger.error
2023-09-08 08:55:12 +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 96f69edf7b
修复重建知识库界面无反应的问题,添加一些log信息 (#1258)
* close #1172: 给webui_page/utils添加一些log信息,方便定位错误

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

---------

Co-authored-by: liunux4odoo <liunu@qq.com>
2023-08-26 18:26:38 +08:00
liunux4odoo c571585ffd optimize recreate vector store: save vector store once after all docs parsed for FAISS 2023-08-21 08:50:15 +08:00
liunux4odoo f40bb69224 优化FAISS向量库多文件操作;修复recreate_vector_store,大量文件时不再超时。 2023-08-20 19:10:29 +08:00
liunux4odoo 69627a2fa3 update chat and knowledge base api: unify exception processing and return types 2023-08-19 15:14:45 +08:00
liunux4odoo 67b8ebef52 update api and webui:
1. 增加search_docs接口,返回原始知识库检索文档,close #1103
2. 为FAISS检索增加score_threshold参数。milvus和PG暂不支持
2023-08-16 13:18:58 +08:00
liunux4odoo cc08e2cb96 update api and webui:
1. add download_doc to api
2. return local path or http url in kowledge_base_chat depends on
   no_remote_api
3. change assistant avater in webui
2023-08-14 11:46:36 +08:00
liunux4odoo 2a57f49d80 update knowledge base management ui.
remove numpy/pandas from requirements, move them to webui requirements
2023-08-11 13:53:20 +08:00
imClumsyPanda 8a4d9168fa update import pkgs and format 2023-08-10 21:26:05 +08:00
imClumsyPanda 1b70fb5f9b update faiss_kb_service.py 2023-08-09 22:57:36 +08:00
liunux4odoo 997f8b2e3f update knowledge base api:
1. list_kbs_from_db return all kbs by default instead of return kbs with
   file_count > 0 only.
2. KBServiceFactory.get_service_by_name could return a FaissKBService
   that not in the db
2023-08-09 21:57:40 +08:00
liunux4odoo 323fc13d4c make parameter examples available in openapi docs 2023-08-09 18:15:14 +08:00
liunux4odoo c7b91bfaf1 update api/kb_doc_api and knowledge base management ui:
1. add update_doc to api which can udpate vector store from existed
   content file
2. add parameter `delete_content` to delete_doc api. user can decide
   whether delete local content file when delete doc.
3. fix bug in ApiReqeust.upload_doc
4. support listing docs existed in local folder bu not in db
2023-08-09 16:52:04 +08:00
liunux4odoo b98f5fd0b9 update knowledge base kbservice and api:
1. make huggingfaceembeddings hashable
2. unify embeddings' loading method for all kbservie
3. make ApiRequest skip empty content when streaming json to avoid dict
   KeyError
2023-08-09 10:46:01 +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 2b0f8caa62 improve recreate_vector_store:
1. allow empty knowledge base
2. skip unspported files instead of exception
2023-08-08 17:59:41 +08:00
liunux4odoo e918244159 move KBServiceFactory to server.knowledge_base.kb_service.base 2023-08-08 17:41:58 +08:00
liunux4odoo c4a3995310 move commonto tools from kbservice.base to server.knowledge_base.utils 2023-08-08 16:40:18 +08:00
liunux4odoo 584e3a9234 remove server/knowledge_base/knowledge_base_factory.py 2023-08-08 16:21:00 +08:00
liunux4odoo 44c713ef98 use KBServiceFactory to replace all the KnowledgeBase.
make KBServiceFactory support embed_model parameter.
rewrite api: recreate_vector_store.
fix some bugs.
2023-08-07 20:37:16 +08:00
imClumsyPanda b91d96ab0c update kb_doc_api.py 2023-08-06 18:32:10 +08:00
imClumsyPanda a447529c2e update kb_doc_api.py 2023-08-05 23:35:20 +08:00
imClumsyPanda 7f89efee4b fix kb_doc_api.py 2023-08-05 23:01:56 +08:00
imClumsyPanda 3f045cedb9 1. add add_doc and list_docs to KnowledgeBase class
2. add DB_ROOT_PATH to model_config.py.example
2023-08-05 22:57:19 +08:00
imClumsyPanda 206261cd0c update class method of KnowledgeBase and KnowledgeFile 2023-08-05 13:46:00 +08:00
imClumsyPanda 590367a5b5 add KnowledgeFile class 2023-08-04 23:54:26 +08:00
imClumsyPanda bc3ee83910 update kb_doc_api.py 2023-08-04 22:22:48 +08:00
liunux4odoo 5d1a0ec15d add recreate_vector_store to kb_doc_api, and the router in api.py. 2023-08-04 20:26:14 +08:00
liunux4odoo 46c7d8d169 allow kb_doc_api.upload_doc to override existed file by parameter.
update_doc is not needed.
2023-08-04 15:53:44 +08:00
imClumsyPanda 7bfbe18011 update requirements.txt and kb_doc_api.py 2023-08-04 15:12:14 +08:00