Commit Graph

134 Commits

Author SHA1 Message Date
zR 38a48bc831
紧急修复 温度 参数代码消失问题 (#1816) 2023-10-21 01:28:34 +08:00
liunux4odoo d316efe8d3
release 0.2.6 (#1815)
## 🛠 新增功能

- 支持百川在线模型 (@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)
2023-10-20 23:16:06 +08:00
zR e88d926bbb
修改部分错误的文档,加长了历史记录(for 32k Models) (#1630)
* 更新上agent提示词代码 (#1626)

* 修改部分错误的文档,加长了历史记录(for 32k Models) (#1629)

* 更新上agent提示词代码

* 按需修改
2023-09-29 20:19:31 +08:00
liunux4odoo ba8d0f8e17
发版:v0.2.5 (#1620)
* 优化configs (#1474)

* remove llm_model_dict

* optimize configs

* fix get_model_path

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

* Update server_config.py.example

* fix merge conflict for #1474 (#1494)

* 修复ChatGPT api_base_url错误;用户可以在model_config在线模型配置中覆盖默认的api_base_url (#1496)

* 优化LLM模型列表获取、切换的逻辑: (#1497)

1、更准确的获取未运行的可用模型
2、优化WEBUI模型列表显示与切换的控制逻辑

* 更新migrate.py和init_database.py,加强知识库迁移工具: (#1498)

1. 添加--update-in-db参数,按照数据库信息,从本地文件更新向量库
2. 添加--increament参数,根据本地文件增量更新向量库
3. 添加--prune-db参数,删除本地文件后,自动清理相关的向量库
4. 添加--prune-folder参数,根据数据库信息,清理无用的本地文件
5. 取消--update-info-only参数。数据库中存储了向量库信息,该操作意义不大
6. 添加--kb-name参数,所有操作支持指定操作的知识库,不指定则为所有本地知识库
7. 添加知识库迁移的测试用例
8. 删除milvus_kb_service的save_vector_store方法

* feat: support volc fangzhou

* 使火山方舟正常工作,添加错误处理和测试用例

* feat: support volc fangzhou (#1501)

* feat: support volc fangzhou

---------

Co-authored-by: liunux4odoo <41217877+liunux4odoo@users.noreply.github.com>
Co-authored-by: liqiankun.1111 <liqiankun.1111@bytedance.com>

* 第一版初步agent实现 (#1503)

* 第一版初步agent实现

* 增加steaming参数

* 修改了weather.py

---------

Co-authored-by: zR <zRzRzRzRzRzRzR>

* 添加configs/prompt_config.py,允许用户自定义prompt模板: (#1504)

1、 默认包含2个模板,分别用于LLM对话,知识库和搜索引擎对话
2、 server/utils.py提供函数get_prompt_template,获取指定的prompt模板内容(支持热加载)
3、 api.py中chat/knowledge_base_chat/search_engine_chat接口支持prompt_name参数

* 增加其它模型的参数适配

* 增加传入矢量名称加载

* 1. 搜索引擎问答支持历史记录;
2. 修复知识库问答历史记录传参错误:用户输入被传入history,问题出在webui中重复获取历史消息,api知识库对话接口并无问题。

* langchain日志开关

* move wrap_done & get_ChatOpenAI from server.chat.utils to server.utils (#1506)

* 修复faiss_pool知识库缓存key错误 (#1507)

* fix ReadMe anchor link (#1500)

* fix : Duplicate variable and function name (#1509)

Co-authored-by: Jim <zhangpengyi@taijihuabao.com>

* Update README.md

* fix #1519: streamlit-chatbox旧版BUG,但新版有兼容问题,先在webui中作处理,并限定chatbox版本 (#1525)

close #1519

* 【功能新增】在线 LLM 模型支持阿里云通义千问 (#1534)

* feat: add qwen-api

* 使Qwen API支持temperature参数;添加测试用例

* 将online-api的sdk列为可选依赖

---------

Co-authored-by: liunux4odoo <liunux@qq.com>

* 处理序列化至磁盘的逻辑

* remove depends on volcengine

* update kb_doc_api: use Form instead of Body when upload file

* 将所有httpx请求改为使用Client,提高效率,方便以后设置代理等。 (#1554)

将所有httpx请求改为使用Client,提高效率,方便以后设置代理等。

将本项目相关服务加入无代理列表,避免fastchat的服务器请求错误。(windows下无效)

* update QR code

* update readme_en,readme,requirements_api,requirements,model_config.py.example:测试baichuan2-7b;更新相关文档

* 新增特性:1.支持vllm推理加速框架;2. 更新支持模型列表

* 更新文件:1. startup,model_config.py.example,serve_config.py.example,FAQ

* 1. debug vllm加速框架完毕;2. 修改requirements,requirements_api对vllm的依赖;3.注释掉serve_config中baichuan-7b的device为cpu的配置

* 1. 更新congif中关于vllm后端相关说明;2. 更新requirements,requirements_api;

* 增加了仅限GPT4的agent功能,陆续补充,中文版readme已写 (#1611)

* Dev (#1613)

* 增加了仅限GPT4的agent功能,陆续补充,中文版readme已写

* issue提到的一个bug

* 温度最小改成0,但是不应该支持负数

* 修改了最小的温度

* fix: set vllm based on platform to avoid error on windows

* fix: langchain warnings for import from root

* 修复webui中重建知识库以及对话界面UI错误 (#1615)

* 修复bug:webui点重建知识库时,如果存在不支持的文件会导致整个接口错误;migrate中没有导入CHUNK_SIZE

* 修复:webui对话界面的expander一直为running状态;简化历史消息获取方法

* 根据官方文档,添加对英文版的bge embedding的指示模板 (#1585)

Co-authored-by: zR <2448370773@qq.com>

* Dev (#1618)

* 增加了仅限GPT4的agent功能,陆续补充,中文版readme已写

* issue提到的一个bug

* 温度最小改成0,但是不应该支持负数

* 修改了最小的温度

* 增加了部分Agent支持和修改了启动文件的部分bug

* 修改了GPU数量配置文件

* 1

1

* 修复配置文件错误

* 更新readme,稳定测试

* 更改readme 0928 (#1619)

* 增加了仅限GPT4的agent功能,陆续补充,中文版readme已写

* issue提到的一个bug

* 温度最小改成0,但是不应该支持负数

* 修改了最小的温度

* 增加了部分Agent支持和修改了启动文件的部分bug

* 修改了GPU数量配置文件

* 1

1

* 修复配置文件错误

* 更新readme,稳定测试

* 更新readme

* fix readme

* 处理序列化至磁盘的逻辑

* update version number to v0.2.5

---------

Co-authored-by: qiankunli <qiankun.li@qq.com>
Co-authored-by: liqiankun.1111 <liqiankun.1111@bytedance.com>
Co-authored-by: zR <2448370773@qq.com>
Co-authored-by: glide-the <2533736852@qq.com>
Co-authored-by: Water Zheng <1499383852@qq.com>
Co-authored-by: Jim Zhang <dividi_z@163.com>
Co-authored-by: Jim <zhangpengyi@taijihuabao.com>
Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
Co-authored-by: Leego <leegodev@hotmail.com>
Co-authored-by: hzg0601 <hzg0601@163.com>
Co-authored-by: WilliamChen-luckbob <58684828+WilliamChen-luckbob@users.noreply.github.com>
2023-09-28 23:30:21 +08:00
liunux4odoo 6c4598b356
fix #1519: streamlit-chatbox旧版BUG,但新版有兼容问题,先在webui中作处理,并限定chatbox版本 (#1525)
close #1519
2023-09-19 10:09:40 +08:00
imClumsyPanda a87a2815da update knowledge_base and dialogue page of webui 2023-09-15 13:45:47 +08:00
imClumsyPanda eb49a91190 update webui_pages/knowledge_base.py 2023-09-15 11:04:23 +08:00
imClumsyPanda f066e427ce update webui_pages/knowledge_base.py 2023-09-15 10:58:52 +08:00
liunux4odoo 30aeec1c45
修改智谱API默认名称,给WEBUI设置主题 (#1484)
* 給WEBUI设置主题

* chatglm-api更名为zhipu-api
2023-09-15 01:48:02 +08:00
liunux4odoo 16d8809c9a
api和webui知识库操作支持chunk_size/overlap_size/zh_title_enhance参数 (#1459) 2023-09-13 11:19:47 +08:00
liunux4odoo 8b040620de
对话接口支持temperature参数 (#1455) 2023-09-13 10:00:54 +08:00
liunux4odoo a03b8d330d
升级到langchain==0.0.287,fschat==0.0.28;处理langchain.Milvus bug(#10492) (#1454)
* 修复milvus_kb_service中一些bug,添加文档后将数据同步到数据库
* 升级到langchain==0.0.287,fschat==0.0.28;处理langchain.Milvus bug(#10492)
* 修复切换模型BUG: 从在线API切换模型时出错
2023-09-13 08:43:11 +08:00
liunux4odoo 6a03611750
fix api and webui: (#1435)
1. fix #1431: 优化知识库问答与搜索引擎问答的API接口,避免docs重复返回
2. startup.py根据configs.log_verbose控制log级别
3. 修复/llm_model/list_models的bug:
   只有一个参数时,fastapi未返回json导致视图函数出错
2023-09-12 08:31:17 +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 f94f2793f8
update startup.py: (#1416)
1. 恢复模型切换功能
2. --model-name支持多个名称(空格分开),同时启动多个模型
3. 优化服务启动顺序。严格按照顺序启动:controller -> [openai-api,
   model_worker, api_worker]并行 -> api.py -> webui.py
4. 修复:从在线API模型切换到本地模型时失败
2023-09-08 15:18:13 +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 1195eb75eb merge pr1413 2023-09-08 10:30:07 +08:00
liunux4odoo 4cfee9c17c 根据新的接口修改ApiRequest和webui,以及测试用例。修改后预期webui中批量知识文件相关操作减少时间 2023-09-08 10:22:04 +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
imClumsyPanda 6702f39db1 update knowledge_base page 2023-09-05 21:01:40 +08:00
imClumsyPanda fdfbf31318 fix streamlit-aggrid showing "For Trial Use Only" 2023-09-05 18:19:13 +08:00
imClumsyPanda 2275b1d84a fix place_holder mistake 2023-09-05 09:53:58 +08:00
liunux4odoo 6cb1bdf623
添加切换模型功能,支持智谱AI在线模型 (#1342)
* 添加LLM模型切换功能,需要在server_config中设置可切换的模型
* add tests for api.py/llm_model/*
* - 支持模型切换
- 支持智普AI线上模型
- startup.py增加参数`--api-worker`,自动运行所有的线上API模型。使用`-a
  (--all-webui), --all-api`时默认开启该选项
* 修复被fastchat覆盖的标准输出
* 对fastchat日志进行更细致的控制,startup.py中增加-q(--quiet)开关,可以减少无用的fastchat日志输出
* 修正chatglm api的对话模板


Co-authored-by: liunux4odoo <liunu@qq.com>
2023-09-01 23:58:09 +08:00
liunux4odoo 34a416b941
优化server_config配置项 (#1293)
* update server_config.py:
- 在model_config中增加HISTORY_LEN配置参数
- 将server_config中helper function移动到server.utils中
- 统一set_httpx_timeout的定义和调用

* update webui.py:
应用model_config中的配置项:HISTORY_LEN,VECTOR_SEARCH_TOP_K,SEARCH_ENGINE_TOP_K

---------

Co-authored-by: liunux4odoo <liunu@qq.com>
2023-08-29 10:06:09 +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 9ca53fa3ad
fix #1224: failed to load json and pdf files (#1252)
Co-authored-by: liunux4odoo <liunu@qq.com>
2023-08-26 14:21:59 +08:00
imClumsyPanda 33ce276e3e change default search_engine option to 'duckduckgo' 2023-08-25 15:18:43 +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 d4cf77170a fix webui: correct error messages 2023-08-18 11:47:49 +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 1551adb867 fix webui: use kb_names as selected_kb's options to avoid index error after delete_doc 2023-08-16 10:04:17 +08:00
liunux4odoo f9d5038e59 fix webui utils: remove unneeded error check 2023-08-16 09:33:55 +08:00
liunux4odoo 7c0e9c46db fix api & webui: 1.add logs, 2. check json response, 3. set timeout=False in recreate_vector_stoore 2023-08-15 14:24:54 +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 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
imClumsyPanda b543f49278 update webui design 2023-08-13 22:25:01 +08:00
imClumsyPanda 77364c046e withdraw conversation management func 2023-08-13 17:53:59 +08:00
imClumsyPanda 1b07648238 fix bug in webui search_engine_chat 2023-08-13 16:20:53 +08:00
liunux4odoo 5df3de8dd0 fix webui: keep chat session sequence when delete session, again 2023-08-13 14:58:14 +08:00
liunux4odoo 9974bf33a0 fix webui: switch to created chat session automatically 2023-08-13 12:59:06 +08:00
imClumsyPanda 353d9fc72b update init_database.py 2023-08-13 10:25:02 +08:00
liunux4odoo b59b34eaf7 fix webui: switch to created chat session automatically 2023-08-12 22:58:13 +08:00
liunux4odoo 1535059d2c fix webui: create and rename chat session 2023-08-12 22:30:21 +08:00
imClumsyPanda 2ad33e010d update webui.py and README.md 2023-08-12 14:08:21 +08:00
imClumsyPanda e65458a506 update requirements.txt 2023-08-12 10:44:04 +08:00
imClumsyPanda 90d385cb92 update webui.dialogue layout 2023-08-12 02:30:50 +08:00
imClumsyPanda 844b15a6f7 update webui.knowledge_base layout 2023-08-12 01:26:17 +08:00
imClumsyPanda afc6aa968d update webui layout 2023-08-11 23:40:41 +08:00
liunux4odoo 2bb9a7949f fix: delete knowledge base error 2023-08-11 23:35:27 +08:00
liunux4odoo 9add46ebbd add recreate vector store to knowledge base mamagement ui 2023-08-11 14:11:34 +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
liunux4odoo a08fe994c2 更新API与ApiReuest:
1. 重新整理webui_pages/utils与server/knowledge_base间的工具依赖
2.
将delete_knowledge_base与delete_doc接口从delete改为post.delete不支持body参数
3. 修复update_doc
4. 修复部分bug
2023-08-11 08:45:26 +08:00
imClumsyPanda 3c44cf65cd update webui layout 2023-08-10 23:51:10 +08:00
liunux4odoo b733a47902 split requirements to 2 parts: basic with api; webui 2023-08-10 15:51:22 +08:00
liunux4odoo 9ed91f0e8a automatically init vector store info to database when run api.py & webui.py 2023-08-10 14:12:02 +08:00
liunux4odoo 7a57f67587 fix: bug when delete chat session 2023-08-10 13:06:30 +08:00
liunux4odoo d89fcb3b2e update knowledge base management page:
1. move get_kb_details & get_doc_details to utils.py
2. adjust aggrid columns width.
2023-08-10 11:37:14 +08:00
liunux4odoo 222689ed5b update kb and search chat: disable streaming in swagger besides streaming in ApiRequest 2023-08-09 23:35:36 +08:00
liunux4odoo 450b23c4f2 update knowledge base management api and ui 2023-08-09 22:00:33 +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 25280e0cea update webui: use history_len as pairs of conversation 2023-08-09 14:11:10 +08:00
liunux4odoo 4da7c04859 fix: parse history parameter to correct type 2023-08-09 12:09:45 +08:00
liunux4odoo 973d3097e7 fix webui_pages/utils.py: support history parameter for chat_chat 2023-08-09 11:00:22 +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 ec76adc81d update knowledge base management ui 2023-08-08 23:58:44 +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 08493bffbb add a basic knowledge base management ui. 2023-08-07 21:00:55 +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
liunux4odoo 3318cef751 update streamlit ui: support latest knowledge base and search engine
chat api; export messages to markdown.
2023-08-04 12:52:58 +08:00
liunux4odoo 27d49be706 make apirequest support streaming dict 2023-08-04 12:49:39 +08:00
imClumsyPanda 329c24ee73 1. change bing_search_chat and duckduckgo_search_chat into search_engine_chat
2. add knowledge_base not found to knowledge_base_chat and add search_engine not found to search_engine_chat
2023-08-03 18:22:36 +08:00
liunux4odoo 5c804aac75 make api and webui support top_k paramter 2023-08-03 15:47:53 +08:00
liunux4odoo df61f31c8e 修改knowledge_base_chat实现:利用缓存避免每次请求重新加载向量库;增加top_k参数。 2023-08-03 15:22:46 +08:00
liunux4odoo e1698ce12e webui中增加多会话功能 2023-08-03 15:06:10 +08:00
liunux4odoo 4651b50176 WEB UI中对话功能已完成。目前很多参数还不支持,待API接口完善后再加入。 2023-08-03 13:41:31 +08:00
liunux4odoo dc74bdab41 将httpx.stream返回结果转化为普通生成器,使得httpx api请求与直接调用server.chat.xx返回相同的结果。 2023-08-03 12:52:49 +08:00
liunux4odoo 3c2b8a85d6 add knowledge base api methods 2023-08-03 10:49:57 +08:00
liunux4odoo d36d801a58 add api request methods for all chat apis 2023-08-03 09:33:24 +08:00
imClumsyPanda 5ce2484af0 update webui.py 2023-08-01 15:08:19 +08:00
imClumsyPanda bcfd3f5af5 add webui_pages 2023-08-01 14:47:38 +08:00