Compare commits

..

1660 Commits

Author SHA1 Message Date
imClumsyPanda
8f4e62ad5b
Update README.md 2024-06-12 16:17:25 +08:00
imClumsyPanda
2123569598
Add files via upload 2024-06-12 16:16:48 +08:00
zR
3ecff4bce7
Merge pull request #3966 from yhfgyyf/glm-4-stream
修复glm-4 无法流式输出的bug
2024-06-08 16:34:58 +08:00
ChillWay
4cd8d0e97c
Update test_different_splitter.py (#3887)
fix path error
2024-05-29 22:11:28 +08:00
Selfuppen
200f9fb481
Update 大模型应用技术原理.md (#3873)
Fixed a spelling error:
juava -> java
2024-05-29 22:10:39 +08:00
imClumsyPanda
1ab62ad339
Update README.md 2024-05-29 17:46:06 +08:00
imClumsyPanda
7cb8b96ed5
Add files via upload 2024-05-29 17:45:45 +08:00
af su
b9827529aa
fix: incorrect variable usage in update_doc_by_ids method (#4048)
Co-authored-by: saf <saf@zjuici.com>
2024-05-20 14:44:02 +08:00
liunux4odoo
8ca9e8ff28
replace Path.is_relative_to to make py38 compatible (#4029) 2024-05-16 11:06:22 +08:00
liunux4odoo
ede538bfe2
update "path traversal bug in api /knowledge_base/download_doc(#4008)… (#4017)
* Revert "path traversal bug in api /knowledge_base/download_doc(#4008) (#4009)"

This reverts commit 2c146aff74bac427f0a4921971d8472097410bdf.

* Update utils.py
2024-05-14 18:48:55 +08:00
liunux4odoo
2c146aff74
path traversal bug in api /knowledge_base/download_doc(#4008) (#4009)
close #4008
2024-05-14 09:46:19 +08:00
imClumsyPanda
703d0f6aa7
Update README.md 2024-05-09 17:19:13 +08:00
imClumsyPanda
8e2515f768
Add files via upload 2024-05-09 17:18:50 +08:00
yhfgyyf
d9323ea3f6 修复glm-4 无法流式输出的bug 2024-05-08 15:05:00 +08:00
zR
24faba561b
Merge pull request #3203 from qqlww1987/master
百川调用示例
2024-05-01 16:49:50 +08:00
zR
cbc28d7296
Merge pull request #3912 from pearjelly/master
修复zhipu-api向量化失败问题
2024-05-01 16:49:24 +08:00
imClumsyPanda
f9beb142c8
Update README.md 2024-04-30 14:57:54 +08:00
imClumsyPanda
781b782f73
Add files via upload 2024-04-30 14:57:37 +08:00
hxb
160f0b8af4
Merge branch 'chatchat-space:master' into master 2024-04-28 16:15:31 +08:00
hxb
26672ffeda feature:长文档循环处理texts时,增加重试极致,降低单片文档失败导致整个文档向量化失败的概率 2024-04-28 16:14:31 +08:00
hxb
0078cdc724 bugfix: 使用向量计算方式METRIC_INNER_PRODUCT时启用normalize_L2会导致向量化失败 2024-04-28 16:12:23 +08:00
An0nymous
9c0820c94a
更新火山方舟调用 (#3564)
* 更新火山方舟调用
2024-04-25 14:33:28 +08:00
imClumsyPanda
cf049511cf
Update README.md 2024-04-25 13:56:39 +08:00
imClumsyPanda
c52e89d92a
Add files via upload 2024-04-25 13:56:17 +08:00
做梦好啊
2c7feae7bb
Update README.md (#3804) 2024-04-18 20:51:40 +08:00
imClumsyPanda
52f2a2a046
Update requirements.txt 2024-04-18 11:36:48 +08:00
yuehua-s
9bf0612e3d
Feat/action update readme (#3779) 2024-04-17 09:59:54 +08:00
yuehua-s
7da7636abc
feat:support action update Readme (#3773) 2024-04-16 23:19:56 +08:00
imClumsyPanda
326a9652aa
Update README.md 2024-04-16 14:23:02 +08:00
imClumsyPanda
b6e1f208e9
Add files via upload 2024-04-16 14:22:41 +08:00
yuehua-s
4815a6c92e
fix:fix model_config claude-api (#3760)
Co-authored-by: yuehuazhang <yuehuazhang@tencent.com>
2024-04-16 09:56:11 +08:00
Art Jiang
448e79576c
Adding Claude 3 API support (#3340)
---------

Co-authored-by: Jiang, Fengyi <art.jiang@gatech.edu>
2024-04-16 08:32:48 +08:00
liunux4odoo
3902f6d235
Merge pull request #3574 from dengpeng777/master
support zhipu-api embedding
2024-04-16 07:10:24 +08:00
yuehua-s
72a6878287
Feat/update actions (#3758) 2024-04-16 06:35:20 +08:00
yuehua-s
5eb37ea2e3
Feat/git action (#3745) 2024-04-15 23:29:30 +08:00
saliven1970
f29ab1e67f
修复获取reranker_model_path出错的问题 (#3458) 2024-04-15 21:53:06 +08:00
Qinyu Luo
341ee9db44
Generate repository-level Chinese code documentation by RepoAgent. (#3108) 2024-04-15 21:51:13 +08:00
你的代码TT
2f2221ca47
Add document normalization in Chroma. (#3640) 2024-04-15 21:37:32 +08:00
allseeeeeee
6d128f24f0
fix: 以lite模式启动时仅加载了在线嵌入模型,未加载配置的默认嵌入模型,导致创建知识库时报错 'bge-large-zh-v1.5' is not in list. (#3670)
修复方式: 如果lite模式启动, 配置的默认嵌入模型也添加到列表

Co-authored-by: LuoJingtian <luojingtian@siiture.com>
2024-04-15 21:29:40 +08:00
imClumsyPanda
8721aad18d
Update README.md 2024-04-11 15:16:07 +08:00
imClumsyPanda
13377191e7
Add files via upload 2024-04-11 15:15:43 +08:00
yuehua-s
110b5694da
Feat/docker v0.2.10 (#3664)
* feat:update docker image to v0.2.10.

* feat:update docker image to v0.2.10.

---------

Co-authored-by: yuehuazhang <yuehuazhang@tencent.com>
2024-04-08 10:29:16 +08:00
jinke
da1c1a225c add docker registries 2024-04-08 01:15:10 +08:00
jinke
5eb025d9dc update docker aliyun mirror to 0.2.10
update docker aliyun mirror to 0.2.10
2024-04-08 00:30:40 +08:00
imClumsyPanda
6003d8dd83
Update README.md 2024-04-07 13:07:26 +08:00
imClumsyPanda
b0f5fb2d3e
Add files via upload 2024-04-07 13:07:00 +08:00
imClumsyPanda
6dd066ca72
Update README.md 2024-04-02 15:50:11 +08:00
imClumsyPanda
c0dafb95cc
Add files via upload 2024-04-02 15:49:55 +08:00
RoceoRobin
487235259e
Update README.md (#3585)
错别字
2024-04-01 13:17:02 +08:00
dengpeng777
a592b1cd3f
fix add default embed model 2024-03-30 10:00:55 +08:00
dengpeng777
6011bac07f
support zhipu-api embedding 2024-03-30 09:58:18 +08:00
imClumsyPanda
ae9f4d208e
Add files via upload 2024-03-29 21:53:01 +08:00
imClumsyPanda
78290d360f
Update README.md 2024-03-29 21:44:54 +08:00
imClumsyPanda
966c582a2a
Update README.md 2024-03-26 12:48:14 +08:00
imClumsyPanda
bfb76faadb
Add files via upload 2024-03-26 12:46:59 +08:00
imClumsyPanda
40263dd403
Update README.md 2024-03-22 14:38:30 +08:00
imClumsyPanda
825e4976ae
Add files via upload 2024-03-22 14:37:40 +08:00
iimm
253d4b9b9a
修复使用pgvector时get_doc_by_ids方法报错的bug及知识库文件删除后向量仍然存在的bug (#3407)
* 修复使用pgvector无法查询到document

* 修复使用pg/es向量库无法知识库删除文档后向量库并未删除对应记录的bug
2024-03-20 08:41:41 +08:00
BlizBearer
07b7c966ed
Dev fix csv loader (#3404)
* fix: csv loader only load one column

* csv data merge with col name
2024-03-20 08:40:22 +08:00
imClumsyPanda
d78b14721c
Update README.md 2024-03-19 13:04:40 +08:00
imClumsyPanda
5ad4d520dd
Add files via upload 2024-03-19 13:04:18 +08:00
imClumsyPanda
d879e86cab
Update README.md 2024-03-12 09:21:42 +08:00
imClumsyPanda
cd54eeb137
Add files via upload 2024-03-12 09:21:13 +08:00
imClumsyPanda
021d635af0
Update README.md 2024-03-06 20:20:51 +08:00
imClumsyPanda
f40d415f07
Add files via upload 2024-03-06 20:20:30 +08:00
qqlww1987
7198654611 Merge branch 'master' of https://github.com/qqlww1987/Langchain-Chatchat 2024-03-06 15:30:57 +08:00
qqlww1987
818f87b5e4 更新百川API示例
百川大模型API调用示例修改
2024-03-06 14:59:16 +08:00
qqlww1987
c6d91c3e3d
百川API示例处理
百川API调用示例
2024-03-06 14:14:06 +08:00
qqlww1987
5c74a28de9
Merge branch 'chatchat-space:master' into master 2024-03-06 14:11:57 +08:00
hollowdjj
e48f4a24c9
修复使用Milvus数据库时上传知识库文件报错的问题 (#3155)
milvus 返回的 Document.metadata 携带了 vector 信息,导致 API 接口序列化失败。

---------

Co-authored-by: liunux4odoo <41217877+liunux4odoo@users.noreply.github.com>
2024-03-06 08:46:46 +08:00
qqlww1987
279fe9c659
Merge pull request #1 from chatchat-space/master
百川API调用事例调整
2024-03-03 20:15:53 +08:00
imClumsyPanda
bab93690fc
Update README.md 2024-03-02 14:50:17 +08:00
imClumsyPanda
54bed50713
Add files via upload 2024-03-02 14:49:45 +08:00
imClumsyPanda
caf502d141
Update README.md 2024-02-28 09:57:20 +08:00
imClumsyPanda
76e82a9b8f
Add files via upload 2024-02-28 09:56:58 +08:00
imClumsyPanda
574ea4f4d5
Update README.md 2024-02-24 23:49:34 +08:00
imClumsyPanda
cf1c853b19
Add files via upload 2024-02-24 23:49:09 +08:00
imClumsyPanda
fb8fbe96e4
Update README.md 2024-02-21 11:51:52 +08:00
imClumsyPanda
7c89f88513
Add files via upload 2024-02-21 11:51:24 +08:00
imClumsyPanda
1fa714ee71
Update README.md 2024-02-19 14:56:49 +08:00
imClumsyPanda
b2fabe211b
Update README.md 2024-02-19 12:10:44 +08:00
imClumsyPanda
d5edb08b24
Add files via upload 2024-02-19 12:10:24 +08:00
ai松柏君
051c599bb5
requirements_webui.txt (#2960) 2024-02-07 10:21:42 +08:00
zR
cd13aee97d
Merge pull request #2958 from chatchat-space/dev
更新readme
2024-02-07 00:28:04 +08:00
zR
8146279bbe
Merge pull request #2957 from zRzRzRzRzRzRzR/dev
更新readme
2024-02-07 00:27:30 +08:00
zR
c49c6923a1 更新readme 2024-02-07 00:26:58 +08:00
zR
041e964b30
Merge pull request #2949 from criwits/dev
增加对 `.htm` 扩展名的显式支持,以解决 `.htm` 格式网页可被上传但不被入库的问题
2024-02-07 00:22:53 +08:00
imClumsyPanda
f75ae3ea5f
Update README.md 2024-02-06 19:51:54 +08:00
imClumsyPanda
0522a42ab7
Add files via upload 2024-02-06 19:51:33 +08:00
Hans WAN
5460b93ba2
增加对 .htm 扩展名的显式支持 2024-02-06 16:28:41 +08:00
zR
ab650253d1
Merge pull request #2946 from chatchat-space/dev
Dev
2024-02-06 13:52:55 +08:00
zR
670131c886
Merge pull request #2945 from zRzRzRzRzRzRzR/dev
更新zhipuai请求方式
2024-02-06 13:51:43 +08:00
zR
2756996125 更新zhipuai请求方式 2024-02-06 13:50:57 +08:00
zR
f04a2bfcc7
Merge pull request #2919 from fengyaojieTTT/bugfix/es-document-query
修复es 知识库查询bug (#2848)
2024-02-06 12:25:56 +08:00
fengyaojie
9c5aa5bf2f 修复es 知识库查询bug (#2848) 2024-02-05 16:28:23 +08:00
fengyaojie
36956520ea 修复es 知识库查询bug (#2848) 2024-02-03 18:01:54 +08:00
imClumsyPanda
4f67f4a841
Update README.md 2024-02-01 10:00:14 +08:00
imClumsyPanda
e042a76f11
Add files via upload 2024-02-01 09:59:44 +08:00
zR
13628c5f9a
Merge pull request #2871 from chatchat-space/master
merege
2024-01-30 21:39:30 +08:00
zR
5afbae56fc
Merge pull request #2870 from chatchat-space/dev
更新星火大模型
2024-01-30 21:38:49 +08:00
zR
2504ea3393
Merge pull request #2869 from zRzRzRzRzRzRzR/dev
支持星火3.5模型
2024-01-30 21:37:55 +08:00
zR
07906751c1 支持星火3.5模型 2024-01-30 21:37:29 +08:00
zqt996
b7a249f46a
Merge pull request #2868 from zqt996/master
修复milvus相关bug
2024-01-30 21:33:18 +08:00
zqt
cbfbbe5e6b 修复milvus相关bug 2024-01-30 21:28:42 +08:00
imClumsyPanda
845adfbc0b
Update README.md 2024-01-30 16:51:03 +08:00
imClumsyPanda
53ff5040e2
Update README.md 2024-01-30 16:50:35 +08:00
imClumsyPanda
77914386b0
Update README.md 2024-01-30 16:50:07 +08:00
zR
03edc3e501
Merge pull request #2858 from chatchat-space/dev
修复部分0.2.10的问题
2024-01-30 14:28:55 +08:00
zR
3f70a0d18c
Merge pull request #2857 from zRzRzRzRzRzRzR/dev
autodl代号错误修复
2024-01-30 14:28:05 +08:00
zR
b0708c7a8d
Merge branch 'chatchat-space:dev' into dev 2024-01-30 14:27:36 +08:00
zR
887cf95db7 autodl代号错误 2024-01-30 14:27:09 +08:00
zR
b39b585867
Merge pull request #2856 from zRzRzRzRzRzRzR/dev
更新掉部分错误的依赖
2024-01-30 14:19:14 +08:00
zR
042a70c09a 更新了chromadb的打印的符号 2024-01-30 14:18:14 +08:00
zR
ffbfcd41f2 API前端丢失问题解决 2024-01-30 13:43:16 +08:00
zR
22ee1a0c97
Merge pull request #2816 from songpb/master
修复PDF旋转的BUG (Issues #2792)
2024-01-30 13:01:24 +08:00
songpb
4157201c2c
Merge branch 'dev' into master 2024-01-30 12:42:28 +08:00
zR
6eab501baf
Merge pull request #2843 from zRzRzRzRzRzRzR/dev
更新文件
2024-01-29 21:18:06 +08:00
zR
268bb68122 更新文件 2024-01-29 21:17:10 +08:00
zR
4f5824e964
Merge pull request #2820 from showmecodett/feat-chromadb
支持Chroma向量数据库
2024-01-29 20:59:15 +08:00
tonysong
25f5f103c1 忽略测试代码 2024-01-29 10:03:28 +08:00
showmecodett
0c465faf8b perf delete unused import 2024-01-29 06:09:59 +08:00
showmecodett
c94938bc83 Support Chroma 2024-01-29 05:52:52 +08:00
songpb
147b4c0688
Merge branch 'master' into master 2024-01-28 16:28:28 +08:00
tonysong
e1e8b0f056 修复PDF旋转的BUG 2024-01-28 16:22:57 +08:00
imClumsyPanda
38bc4050ac
Update README.md 2024-01-26 21:11:54 +08:00
imClumsyPanda
ae31e6dd8b
Add files via upload 2024-01-26 21:11:31 +08:00
glide-the
e1f125be4e
Merge pull request #2809 from chatchat-space/glide-the-patch-1
Update README.md
2024-01-26 19:50:15 +08:00
glide-the
597ca146d0
Update README.md 2024-01-26 19:50:06 +08:00
liunux4odoo
9c525b7fa5
publish 0.2.10 (#2797)
新功能:
- 优化 PDF 文件的 OCR,过滤无意义的小图片 by @liunux4odoo #2525
- 支持 Gemini 在线模型 by @yhfgyyf #2630
- 支持 GLM4 在线模型 by @zRzRzRzRzRzRzR
- elasticsearch更新https连接 by @xldistance #2390
- 增强对PPT、DOC知识库文件的OCR识别 by @596192804 #2013
- 更新 Agent 对话功能 by @zRzRzRzRzRzRzR
- 每次创建对象时从连接池获取连接,避免每次执行方法时都新建连接 by @Lijia0 #2480
- 实现 ChatOpenAI 判断token有没有超过模型的context上下文长度 by @glide-the
- 更新运行数据库报错和项目里程碑 by @zRzRzRzRzRzRzR #2659
- 更新配置文件/文档/依赖 by @imClumsyPanda @zRzRzRzRzRzRzR
- 添加日文版 readme by @eltociear #2787

修复:
- langchain 更新后,PGVector 向量库连接错误 by @HALIndex #2591
- Minimax's model worker 错误 by @xyhshen 
- ES库无法向量检索.添加mappings创建向量索引 by MSZheng20 #2688
2024-01-26 06:58:49 +08:00
liunux4odoo
a5e758bf82 fix: set default score_threshold to 1; add weather api key to kb_config 2024-01-25 22:50:22 +08:00
Ikko Eltociear Ashimine
370dbfef37 Add README_ja.md (#2787) 2024-01-25 22:50:21 +08:00
imClumsyPanda
1c3b928223 Update README.md 2024-01-25 22:50:16 +08:00
imClumsyPanda
454d82b2e4 Add files via upload 2024-01-25 22:49:16 +08:00
Ikko Eltociear Ashimine
ee6a28b565
Add README_ja.md (#2787) 2024-01-25 22:17:07 +08:00
zR
f50400a204
Merge pull request #2782 from zRzRzRzRzRzRzR/dev
Dev
2024-01-24 17:04:10 +08:00
zR
852ca5f849 更新两行注释 2024-01-24 15:57:04 +08:00
zR
f9a5ae99ee 更新了部分依赖 2024-01-24 15:28:34 +08:00
liunux4odoo
7248163b07 调整依赖;优化webui模型列表;更新wiki版本 2024-01-23 13:11:15 +08:00
imClumsyPanda
60d5f7d439 update req 2024-01-22 23:29:06 +08:00
zR
088a27df27
Merge pull request #2759 from zRzRzRzRzRzRzR/dev
更新依赖错误
2024-01-22 20:47:10 +08:00
zR
481d1c4b3a
Merge branch 'chatchat-space:dev' into dev 2024-01-22 20:46:47 +08:00
zR
6df6ed2920 修复错误依赖 2024-01-22 20:46:34 +08:00
zR
57c73b1424 更新错误的依赖 2024-01-22 20:46:04 +08:00
imClumsyPanda
c9c867664e
Update README.md 2024-01-22 15:09:34 +08:00
imClumsyPanda
65a2ccdc64
Add files via upload 2024-01-22 15:09:13 +08:00
zR
31631e56ca
Merge pull request #2753 from zRzRzRzRzRzRzR/dev
细节更新和补充
2024-01-22 13:43:56 +08:00
zR
56d32a9908 删除掉一些没用的注释,已经不需要todo了 2024-01-22 13:42:52 +08:00
zR
1adff316e5 更新了最新的整理好的依赖 2024-01-22 13:37:48 +08:00
zR
c50e988f5a readme更新 2024-01-22 13:24:11 +08:00
zR
85771825ba 更新readme 2024-01-22 13:18:46 +08:00
zR
54e5b41647
Merge pull request #2752 from zRzRzRzRzRzRzR/dev
gemini API 修复
2024-01-22 13:15:06 +08:00
zR
17803cb7c1 gemini api 修复调用 2024-01-22 13:14:13 +08:00
zR
64378837ef
Merge pull request #2751 from zRzRzRzRzRzRzR/dev
恢复 删除知识库选项
2024-01-22 12:47:05 +08:00
zR
b6d2bc71ce 恢复 删除知识库选项 2024-01-22 12:46:15 +08:00
zR
fb6c84bc57
Merge pull request #2749 from zRzRzRzRzRzRzR/dev
配置文件修改
2024-01-22 12:17:07 +08:00
zR
80c26e4a24 Merge branch 'dev' of https://github.com/zRzRzRzRzRzRzR/Langchain-Chatchat into dev 2024-01-22 12:16:13 +08:00
zR
eeba2e2665 配置文件修改 2024-01-22 12:15:47 +08:00
zR
c0968fb581
Merge pull request #2746 from zRzRzRzRzRzRzR/dev
支持GLM4
2024-01-22 11:48:43 +08:00
zR
8483c0bc96 Merge branch 'dev' of https://github.com/zRzRzRzRzRzRzR/Langchain-Chatchat into dev 2024-01-22 11:48:16 +08:00
zR
6b61d917a1 支持GLM4 2024-01-22 11:48:13 +08:00
zR
8ac255fc55
Merge branch 'chatchat-space:dev' into dev 2024-01-22 11:46:46 +08:00
zR
56c2a70a74
Merge pull request #2740 from showmecodett/perf-typing
perf typing
2024-01-22 10:46:46 +08:00
showmecodett
71deed93df perf typing 2024-01-21 21:00:12 +08:00
showmecodett
3057c29e47 perf typing 2024-01-21 20:56:26 +08:00
zR
554d6b4820 依赖文件删除,智谱AI 0.2.x 不兼容 2024-01-21 11:50:30 +08:00
zR
e5b4bb41d8 更新GLM 临时解决方案,支持GLM4,版本不兼容,会有bug 2024-01-21 11:48:44 +08:00
zR
0cf65d5933 更新模型配置文件和支持列表 2024-01-20 22:40:31 +08:00
zR
8c2019f8b9 pr 2775 maybe need? 2024-01-20 22:20:02 +08:00
zR
4a77880ee1 Merge branch 'dev' of https://github.com/zRzRzRzRzRzRzR/Langchain-Chatchat into dev 2024-01-20 22:18:25 +08:00
zR
dc07cba1d4 更新依赖 2024-01-20 22:18:22 +08:00
zR
b058e1906f
Merge pull request #2704 from MSZheng20/dev
1、ES库index_name获取兼容windows和linux系统 2、补充mappings,创建向量索引结构保持一致 3、添加ES测试方法
2024-01-18 13:11:56 +08:00
zhengmingsheng
2ab944996e fix:1、index_name获取兼容windows和linux系统 2、补充mappings,创建向量索引结构保持一致 3、添加ES向量库的测试方法 2024-01-18 11:25:27 +08:00
zR
e5acf3d2e6
Merge pull request #2688 from MSZheng20/dev
fix:修复ES库无法向量检索.添加mappings创建向量索引
2024-01-17 13:22:13 +08:00
zR
1b5efecc89
Merge pull request #2681 from Lijia0/adapter_pgvector
修复bug-langchain新版本PGVector传入connection,插入、删除操作会回滚
2024-01-17 13:22:01 +08:00
zhengmingsheng
b2ea386f60 fix:修复ES库无法使用向量检索.添加mappings创建向量索引 2024-01-17 11:24:13 +08:00
imClumsyPanda
d83de508cc
Update README.md 2024-01-17 10:27:18 +08:00
imClumsyPanda
0a4dfe58a4
Add files via upload 2024-01-17 10:26:58 +08:00
lijia
2c92cd00ae langchain新版本PGVector传入connection,插入、删除操作会回滚 2024-01-16 16:58:19 +08:00
lijia
67ae61d567 langchain新版本PGVector传入connection,插入、删除操作会回滚 2024-01-16 16:38:06 +08:00
zR
cb3822651b
Merge pull request #2659 from zRzRzRzRzRzRzR/dev
更新运行数据库报错和项目里程碑
2024-01-14 10:47:40 +08:00
zR
241690d593 更新运行数据库报错和项目里程碑 2024-01-14 10:46:41 +08:00
zR
f28cd59557
Merge pull request #2648 from xyhshen/patch-1
Fix two bugs in Minimax's model worker that affect usage
2024-01-13 16:37:05 +08:00
glide-the
991e824bcd
Merge pull request #2649 from glide-the/dev
ChatOpenAI为了判断token有没有超过模型的context上下文长度,
2024-01-13 16:12:43 +08:00
glide-the
f031ebc19e ChatOpenAI为了判断token有没有超过模型的context上下文长度,每个模型的token算法不一样 ,所以这里应该自己实现token长度计算
第一次初始化的时候,openai的类会强制使用3.5,
2024-01-13 16:11:30 +08:00
xieyh
ebda1056e5
Fix two bugs in Minimax's model worker that affect usage, namely do_ Embeddings should return result for multiple documents, and the other option is validate_ Messages, 'role': 'user' should be the uppercase letter 'USER' 2024-01-13 15:44:26 +08:00
zR
0a37fe93b8
Merge pull request #2647 from zRzRzRzRzRzRzR/dev
更新即将废弃的启动内容
2024-01-13 13:00:58 +08:00
zR
6df4554c8b 更新即将废弃的启动内容 2024-01-13 13:00:01 +08:00
Zhi-guo Huang
3e959e5b0f
Merge pull request #2640 from chatchat-space/hzg0601-patch-1
Update milvus_kb_service.py
2024-01-12 16:58:44 +08:00
Zhi-guo Huang
e55f8cf7a9
Update milvus_kb_service.py
修复typo
2024-01-12 16:58:32 +08:00
zR
c5985ae5be
Merge pull request #2638 from zRzRzRzRzRzRzR/dev
0.2.10 Agent更新
2024-01-12 12:50:12 +08:00
zR
3333007e13
Merge branch 'chatchat-space:dev' into dev 2024-01-12 12:45:37 +08:00
Lijia0
ff91508d8b
每次创建对象时从连接池获取连接,避免每次执行方法时都新建连接 (#2480) 2024-01-12 12:34:40 +08:00
zR
4ac510ff4a 版本更新 2024-01-12 12:02:34 +08:00
zR
269090ea66 更新0.2.x Agent,之后的Agent在0.3.x更新 2024-01-12 12:01:22 +08:00
Creation
75ff268e88
【功能新增】增强对PPT、DOC知识库文件的OCR识别 (#2013)
* 【功能新增】增强对PPT、DOC文件的OCR识别

* 【功能新增】增强对PPT、DOC文件的OCR识别

* Update mydocloader.py

---------

Co-authored-by: zR <2448370773@qq.com>
2024-01-12 11:04:50 +08:00
zR
e615932e7e Merge branch 'master' into dev 2024-01-12 10:27:15 +08:00
xldistance
a5b52e1bd1
elasticsearch更新https连接 (#2390) 2024-01-12 10:17:28 +08:00
HALIndex
29ef5dda64
Update pgvector connection method following updates in langchain_community, to resolve the 'PGVector' object has no attribute 'connect' error. (#2591) 2024-01-12 10:17:04 +08:00
yhfgyyf
03eb5e9d2e
Gemini api (#2630)
* Gemini-pro api

* Update gemini.py

* Update gemini.py
2024-01-12 10:16:31 +08:00
zR
4f07384c66
0.2.x稳定依赖更新 (#2627)
0.2.x不会支持langchain 0.1.x以上的内容
2024-01-11 19:58:25 +08:00
天地
3da68b5ce3
删除重复的引入和纠正拼写错误 (#2599)
* 1.删除重复的引入
2.拼写错误

* 1.参数或者文档拼写错误纠正
2.doc下的faq、install已经删除,更新为ES部署指南,考虑到doc下的文档经常更新,即使扫描doc文件夹,也可能为空的情况,readme.md大概率不会删除。
2024-01-11 18:45:09 +08:00
chatgpt-bot
b653c25fbc
Fix device detection and fallback logic and add 'xpu' (#2570)
Co-authored-by: zR <2448370773@qq.com>
2024-01-11 18:36:38 +08:00
高厉害
e7bba6bd0a
fix: automatically replace unsupported torch device (#2514) 2024-01-11 18:16:31 +08:00
imClumsyPanda
b5064813af
Update README.md 2024-01-11 15:06:59 +08:00
imClumsyPanda
01bac077bc
Add files via upload 2024-01-11 15:06:35 +08:00
liunux4odoo
448c99f969
fix: 过滤 sse_starlette 返回的 ping 包,避免 JSON Decoder error : ping -... (#2585) 2024-01-09 09:14:29 +08:00
imClumsyPanda
6f85119f03
Update README.md 2024-01-07 21:59:06 +08:00
imClumsyPanda
440307fa94
Add files via upload 2024-01-07 21:58:35 +08:00
liunux4odoo
17e8bc072b
fix: make_text_splitter use wrong chunk_* parameters when exception. (close #2561) (#2564) 2024-01-05 15:06:59 +08:00
liunux4odoo
67034669a9 Merge branch 'panda-master' into panda-dev 2024-01-05 15:05:38 +08:00
Zhi-guo Huang
3d66899b0f
Merge pull request #2540 from chatchat-space/hzg0601-patch-1
修复milvus_kwargs问题
2024-01-03 17:14:48 +08:00
Zhi-guo Huang
ce29d14f46
修复milvus_kwargs问题 2024-01-03 17:14:38 +08:00
imClumsyPanda
50aeb24582
Update README.md 2024-01-03 15:30:24 +08:00
imClumsyPanda
fc75c4513a
Add files via upload 2024-01-03 15:30:02 +08:00
liunux4odoo
aeb7a7e93f
增加 PDF_OCR_THRESHOLD 配置项,只对宽高超过页面一定比例(图片宽/页面宽,图片高/页面高)的图片进行 OCR。 (#2525)
这样可以避免 PDF 中一些小图片的干扰,提高非扫描版 PDF 处理速度
2024-01-02 16:28:36 +08:00
liunux4odoo
61bc815540
fix: Chinese comma in requirements (#2523) 2024-01-02 11:26:03 +08:00
liunux4odoo
7d4a6b5edf
fix: ApiRequest.agent_chat 应当返回 dict 而非 str (#2520) 2024-01-02 09:54:23 +08:00
imClumsyPanda
3c33ca7b89 Release v0.2.9 2023-12-31 20:15:35 +08:00
imClumsyPanda
f1ae95c8ca fix typos 2023-12-31 20:14:01 +08:00
imClumsyPanda
719e2713ed fix typos 2023-12-31 20:13:14 +08:00
imClumsyPanda
349de9b955 Merge branch 'master' into dev 2023-12-31 19:25:01 +08:00
imClumsyPanda
e6c376fba0 update pics 2023-12-31 19:24:42 +08:00
liunux4odoo
c179230ce0
remove /chat/fastchat API endpoint (#2506) 2023-12-29 09:44:37 +08:00
liunux4odoo
3b28f40c6a update requirements: 统一各文件依赖顺序,便于比对;移出streamlit-antd-components; jq默认安装; numexpr 限定 2.8.6 以兼容 py38 2023-12-29 09:35:02 +08:00
liunux4odoo
5cccd5e7aa merge from master 2023-12-29 09:10:01 +08:00
imClumsyPanda
af38f75b29
Update README.md 2023-12-28 15:50:30 +08:00
imClumsyPanda
a8f94dd595
Add files via upload 2023-12-28 15:49:59 +08:00
liunux4odoo
1f3a32ebaf
fix Yi-34b model config error(close #2491) (#2492) 2023-12-28 07:57:25 +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
zR
2e1442a5c1 修复 Langchain 更新之后OpenAI在线embed无法正常使用问题 2023-12-23 11:36:11 +08:00
liunux4odoo
4e5bc8b399 修复: zhipu-api 请求出错时返回准确的错误信息 2023-12-22 10:17:00 +08:00
imClumsyPanda
4e69033d33
Update README.md 2023-12-21 22:19:41 +08:00
imClumsyPanda
778d2d906a
Add files via upload 2023-12-21 22:19:12 +08:00
Zhi-guo Huang
d77f778e0d
Merge pull request #2435 from chatchat-space/reranker
新增特性:使用Reranker模型对召回语句进行重排
2023-12-21 19:06:59 +08:00
hzg0601
129c765a74 新增特性:reranker对向量召回文本进行重排 2023-12-21 19:05:11 +08:00
hzg0601
5891f94c88 temporarily add reranker 2023-12-21 16:05:16 +08:00
Zhi-guo Huang
60510ff2f0
Update model_config.py.example 2023-12-20 13:33:00 +08:00
Funkeke
c1a32d9f1a
fix:使用在线embedding模型时 报错 There is no current event loop in thread 'Any… (#2393)
* fix:使用在线embedding模型时 报错 There is no current event loop in thread 'AnyIO worker thread'

* 动态配置在线embbding模型

---------

Co-authored-by: fangkeke <3339698829@qq.com>
2023-12-20 08:40:53 +08:00
liunux4odoo
fdea406101 update requirements: 统一各文件依赖顺序,便于比对;移出streamlit-antd-components; jq默认安装 2023-12-19 15:59:41 +08:00
imClumsyPanda
bba4754994
Update README.md 2023-12-18 15:21:27 +08:00
imClumsyPanda
9fdeb475e9
Add files via upload 2023-12-18 15:20:58 +08:00
huangzhiguo
a870076051 在model_config.py.example中增加qwen量化模型启动的说明 2023-12-15 14:23:34 +08:00
Astlvk
7e01e82470
fixed 迭代器参数传递错误,知识库问答报错TypeError: unhashable type: 'list' (#2383)
Co-authored-by: liunux4odoo <41217877+liunux4odoo@users.noreply.github.com>
2023-12-15 07:54:36 +08:00
xldistance
7e8391eb55
修复knowledge_base_chat_iterator传参错误 (#2386) 2023-12-15 07:53:36 +08:00
xldistance
332e1ccfaa
更新self.dims_length赋值错误 (#2380) 2023-12-14 19:56:39 +08:00
jaluik
e7410e40df
fix: 文档错误 (#2384) 2023-12-14 16:32:05 +08:00
imClumsyPanda
1cbad32b6e
Update README.md 2023-12-13 18:56:43 +08:00
imClumsyPanda
f45d6ab49c
Add files via upload 2023-12-13 18:56:20 +08:00
lookou
9c5b81cb2b
优化EventSource回包 (#1200)
通过 sse_startllete 支持 JS 前端 SSE 协议 (Close #2333) 

Co-authored-by: liunux4odoo <41217877+liunux4odoo@users.noreply.github.com>
2023-12-13 17:02:27 +08:00
liunux4odoo
472a97a616 所有 chat 接口都改为 EventSourceResponse;ApiRequest 作对应修改 2023-12-13 16:53:24 +08:00
liunux4odoo
c8fef3380c merge from dev 2023-12-13 16:52:40 +08:00
hzg0601
db008c1af8 为milvus增加额外索引与搜索配置 2023-12-13 15:52:11 +08:00
liunux4odoo
2604c9e761
fix: prompt template name error in file_chat (#2366) 2023-12-12 21:12:33 +08:00
hzg0601
95c09981a6 给出chatglm3-6b输出角色标签<|user|>等及自问自答的解决方案 2023-12-11 11:22:39 +08:00
hzg0601
db1c1e2ee4 解决多次调用es创建索引失败的问题 2023-12-11 10:39:59 +08:00
liunux4odoo
2e9319846e support .xls files 2023-12-08 15:04:08 +08:00
liunux4odoo
7b70776810 fix: doc ext name error in LOADER_DICT 2023-12-08 13:59:55 +08:00
imClumsyPanda
fdd6eb5f6d
Update README.md 2023-12-07 16:07:24 +08:00
imClumsyPanda
bcbeb9d8ac
Add files via upload 2023-12-07 16:07:00 +08:00
hzg0601
ad0b133ac8 解决faiss相似度阈值不在0-1之间的问题 2023-12-06 21:57:59 +08:00
hzg0601
4c2fda7200 Merge branch 'dev' of https://github.com/chatchat-space/Langchain-Chatchat into dev 2023-12-06 20:42:32 +08:00
hzg0601
d1f94c2846 temporarily add reranker 2023-12-06 20:42:27 +08:00
hzg0601
1fac51fe35 temporarily save faiss_cache 2023-12-06 09:45:56 +00:00
imClumsyPanda
6547005073
Update README.md 2023-12-04 22:43:20 +08:00
imClumsyPanda
5fe933fa44
Add files via upload 2023-12-04 22:42:49 +08:00
liunux4odoo
67b7c99d03
ocr 支持 GPU 加速(需要手动安装 rapidocr_paddle[gpu]);知识库支持 MHTML 和 Evernote 文件。 (#2265)
在 requirements 和 Wiki 中增加对可选文档加载器 SDK 的说明 ( close #2264 )
2023-12-04 09:39:56 +08:00
Ean Yang
cf65f44eb6
更新默认模型下载链接 (#2259) 2023-12-03 11:59:48 +08:00
liunux4odoo
7d2de47bcf
文件对话和知识库对话 API 接口实现全异步操作,防止阻塞 (#2256)
* EmbeddingFunAdapter 支持异步操作;文件对话和知识库对话 API 接口实现全异步操作,防止阻塞

* 修复: 使 list_files_from_folder 返回相对路径
2023-12-02 19:22:44 +08:00
zR
dcb76984bc
修复Azure 不设置Max token的bug (#2254) 2023-12-02 16:50:56 +08:00
zR
023cb22da7
修改 duckduckgo 依赖错误 (#2252) 2023-12-02 12:30:07 +08:00
Zhi-guo Huang
2d0615aede
Merge pull request #2251 from chatchat-space/hzg0601-patch-1
Update duckduckgo version
2023-12-02 12:25:24 +08:00
Zhi-guo Huang
643cc6c5be
Update duckduckgo version 2023-12-02 12:25:12 +08:00
liunux4odoo
12113be6ec 在startup中自动执行 create_tables, 确保数据库表被创建 2023-12-02 10:52:29 +08:00
imClumsyPanda
6558647b65 update version 2023-12-01 21:55:35 +08:00
imClumsyPanda
f9348326f5 update config template 2023-12-01 21:54:11 +08:00
liunux4odoo
4fa28c71b1
修复:chat 接口默认使用 memory获取10条历史消息,导致最终拼接的prompt出错 (#2247)
修改后默认使用用户传入的history,只有同时传入conversation_id和history_len时才从数据库读取历史消息
使用memory还有一个问题,对话角色是固定的,不能适配不同的模型。

其它:注释一些无用的 print
2023-12-01 11:35:43 +08:00
zR
0cc1be224d
依赖升级 (#2246)
大量依赖升级到最新版
测试环境:Ubuntu 22.04 LTS kernel 6.6.3 Python 3.10.12,Cuda12.3 update1
2023-12-01 11:34:41 +08:00
imClumsyPanda
60f8e1d55e update aggrid pagination 2023-11-30 23:40:03 +08:00
imClumsyPanda
c34b4136c0 update file format 2023-11-30 23:33:48 +08:00
imClumsyPanda
f2d917d1e4 update config templates 2023-11-30 23:26:15 +08:00
imClumsyPanda
89b07ba55d update config templates 2023-11-30 23:20:39 +08:00
imClumsyPanda
072e0a2a32 update reqs and server/utils 2023-11-30 22:23:15 +08:00
imClumsyPanda
7e99cc12b3 update reqs 2023-11-30 21:54:09 +08:00
imClumsyPanda
d55f53d8c0 update README.md 2023-11-30 21:50:50 +08:00
imClumsyPanda
120dc50004 update README.md 2023-11-30 21:44:51 +08:00
zty
5ac77e5089
修复: MiniMax和千帆在线embedding模型分批请求的bug (#2208)
* 修复: MiniMax和千帆在线embedding模型分批请求的bug

* 修改了一处typo
2023-11-30 17:28:22 +08:00
zR
8b70b1db7e
一些细节更新 (#2235)
* 更新Langchain依赖到0.0.342以上版本

* 更改了一些提示词和依赖,修改了openai异常的问题

* 注释data的打印日志

* 增加Qwen新模型的支持
2023-11-30 17:25:48 +08:00
zR
40918c21de
bug修复和提示词修改 (#2230)
* 更新Langchain依赖到0.0.343以上版本

* 更改了一些提示词和依赖,修改了openai异常的问题

* 注释data的打印日志
2023-11-30 12:09:53 +08:00
imClumsyPanda
0ca6f40c45
Update README.md 2023-11-30 11:58:04 +08:00
liunux4odoo
c4fe3393b3
添加自定义命令: (#2229)
/new [conv_name] 新建会话
/del [conv_name] 删除会话
/clear [conv_name] 清空会话
/help 命令帮助

新增依赖:streamlit-modal
2023-11-30 11:39:41 +08:00
imClumsyPanda
7487af3bad
Add files via upload 2023-11-30 11:04:14 +08:00
zR
c4bf8c48ec
0.2.7版本依赖更新,Langchain在0.0.340下才能使用 (#2213) 2023-11-29 15:15:03 +08:00
zR
b7a50daa0f
更新Langchain依赖到0.0.342以上版本 (#2212) 2023-11-29 15:08:13 +08:00
liunux4odoo
509dee0425 fix: empty docs error in KnowledgeFile 2023-11-29 11:33:43 +08:00
liunux4odoo
7d580d9a47 修复:*_chat 接口中重设 max_tokens 时导致 local variable 'max_tokens' referenced before assignment 错误 2023-11-28 21:00:00 +08:00
imClumsyPanda
6076ab1198
Update README.md 2023-11-27 11:59:35 +08:00
imClumsyPanda
02c33e6ce9
Add files via upload 2023-11-27 11:58:57 +08:00
liunux4odoo
8b695dba03 *_chat 接口中,当 max_tokens=0时,将其设为 None,避免 swagger ui 中默认值为0时访问出错 2023-11-26 16:47:58 +08:00
glide-the
75a2cba078
Merge pull request #2176 from glide-the/dev_command_summary
单个知识库根据doc_ids摘要
2023-11-25 23:32:19 +08:00
glide-the
279ffdf117 单个知识库根据doc_ids摘要 2023-11-25 23:31:13 +08:00
glide-the
33374bd9f2
Merge pull request #2175 from glide-the/dev_command_summary
提供文档summary_chunk ,支持单文件总结业务实现 使用 MapReduceDocumentsChain 生成摘要
2023-11-25 22:32:13 +08:00
glide-the
248db46187 Merge branch 'dev_summary' into dev_command_summary
实现summary_chunk 文档分段总结业务实现
使用 MapReduceDocumentsChain 生成摘要
# Conflicts:
#	server/api.py
#	server/knowledge_base/kb_doc_api.py
#	server/knowledge_base/kb_service/base.py
#	server/knowledge_base/migrate.py
2023-11-25 22:30:41 +08:00
glide-the
f57837c07a Merge branch 'dev_summary' into dev_tmp
# Conflicts:
#	server/api.py
#	server/knowledge_base/kb_doc_api.py
#	server/knowledge_base/kb_service/base.py
#	server/knowledge_base/migrate.py
2023-11-25 21:02:46 +08:00
hzg0601
08530edb3d add some comment 2023-11-25 19:56:36 +08:00
Zhi-guo Huang
92dcb11b26
Merge pull request #2173 from chatchat-space/hzg0601-patch-4
Update startup.py
2023-11-25 19:45:13 +08:00
Zhi-guo Huang
abb32722fe
Update startup.py
修复vllm=0.2.2版本中vllm_worker启动失败的bug
2023-11-25 19:44:33 +08:00
Zhi-guo Huang
717355bf1e
Merge pull request #2171 from chatchat-space/hzg0601-patch-3
Update server_config.py.example
2023-11-25 19:41:37 +08:00
Zhi-guo Huang
a83e03011d
Update server_config.py.example
针对fschat=0.2.33关于vllm启动的bug给出修补方案
2023-11-25 19:41:21 +08:00
Zhi-guo Huang
f9f16edd13
Update startup.py
解决vllm在0.2.2版本启动的bug
2023-11-25 19:38:18 +08:00
Zhi-guo Huang
63bdca1343
Merge pull request #2170 from chatchat-space/hzg0601-patch-2
Update requirements.txt
2023-11-25 19:35:11 +08:00
Zhi-guo Huang
3c4d4a5345
Update requirements.txt
针对win上的reqirements某些包的安装安装增说明
2023-11-25 19:34:57 +08:00
liunux4odoo
1de4258aa0
给 ApiModelWorker 添加 logger 成员变量,API请求出错时输出有意义的错误信息。 (#2169)
* 给 ApiModelWorker 添加 logger 成员变量,API请求出错时输出有意义的错误信息。
/chat/chat 接口 conversation_id参数改为默认 "",避免 swagger 页面默认值错误导致历史消息失效

* 修复在线模型一些bug
2023-11-25 13:51:07 +08:00
zR
1b0cf67a57
支持软连接的知识库 (#2167)
* GLM3支持传入提示词

支持传入提示词的Agent ChatGLM3-6B

* 软连接处理

1. 有效的软连接处理,参考了 #2125
2. 更新了依赖,现在fschat原生支持GLM3的全功能

* 更新了支持的模型列表和依赖
1. 推荐用户使用GLM3-6B取代2代GLM模型
2. 推荐用户使用性能更强的bge模型
3 推荐使用vllm和torch的最新稳定版本
2023-11-24 22:47:55 +08:00
Eden
dfcebf7bc3
支持昆仑万维天工大模型 (#2166)
---------

Co-authored-by: Eden <chuangqi.huang@ubtrobot.com>
Co-authored-by: liunux4odoo <liunux@qq.com>
2023-11-24 22:25:35 +08:00
Zhi-guo Huang
3839c212db
Merge pull request #2162 from chatchat-space/hzg0601-patch-1
Update startup.py
2023-11-24 17:03:19 +08:00
Zhi-guo Huang
1d3a69ff86
Update startup.py
解决vllm启动worker_id used before assigned的问题
2023-11-24 17:03:02 +08:00
liunux4odoo
824c29a6d2
将 MiniMax 和 千帆 在线 Embedding 改为 10 个文本一批,防止接口数量限制 (#2161) 2023-11-24 16:42:20 +08:00
qiankunli
76151e884a
feat: add with-history prompt (#2156)
Co-authored-by: liqiankun.1111 <liqiankun.1111@bytedance.com>
2023-11-24 10:05:50 +08:00
liunux4odoo
1b9b777eaf 使 MessageModel 中 conversation_id 为非必填项,避免前端请求错误 2023-11-23 21:42:27 +08:00
liunux4odoo
aae4144476
数据库和向量库中文档 metadata["source"] 改为相对路径,便于向量库迁移 (#2153)
修复:
- 上传知识库文件名称包括子目录时,自动创建子目录
2023-11-23 19:54:00 +08:00
hzg0601
7a85fe74e9 add llm article to kb/smaples 2023-11-23 14:18:00 +08:00
qiankunli
1c97673d41
feat: add db memory (#2046)
* feat: add db memory
* WEBUI 添加多会话功能

---------

Co-authored-by: liqiankun.1111 <liqiankun.1111@bytedance.com>
Co-authored-by: liunux4odoo <liunux@qq.com>
2023-11-22 18:38:26 +08:00
imClumsyPanda
274e7a9c0a
Update README.md 2023-11-22 15:27:14 +08:00
imClumsyPanda
7eee9212e0
Add files via upload 2023-11-22 15:26:45 +08:00
glide-the
569209289b
Merge pull request #2130 from glide-the/dev
统一在线模型异常报文、增加详细日志
2023-11-21 21:48:39 +08:00
glide-the
17c9632942 统一在线模型异常报文、增加详细日志 2023-11-21 21:47:02 +08:00
liunux4odoo
3cf7422c21
修复:知识库json文件的中文被转为unicode码,导致无法匹配 (#2128) 2023-11-21 21:00:46 +08:00
Zhi-guo Huang
ce7255dce1
Update model_config.py.example (#2110) 2023-11-20 16:45:55 +08:00
liunux4odoo
a9cf191532 update webui: 默认对话模式改为 LLM对话;lite 模式下可选模型列表不显示本地模型 2023-11-20 16:37:20 +08:00
Zhi-guo Huang
700c4ad170
Update requirements.txt
删除中文以防止win上的安装错误
2023-11-20 15:57:26 +08:00
Zhi-guo Huang
262c1fc8c3
Update requirements_api.txt
删除中文以防止win安装错误
2023-11-20 15:56:51 +08:00
Zhi-guo Huang
33f43f7a96
Update requirements_lite.txt
删除中文,以防止win设备安装错误
2023-11-20 15:56:16 +08:00
liunux4odoo
1a291d9db9 add .pdf & .pptx as knowledge test files; update wiki 2023-11-17 14:32:30 +08:00
liunux4odoo
ad7a6fd438
开发者: (#2091)
- 修复列出知识库磁盘文件时跳过临时文件的bug:只有目录被排除了,文件未排除
- 优化知识库文档加载器:
  - 将 elements 模式改为 single 模式,避免文档被切分得太碎
  - 给 get_loader 和 KnowledgeFile 增加 loader_kwargs 参数,可以自定义文档加载器参数
2023-11-17 11:39:32 +08:00
liunux4odoo
68a544ea33 开发者:XXKBService.get_doc_by_id 改为批量处理,提高访问向量库效率。 2023-11-16 11:09:40 +08:00
imClumsyPanda
4ed8f049ab
Update README.md 2023-11-16 10:20:39 +08:00
imClumsyPanda
51c43122cb
Add files via upload 2023-11-16 10:20:18 +08:00
liunux4odoo
fbe214471b
知识库支持 .jsonl, .epub, .xlsx, .xlsd, .ipynb, .odt, .py, .srt, .toml, .doc, .ppt 文件 (#2079)
* 知识库支持行式 json 文件
如果要使用 json 文件, 需要 `conda install jq`(windows 下 pip install jq 会失败)

开发者:
删除 CustomJsonLoader,使用 langchain 自带的 JsonLoader 处理 json 文件,添加 JsonLinesLoader 处理 jsonl 文件。

* 知识库支持 .epub, .xlsx, .xlsd, .ipynb, .odt, .py, .srt, .toml, .doc, .ppt 文件
为 .eml, .msg, .rst, .rtf, .tsv, .docx, .xml, .pptx 指定专用加载器
2023-11-16 09:37:09 +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
liunux4odoo
2adfa4277c
在webui模型列表中包括:非model worker启动的在线模型(如openai-api);已经下载的本地模型 (#2060) 2023-11-14 21:17:32 +08:00
zR
21b079d751
GLM3支持传入提示词 (#2058)
支持传入提示词的Agent ChatGLM3-6B
2023-11-14 17:45:22 +08:00
Hans
c094b5f91c
删除多余文字 (#2049) 2023-11-14 10:30:12 +08:00
liunux4odoo
e78a804ec6 close #2044: duplicated mount_knowledge_base_routes in server/api.py 2023-11-13 20:30:32 +08:00
zR
94d4304638
更新了chatglm3 6b agent的文档,提示词 (#2041)
更新了chatglm3 6b agent的文档,提示词
修复代理no_proxy格式问题 #1838 的问题,感谢多次复现和验证
修改了pg清理知识库后还会引用之前知识库的问题
2023-11-13 16:30:09 +08:00
Jack
4e8e6de7ff
Update README.md (#2034) 2023-11-13 14:27:27 +08:00
liunux4odoo
861510a92b
Update requirements: change comments to english (#2033)
* Update requirements: change comments to english
2023-11-13 14:03:41 +08:00
imClumsyPanda
e4ffa2f93b update README.md 2023-11-13 07:33:02 +08:00
imClumsyPanda
f06a819ba6 Merge remote-tracking branch 'origin/master' 2023-11-13 07:13:43 +08:00
imClumsyPanda
b6e366d93a update README.md 2023-11-13 07:13:28 +08:00
zR
91ff0574df
支持ChatGLM3-6B (#2021)
* 更新依赖和配置文件中的Agent模型

* 支持基础的glm3_agent
2023-11-12 16:45:50 +08:00
imClumsyPanda
068cb5df9c
Update README.md 2023-11-12 13:21:46 +08:00
imClumsyPanda
33c462a281
Add files via upload 2023-11-12 13:20:39 +08:00
imClumsyPanda
72a1f5dcb3 update README.md 2023-11-10 19:59:31 +08:00
imClumsyPanda
4fca531d97 update README.md 2023-11-10 19:58:24 +08:00
imClumsyPanda
89be31c66c update version 2023-11-10 19:45:32 +08:00
imClumsyPanda
3462d06759 update model_config.py.example 2023-11-10 19:40:55 +08:00
imClumsyPanda
5e9acfd633 update model_config.py.example 2023-11-10 16:35:42 +08:00
imClumsyPanda
9a741fd14d update model_config.py.example 2023-11-10 16:34:13 +08:00
imClumsyPanda
3e20e47328 Merge branch 'dev' of https://github.com/chatchat-space/Langchain-Chatchat into dev 2023-11-10 16:32:21 +08:00
Zhi-guo Huang
a8f4e7603e
Merge pull request #2011 from hzg0601/dev
1. 增加ES支持;2. 修复了若干typo bug
2023-11-10 16:30:18 +08:00
hzg0601
c1440c2609 增加ElasticSearch支持 2023-11-10 16:04:41 +08:00
liunux4odoo
63111a5c87 supdate model_config 2023-11-10 11:46:41 +08:00
liunux4odoo
261b4899c1 supdate model_config 2023-11-10 11:44:40 +08:00
liunux4odoo
b51ba11f45
支持通过配置项同时启动多个模型,将Wiki纳入samples知识库 (#2002)
新功能:
- 将 LLM_MODEL 配置项改为 LLM_MODELS 列表,同时启动多个模型
- 将 wiki 纳入 samples 知识库

依赖变化:
- 指定 streamlit~=1.27.0。1.26.0会报rerun错误,1.28.0会有无限刷新错误

修复优化:
- 优化 get_default_llm_model 逻辑
- 适配 Qwen 在线 API 做 Embeddings 时最大 25 行的限制
- 列出知识库磁盘文件时跳过 . 开头的文件
2023-11-09 22:15:52 +08:00
WilliamChen-luckbob
ce1001a043
bugfix:dev分支创建知识库必然失败的bug修复 (#1980)
* bugfix:dev分支创建知识库必然失败的bug修复

* 统一 KBServiceFactory.get_service_by_name 的逻辑,数据库中不存在知识库时返回 None

---------

Co-authored-by: liunux4odoo <liunux@qq.com>
2023-11-09 17:45:21 +08:00
imClumsyPanda
9588bcfa94 Merge branch 'master' into dev 2023-11-09 09:41:26 +08:00
imClumsyPanda
35164b5196 delete outdated qrcode 2023-11-09 09:41:06 +08:00
liunux4odoo
d0d688d4b0 修复:重建知识库时自动创建库表 2023-11-07 21:00:45 +08:00
imClumsyPanda
ccf277c96f delete outdated qrcode 2023-11-07 16:32:44 +08:00
imClumsyPanda
0e8700edb9 Merge branch 'master' into dev 2023-11-07 16:31:45 +08:00
imClumsyPanda
349adbdfa7
Add files via upload 2023-11-07 16:05:26 +08:00
imClumsyPanda
da1dbf9763
Update README.md 2023-11-07 16:05:03 +08:00
zR
3952fbd464
更新依赖和配置文件中的Agent模型 (#1984) 2023-11-07 13:52:47 +08:00
imClumsyPanda
e233e4f220 reformat server/knowledge_base/migrate.py 2023-11-06 22:49:35 +08:00
imClumsyPanda
fb32c31a70 reformat kb_doc_api.py 2023-11-06 22:44:50 +08:00
imClumsyPanda
fe73ceab15 Merge branch 'master' into dev 2023-11-06 22:38:52 +08:00
imClumsyPanda
051a2e97dc add support for Zhipu-api "chatglm-turbo" 2023-11-06 22:38:05 +08:00
imClumsyPanda
f4f7845f93 reformat startup.py 2023-11-06 22:31:09 +08:00
imClumsyPanda
ce9160fbfa update requirements.txt 2023-11-06 22:11:55 +08:00
imClumsyPanda
ed2122a8f6 fix bug in basic_config.py.example 2023-11-06 21:49:05 +08:00
imClumsyPanda
a938b67163 reformat config files 2023-11-05 11:17:09 +08:00
imClumsyPanda
5e0476925b reformat copy_config_example.py 2023-11-05 11:08:55 +08:00
zR
57612d5232
修复一些bug (#1965)
* 修改一些bug

* 更新掉了一部分之前的bug
2023-11-03 18:56:27 +08:00
qiankunli
fa906b33a8
添加对话评分与历史消息保存功能 (#1940)
* 新功能:
- WEBUI 添加对话评分功能
- 增加 /chat/feedback 接口,用于接收对话评分
- /chat/chat 接口返回值由 str 改为 {"text":str, "chat_history_id": str}
- init_database.py 添加 --create-tables --clear-tables 参数

依赖:
- streamlit-chatbox==1.1.11

开发者:
- ChatHistoryModel 的 id 字段支持自动生成
- SAVE_CHAT_HISTORY 改到 basic_config.py

* 修复:点击反馈后页面未刷新

---------

Co-authored-by: liqiankun.1111 <liqiankun.1111@bytedance.com>
Co-authored-by: liunux4odoo <liunux@qq.com>
Co-authored-by: liunux4odoo <41217877+liunux4odoo@users.noreply.github.com>
2023-11-03 11:31:45 +08:00
liunux4odoo
554122f60e
Feat (#1951)
* 知识库支持子目录(不包括temp和tmp开头的目录),文件相对路径总长度不可超过255

* init_database.py 增加 --import-db 参数,在版本升级时,如果 info.db
表结构发生变化,但向量库无需重建,可以在重建数据库后,使用本参数从旧的数据库中导入信息
2023-11-02 14:46:39 +08:00
imClumsyPanda
d4b0b4d83d
Update README.md 2023-11-02 13:32:38 +08:00
imClumsyPanda
36584428d5
Add files via upload 2023-11-02 13:31:52 +08:00
liunux4odoo
d8e15b57ba
知识库支持子目录(不包括temp和tmp开头的目录),文件相对路径总长度不可超过255 (#1928) 2023-10-31 16:59:40 +08:00
liunux4odoo
65592a45c3
支持在线 Embeddings, Lite 模式支持所有知识库相关功能 (#1924)
新功能:
- 支持在线 Embeddings:zhipu-api, qwen-api, minimax-api, qianfan-api
- API 增加 /other/embed_texts 接口
- init_database.py 增加 --embed-model 参数,可以指定使用的嵌入模型(本地或在线均可)
- 对于 FAISS 知识库,支持多向量库,默认位置:{KB_PATH}/vector_store/{embed_model}
- Lite 模式支持所有知识库相关功能。此模式下最主要的限制是:
  - 不能使用本地 LLM 和 Embeddings 模型
  - 知识库不支持 PDF 文件
- init_database.py 重建知识库时不再默认情况数据库表,增加 clear-tables 参数手动控制。
- API 和 WEBUI 中 score_threshold 参数范围改为 [0, 2],以更好的适应在线嵌入模型

问题修复:
- API 中 list_config_models 会删除 ONLINE_LLM_MODEL 中的敏感信息,导致第二轮API请求错误

开发者:
- 统一向量库的识别:以(kb_name,embed_model)为判断向量库唯一性的依据,避免 FAISS 知识库缓存加载逻辑错误
- KBServiceFactory.get_service_by_name 中添加 default_embed_model 参数,用于在构建新知识库时设置 embed_model
- 优化 kb_service 中 Embeddings 操作:
  - 统一加载接口: server.utils.load_embeddings,利用全局缓存避免各处 Embeddings 传参
  - 统一文本嵌入接口:server.knowledge_base.kb_service.base.[embed_texts, embed_documents]
- 重写 normalize 函数,去除对 scikit-learn/scipy 的依赖
2023-10-31 14:26:50 +08:00
imClumsyPanda
7f9592773b
Update README.md 2023-10-29 14:54:40 +08:00
imClumsyPanda
1eddb2c321
Add files via upload 2023-10-29 14:54:13 +08:00
imClumsyPanda
ff22d5f98f
Update README.md 2023-10-29 14:53:01 +08:00
imClumsyPanda
b1100ddefb
Add files via upload 2023-10-29 14:52:31 +08:00
liunux4odoo
deed92169f
支持在线 Embeddings:zhipu-api, qwen-api, minimax-api, qianfan-api (#1907)
* 新功能:
- 支持在线 Embeddings:zhipu-api, qwen-api, minimax-api, qianfan-api
- API 增加 /other/embed_texts 接口
- init_database.py 增加 --embed-model 参数,可以指定使用的嵌入模型(本地或在线均可)

问题修复:
- API 中 list_config_models 会删除 ONLINE_LLM_MODEL 中的敏感信息,导致第二轮API请求错误

开发者:
- 优化 kb_service 中 Embeddings 操作:
  - 统一加载接口: server.utils.load_embeddings,利用全局缓存避免各处 Embeddings 传参
  - 统一文本嵌入接口:server.embedding_api.[embed_texts, embed_documents]
2023-10-28 23:37:30 +08:00
zR
aa7c580974
Dev (#1902)
修改Agent的内容
2023-10-27 22:53:43 +08:00
zR
bb72d9ac26
支持GLM (#1896)
* 支持glm3
2023-10-27 17:56:27 +08:00
zR
d054244e55
Dev (#1895)
* 修复科大讯飞token问题和Azure的token问题

* 合并PR并改变位置

---------

Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-27 14:38:24 +08:00
charlesyju
f19211b1f5
support adding keywords to model tokenizer (#1622)
* support adding keywords to model tokenizer

* add keyword_preprocess.py usage doc

* init new token with good weights

---------

Co-authored-by: Charles Ju <charlesyju@gmail.com>
2023-10-27 13:57:14 +08:00
zR
6ed87954b2
修复科大讯飞token问题和Azure的token问题 (#1894)
Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-27 13:51:59 +08:00
liunux4odoo
b68f7fcdea 修改qianfan-api使用原始post访问,qianfan sdk无法访问 2023-10-27 13:42:16 +08:00
zR
dea468ab0f
Dev (#1892)
* 支持了agentlm

* 支持了agentlm和相关提示词

* 修改了Agent的一些功能,加入了Embed方面的一个优化

* 修改了部分Agent的工具

* 增加一些Langchain的自带工具

* 修复一些兼容性的bug

* 恢复知识库

* 恢复知识库

* 1

* 修复Azure问题

* 修复zilliz的问题

* 修复Agent历史记录问题,优化知识库问答搜索的uoji

* 修复讯飞大模型token问题

* 修复讯飞大模型token问题和配置文件

---------

Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-27 13:14:48 +08:00
zR
24d1e28a07
一些细节优化 (#1891)
Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-27 11:52:44 +08:00
liunux4odoo
ce8e341b9f update server_config.py.example: qianfan-api 默认模型改为 ERNIE-Bot。qianfan sdk 对模型名称大小写敏感 2023-10-26 22:48:56 +08:00
liunux4odoo
b4c68ddd05
优化在线 API ,支持 completion 和 embedding,简化在线 API 开发方式 (#1886)
* 优化在线 API ,支持 completion 和 embedding,简化在线 API 开发方式

新功能
- 智谱AI、Minimax、千帆、千问 4 个在线模型支持 embeddings(不通过Fastchat,后续会单独提供相关api接口)
- 在线模型自动检测传入参数,在传入非 messages 格式的 prompt 时,自动转换为 completion 形式,以支持 completion 接口

开发者:
- 重构ApiModelWorker:
  - 所有在线 API 请求封装到 do_chat 方法:自动传入参数 ApiChatParams,简化参数与配置项的获取;自动处理与fastchat的接口
  - 加强 API 请求错误处理,返回更有意义的信息
  - 改用 qianfan sdk 重写 qianfan-api
  - 将所有在线模型的测试用例统一在一起,简化测试用例编写

* Delete requirements_langflow.txt
2023-10-26 22:44:48 +08:00
zR
e74fe2d950
Zilliz修复 (#1874)
* 修复zilliz的问题
2023-10-25 21:59:26 +08:00
zR
35a7ca74c0
Azure 的fschat支持,弃用Langchain-MODEL (#1873)
* 支持了agentlm

* 支持了agentlm和相关提示词

* 修改了Agent的一些功能,加入了Embed方面的一个优化

* 修改了部分Agent的工具

* 增加一些Langchain的自带工具

* 修复一些兼容性的bug

* 恢复知识库

* 恢复知识库

* 修复Azure问题
2023-10-25 21:32:40 +08:00
liunux4odoo
27418ba9fa fix bug, add dependencies: strsimpy, markdownify 2023-10-25 08:58:31 +08:00
liunux4odoo
03e55e11c4
支持lite模式:无需安装torch等重依赖,通过在线API实现LLM对话和搜索引擎对话 (#1860)
* move get_default_llm_model from webui to ApiRequest

增加API接口及其测试用例:
- /server/get_prompt_template: 获取服务器配置的 prompt 模板
- 增加知识库多线程访问测试用例

支持lite模式:无需安装torch等重依赖,通过在线API实现LLM对话和搜索引擎对话

* fix bug in server.api

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-10-25 08:30:23 +08:00
Zhi-guo Huang
be67ea43d8
Merge pull request #1828 from qiankunli/feat/add-completion-api
增加completion功能的API接口,注意暂不支持online_api模型
2023-10-24 22:10:54 +08:00
liunux4odoo
19f5f07d57 fix: unused imported faiss in milvus_kb_server (close #1849) 2023-10-24 15:01:19 +08:00
jinke
2f67e1d0cc update docker image to 0.2.6
43.4G, chatglm6b+text2vec-bge-large-chinese.
2023-10-24 12:32:26 +08:00
imClumsyPanda
b166457897
Update README.md 2023-10-24 10:43:04 +08:00
imClumsyPanda
e904bc2ade
Add files via upload 2023-10-24 10:42:34 +08:00
imClumsyPanda
68498bd93b
Update README.md 2023-10-23 22:40:14 +08:00
zR
a036e3ccda
修改了部分Agent Prompt 修改了一些适配问题 (#1839)
* 支持了agentlm

* 支持了agentlm和相关提示词

* 修改了Agent的一些功能,加入了Embed方面的一个优化

* 修改了部分Agent的工具

* 增加一些Langchain的自带工具

* 修复一些兼容性的bug
2023-10-23 14:53:14 +08:00
zR
e6382cacb1
修复了migrate兼容性错误,python3.8正常使用 (#1837)
Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-23 14:41:56 +08:00
zR
c983e9f559
增加一些Langchain的Agent工具 (#1836)
* 支持了agentlm

* 支持了agentlm和相关提示词

* 修改了Agent的一些功能,加入了Embed方面的一个优化

* 修改了部分Agent的工具

* 增加一些Langchain的自带工具

---------

Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-23 13:22:10 +08:00
liqiankun.1111
b002a2879b feat: add completion api 2023-10-22 17:07:26 +08:00
zR
303c9d94df
修改,格式了部分Agent工具 (#1823)
* 支持了agentlm

* 支持了agentlm和相关提示词

* 修改了Agent的一些功能,加入了Embed方面的一个优化

* 修改了部分Agent的工具

---------

Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-22 00:07:32 +08:00
zR
1b50547e60
Dev (#1822)
* 支持了agentlm

* 支持了agentlm和相关提示词

* 修改了Agent的一些功能,加入了Embed方面的一个优化

---------

Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-22 00:00:15 +08:00
zR
1c5382d96b
支持AgentLM模型 (#1821)
* 支持了agentlm

Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-21 22:09:53 +08:00
zR
fcbd97203a
Dev (#1817)
* 更新了最新的readme

* 更新readme,加上目录

* 删掉所有没用的材料,之后都转wiki

* 更新readme和新版本图
2023-10-21 11:35:51 +08:00
liunux4odoo
4aa16d1c7b merge dev from master hotfix: no temperature in webui 2023-10-21 07:17:18 +08:00
zR
38a48bc831
紧急修复 温度 参数代码消失问题 (#1816) 2023-10-21 01:28:34 +08:00
imClumsyPanda
115a123442
Update README.md 2023-10-20 23:34:05 +08:00
imClumsyPanda
9186532fcb
Update README.md 2023-10-20 23:33:04 +08:00
liunux4odoo
9b5f64788c update dev version: v0.2.7-preview 2023-10-20 23:32:30 +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
liunux4odoo
0e7f0e1452 update readme: remove milestone 2023-10-20 23:12:36 +08:00
zR
c41d7add7d
Dev (#1814)
* 更新了最新的readme

* 更新readme,加上目录

* 删掉所有没用的材料,之后都转wiki
2023-10-20 23:02:21 +08:00
liunux4odoo
df0ee992f3 update readme: remove milestone 2023-10-20 22:00:33 +08:00
liunux4odoo
ce54414b4f update readme: remove partners 2023-10-20 21:53:36 +08:00
liunux4odoo
dd7223b3a9 merge master to dev 2023-10-20 21:48:24 +08:00
zR
86ee6fe08c
更新readme (#1813)
* 更新了最新的readme

* 更新readme,加上目录
2023-10-20 21:37:43 +08:00
zR
46225ad784
Dev (#1811)
* 北京黑客松更新

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

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

提示词选择
1. UI 和模板支持提示词模板更换选择

* 数据库更新介绍问题解决

* 关于Langchain自己支持的模型

1. 修复了Openai无法调用的bug
2. 支持了Azure Openai Claude模型
(在模型切换界面由于优先级问题,显示的会是其他联网模型)
3. 422问题被修复,用了另一种替代方案。
4. 更新了部分依赖

* 换一些图
2023-10-20 20:07:59 +08:00
Zhi-guo Huang
109bb7f6c5
Merge pull request #1810 from hzg0601/dev
1. 支持加载p-tuning,详细步骤见docs/chatchat加载ptuing.md;2. 根据系统自动指定binding_host
2023-10-20 19:34:02 +08:00
hzg0601
a81bd827dd 根据系统指定binding_host 2023-10-20 19:32:06 +08:00
hzg0601
6e9acfc1af Merge branch 'dev' of https://github.com/chatchat-space/Langchain-Chatchat into dev 2023-10-20 19:22:36 +08:00
hzg0601
195929b518 支持加载p-tuning,详细步骤见docs/chatchat加载ptuing.md 2023-10-20 19:22:24 +08:00
liunux4odoo
1d9d9df9e9 update baichuan-api: 修正messages参数;支持流式;添加测试用例 2023-10-20 19:09:05 +08:00
zR
e920cd0064
合并分支,支持 (#1808)
* 北京黑客松更新

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

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

提示词选择
1. UI 和模板支持提示词模板更换选择

* 数据库更新介绍问题解决

* 关于Langchain自己支持的模型

1. 修复了Openai无法调用的bug
2. 支持了Azure Openai Claude模型
(在模型切换界面由于优先级问题,显示的会是其他联网模型)
3. 422问题被修复,用了另一种替代方案。
4. 更新了部分依赖
2023-10-20 18:13:55 +08:00
liunux4odoo
83e25f8011 remove xformers from requirements*.txt; check llm_model before change model in webui 2023-10-20 15:01:39 +08:00
liunux4odoo
0b25d7b079 fix: correct model_worker's logger and semaphor 2023-10-20 11:50:50 +08:00
liunux4odoo
1b3bd4442c update model_config.py.example (#1784) 2023-10-19 22:37:08 +08:00
liunux4odoo
d053950aee
新功能: (#1801)
- 更新langchain/fastchat依赖,添加xformers依赖
- 默认max_tokens=None, 生成tokens自动为模型支持的最大值

修复:
- history_len=0 时会带入1条不完整的历史消息,导致LLM错误
- 当对话轮数 达到history_len时,传入的历史消息为空
2023-10-19 22:09:15 +08:00
liunux4odoo
7e28291e9f
Merge pull request #1792 from liunux4odoo/fix
支持metaphor搜索引擎(无需代理,key申请简单,目前不支持中文)
2023-10-18 23:05:57 +08:00
liunux4odoo
b9b42991f6 - 支持metaphor搜索引擎(无需代理,key申请简单,目前不支持中文)
- 增加默认知识库和默认搜索引擎的配置项
- 修复WEBUI弹出当前模型错误
2023-10-18 23:02:20 +08:00
imClumsyPanda
b8aad555a1
Update README.md 2023-10-18 22:49:00 +08:00
imClumsyPanda
4d48d5f2ab
Add files via upload 2023-10-18 22:48:37 +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
9ce328fea9
实现Api和WEBUI的前后端分离 (#1772)
* update ApiRequest: 删除no_remote_api本地调用模式;支持同步/异步调用
* 实现API和WEBUI的分离:
- API运行服务器上的配置通过/llm_model/get_model_config、/server/configs接口提供,WEBUI运行机器上的配置项仅作为代码内部默认值使用
- 服务器可用的搜索引擎通过/server/list_search_engines提供
- WEBUI可选LLM列表中只列出在FSCHAT_MODEL_WORKERS中配置的模型
- 修改WEBUI中默认LLM_MODEL获取方式,改为从api端读取
- 删除knowledge_base_chat中`local_doc_url`参数

其它修改:
- 删除多余的kb_config.py.exmaple(名称错误)
- server_config中默认关闭vllm
- server_config中默认注释除智谱AI之外的在线模型
- 修改requests从系统获取的代理,避免model worker注册错误

* 修正:
- api.list_config_models返回模型原始配置
- api.list_config_models和api.get_model_config中过滤online api模型的敏感信息
- 将GPT等直接访问的模型列入WEBUI可选模型列表

其它:
- 指定langchain==0.3.313, fschat==0.2.30, langchain-experimental==0.0.30
2023-10-17 16:52:07 +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
imClumsyPanda
9163dda5df
Update README.md 2023-10-15 22:20:22 +08:00
imClumsyPanda
70dd7c1f64
Add files via upload 2023-10-15 22:19:57 +08:00
liunux4odoo
cd748128c3
add paramter max_tokens to 4 chat api with default value 1024 (#1744) 2023-10-12 16:18:56 +08:00
liunux4odoo
1ac173958d fix #1737: MakeFastAPIOffline函数内代码编写错误 2023-10-12 10:56:49 +08:00
liunux4odoo
01577d6264 只启动在server_config中配置的在线API模型 2023-10-12 10:55:53 +08:00
imClumsyPanda
f4153beccf
Update README.md 2023-10-12 09:30:26 +08:00
imClumsyPanda
d35dbc730a
Update README.md 2023-10-11 22:22:23 +08:00
imClumsyPanda
68eb72e94f
Update README.md 2023-10-11 09:21:48 +08:00
imClumsyPanda
dfb36562ca
Add files via upload 2023-10-11 09:21:18 +08:00
imClumsyPanda
c313f99b40 update README.md 2023-10-11 06:13:48 +08:00
imClumsyPanda
76e21c87da update README.md 2023-10-11 06:10:02 +08:00
imClumsyPanda
bc5f846c6a update README.md 2023-10-10 21:33:38 +08:00
imClumsyPanda
4578bc4780 update README.md 2023-10-10 21:24:48 +08:00
glide-the
21cf43567a
Merge pull request #1707 from chatchat-space/glide-the-patch-3
Update README.md
2023-10-09 14:00:58 +08:00
glide-the
ff652f1f6b
Update README.md 2023-10-09 14:00:49 +08:00
glide-the
e9381f74af
Merge pull request #1705 from chatchat-space/glide-the-patch-1
微信二维码
2023-10-09 13:59:37 +08:00
glide-the
97c2126e80
Merge pull request #1706 from chatchat-space/glide-the-patch-2
Update README.md
2023-10-09 13:59:24 +08:00
glide-the
15fab6e10f
Update README.md 2023-10-09 13:59:09 +08:00
glide-the
27f5e7d967
微信二维码 2023-10-09 13:58:20 +08:00
zR
111bc45d04
Wiki完善和Agent完善计划 (#1680)
* 更新上agent提示词代码

* 更新部分文档,修复了issue中提到的bge匹配超过1 的bug

* 按需修改

* 解决了部分最新用户用依赖的bug,加了两个工具,移除google工具

* Agent大幅度优化

1. 修改了UI界面
(1)高亮所有没有进行agent对齐的模型,
(2)优化输出体验和逻辑,使用markdown

2. 降低天气工具使用门槛
3. 依赖更新
(1) vllm 更新到0.2.0,增加了一些参数
(2) torch 建议更新到2.1
(3)pydantic不要更新到1.10.12

* 更新了一些注释

* 修改部分依赖,修改了部分wiki用图

---------

Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-10-07 22:00:56 +08:00
zR
7475205eca
Agent提示词更改,增加图片 (#1667)
* 更新上agent提示词代码

* 更新部分文档,修复了issue中提到的bge匹配超过1 的bug

* 按需修改

* 解决了部分最新用户用依赖的bug,加了两个工具,移除google工具

* Agent大幅度优化

1. 修改了UI界面
(1)高亮所有没有进行agent对齐的模型,
(2)优化输出体验和逻辑,使用markdown

2. 降低天气工具使用门槛
3. 依赖更新
(1) vllm 更新到0.2.0,增加了一些参数
(2) torch 建议更新到2.1
(3)pydantic不要更新到1.10.12

* 更新了一些注释
2023-10-07 11:52:54 +08:00
zR
2c8fc95f7a
Agent大更新合并 (#1666)
* 更新上agent提示词代码

* 更新部分文档,修复了issue中提到的bge匹配超过1 的bug

* 按需修改

* 解决了部分最新用户用依赖的bug,加了两个工具,移除google工具

* Agent大幅度优化

1. 修改了UI界面
(1)高亮所有没有进行agent对齐的模型,
(2)优化输出体验和逻辑,使用markdown

2. 降低天气工具使用门槛
3. 依赖更新
(1) vllm 更新到0.2.0,增加了一些参数
(2) torch 建议更新到2.1
(3)pydantic不要更新到1.10.12
2023-10-07 11:26:11 +08:00
liunux4odoo
387b4cb967 fix #1638: baichuan-api未正确配置 2023-10-05 22:46:31 +08:00
liunux4odoo
0304279545 fix #1656: rename kb_config.py.exmaple to kb_config.py.example 2023-10-05 22:35:13 +08:00
glide-the
038f2eb1ec 修复代理为空的问题
(cherry picked from commit 84a4141dec1b8c5da5b62d3ad885927791f6d3ee)
2023-10-04 14:05:00 +08:00
glide-the
37500b878e 指定transformers==4.33.3版本
(cherry picked from commit f30b4d5d575308e6ec3794d43c9e7696e399e7fe)
2023-10-04 14:05:00 +08:00
glide-the
48338207bd 修复代理为空的问题
(cherry picked from commit a655608d01a1ff44c8f6a3e0ab6ed07cb4e217c4)
2023-10-04 14:05:00 +08:00
glide-the
295783b549
Merge pull request #1654 from glide-the/master
修复代理为空的问题
2023-10-04 14:04:11 +08:00
glide-the
84a4141dec 修复代理为空的问题 2023-10-04 14:02:57 +08:00
glide-the
db3efb306a
Merge pull request #1653 from glide-the/master
修复代理和transformers版本问题
2023-10-04 13:38:21 +08:00
glide-the
f30b4d5d57 指定transformers==4.33.3版本 2023-10-04 13:35:11 +08:00
glide-the
a655608d01 修复代理为空的问题 2023-10-04 13:33:42 +08:00
zR
fc6a3b07ed
Dev (#1652)
* 更新上agent提示词代码

* 更新部分文档,修复了issue中提到的bge匹配超过1 的bug

* 按需修改

* 解决了部分最新用户用依赖的bug,加了两个工具,移除google工具
2023-10-04 12:05:46 +08:00
liunux4odoo
332f8be401
fix: windows下bind_host设为0.0.0.0时,将fschat_xx_address指向127.0.0.1,避免请求错误 (#1651) 2023-10-03 23:40:05 +08:00
zR
e88d926bbb
修改部分错误的文档,加长了历史记录(for 32k Models) (#1630)
* 更新上agent提示词代码 (#1626)

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

* 更新上agent提示词代码

* 按需修改
2023-09-29 20:19:31 +08:00
zR
77d38db00e
修改部分错误的文档,加长了历史记录(for 32k Models) (#1629)
* 更新上agent提示词代码

* 更新部分文档,修复了issue中提到的bge匹配超过1 的bug

* 按需修改
2023-09-29 20:17:29 +08:00
liunux4odoo
eb6f5cf84b
fix: embedding_model_dict used for bge-* models (#1628)
change to use `get_model_path`
2023-09-29 18:57:15 +08:00
zR
b11d6ab5bb
更新上agent提示词代码 (#1626) (#1627) 2023-09-29 18:47:11 +08:00
zR
61c4000859
更新上agent提示词代码 (#1626) 2023-09-29 18:45:50 +08:00
zR
b077085fbe Merge branch 'dev' 2023-09-29 16:44:10 +08:00
zR
d9056a8df6
python3.8用户需要加上__future__ (#1624)
* 增加了仅限GPT4的agent功能,陆续补充,中文版readme已写

* issue提到的一个bug

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

* 修改了最小的温度

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

* 修改了GPU数量配置文件

* 1

1

* 修复配置文件错误

* 更新readme,稳定测试

* 更新readme

* python3.8用户需要加这两行
2023-09-29 16:04:44 +08:00
Zhi-guo Huang
6b1e13a4e2
Merge pull request #1623 from hzg0601/dev
1. 增加baichuan-api支持;2.增加批量复制configs下.example文件为.py文件的脚本copy_config_example.py
2023-09-29 13:19:44 +08:00
hzg0601
00745c99e2 update baichuan.py 2023-09-29 13:19:17 +08:00
hzg0601
0e20552083 1. 增加baichuan-api支持;2.增加批量复制configs下.example文件为.py文件的脚本copy_config_example.py;3. 更新model_config.py.example 2023-09-29 13:16:14 +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
30b8daecb3 fix readme 2023-09-28 23:21:35 +08:00
zR
1b312d5715
更改readme 0928 (#1619)
* 增加了仅限GPT4的agent功能,陆续补充,中文版readme已写

* issue提到的一个bug

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

* 修改了最小的温度

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

* 修改了GPU数量配置文件

* 1

1

* 修复配置文件错误

* 更新readme,稳定测试

* 更新readme
2023-09-28 23:09:21 +08:00
zR
efd8edda16
Dev (#1618)
* 增加了仅限GPT4的agent功能,陆续补充,中文版readme已写

* issue提到的一个bug

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

* 修改了最小的温度

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

* 修改了GPU数量配置文件

* 1

1

* 修复配置文件错误

* 更新readme,稳定测试
2023-09-28 20:19:26 +08:00
WilliamChen-luckbob
8fa99026c8
根据官方文档,添加对英文版的bge embedding的指示模板 (#1585)
Co-authored-by: zR <2448370773@qq.com>
2023-09-28 19:18:31 +08:00
imClumsyPanda
db169f628c
Update README.md 2023-09-28 16:00:01 +08:00
imClumsyPanda
0641ce5db4
Add files via upload 2023-09-28 15:59:25 +08:00
liunux4odoo
b3c7f8b072
修复webui中重建知识库以及对话界面UI错误 (#1615)
* 修复bug:webui点重建知识库时,如果存在不支持的文件会导致整个接口错误;migrate中没有导入CHUNK_SIZE

* 修复:webui对话界面的expander一直为running状态;简化历史消息获取方法
2023-09-28 15:12:03 +08:00
liunux4odoo
8d0f8a5d67 fix: langchain warnings for import from root 2023-09-27 21:55:02 +08:00
liunux4odoo
523764e284 fix: set vllm based on platform to avoid error on windows 2023-09-27 21:43:54 +08:00
zR
d39878ff35
Dev (#1613)
* 增加了仅限GPT4的agent功能,陆续补充,中文版readme已写

* issue提到的一个bug

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

* 修改了最小的温度
2023-09-27 21:17:50 +08:00
zR
5702554171
增加了仅限GPT4的agent功能,陆续补充,中文版readme已写 (#1611) 2023-09-27 19:19:25 +08:00
Zhi-guo Huang
c546b4271e
Merge pull request #1603 from hzg0601/dev
1. 更新congif中关于vllm后端相关说明;2. 更新requirements,requirements_api;
2023-09-26 21:57:03 +08:00
hzg0601
2716ff739d 1. 更新congif中关于vllm后端相关说明;2. 更新requirements,requirements_api; 2023-09-26 21:55:57 +08:00
Zhi-guo Huang
56d75af824
Merge pull request #1582 from chatchat-space/fschat_vllm
支持vllm推理后端
2023-09-24 13:28:32 +08:00
Zhi-guo Huang
9cbd9f6711
Merge pull request #1581 from hzg0601/dev
测试vllm推理框架成功
2023-09-24 02:08:44 +08:00
hzg0601
2d823aa4b1 1. debug vllm加速框架完毕;2. 修改requirements,requirements_api对vllm的依赖;3.注释掉serve_config中baichuan-7b的device为cpu的配置 2023-09-24 02:05:40 +08:00
imClumsyPanda
af46ed9539
Update README.md 2023-09-23 08:35:13 +08:00
imClumsyPanda
39337a6603
Add files via upload 2023-09-23 08:34:50 +08:00
Zhi-guo Huang
3309b5c0c1
Merge pull request #1574 from hzg0601/dev
支持vllm模型;根据vllm模型更新支持模型列表
2023-09-23 01:49:04 +08:00
hzg0601
3a6d166e17 Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-09-23 01:46:52 +08:00
hzg0601
f4da0845b9 更新文件:1. startup,model_config.py.example,serve_config.py.example,FAQ 2023-09-23 01:38:54 +08:00
hzg0601
810145c5fb 新增特性:1.支持vllm推理加速框架;2. 更新支持模型列表 2023-09-23 01:37:37 +08:00
Zhi-guo Huang
192fbee1fb
Merge pull request #1568 from hzg0601/dev
update readme_en,readme,requirements_api,requirements,model_config.py…
2023-09-22 14:35:06 +08:00
hzg0601
89aed8e675 update readme_en,readme,requirements_api,requirements,model_config.py.example:测试baichuan2-7b;更新相关文档 2023-09-22 14:30:28 +08:00
imClumsyPanda
f3042a6a29 merge master 2023-09-22 12:36:45 +08:00
imClumsyPanda
171300c513 update QR code 2023-09-22 12:24:31 +08:00
liunux4odoo
e4a927c5d1
将所有httpx请求改为使用Client,提高效率,方便以后设置代理等。 (#1554)
将所有httpx请求改为使用Client,提高效率,方便以后设置代理等。

将本项目相关服务加入无代理列表,避免fastchat的服务器请求错误。(windows下无效)
2023-09-21 15:19:51 +08:00
peterz3g
3ff130ecc2
修复csv文件解析编码报错的问题。 (#1508) 2023-09-21 14:41:49 +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
0586f94c5a summary_chunk 文档分段总结业务实现
使用 MapReduceDocumentsChain 生成摘要
2023-09-20 23:55:56 +08:00
liunux4odoo
92359fb6b9 remove depends on volcengine 2023-09-20 23:02:43 +08:00
imClumsyPanda
6a0a791c80
Update README.md 2023-09-20 22:42:46 +08:00
glide-the
bd0164ea62 处理序列化至磁盘的逻辑 2023-09-20 21:35:23 +08:00
Leego
9bcce0a572
【功能新增】在线 LLM 模型支持阿里云通义千问 (#1534)
* feat: add qwen-api

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

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

---------

Co-authored-by: liunux4odoo <liunux@qq.com>
2023-09-20 21:34:12 +08:00
liunux4odoo
b161985d79 fix #1519: streamlit-chatbox旧版BUG,但新版有兼容问题,先在webui中作处理,并限定chatbox版本 (#1525)
close #1519
2023-09-20 16:47:07 +08:00
imClumsyPanda
be22869c5e Update README.md 2023-09-20 16:46:32 +08:00
Jim Zhang
cb2b560a5b fix : Duplicate variable and function name (#1509)
Co-authored-by: Jim <zhangpengyi@taijihuabao.com>
2023-09-20 16:46:31 +08:00
Water Zheng
a580cbddab fix ReadMe anchor link (#1500) 2023-09-20 16:46:31 +08:00
lehug
b6c390777a
fix argument name in help text (#1532) 2023-09-20 10:38:50 +08:00
imClumsyPanda
30e72ebc3f
Update README.md 2023-09-20 08:26:48 +08:00
imClumsyPanda
3cd73ef11e
Add files via upload 2023-09-20 08:26:26 +08:00
Orion
e07bbf6efb
Add: standard python ignore files (#1530) 2023-09-19 18:04:34 +08:00
liunux4odoo
6c4598b356
fix #1519: streamlit-chatbox旧版BUG,但新版有兼容问题,先在webui中作处理,并限定chatbox版本 (#1525)
close #1519
2023-09-19 10:09:40 +08:00
liunux4odoo
46af5b7571
fix: llm_model_dict with xxx/xxx local_model_path was parsed as online-api (#1513) 2023-09-18 12:10:03 +08:00
imClumsyPanda
1ec63de968
Update README.md 2023-09-18 12:02:42 +08:00
Jim Zhang
59fb309ba4
fix : Duplicate variable and function name (#1509)
Co-authored-by: Jim <zhangpengyi@taijihuabao.com>
2023-09-18 11:00:04 +08:00
liunux4odoo
1bae930691
修复faiss_pool知识库缓存key错误 (#1507) 2023-09-17 16:31:44 +08:00
liunux4odoo
ec85cd1954
move wrap_done & get_ChatOpenAI from server.chat.utils to server.utils (#1506) 2023-09-17 16:19:50 +08:00
glide-the
7d31e84cc7 langchain日志开关 2023-09-17 14:18:22 +08:00
liunux4odoo
bb7ce601fc 1. 搜索引擎问答支持历史记录;
2. 修复知识库问答历史记录传参错误:用户输入被传入history,问题出在webui中重复获取历史消息,api知识库对话接口并无问题。
2023-09-17 13:58:57 +08:00
glide-the
902ba0c321 增加传入矢量名称加载 2023-09-17 13:56:18 +08:00
glide-the
175c90c362 增加其它模型的参数适配 2023-09-17 13:56:08 +08:00
liunux4odoo
a65bc4a63c
添加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参数
2023-09-17 13:27:11 +08:00
zR
598eb298df
第一版初步agent实现 (#1503)
* 第一版初步agent实现

* 增加steaming参数

* 修改了weather.py

---------

Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-09-17 11:19:16 +08:00
qiankunli
13cca9cf81
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>
2023-09-17 00:53:12 +08:00
liunux4odoo
7577bd52ce Merge branch 'pr1501' into dev 2023-09-17 00:30:24 +08:00
liunux4odoo
9a7beef270 使火山方舟正常工作,添加错误处理和测试用例 2023-09-17 00:21:13 +08:00
liunux4odoo
745a105bae feat: support volc fangzhou 2023-09-16 22:21:16 +08:00
Water Zheng
7eed50337d
fix ReadMe anchor link (#1500) 2023-09-16 19:26:29 +08:00
liunux4odoo
42d76aabdf
Update model_config.py.example: wrong provider for qianfan-api (#1499) 2023-09-16 11:19:22 +08:00
liunux4odoo
c8d8727783
更新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方法
2023-09-16 09:09:27 +08:00
liunux4odoo
3dde02be28
优化LLM模型列表获取、切换的逻辑: (#1497)
1、更准确的获取未运行的可用模型
2、优化WEBUI模型列表显示与切换的控制逻辑
2023-09-16 07:15:08 +08:00
liunux4odoo
955b0bc211
修复ChatGPT api_base_url错误;用户可以在model_config在线模型配置中覆盖默认的api_base_url (#1496) 2023-09-15 22:56:13 +08:00
liunux4odoo
80375e1ff3
fix merge conflict for #1474 (#1494) 2023-09-15 18:11:15 +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
imClumsyPanda
456229c13f update README.md and README_en.md 2023-09-15 14:18:35 +08:00
imClumsyPanda
b2d86bf3f8 Merge branch 'master' into pre-release 2023-09-15 13:53:34 +08:00
imClumsyPanda
fc78004ab3 update qr code 2023-09-15 13:53:07 +08:00
imClumsyPanda
42fba7ef90 Merge branch 'dev' into pre-release 2023-09-15 13:47:25 +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
63f0d27167
在readme中添加支持的在线API模型 (#1485) 2023-09-15 10:16:15 +08:00
imClumsyPanda
20eef45a58 update README.md 2023-09-15 09:53:58 +08:00
liunux4odoo
30aeec1c45
修改智谱API默认名称,给WEBUI设置主题 (#1484)
* 給WEBUI设置主题

* chatglm-api更名为zhipu-api
2023-09-15 01:48:02 +08:00
liunux4odoo
f0f1dc2537 补充更多千帆平台支持的模型;除了指定模型名称,支持直接指定模型APIURL,便于填写单独申请的模型地址 2023-09-15 00:30:18 +08:00
liunux4odoo
4cf2e5ea5e 修复文心一言,添加测试用例 2023-09-14 23:37:34 +08:00
imClumsyPanda
fbaca1009e update requirements.txt, requirements_api.txt, test_different_splitter.py and chinese_recursive_text_splitter.py 2023-09-14 22:59:05 +08:00
imClumsyPanda
1813814a65 update model_config.py.example 2023-09-14 22:29:49 +08:00
imClumsyPanda
4c61a642cf update model_config.py.example 2023-09-14 22:29:26 +08:00
imClumsyPanda
bda1b01a2d update model_config.py.example 2023-09-14 22:27:57 +08:00
imClumsyPanda
17985c7f8e update splitter.md 2023-09-14 22:24:58 +08:00
Zhi-guo Huang
3745b1d1bb
Merge pull request #1479 from hzg0601/dev
update readme,readme_en:更新fastchat信息;删除订阅号二维码
2023-09-14 17:01:35 +08:00
hzg0601
6b734ced56 update readme,readme_en:更新fastchat信息;删除订阅号二维码 2023-09-14 17:00:20 +08:00
imClumsyPanda
883445e5b2
增加 百度文心一言 API 接入支持 (#1477)
* add RapidOCRPDFLoader

* update mypdfloader.py and requirements.txt

* add myimgloader.py

* add test samples

* add TODO to mypdfloader

* add loaders to KnowledgeFile class

* add loaders to KnowledgeFile class

* add ChineseRecursiveTextSplitter

* add ChineseRecursiveTextSplitter

* add baidu ernie api
2023-09-14 15:30:06 +08:00
唐国梁
4c5fc6ab01 edit model_config.py.example 2023-09-14 12:38:37 +08:00
唐国梁
6ad8aee88c add ES function 2023-09-14 07:54:42 +08:00
zR
769d75d784
修复测试文件 (#1467)
Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-09-13 17:12:05 +08:00
imClumsyPanda
dc413120e2 update text splitter unit test name 2023-09-13 15:53:07 +08:00
imClumsyPanda
f75812afcb update text splitter unit test name 2023-09-13 15:47:34 +08:00
zR
bfdbe69fa1
增加了自定义分词器适配 (#1462)
* 添加了自定义分词器适配和测试文件
---------

Co-authored-by: zR <zRzRzRzRzRzRzR>
2023-09-13 15:42:12 +08:00
liunux4odoo
c4cb4e19e5
清理不必要的依赖,增加星火API需要的websockets (#1463) 2023-09-13 15:35:04 +08:00
liunux4odoo
99b862dfc8 fix SparkApi import error 2023-09-13 14:03:09 +08:00
liunux4odoo
512638a3b1
支持讯飞星火大模型在线API (#1460)
* 支持讯飞星火大模型在线API
2023-09-13 13:51:05 +08:00
liunux4odoo
16d8809c9a
api和webui知识库操作支持chunk_size/overlap_size/zh_title_enhance参数 (#1459) 2023-09-13 11:19:47 +08:00
liunux4odoo
9defa4332e fix minimax api history error 2023-09-13 10:12:31 +08:00
liunux4odoo
f1f8ab80e4
Update close-issue.yml:提示改成中文,改到凌晨05:30运行 (#1456) 2023-09-13 10:06:54 +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
efd6d4a251
修复milvus_kb_service中一些bug,添加文档后将数据同步到数据库 (#1452) 2023-09-12 22:34:03 +08:00
imClumsyPanda
4aa14b859e
增加 ChineseRecursiveTextSplitter (#1447)
* add RapidOCRPDFLoader

* update mypdfloader.py and requirements.txt

* add myimgloader.py

* add test samples

* add TODO to mypdfloader

* add loaders to KnowledgeFile class

* add loaders to KnowledgeFile class

* add ChineseRecursiveTextSplitter

* add ChineseRecursiveTextSplitter
2023-09-12 17:38:52 +08:00
imClumsyPanda
1d0c6a9184 Merge branch 'master' into pre-release 2023-09-12 15:51:53 +08:00
imClumsyPanda
2020f5bb88 merge master 2023-09-12 15:51:28 +08:00
liunux4odoo
03c021d50f
添加MiniMax在线API支持 (#1445) 2023-09-12 15:24:47 +08:00
imClumsyPanda
8064586374 delete .doc from supported formats 2023-09-12 15:22:18 +08:00
liunux4odoo
8a12b9c658
添加自动关闭issue的action (#1437) 2023-09-12 10:16:19 +08:00
liunux4odoo
60f88ae92e
fix: 由于server.utils导入model_workers时,导入fastchat model_worker,导致startup启动延迟明显 (#1436) 2023-09-12 08:52:00 +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
imClumsyPanda
518d3c4951
Update README.md 2023-09-11 15:18:03 +08:00
imClumsyPanda
be621772ab
Add files via upload 2023-09-11 15:17:38 +08:00
Zhi-guo Huang
d0e654d847
Merge pull request #1422 from hzg0601/dev
update readme.md,readme_cn.md:更新订阅号QRcode
2023-09-09 17:36:10 +08:00
hzg0601
ed6df7cd24 update readme.md,readme_cn.md:更新订阅号QRcode 2023-09-09 17:34:56 +08:00
glide-the
b0a9d8f30e 增加显示ocr识别进度 2023-09-08 21:32:41 +08:00
glide-the
60e6887e94
Merge pull request #1419 from glide-the/dev
增加显示详细日志开关
2023-09-08 20:50:31 +08:00
glide-the
5550e3c1a9 增加显示详细日志开关 2023-09-08 20:48:31 +08:00
liunux4odoo
228fc5bd93 fix startup.py: correct processes count 2023-09-08 15:24:43 +08:00
liunux4odoo
f082edbaad fix startup.py: correct processes count 2023-09-08 15:23:54 +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
Kyle Zhang
6e9a7e0c89
chore: update .gitignore (#1364)
Added '/' before knowledge_base/ and configs/*.py to make them match
directories at root folder only.

Signed-off-by: Kyle Zhang <zhangk1985@gmail.com>
Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-09-08 13:29:40 +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
roki1031
196bde3ead
提醒fitz包是来自pyMuPDF (#1407) 2023-09-08 12:20:20 +08:00
liunux4odoo
1195eb75eb merge pr1413 2023-09-08 10:30:07 +08:00
Zhi-guo Huang
f2aed727c2
Merge pull request #1412 from hzg0601/dev
update reamd_en.md:删除中文对照
2023-09-08 10:22:24 +08:00
liunux4odoo
4cfee9c17c 根据新的接口修改ApiRequest和webui,以及测试用例。修改后预期webui中批量知识文件相关操作减少时间 2023-09-08 10:22:04 +08:00
hzg0601
136b667683 update reamd_en.md:删除中文对照 2023-09-08 10:19:49 +08:00
Zhi-guo Huang
71a1ae0627
Merge pull request #1411 from hzg0601/dev
增加中英对照的reame_en.md, 更新readme.md
2023-09-08 10:01:57 +08:00
hzg0601
607831496b update readme.md 2023-09-08 09:54:11 +08:00
hzg0601
bf748eb732 add README_en.md: 增加中英对照的readme 2023-09-08 09:46:23 +08:00
hzg0601
10237d24ca update readme_cn.md 2023-09-08 09:32:33 +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
Light
f422575a17
修复chat接口报错时信息显示KeyError: 'answer'的Bug (#1399)
Co-authored-by: Light <>
2023-09-07 20:44:21 +08:00
hzg0601
80f00e27f9 update readme.md, add reame_en.md: 1. update supported models list;2. add readme_en.md 2023-09-07 16:27:12 +08:00
imClumsyPanda
6ea4fc7a30 Merge branch 'master' into dev 2023-09-06 21:19:59 +08:00
imClumsyPanda
9ed43ab2ab Merge branch 'master' into pre-release 2023-09-06 21:19:38 +08:00
imClumsyPanda
54cf79f521 add support for new embedding models sensenova/piccolo-base-zh and sensenova/piccolo-large-zh 2023-09-06 21:17:32 +08:00
imClumsyPanda
eeb152e22c Merge branch 'master' into dev 2023-09-06 20:09:53 +08:00
imClumsyPanda
59bdfd85ea Merge branch 'master' into pre-release 2023-09-06 20:09:36 +08:00
imClumsyPanda
f607424c11 fix pdf ocr bug 2023-09-06 20:09:18 +08:00
imClumsyPanda
673410ecd5 fix pdf ocr bug 2023-09-06 20:08:56 +08:00
imClumsyPanda
8ec3db94f7
Update README.md 2023-09-06 20:04:03 +08:00
imClumsyPanda
e9b25e3f14
Add files via upload 2023-09-06 20:03:41 +08:00
hzg0601
76c2c61bb2 update server.model_worker.zhipu.py:更新prompt,遵守zhipu的格式要求 2023-09-06 17:33:00 +08:00
hzg0601
5e4bd5c3d3 update server.model_worker.zhipu.py/base.py:增加流式响应 2023-09-06 11:16:16 +08:00
jinke
bc0a39ab82 update docker desc
更新0.2.3 docker
2023-09-06 10:23:34 +08:00
hzg0601
6f039cfdeb update server.model_workers.base.py/zhipu.py: 支持zhipuapi的stream 流式输出 2023-09-05 23:13:42 +08:00
imClumsyPanda
0ea18314f2 fix unit test name 2023-09-05 21:08:02 +08:00
glide-the
082f429809
Merge pull request #1382 from glide-the/dev
增加构建文档metadata检索的开关,移动到dev_metadata_search
2023-09-05 21:02:18 +08:00
imClumsyPanda
5f533570a1 Merge branch 'pre-release' into dev 2023-09-05 21:01:45 +08:00
imClumsyPanda
6702f39db1 update knowledge_base page 2023-09-05 21:01:40 +08:00
imClumsyPanda
afd02317bd Merge branch 'master' into pre-release 2023-09-05 21:00:58 +08:00
imClumsyPanda
629e0278d5 update knowledge_base page 2023-09-05 21:00:35 +08:00
glide-the
1027ab6c06 增加构建文档metadata检索的开关,移动到dev_metadata_search 2023-09-05 20:59:57 +08:00
glide-the
b9ce09cbab
Merge pull request #1380 from glide-the/dev
增加构建文档metadata检索的开关
2023-09-05 18:36:42 +08:00
glide-the
491c9605d9 增加构建文档metadata检索的开关 2023-09-05 18:35:11 +08:00
imClumsyPanda
c26d66772a Merge branch 'pre-release' into dev 2023-09-05 18:19:21 +08:00
imClumsyPanda
e23e27a9f2 update autodl version 2023-09-05 18:19:13 +08:00
imClumsyPanda
74cca5eb0e add support for shibing624/text2vec-bge-large-chinese 2023-09-05 18:19:13 +08:00
imClumsyPanda
fdfbf31318 fix streamlit-aggrid showing "For Trial Use Only" 2023-09-05 18:19:13 +08:00
imClumsyPanda
33cbfb72b4 Merge branch 'master' into pre-release 2023-09-05 18:17:31 +08:00
imClumsyPanda
75f1e84b1f update autodl version 2023-09-05 18:15:43 +08:00
imClumsyPanda
780c1457d0 add support for shibing624/text2vec-bge-large-chinese 2023-09-05 18:04:21 +08:00
imClumsyPanda
c24e00a386 fix streamlit-aggrid showing "For Trial Use Only" 2023-09-05 17:30:58 +08:00
glide-the
0b60a25f2a 知识库默认存储路径 默认自动创建 2023-09-05 17:27:43 +08:00
imClumsyPanda
3a706907ff Merge branch 'pre-release' into dev 2023-09-05 14:50:06 +08:00
imClumsyPanda
30c00ffac6 Merge branch 'master' into pre-release 2023-09-05 14:47:28 +08:00
imClumsyPanda
9da7313e7e update requirements.txt 2023-09-05 14:46:26 +08:00
imClumsyPanda
220b1bd9ae update requirements.txt 2023-09-05 13:41:08 +08:00
liunux4odoo
3e87530478 使zhipuai变为非必要依赖(close #1369) 2023-09-05 12:43:51 +08:00
liunux4odoo
464ccc6d53 Update migrate.py (#1371)
fix bug at line 85 : for kb_file in kb_file
2023-09-05 11:52:22 +08:00
TongTie
98e4fbaaa3 docs: Correcting a spelling mistake in README (#1367)
Co-authored-by: tongtie <tongtie@gmail.com>
2023-09-05 11:52:22 +08:00
liunux4odoo
015ce57691
Update migrate.py (#1371)
fix bug at line 85 : for kb_file in kb_file
2023-09-05 11:47:25 +08:00
TongTie
53d3fbc335
docs: Correcting a spelling mistake in README (#1367)
Co-authored-by: tongtie <tongtie@gmail.com>
2023-09-05 11:10:14 +08:00
imClumsyPanda
8ea75417ec update VERSION 2023-09-05 10:20:59 +08:00
imClumsyPanda
d1b4dea2ca update VERSION 2023-09-05 10:19:14 +08:00
imClumsyPanda
44262da4e5 Merge branch 'dev' into pre-release 2023-09-05 10:02:37 +08:00
imClumsyPanda
3a7c1f2744 Merge branch 'master' into dev 2023-09-05 09:57:02 +08:00
imClumsyPanda
62aa17b9a4 clean up qr_code 2023-09-05 09:56:51 +08:00
liunux4odoo
053ebb82bf update startup.py:
1. controller改为自动等待
2. 修复:分部分启动时进程引用错误
2023-09-05 09:55:13 +08:00
imClumsyPanda
2275b1d84a fix place_holder mistake 2023-09-05 09:53:58 +08:00
imClumsyPanda
15619a1270 update model_config.py.example 2023-09-05 08:59:06 +08:00
glide-the
35f2c04535 启动进程放入 try catch 保证任务收到SIGINT后,能够正常退出 2023-09-04 23:03:56 +08:00
glide-the
aa4a5ad224 CTRL-C exit with Python multiprocessing 2023-09-04 22:46:46 +08:00
liunux4odoo
93b133f9ac 将KnowledgeFile的file2text拆分成file2docs、docs2texts和file2text三个部分,在保持接口不变的情况下,实现:
1、支持chunk_size和chunk_overlap参数
2、支持自定义text_splitter
3、支持自定义docs
修复:csv文件不使用text_splitter
2023-09-04 21:00:16 +08:00
Zhi-guo Huang
df23349584
Merge pull request #1361 from hzg0601/dev
update readme.md:1. 更改一键启动说明的顺序;2. 在一键启动中增加多卡启动的说明;3. 增加多卡启动gpus参数不生效的说明
2023-09-04 19:27:44 +08:00
hzg0601
8dce5f7e7c update readme.md:增加多卡启动gpus参数不生效的说明 2023-09-04 19:26:35 +08:00
hzg0601
b82ef5dcea update readme.md:1. 更改一键启动说明的顺序;2. 在一键启动中增加多卡启动的说明 2023-09-04 19:25:57 +08:00
zqt
e21ca447af milvus/pg kb_service需要实现get_doc_by_id方法 2023-09-04 16:40:05 +08:00
liunux4odoo
8475a5dfd3
Merge branch 'chatchat-space:dev' into dev 2023-09-04 14:44:55 +08:00
imClumsyPanda
38e7c8299c
Update README.md 2023-09-04 10:29:30 +08:00
imClumsyPanda
857e689b8c
Add files via upload 2023-09-04 10:28:50 +08:00
liunux4odoo
0bc9d5c8ee
Merge branch 'dev' into opt_add_doc 2023-09-03 21:38:45 +08:00
imClumsyPanda
27e9ac57cf Merge branch 'master' into dev 2023-09-03 16:23:57 +08:00
imClumsyPanda
e2354c215b clean up qr_code 2023-09-03 16:23:37 +08:00
imClumsyPanda
a9035205ff Merge branch 'master' into dev 2023-09-03 16:22:08 +08:00
imClumsyPanda
4fae7d4884 add unit test for RapidOCRLoader and RapidOCRPDFLoader 2023-09-03 16:13:37 +08:00
imClumsyPanda
8a73673d6b update model_config.py.example 2023-09-03 15:57:44 +08:00
imClumsyPanda
9855bc6f55 update model_config.py.example 2023-09-03 15:52:17 +08:00
imClumsyPanda
25880ebd52 fix bug when config["device"]="auto" 2023-09-02 22:11:54 +08:00
glide-the
3de9b2649c 协程兼容python版本 2023-09-02 19:29:24 +08:00
glide-the
d7c884e34a 注册器未启动时,整个启动链因为异常被终止
使用await asyncio.sleep(3)可以让后续代码等待一段时间,但不是最优解
2023-09-02 19:20:41 +08:00
imClumsyPanda
3391155077 update model_config.py.example 2023-09-02 15:33:57 +08:00
glide-the
3a660d4f74 TODO 2023-09-02 01:10:04 +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
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
96770cca53
Merge branch 'chatchat-space:dev' into dev 2023-09-01 21:01:29 +08:00
zqt
ab4c8d2e5d Merge remote-tracking branch 'origin/dev' into dev 2023-09-01 18:10:32 +08:00
zqt
9b664d5eb2 添加例子例子"openai_proxy": 'http://127.0.0.1:4780' 2023-09-01 18:09:59 +08:00
liunux4odoo
1db8a07765
Merge branch 'chatchat-space:dev' into dev 2023-09-01 14:37:32 +08:00
imClumsyPanda
d6dce95682 bug fix 2023-09-01 14:15:13 +08:00
liunux4odoo
427646ff36
Merge branch 'chatchat-space:dev' into dev 2023-09-01 13:57:23 +08:00
imClumsyPanda
6c4ef26e9a
add RapidOCRPDFLoader and RapidOCRLoader (#1275)
* add RapidOCRPDFLoader

* update mypdfloader.py and requirements.txt

* add myimgloader.py

* add test samples

* add TODO to mypdfloader

* add loaders to KnowledgeFile class

* add loaders to KnowledgeFile class
2023-09-01 10:23:57 +08:00
liunux4odoo
72b9da2649
startup.py增加参数-q | quiet,可以过滤fastchat的controller/model_worker不必要的日志输出 (#1333)
* startup.py增加参数`-q | quiet`,可以过滤fastchat的controller/model_worker不必要的日志输出
2023-08-31 22:55:07 +08:00
liunux4odoo
c54ee8c289 startup.py增加参数-q | quiet,可以过滤fastchat的controller/model_worker不必要的日志输出 2023-08-31 22:51:51 +08:00
liunux4odoo
ab70f5582d
Merge branch 'chatchat-space:dev' into dev 2023-08-31 22:51:30 +08:00
liunux4odoo
b1201a5f23
优化LLM和Embedding模型运行设备配置,可设为auto自动检测;修复:重建知识库时FAISS未保存 (#1330)
* 避免configs对torch的依赖;
* webui自动从configs获取api地址(close #1319)
* bug fix: 重建知识库时FAISS未保存
* 优化LLM和Embedding模型运行设备配置,可设为auto自动检测
2023-08-31 17:44:48 +08:00
liunux4odoo
16fb19d2c3 优化LLM和Embedding模型运行设备配置,可设为auto自动检测 2023-08-31 17:41:09 +08:00
liunux4odoo
80590ef5dc bug fix: faiss vector store not saved when recreate 2023-08-31 17:34:22 +08:00
liunux4odoo
4bdfb6e154
Merge branch 'chatchat-space:dev' into dev 2023-08-31 17:34:10 +08:00
liunux4odoo
26a9237237
避免configs对torch的依赖;webui自动从configs获取api地址(close #1319) (#1328) 2023-08-31 16:18:12 +08:00
liunux4odoo
4e73e561fd 避免configs对torch的依赖;webui自动从configs获取api地址(close #1319) 2023-08-31 16:08:16 +08:00
imClumsyPanda
a5ee38511d
Update README.md 2023-08-30 15:58:47 +08:00
imClumsyPanda
b8831b6d91
Add files via upload 2023-08-30 15:57:29 +08:00
zqt
215bc25f5c 添加知识库使用的向量库测试用例 2023-08-29 15:01:26 +08:00
miraged3
17c842df43
改正文本错误 (#1296) 2023-08-29 11:30:25 +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
ca0ae29fef
运行startup.py时,如果不加参数直接显示配置和帮助信息后退出 (#1284)
* 统一XX_kb_service.add_doc/do_add_doc接口,不再需要embeddings参数

* 运行startup.py时,如果不加参数直接显示配置和帮助信息后退出

---------

Co-authored-by: liunux4odoo <liunu@qq.com>
2023-08-28 16:03:53 +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
imClumsyPanda
3eb3b7cbaa
Update README.md 2023-08-28 09:11:51 +08:00
imClumsyPanda
9369a6031b
Add files via upload 2023-08-28 09:11:28 +08:00
imClumsyPanda
89e3e9a691 Merge remote-tracking branch 'origin/dev' into dev 2023-08-27 20:23:19 +08:00
imClumsyPanda
8faafa6a32 update format 2023-08-27 20:23:07 +08:00
liunux4odoo
6ef8844b2b
修复使用chatgpt等在线API服务时模型加载错误 (#1271)
* close #1172: 给webui_page/utils添加一些log信息,方便定位错误

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

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

---------

Co-authored-by: liunux4odoo <liunu@qq.com>
2023-08-27 16:46:59 +08:00
imClumsyPanda
58d5787bdf Merge branch 'master' into dev 2023-08-27 16:03:14 +08:00
imClumsyPanda
1af8f89a49 Merge branch 'master' into pre-release 2023-08-27 16:02:57 +08:00
zqt
1fa4e906c7 适配score_threshold 2023-08-27 11:21:10 +08:00
zqt
ead2e26da1 Merge remote-tracking branch 'origin/dev' into dev 2023-08-27 10:32:02 +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
37985f29f0
Update requirements.txt 2023-08-26 13:35:47 +08:00
mz
78e79af68b
update INSTALL.md (#1250)
Co-authored-by: zzflybird <cmz1@qq.com>
2023-08-26 12:30:54 +08:00
zqt
7cbd8ee089 Merge remote-tracking branch 'origin/dev' into dev 2023-08-26 12:22:59 +08:00
imClumsyPanda
f95d41ef47 [BUG] 修复csv文件读取后,单行数据被分成多段。 2023-08-26 11:45:01 +08:00
imClumsyPanda
fea7e8ddf1 update VERSION 2023-08-26 11:10:45 +08:00
imClumsyPanda
32bf508745 update requirements 2023-08-25 22:53:49 +08:00
imClumsyPanda
ab5d1df2a3 update requirements 2023-08-25 22:16:49 +08:00
imClumsyPanda
ec5e5c9b2a Merge remote-tracking branch 'origin/master' 2023-08-25 22:15:12 +08:00
imClumsyPanda
2e930cf43c update requirements.txt 2023-08-25 22:14:56 +08:00
imClumsyPanda
021677d5d6
Update README.md 2023-08-25 18:04:06 +08:00
imClumsyPanda
79d225be36 update VERSION 2023-08-25 16:26:51 +08:00
imClumsyPanda
4dafca2376 Merge branch 'master' into pre-release 2023-08-25 16:25:35 +08:00
imClumsyPanda
aaa3e8133c Merge branch 'dev' into pre-release 2023-08-25 16:24:34 +08:00
hzg0601
faba1b3877 update readme.md, shutdown_all.sh: 在Linux上使用ctrl+C退出可能会由于linux的多进程机制导致multiprocessing遗留孤儿进程 2023-08-25 16:16:44 +08:00
hzg0601
c5e6d4ddf8 Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-25 15:45:38 +08:00
imClumsyPanda
33ce276e3e change default search_engine option to 'duckduckgo' 2023-08-25 15:18:43 +08:00
hzg0601
e68e155687 Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-25 14:47:31 +08:00
zqt
9550c8262e Merge branch 'master' into dev 2023-08-25 13:47:56 +08:00
zqt996
b07d1da90f
Merge pull request #1236 from Pickupppp/master
修复上次提交错误
2023-08-25 13:16:28 +08:00
hzg0601
cc0bd4efd9 update server_config.py.example: 增加多卡启动的说明 2023-08-25 11:27:39 +08:00
liunux4odoo
447b370416 在search_engine_chat中检查Bing KEY,并更新tests 2023-08-25 10:58:40 +08:00
hzg0601
999870c3a7 Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-25 09:43:46 +08:00
liunux4odoo
29738c071c update readme about startup.py 2023-08-25 08:19:58 +08:00
Pickupppp
0c63839ff6 修正 milvus 更改错误 2023-08-24 22:53:13 +08:00
zqt
2604341e9e 调整KBService 接口函数do_search 并适配pg 2023-08-24 22:35:30 +08:00
zqt
24e7351d32 Merge branch 'master' into dev 2023-08-24 22:31:37 +08:00
zqt996
67ac53242d
Merge pull request #1233 from Pickupppp/master
修复 milvus 作为默认数据库初始化异常和调用search方法异常
2023-08-24 22:28:38 +08:00
Meiracle
bc3dbb443e
修复搜索引擎聊天接口 (#1228)
* 修复搜索引擎聊天接口

* 修复知识库聊天接口

* 恢复
2023-08-24 22:18:33 +08:00
imClumsyPanda
659d017fd3 Merge branch 'master' into dev 2023-08-24 21:46:00 +08:00
imClumsyPanda
412a3ea9c8 Update README.md 2023-08-24 21:45:54 +08:00
imClumsyPanda
c9220ae9bf Add files via upload 2023-08-24 21:45:54 +08:00
imClumsyPanda
e995301995 Merge branch 'dev' into pre-release 2023-08-24 21:44:22 +08:00
imClumsyPanda
12cd7327f8 Merge branch 'master' into dev 2023-08-24 21:44:08 +08:00
Pickupppp
050a585a9d 修复 milvus 作为默认数据库初始化异常和调用search方法异常 2023-08-24 21:31:02 +08:00
zqt
2a2b95d214 search_engine_chat bug 2023-08-24 17:25:54 +08:00
liunux4odoo
63ca393731 参照chat,给knowledge_base_chat/search_engine_chat添加chatgpt代理设置 2023-08-24 15:10:51 +08:00
imClumsyPanda
50c6369f46
Update README.md 2023-08-24 14:25:19 +08:00
imClumsyPanda
a0437ba94f
Add files via upload 2023-08-24 14:24:44 +08:00
zqt
ea4b5ebd16 Merge branch 'master' into dev 2023-08-24 14:16:21 +08:00
zqt996
4180fdbbb8
Merge pull request #1221 from zqt996/master
添加chatgpt 调用代理设置
2023-08-24 13:54:34 +08:00
zqt
37454db3ec 添加chatgpt 调用代理设置 2023-08-24 13:51:17 +08:00
liunux4odoo
4899c3b3cc set max threads of numexpr to improve performance and ommit warnings 2023-08-24 11:04:30 +08:00
imClumsyPanda
3504cb5274 update model_config.py.example 2023-08-23 23:04:13 +08:00
zR
7291e77978
support for bge-large-zh-noinstruct and openai text-embedding-ada-002 (#1119)
* support for bge-large-zh-noinstruct and openai text-embedding-ada-002

* 完善了readme,修改了BGE模型的载入方式

* 补充了readme中bge-large-zh-noinstruct的信息

* Update faiss_kb_service.py

* Update utils.py

---------

Co-authored-by: zR <zRzRzRzRzRzRzR>
Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-08-23 22:55:53 +08:00
imClumsyPanda
4bcc74d214 update prompt template 2023-08-23 21:52:12 +08:00
liunux4odoo
351b62f7a7 fix part of #1206: add/delete/update_doc() get unexpected keyword argument 'not_refresh_vs_cache` 2023-08-23 15:26:52 +08:00
liunux4odoo
44edce6bcf fix #1142: 在History中使用jinja2模板代替f-string,避免消息中含有{ }时出错 2023-08-23 08:35:26 +08:00
Zhi-guo Huang
054ae4715d
Merge pull request #1203 from chatchat-space/hzg0601-patch-1
Update README.md:lora加载详细步骤参考
2023-08-22 23:57:51 +08:00
Zhi-guo Huang
42f6b2d1f6
Update README.md
lora加载详细步骤参考
2023-08-22 23:53:29 +08:00
zqt996
d79676cad1
Merge pull request #1199 from zqt996/master
修复pg和milvus kbservice代码
2023-08-22 16:53:39 +08:00
zqt
16542f20b4 修复pg和milvus kbservice代码 2023-08-22 16:52:04 +08:00
zqt996
cb29e1ed23
Merge pull request #1198 from chatchat-space/dev
pg similarity_search 转 similarity_search_with_score
2023-08-22 16:41:37 +08:00
zqt996
11856cc542
Merge pull request #1160 from shutter-cp/master
fix bug 1159
2023-08-22 16:38:06 +08:00
imClumsyPanda
2802e96b91
Update README.md 2023-08-22 11:29:18 +08:00
imClumsyPanda
01233ef1a1
Add files via upload 2023-08-22 11:28:54 +08:00
liunux4odoo
c82134c07b
Update utils.py: correct recreate_vector_store's timeout (#1181) 2023-08-21 18:01:59 +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
zqt996
71d0f7d965
Merge pull request #1171 from zqt996/master
添加向量库的QA
2023-08-20 18:10:26 +08:00
zqt996
8d5966e9e1
Merge branch 'chatchat-space:master' into master 2023-08-20 18:04:13 +08:00
zqt
b3450bfc96 添加milvus 和 pg QA说明 2023-08-20 18:03:23 +08:00
imClumsyPanda
cae0452f69 Merge branch 'master' into pre-release 2023-08-20 17:55:29 +08:00
imClumsyPanda
7bd644701c Merge branch 'master' into dev 2023-08-20 17:55:12 +08:00
imClumsyPanda
1996db9e4d update bug_report template 2023-08-20 17:54:19 +08:00
imClumsyPanda
56fdc02030 Merge branch 'master' into pre-release 2023-08-20 17:31:58 +08:00
imClumsyPanda
b05f7b758e Merge branch 'master' into dev 2023-08-20 17:30:47 +08:00
imClumsyPanda
adbee9f777 fix add_argument fault in startup.py 2023-08-20 17:30:39 +08:00
imClumsyPanda
f0bcb3105a update langchain version requirements 2023-08-20 17:30:39 +08:00
imClumsyPanda
2e1396a2d5 fix add_argument fault in startup.py 2023-08-20 17:29:50 +08:00
imClumsyPanda
fd5988422e update langchain version requirements 2023-08-20 16:52:56 +08:00
liunux4odoo
150a78bfd9 update kb_doc_api:make faiss cache working; delete vector store docs before add duplicate docs 2023-08-20 16:52:49 +08:00
imClumsyPanda
cb3fe84fe3 update VERSION 2023-08-20 10:41:28 +08:00
imClumsyPanda
d694652b87 update VERSION 2023-08-20 10:40:31 +08:00
imClumsyPanda
62aa97bb32 Merge branch 'master' into dev 2023-08-20 10:39:30 +08:00
imClumsyPanda
cdea240c31 update README.md and llm_api_stale.py 2023-08-20 10:38:41 +08:00
liunux4odoo
956237feac add api tests 2023-08-19 15:19:01 +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
62d6f44b28 fix startup.py 2023-08-18 21:30:50 +08:00
imClumsyPanda
523aed015c
Update README.md 2023-08-18 19:46:16 +08:00
imClumsyPanda
2bf9d0d812
Add files via upload 2023-08-18 19:45:45 +08:00
liunux4odoo
fe9f2df17d fix startup.py: correct command help info 2023-08-18 16:46:59 +08:00
陈鹏
95d9fb0ee9
fix bug 1159
修复使用使用pg存储向量时,向量检索错误 {TypeError}TypeError("'Document' object is not subscriptable")
2023-08-18 14:41:11 +08:00
liunux4odoo
d4cf77170a fix webui: correct error messages 2023-08-18 11:47:49 +08:00
liunux4odoo
c3627de005 fix startup.py: add log info before server starting 2023-08-18 08:48:02 +08:00
imClumsyPanda
adb102f5f0 update VERSION 2023-08-17 22:32:42 +08:00
imClumsyPanda
4fb2e2198b merge dev_allinone 2023-08-17 22:29:26 +08:00
imClumsyPanda
d9f74ec061 update README.md 2023-08-17 22:26:41 +08:00
imClumsyPanda
67839daad3 reformat and add version to startup.py 2023-08-17 22:22:28 +08:00
imClumsyPanda
52837429d2 update configs.__init__, webui.py and api.py 2023-08-17 22:19:37 +08:00
liunux4odoo
4278d1e000 fix startup.py 2023-08-17 21:57:13 +08:00
imClumsyPanda
5ec512801f update configs.__init__ 2023-08-17 21:51:21 +08:00
liunux4odoo
f8229fc4a9 update server_config example 2023-08-17 21:50:36 +08:00
imClumsyPanda
8b3b869418 update README.md 2023-08-17 21:44:30 +08:00
imClumsyPanda
7f7238168c reformat model_config.py.example 2023-08-17 21:31:30 +08:00
imClumsyPanda
4318197ac7 reformat server_config.py.example 2023-08-17 21:30:40 +08:00
imClumsyPanda
0ecf3379b4 add descriptions about server_config in README.md 2023-08-17 21:29:16 +08:00
imClumsyPanda
a97cf021a9 Merge branch 'pre-release' into dev 2023-08-17 21:23:07 +08:00
imClumsyPanda
7b7981facc Merge branch 'master' into pre-release 2023-08-17 21:20:33 +08:00
imClumsyPanda
d430ec2be1 Update README.md 2023-08-17 21:09:05 +08:00
imClumsyPanda
3f0c5727ca Add files via upload 2023-08-17 21:09:05 +08:00
Ikko Eltociear Ashimine
c792e770e8 Fix typo in README.md
--model-path-addresss -> --model-path-address
2023-08-17 21:09:05 +08:00
xain
6d1ea9bc99 Update utils.py (#1128)
不区分文件扩展名的大小写。
2023-08-17 21:09:05 +08:00
liunux4odoo
d4c6a23a8d log server informations after startup 2023-08-17 20:02:28 +08:00
hzg0601
0830f0d3b7 update readme: 更新startup启动方式说明 2023-08-17 17:17:06 +08:00
hzg0601
44d4bacf1c update llm_api_launch,api_allinone,webui_allinone,readme:1.llm_api_launch,api_allinone_webui_allinone更名;2. 更新readme关于startup的说明 2023-08-17 16:59:16 +08:00
liunux4odoo
6c9e3ddc21 make webui started at last 2023-08-17 14:22:19 +08:00
liunux4odoo
7dfc337bfa add controller parameter. used to run model-worker 2023-08-17 14:11:21 +08:00
hzg0601
f1251454b1 Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-17 13:40:55 +08:00
liunux4odoo
f92b002342 add startup.py: start specified servers with one command. see python startup.py --help 2023-08-17 13:24:53 +08:00
Zhi-guo Huang
f29a877bd0
Merge pull request #1137 from gaoyuanzero/dev
Update README.md
2023-08-17 10:49:14 +08:00
gaoyuanzero
a87fa10213
Update README.md
fastchat以hugggingface的PEFT包加载精调模型,不仅仅支持LoRA,还支持P-tuing, prefix-tuning, IA3等精调模型,故文档中的LoRA应统一改为PEFT
2023-08-17 10:43:46 +08:00
Zhi-guo Huang
0d763cd2bc
Merge pull request #1135 from bones-zhu/dev
Update README.md
2023-08-17 10:38:04 +08:00
bones-zhu
4f8d65555f
Update README.md
更新端口占用情况下shell脚本启动方式的方法
2023-08-17 10:34:35 +08:00
Zhi-guo Huang
c4208b351c
Merge pull request #1133 from chinainfant/dev
Update README.md
2023-08-17 10:23:10 +08:00
chinainfant
87eecf56bd
Update README.md
fix typo
2023-08-17 10:21:51 +08:00
Zhi-guo Huang
2aca635b3f
Merge pull request #1132 from gaoyuanzero/dev
Update README.md
2023-08-17 10:06:48 +08:00
gaoyuanzero
a0ba4689fe
Update README.md
readme一键启动适用脚本说明修改
2023-08-17 10:05:52 +08:00
imClumsyPanda
7ef032bcf4
Update README.md 2023-08-17 09:57:10 +08:00
imClumsyPanda
3e8eec2e19
Add files via upload 2023-08-17 09:56:48 +08:00
Zhi-guo Huang
e4c5ea5924
Merge pull request #1131 from eltociear/eltociear-patch-1
Fix typo in README.md
2023-08-17 09:29:07 +08:00
Ikko Eltociear Ashimine
bef36608e0
Fix typo in README.md
--model-path-addresss -> --model-path-address
2023-08-17 00:33:58 +09:00
imClumsyPanda
9bf0883587 update webui_allinone.py format 2023-08-16 23:31:07 +08:00
hzg0601
7cca0e2a72 Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-16 23:00:32 +08:00
hzg0601
1e12944a5d 更新shutdown_all.sh:更新mac设备的额外说明 2023-08-16 22:58:59 +08:00
xain
7cd7ca240b
Update utils.py (#1128)
不区分文件扩展名的大小写。
2023-08-16 22:40:05 +08:00
imClumsyPanda
38aea8fd9b update README.md 2023-08-16 22:38:34 +08:00
hzg0601
832c261cdf Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-16 22:26:27 +08:00
hzg0601
1a40d464be 更新model_config.py.example: 更改所有模型的默认端口为8888 2023-08-16 22:26:18 +08:00
imClumsyPanda
8396b57101 update format of api_allinone.py and llm_api_launch.py 2023-08-16 22:24:29 +08:00
imClumsyPanda
b9fa84635d update README.md 2023-08-16 22:21:02 +08:00
imClumsyPanda
641fcaee40 merge dev 2023-08-16 22:19:18 +08:00
imClumsyPanda
8085bc38c0 Update README.md 2023-08-16 22:17:18 +08:00
imClumsyPanda
8e93a69e1a Update README.md 2023-08-16 22:17:18 +08:00
imClumsyPanda
8524196948 Add files via upload 2023-08-16 22:17:18 +08:00
imClumsyPanda
8e805b18db update README.md 2023-08-16 22:17:03 +08:00
imClumsyPanda
d7fe158d78 git update README.md 2023-08-16 22:06:27 +08:00
liunux4odoo
6c00c03faa llm_api can be terminated by Ctrl+c. success on windows 2023-08-16 17:48:55 +08:00
liunux4odoo
e7d07a7923 Merge remote-tracking branch 'refs/remotes/origin/dev' into dev 2023-08-16 16:16:56 +08:00
liunux4odoo
8ed1f8efca update fastchat to 0.2.24 2023-08-16 16:15:45 +08:00
hzg0601
84b491b8b2 Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-16 16:00:40 +08:00
hzg0601
5f1471232d update llm_api_launch.py:修复本地加载问题 2023-08-16 16:00:24 +08:00
liunux4odoo
f64affc930 update llm_api and api server:
1. fastchat's controller/model_worker/api_server use swagger UI offline.
2. add custom title and icon.
3. remove fastapi-offline dependence
2023-08-16 14:20:09 +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
hzg0601
f3a1247629 update readme 2023-08-16 11:36:53 +08:00
hzg0601
b97358ea33 Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-16 11:15:31 +08:00
hzg0601
8e00f8305b 1. 更新allinone脚本提示,增加中文提示;2. 新增服务一键停止脚本shutdown_all.sh;3. 更新readme说明;3. 修复命令行bug 2023-08-16 11:15:10 +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
hzg0601
17278922dc Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-16 10:14:28 +08:00
hzg0601
348edb9a0d 更新提示 2023-08-16 10:13:51 +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
imClumsyPanda
75d6feb55b
Update README.md 2023-08-16 08:30:00 +08:00
hzg0601
b40beac1a8 Merge branch 'dev' of github.com:chatchat-space/Langchain-Chatchat into dev 2023-08-15 15:34:50 +08:00
hzg0601
116302f3b5 update readme 2023-08-15 15:33:16 +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
imClumsyPanda
e3d968d043
Update README.md 2023-08-15 12:09:13 +08:00
imClumsyPanda
c37f3f27ee
Add files via upload 2023-08-15 12:08:43 +08:00
hzg0601
80f44ba24e git pull dev 2023-08-15 11:22:19 +08:00
Zhi-guo Huang
ec4d3e84ce
1. 增加api的一键启动脚本;2. 增加webui的一键启动脚本;3. 更新readme;4. 调整llm_api_launch (#1097) 2023-08-15 11:20:53 +08:00
hzg0601
5c0274efce 1. 增加api的一键启动脚本;2. 增加webui的一键启动脚本;3. 更新readme;4. 调整llm_api_launch 2023-08-15 11:02:32 +08:00
imClumsyPanda
0568e9be47 add stream_api_test.py 2023-08-14 20:08:37 +08:00
imClumsyPanda
d5fcc958b8 update README.md 2023-08-14 19:48:02 +08:00
hzg0601
c81e63eeee 解决多卡启动问题 2023-08-14 19:42:21 +08:00
Zhi-guo Huang
811c308ef4 1. update readme;2. 解决多卡启动问题;3. 更新lora加载方式说明 (#1079)
* fix chat and knowledge_base_chat

* 更新多卡部署

* update readme

* 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

* 解决多卡启动问题

* fix chat and knowledge_base_chat

* 更新readme的lora加载方式

* update readme

* 更新readme

---------

Co-authored-by: liunux4odoo <liunu@qq.com>
2023-08-14 19:42:16 +08:00
hzg0601
d652a28023 update readme 2023-08-14 19:32:28 +08:00
hzg0601
9fb38727fb 更新readme 2023-08-14 19:32:28 +08:00
hzg0601
c591dd7836 update readme 2023-08-14 19:32:28 +08:00
liunux4odoo
8477adfa33 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 19:32:28 +08:00
liunux4odoo
087bb37e08 fix chat and knowledge_base_chat 2023-08-14 19:32:28 +08:00
hzg0601
23421204dc update readme 2023-08-14 19:32:22 +08:00
hzg0601
c320ed60ba update readme 2023-08-14 19:17:34 +08:00
imClumsyPanda
3cbd4d24fa update README.md 2023-08-14 19:17:34 +08:00
imClumsyPanda
f7c82c13da update model_config.py.example 2023-08-14 19:17:34 +08:00
imClumsyPanda
793d972174 Update README.md 2023-08-14 19:17:34 +08:00
imClumsyPanda
d2440d3640 update README.md 2023-08-14 19:11:01 +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
imClumsyPanda
fc56b07f31 update model_config.py.example 2023-08-14 18:53:22 +08:00
hzg0601
bb8331384f 更新readme 2023-08-14 17:36:10 +08:00
Zhi-guo Huang
71b528a2d1
1. update readme;2. 解决多卡启动问题;3. 更新lora加载方式说明 (#1079)
* fix chat and knowledge_base_chat

* 更新多卡部署

* update readme

* 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

* 解决多卡启动问题

* fix chat and knowledge_base_chat

* 更新readme的lora加载方式

* update readme

* 更新readme

---------

Co-authored-by: liunux4odoo <liunu@qq.com>
2023-08-14 17:35:51 +08:00
hzg0601
e730172a5a update readme 2023-08-14 17:18:26 +08:00
hzg0601
c4142e24c5 更新readme的lora加载方式 2023-08-14 17:15:07 +08:00
imClumsyPanda
d14d80d759
Update README.md 2023-08-14 17:06:59 +08:00
hzg0601
8b18cf2a5e git rebase and pull 2023-08-14 16:48:35 +08:00
liunux4odoo
0704eabe23 fix chat and knowledge_base_chat 2023-08-14 16:46:26 +08:00
hzg0601
90c92f8c93 解决多卡启动问题 2023-08-14 16:43:01 +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
hzg0601
0d6a9cf8f3 Merge branch 'master' into dev 2023-08-14 11:39:12 +08:00
hzg0601
986cb9179c update readme 2023-08-14 11:36:58 +08:00
hzg0601
0cea9ad3da Merge branch 'master' of https://github.com/chatchat-space/Langchain-Chatchat 2023-08-14 11:25:11 +08:00
hzg0601
6590ca32db 更新多卡部署 2023-08-14 11:24:52 +08:00
imClumsyPanda
932ca4e4c5
Update README.md 2023-08-14 10:42:05 +08:00
imClumsyPanda
c34215465d
Add files via upload 2023-08-14 10:41:35 +08:00
liunux4odoo
126bd51232 fix chat and knowledge_base_chat 2023-08-14 10:35:47 +08:00
imClumsyPanda
84e4981cc1
Update README.md 2023-08-14 07:44:12 +08:00
jinke
a61c3cb465 update docker image desc
修改docker image镜像描述。
2023-08-14 01:07:52 +08:00
jinke
586d3eda53 add docker image
添加docker镜像链接及描述。
2023-08-14 01:02:38 +08:00
imClumsyPanda
837c4dbf25 update README.md 2023-08-13 23:55:51 +08:00
imClumsyPanda
ac4d22a89f update README.md 2023-08-13 23:10:38 +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
6359f5e883 fix webui: keep chat session sequence when delete session 2023-08-13 13:13:30 +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
liunux4odoo
9514ec1944 fix webui: rename new chat session error 2023-08-12 20:17:36 +08:00
liunux4odoo
e4c541ed0e update webui: switch to new chat after created it 2023-08-12 17:17:04 +08:00
imClumsyPanda
e196ef0b17 update docs 2023-08-12 17:04:38 +08:00
imClumsyPanda
bbfb599412 update master 2023-08-12 16:46:42 +08:00
imClumsyPanda
f539766e8f update README.md 2023-08-12 16:44:42 +08:00
imClumsyPanda
df6ef705b0 update README.md 2023-08-12 16:36:14 +08:00
imClumsyPanda
90eb45ac46 merge dev_fastchat 2023-08-12 16:31:20 +08:00
imClumsyPanda
18fe1b97f9 merge dev_fastchat 2023-08-12 16:30:07 +08:00
imClumsyPanda
4d4aabd8f7 update README.md 2023-08-12 16:24:11 +08:00
imClumsyPanda
d081277618 update README.md 2023-08-12 16:21:55 +08:00
imClumsyPanda
57a9f04e8f update README.md 2023-08-12 16:07:47 +08:00
imClumsyPanda
70055d7f3a update README.md 2023-08-12 16:04:33 +08:00
imClumsyPanda
79d87d3344 update webui.py 2023-08-12 15:44:46 +08:00
imClumsyPanda
b1d48317e1 update README.md 2023-08-12 15:20:36 +08:00
imClumsyPanda
f4a42b8ccb update webui.py and README.md 2023-08-12 15:02:14 +08:00
imClumsyPanda
2ad33e010d update webui.py and README.md 2023-08-12 14:08:21 +08:00
imClumsyPanda
8c289e4974 update README.md 2023-08-12 11:21:29 +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
802ddb7b55 update docs 2023-08-11 23:30:07 +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
imClumsyPanda
2a44bd870e
Dev (#1046)
* 增加lora检查点加载成功提示

* 修复baichuan_llm引起的bug

* update model_config

---------

Co-authored-by: hzg0601 <hzg0601@163.com>
2023-08-11 10:50:21 +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
liunux4odoo
a261fda20b add tools to migrate knowledge base 2023-08-11 08:33:05 +08:00
imClumsyPanda
3c44cf65cd update webui layout 2023-08-10 23:51:10 +08:00
imClumsyPanda
ef098111dc update webui and utils 2023-08-10 23:04:05 +08:00
imClumsyPanda
8b1c5bcf9e update webui.py 2023-08-10 22:32:56 +08:00
imClumsyPanda
0d1d9c5ed7 update img 2023-08-10 22:02:31 +08:00
Wufisher
28a2295f73
线性简单实现了:vecorstores/MyFAISS.py TODO: 增加是否属于同一文档的判断 (#945) 2023-08-10 21:59:47 +08:00
Vincent chen
62047c880e
Adding an implementaion for involving with accessing Baichuan-13B-Chat (#1005) 2023-08-10 21:55:35 +08:00
Chiquitita
22c6192561
Update MyFAISS.py (#1041)
* Update MyFAISS.py

使用remove_ids从faiss索引中删除向量时,索引中剩余的待索引向量idx仍然是连续的  0, 3, 4 - > 0, 1, 2

#为了保证index_to_docstore_id中的idx和faiss索引中的idx相一致,需要将index_to_docstore_id中的idx重排序

* Update MyFAISS.py
2023-08-10 21:54:42 +08:00
imClumsyPanda
9fc467274f update requirements.txt 2023-08-10 21:53:09 +08:00
imClumsyPanda
8d463a31fd update import pkgs and format 2023-08-10 21:50:38 +08:00
imClumsyPanda
8a4d9168fa update import pkgs and format 2023-08-10 21:26:05 +08:00
liunux4odoo
22c8f277bf update readme: describe requirements to install 2023-08-10 17:10:40 +08:00
liunux4odoo
18e7e7307b patch fastapi-offline to use local swagger-ui assests 2023-08-10 17:00:39 +08:00
liunux4odoo
b733a47902 split requirements to 2 parts: basic with api; webui 2023-08-10 15:51:22 +08:00
Laurence Rotolo
3db73d458b
Merge pull request #1039 from nanayashiki1215/IFlytek/IFlytekVoice
添加语音模块
2023-08-10 15:43:54 +08:00
liunux4odoo
0364215987 Merge branch 'pr1037_pg_vs' into dev_fastchat 2023-08-10 15:07:58 +08:00
liunux4odoo
17ddee38a4 fix conflict between def_fastchat and pr1037 2023-08-10 15:02:41 +08:00
hzg0601
a59ab911a7 update readme 2023-08-10 14:49:50 +08:00
hzg0601
9525915a85 update llm_api_launch,llm_api_shutdown 2023-08-10 14:43:18 +08:00
liunux4odoo
fd247f4657 Merge branch 'dev_fastchat' into pr1037_pg_vs 2023-08-10 14:21:37 +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
Pan
4fd07c36c3 添加讯飞语音识别(流式版)与语音合成(流式版)模块,以及在设置中添加语音开启、关闭相关配置选项 2023-08-10 13:46:33 +08:00
liunux4odoo
f5024245a7 make api.py and webui.py working offline 2023-08-10 13:33:40 +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
zqt
d4f728dfa2 添加向量数据库pg支持,和向量库docker-compose.ym环境文件 2023-08-10 11:16:52 +08:00
hzg0601
f7b2c8cd04 更新readme 2023-08-10 10:09:44 +08:00
hzg0601
73393d781a 更新readme,增加启动多个llm服务的说明;增加停止llm服务的说明 2023-08-10 09:52:34 +08:00
imClumsyPanda
b1361be6df
Update README.md 2023-08-10 09:45:41 +08:00
imClumsyPanda
b9da9cdcb5
Add files via upload 2023-08-10 09:45:15 +08:00
hzg0601
6c2b2b7ba2 测试llm_api_shutdown.py,通过 2023-08-10 09:38:45 +08:00
imClumsyPanda
6019671080
Update README.md 2023-08-10 08:15:27 +08:00
imClumsyPanda
a3e724281e
Update README.md 2023-08-10 08:14:29 +08:00
liunux4odoo
53fef3a7e9 add streamlit-aggrid to requirements 2023-08-10 07:50:24 +08:00
imClumsyPanda
8df00d0b04 add SCORE_THRESHOLD to faiss and milvus kb service 2023-08-10 00:36:59 +08:00
liunux4odoo
1a112c6908 update fastch_chat: disable streaming in swagger besides streaming in ApiRequest 2023-08-09 23:48:41 +08:00
imClumsyPanda
d67e354276 update model_config.py.example and README.md 2023-08-09 23:45:27 +08:00
imClumsyPanda
dd26f552db update model_config.py.example 2023-08-09 23:39:05 +08:00
imClumsyPanda
02b9d57072 update textsplitter and pdfloader 2023-08-09 23:36:43 +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
hzg0601
ca49f9d095 Merge branch 'dev_fastchat' of https://github.com/chatchat-space/langchain-ChatGLM into dev_fastchat 2023-08-09 23:24:44 +08:00
hzg0601
be7d31416c update model_config.py.example 2023-08-09 23:24:17 +08:00
imClumsyPanda
168323ab41 update README.md 2023-08-09 23:21:02 +08:00
hzg0601
66ff913bb4 Merge branch 'dev_fastchat' of https://github.com/chatchat-space/langchain-ChatGLM into dev_fastchat 2023-08-09 23:18:54 +08:00
hzg0601
3e9d088cd9 update server 2023-08-09 23:18:44 +08:00
hzg0601
34bb681db1 删除shell脚本 2023-08-09 23:17:51 +08:00
hzg0601
8a34c3f163 增加停止服务的python脚本 2023-08-09 23:16:02 +08:00
imClumsyPanda
24a280ce8c re-add zh_title_enhance.py 2023-08-09 23:09:24 +08:00
imClumsyPanda
1b70fb5f9b update faiss_kb_service.py 2023-08-09 22:57:36 +08:00
liunux4odoo
db29a2fea7 update knowledge_base_chat and search_engine_chat: yield chinese correctly 2023-08-09 22:54:37 +08:00
liunux4odoo
ba3335efb8 update llm_api: move fastchat logs to LOG_PATH 2023-08-09 22:43:45 +08:00
imClumsyPanda
0a95c32f06 update README.md 2023-08-09 22:20:34 +08:00
imClumsyPanda
22260af16f update README.md and INSTALL.md 2023-08-09 22:04:28 +08:00
liunux4odoo
450b23c4f2 update knowledge base management api and ui 2023-08-09 22:00:33 +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
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
9883341924 update server.chat.*: set default value [] to history parameter. 2023-08-09 10:48:37 +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
532ed81ecf add functions to get kb and doc details from db 2023-08-08 23:57:39 +08:00
imClumsyPanda
717ddf4d10 add history to chat apis 2023-08-08 23:56:27 +08:00
imClumsyPanda
c17572b6a6 add history to chat apis 2023-08-08 23:55:27 +08:00
imClumsyPanda
2d49746a8d add history to chat apis 2023-08-08 23:54:51 +08:00
imClumsyPanda
c8b6d53ede add llmchain_with_history.py as example 2023-08-08 22:15:16 +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
444e1afad5 remove server/knowledge_base/knowledge_file.py 2023-08-08 16:51:37 +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
7e07f0bbf4 move configs to configs.model_config 2023-08-08 15:56:32 +08:00
zqt
79be21521a 补充SQLAlchemy==2.0.19版本 2023-08-08 14:29:08 +08:00
zqt
b61e0772c9 使用orm操作数据库 2023-08-08 14:25:55 +08:00
zqt
41fd1acc9c Merge remote-tracking branch 'origin/dev_fastchat' into dev_fastchat
# Conflicts:
#	server/knowledge_base/kb_service/default_kb_service.py
#	server/knowledge_base/kb_service/milvus_kb_service.py
#	server/knowledge_base/knowledge_base_factory.py
2023-08-08 14:06:13 +08:00
hzg0601
82494aec00 Merge branch 'dev_fastchat' of github.com:chatchat-space/langchain-ChatGLM into dev_fastchat 2023-08-08 13:39:31 +08:00
hzg0601
360bd0a559 update llm_api_sh.py 2023-08-08 13:39:19 +08:00
liunux4odoo
0746272525 remove server/knowledge_base/knowledge_base.py 2023-08-08 13:36:20 +08:00
liunux4odoo
40b6d1f178 add python-magic-bin to requirements on windows. or document loader failed at from unstructured.partion.auto import partion on windows 2023-08-08 12:03:33 +08:00
glide-the
de8db40f4b BaseChatOpenAIChain,支持基础的ChatOpenAI对话的Chain接入 2023-08-07 23:05:54 +08:00
glide-the
823eb06c5d BaseChatOpenAIChain,支持基础的ChatOpenAI对话的Chain接入 2023-08-07 22:57:13 +08:00
liunux4odoo
08493bffbb add a basic knowledge base management ui. 2023-08-07 21:00:55 +08:00
imClumsyPanda
035a199c32 update kb_server.base 2023-08-07 20:48:06 +08:00
imClumsyPanda
c981cdb042 update model_config.py.example 2023-08-07 20:41:44 +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
zqt
e666e0d0be Merge remote-tracking branch 'origin/dev_fastchat' into dev_fastchat 2023-08-07 17:07:19 +08:00
zqt996
0f46185cfb
添加Milvus库 (#1011) 2023-08-07 16:56:57 +08:00
zqt
08cf2915bb 添加Milvus库 2023-08-07 16:42:49 +08:00
zqt
72951d95fb 添加milvus库支持 2023-08-07 16:32:34 +08:00
imClumsyPanda
df9b539f74
Update README.md 2023-08-07 10:40:35 +08:00
imClumsyPanda
2a17f7ff10
Add files via upload 2023-08-07 10:40:11 +08:00
imClumsyPanda
18d31f5116 add KBService and KBServiceFactory class 2023-08-06 23:44:02 +08:00
glide-the
06af3f4c5e BaseChatOpenAIChain,支持基础的ChatOpenAI对话的Chain接入 2023-08-06 22:57:57 +08:00
imClumsyPanda
b91d96ab0c update kb_doc_api.py 2023-08-06 18:32:10 +08:00
imClumsyPanda
d7039d05a1 update MyFAISS.py 2023-08-06 16:49:52 +08:00
YikunHan
0ad63aee63
Update FAQ.md (#1006) 2023-08-06 16:39:58 +08:00
imClumsyPanda
a447529c2e update kb_doc_api.py 2023-08-05 23:35:20 +08:00
imClumsyPanda
8773149a3e update api.py 2023-08-05 23:12:17 +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
313e590961 update DocumentLoader in knowledge_file.py 2023-08-05 21:51:07 +08:00
imClumsyPanda
f68e432570 update table_name and column_name in SQL 2023-08-05 21:02:14 +08:00
imClumsyPanda
cd0f2a2c41 update class method of KnowledgeBase and KnowledgeFile 2023-08-05 20:52:14 +08:00
imClumsyPanda
14a5de6a29 update class method of KnowledgeBase and KnowledgeFile 2023-08-05 13:51:05 +08:00
imClumsyPanda
7beeaacea6 update class method of KnowledgeBase and KnowledgeFile 2023-08-05 13:48:55 +08:00
imClumsyPanda
e8a88f174d update class method of KnowledgeBase and KnowledgeFile 2023-08-05 13:48:30 +08:00
imClumsyPanda
206261cd0c update class method of KnowledgeBase and KnowledgeFile 2023-08-05 13:46:00 +08:00
imClumsyPanda
6c7adfbaeb change kb_api functions with KnowledgeBase class method 2023-08-05 03:15:41 +08:00
imClumsyPanda
7e1472a95b add KnowledgeBase class 2023-08-05 00:10:10 +08:00
imClumsyPanda
590367a5b5 add KnowledgeFile class 2023-08-04 23:54:26 +08:00
imClumsyPanda
515dcc1b5f update MyFAISS.py and cli_demo.py 2023-08-04 23:27:13 +08:00
imClumsyPanda
c987a95c92 Merge remote-tracking branch 'origin/master' 2023-08-04 23:26:50 +08:00
imClumsyPanda
2eb35291b2 update MyFAISS.py and cli_demo.py 2023-08-04 23:26:42 +08:00
imClumsyPanda
775d46fecf format update in knowledge_base/utils.py 2023-08-04 23:14:43 +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
b4f80ca370 update server.knowledge_base.utils 2023-08-04 15:32:42 +08:00
imClumsyPanda
7bfbe18011 update requirements.txt and kb_doc_api.py 2023-08-04 15:12:14 +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
liunux4odoo
c4994e85df fix: knowledge_base_chat and search_engine_chat should stream json text
instead of dict. client should use json.loads.
2023-08-04 12:12:13 +08:00
liunux4odoo
88682c87ff 优化server下知识库相关模块的结构:将知识库相关操作从knowledge_base_chat移动到knowledge_base.utils;优化kb_doc_api中embeddings加载。 2023-08-04 10:16:30 +08:00
liunux4odoo
9a18218293 add new config variable to config example 2023-08-04 09:16:28 +08:00
imClumsyPanda
82aa805bf3 update requirements.txt 2023-08-03 23:42:55 +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
imClumsyPanda
b62ea6bd2a add top-k to search_chat apis and add top-k params in model_config 2023-08-03 17:06:43 +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
hzg0601
fdbff8a91f Merge branch 'dev_fastchat' of github.com:chatchat-space/langchain-ChatGLM into dev_fastchat 2023-08-03 14:39:14 +08:00
hzg0601
6f93a27e53 更新llm_api_sh.py调用说明 2023-08-03 14:39:00 +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
f7d465b7d4 bug fix 2023-08-03 12:11:18 +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
904eaa58c4
Update README.md 2023-08-02 11:01:02 +08:00
imClumsyPanda
6b03914446
Add files via upload 2023-08-02 11:00:38 +08:00
hzg0601
d0fd6253a3 update llm_api_sh 2023-08-02 09:19:58 +08:00
hzg0601
1d1a8e9339 Merge branch 'dev_fastchat' of github.com:chatchat-space/langchain-ChatGLM into dev_fastchat 2023-08-01 22:07:12 +08:00
hzg0601
ab7a76f380 update llm_api_sh.py and model_config.example 2023-08-01 22:07:05 +08:00
imClumsyPanda
e4fed93989 update format in api.py 2023-08-01 21:53:19 +08:00
hzg0601
18a94fcf45 Merge branch 'dev_fastchat' of github.com:chatchat-space/langchain-ChatGLM into dev_fastchat 2023-08-01 18:02:52 +08:00
hzg0601
15e67a4d3e 1.*在config里将所有fastchat的命令行参数加入;2.*加入启动和停止fastchat的shell脚本;3. **增加了通过命令行启动所有fastchat服务的python脚本llm_api_sh.py;4. 修改了默认的config日志格式 2023-08-01 17:59:20 +08:00
imClumsyPanda
7c01a2a253 add bing_search_chat.py and duckduckgo_search_chat.py 2023-08-01 16:39:17 +08:00
imClumsyPanda
5ce2484af0 update webui.py 2023-08-01 15:08:19 +08:00
imClumsyPanda
7d79b676d5 add model_config.py.example instead of model_config.py 2023-08-01 14:55:00 +08:00
imClumsyPanda
8261deb99d fix model_config path 2023-08-01 14:49:49 +08:00
imClumsyPanda
bcfd3f5af5 add webui_pages 2023-08-01 14:47:38 +08:00
imClumsyPanda
c8a75ab11f update llm_api.py and webui.py 2023-08-01 14:33:18 +08:00
liunux4odoo
2c5b6bb0ad streamlit ui 实现LLM流式对话 2023-08-01 14:18:30 +08:00
liunux4odoo
a1a7484ef4 增加webui_utils.py,包括制作webui通用的工具,方便以后开发其他webui 2023-08-01 14:15:42 +08:00
imClumsyPanda
9f4567865c add chatglm2-6b-32k and make m3e default embedding model 2023-08-01 14:12:28 +08:00
imClumsyPanda
00cb7bf598 add support for chatglm2-6b-32k 2023-08-01 10:58:05 +08:00
imClumsyPanda
dfe7bee243 Merge branch 'master' into dev 2023-07-31 19:54:43 +08:00
liunux4odoo
9e2b411b01 cuda error with multiprocessing, change model_worker to main process 2023-07-31 11:18:57 +08:00
hzg0601
47dfb6cd8b udpate llm_api 2023-07-31 11:00:33 +08:00
liunux4odoo
946f10e1f2 split api_start to create_app & run_api. user can run api with uvicorn in console: uvicorn server.api:app --port 7861 2023-07-31 10:05:19 +08:00
liunux4odoo
463659f0ba llm_api升级到fschat==0.2.20,支持百川模型 2023-07-30 23:16:47 +08:00
liunux4odoo
51ea717606 Merge branch 'dev_fastchat_me' into dev_fastchat 2023-07-30 09:01:31 +08:00
liunux4odoo
179c2a9a92 修改server.chat.openai_chat中的参数定义,使其与openai中/v1/chat/completions接口的入参保持一致,并按照model_config提供默认值。
openai_chat中的接口还要修改:openai根据参数stream有不同的返回值,本接口要与其对应。
2023-07-30 08:56:49 +08:00
imClumsyPanda
05ccc0346e update test code 2023-07-30 00:48:07 +08:00
imClumsyPanda
41444fd4b5 update requirements.txt and llm_api.py 2023-07-30 00:24:34 +08:00
imClumsyPanda
d4ffc70d96 update requirements.txt 2023-07-29 23:46:02 +08:00
liunux4odoo
1a7271e966 fix: model_worker need global variable: args 2023-07-29 23:22:25 +08:00
liunux4odoo
c880412300 use multiprocessing to run fastchat server 2023-07-29 23:01:24 +08:00
liunux4odoo
829ced398b make api.py import model_config coreectlly 2023-07-29 23:00:50 +08:00
Zhi-guo Huang
fef931d2b8
Merge pull request #859 from cylee0909/chatglm2cpp
support chatglm2cpp
2023-07-28 22:24:51 +08:00
liunux4odoo
8b1cf7effd fix: os.environ['OPENAI_API_KEY'] exception when no environment variable set 2023-07-28 16:51:58 +08:00
liunux4odoo
70c6870776 增加api_one.py,把fastchat
3个服务端整合在一起。后面考虑把api.py也整合进来。
3个进程变成1个进程可能带来少许性能损失,但对于个人用户降低了部署难度。
2023-07-28 16:41:45 +08:00
hzg0601
97ee4686a1 更新会议记录 2023-07-28 16:16:59 +08:00
hzg0601
154cad1b45 会议记录 2023-07-28 16:12:57 +08:00
cylee
4235270a32
Merge branch 'dev' into chatglm2cpp 2023-07-28 14:41:14 +08:00
imClumsyPanda
e95996a9b9 update requirements.txt 2023-07-28 06:59:16 +08:00
imClumsyPanda
59442dcd4a update webui.py 2023-07-28 06:58:34 +08:00
imClumsyPanda
dd0f90b4a4 readd .github 2023-07-28 06:54:54 +08:00
hzg0601
161c9e6c50 fix typo 2023-07-28 03:59:29 +08:00
imClumsyPanda
620ccb3bdc update model_config.py 2023-07-27 23:28:33 +08:00
hzg0601
9326c63a62 Merge branch 'dev' of https://github.com/imClumsyPanda/langchain-ChatGLM into dev 2023-07-27 23:27:53 +08:00
imClumsyPanda
dcf49a59ef v0.2.0 first commit 2023-07-27 23:22:07 +08:00
hzg0601
cd91290bfb 删除reqirements的中文 2023-07-27 14:28:58 +08:00
hzg0601
c431bee941 删除requirements的中文 2023-07-27 14:27:11 +08:00
hzg0601
310a865ccd 删除requirements的中文 2023-07-27 14:26:50 +08:00
imClumsyPanda
f7a32f9248
Update README.md 2023-07-27 09:23:31 +08:00
imClumsyPanda
36a1c72573
Add files via upload 2023-07-27 09:23:07 +08:00
liunux4odoo
8732dcc1c4 恢复被PR659覆盖的model_config 2023-07-27 08:42:17 +08:00
imClumsyPanda
01a54d1042 add chatglm-fitness-RLHF made by @BoFan-tunning to llm_model_dict in model_config.py 2023-07-26 21:41:27 +08:00
imClumsyPanda
0a062ba07b update img 2023-07-26 21:37:22 +08:00
hzg0601
34a2af118b update model_config.py 2023-07-26 18:04:35 +08:00
hzg0601
e8ff31be1f 1.使api.py里可以使用args.py的参数;2.兼容args.py和model_config.py的控制方式;3.更新fastchat调用模型名的说明 2023-07-26 17:46:02 +08:00
hzg0601
58a5de92a5 1.更改加载lora的方式;2.允许api.py调用args.py的命令行;3. FastChat路径提示 2023-07-26 17:05:37 +08:00
liunux4odoo
5f74f70515 fix: streamlit ui在上传多个文件到知识库时出错 2023-07-25 22:36:49 +08:00
YuhaoWU
466f0c9c97
安装教程conda create新增默认的/envs下面,而不只是只能要额外指定路径 用-p (#482)
* Update 安装教程中conda虚拟环境的创建与激活
2023-07-25 16:58:25 +08:00
liunux4odoo
18d453cc18 merge PR 659: make chat api support streaming 2023-07-25 13:23:16 +08:00
imClumsyPanda
db80358df8
Update model_config.py
fix openai api url
2023-07-25 11:16:02 +08:00
liunux4odoo
f21fea41b4 bug fix:
api.py中,所有chat接口的参数history,其元素应支持None,方便其他框架调用。
否则以history=[[None,'some thing']]调用时会返回422错误。
2023-07-25 08:53:28 +08:00
Zhi-guo Huang
1f8924eeac
Merge branch 'dev' into chatglm2cpp 2023-07-24 14:44:00 +08:00
lichongyang
62ba7679fe support chatglm2cpp 2023-07-24 14:41:51 +08:00
imClumsyPanda
3f627af745
Update README.md 2023-07-24 08:32:21 +08:00
imClumsyPanda
b586ee6e1f
Add files via upload 2023-07-24 08:31:54 +08:00
imClumsyPanda
fdd353e48a Merge branch 'master' into dev 2023-07-23 18:40:04 +08:00
imClumsyPanda
ff5d2ecc1e update img 2023-07-23 18:39:49 +08:00
imClumsyPanda
0f43845a98 merge master 2023-07-23 18:38:51 +08:00
hzg0601
1e1075b98a Merge branch 'dev' of github.com:imClumsyPanda/langchain-ChatGLM into dev 2023-07-21 23:13:11 +08:00
hzg0601
b2278f2f25 更改api.py的chat函数的history的类型为Optional,修复chat接口不可调用的问题 2023-07-21 23:12:28 +08:00
liunux4odoo
a6f42e7c8e fix iss#889:
when init_model on startup, set llm model's history_len to LLM_HISTORY_LEN from model_config.
2023-07-21 23:07:50 +08:00
Ma Zhiming
3f76cb5f47
[Fix] INSTALL.md (#907)
* Update INSTALL.md

* Update INSTALL.md
2023-07-21 16:42:53 +08:00
hzg0601
3b6819f091 更改默认的LLM_MODEL 2023-07-21 15:35:17 +08:00
hzg0601
6ec1e56e03 Merge branch 'dev' of github.com:imClumsyPanda/langchain-ChatGLM into dev 2023-07-21 15:29:53 +08:00
Zhi-guo Huang
acee2d5ad2
Merge pull request #905 from chinainfant/dev
解决加载ptuning检查点失败的问题
2023-07-21 15:32:37 +08:00
chinainfant
c1c2ed1943
Update loader.py 解决加载ptuning报错的问题 2023-07-21 15:30:19 +08:00
hzg0601
32122ee225 update gitignore 2023-07-21 15:29:36 +08:00
chinainfant
ec2bf9757c
Update args.py 将use-ptuning-v2的命名行改为action='store_true' 2023-07-21 15:28:11 +08:00
Zhi-guo Huang
7d37dc876e
Merge pull request #904 from bones-zhu/dev
1 修复model_config.py的type;2 修改默认的LLM_model;3. 移除chatglm_llm.py的无用模块
2023-07-21 15:14:33 +08:00
bones-zhu
5479a74789
Update chatglm_llm.py remove unused library 2023-07-21 15:11:51 +08:00
bones-zhu
e2eaefc999
Update model_config.py 修改默认的LLM_MODEL 2023-07-21 15:10:13 +08:00
bones-zhu
a1b454fc43
Update model_config.py fix type 2023-07-21 15:09:33 +08:00
hzg0601
5f4f8dcedc 解决loader.py中以名称匹配模型式未排除chatglm2的问题 2023-07-21 09:49:18 +08:00
hzg0601
a5294748a4 Merge branch 'dev' of github.com:imClumsyPanda/langchain-ChatGLM into dev 2023-07-21 09:32:19 +08:00
hzg0601
915f4f359a 补充openai的连接失败问题解决方案 2023-07-21 09:29:43 +08:00
imClumsyPanda
bf940e9041
Update README.md 2023-07-20 15:06:02 +08:00
imClumsyPanda
2db6604c55
Add files via upload 2023-07-20 15:04:12 +08:00
liunux@home
dd3617fcdf 将paddle相关loader改为动态引入,可以在不上传pdf/image知识文件的前提下使用protobuf=4.x。
这样可以使用最新版streamlit和chainlit。
2023-07-20 12:32:37 +08:00
Zhi-guo Huang
ee7285cd93
在args.py中增加ptuning相关的参数 (#838)
* 修复 bing_search.py的typo;更新model_config.py中Bing Subscription Key申请方式及注意事项

* 更新FAQ,增加了[Errno 110] Connection timed out的原因与解决方案

* 修改loader.py中load_in_8bit失败的原因和详细解决方案

* update loader.py

* stream_chat_bing

* 修改stream_chat的接口,在请求体中选择knowledge_base_id;增加stream_chat_bing接口

* 优化cli_demo.py的逻辑:支持 输入提示;多输入;重新输入

* update cli_demo.py

* 按照review建议进行修改

* 修改默认的多卡部署方案,基本保证针对新模型也不会失败

* 测试openai接口成功

* add ptuning-v2 dir

* 支持命令行输入ptuning路径

* 在FAQ中给出加载量化版本失败的原因和解决方案

* print error

* udpate

* Update args.py

* debug for fastchat_openai_llm

* temporarily save

* update faq for

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
Co-authored-by: zg h <bj wang@hzg0601-acer.hundsun.com>
2023-07-19 23:15:14 +08:00
hzg0601
50c872c0b8 update faq for 2023-07-19 23:09:19 +08:00
hzg0601
c501df2405 temporarily save 2023-07-19 10:57:09 +08:00
hzg0601
6199c45a13 Merge branch 'dev' of github.com:hzg0601/langchain-ChatGLM-annotation into dev
git pull origin dev.
2023-07-19 10:04:05 +08:00
hzg0601
391dc1d33a debug for fastchat-openai-llm 2023-07-19 10:02:39 +08:00
hzg0601
90fe40b221 debug for fastchat_openai_llm 2023-07-19 10:00:23 +08:00
liunux4odoo
f88bf2cbf3
fix issue#580: 新建知识库出错 (#880)
* Add files via upload

* Update README.md

* fix: make get_vs_list return folders only

* fix: bugs when create new knowledgebase

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-07-18 23:40:18 +08:00
hzg0601
d714644afc Merge branch 'dev' of https://github.com/imClumsyPanda/langchain-ChatGLM into dev 2023-07-18 21:23:14 +08:00
imClumsyPanda
6b66efa576
Update README.md 2023-07-18 14:30:58 +08:00
imClumsyPanda
343d16e583
Add files via upload 2023-07-18 14:30:30 +08:00
imClumsyPanda
1ef3ef5d27 update gradio version in requirements.txt 2023-07-18 04:03:28 +08:00
imClumsyPanda
7dc44249eb update model_config.py 2023-07-17 21:49:05 +08:00
imClumsyPanda
98b773c43a rebase master 2023-07-17 21:45:04 +08:00
imClumsyPanda
10a3185b34 rebase master 2023-07-17 21:43:57 +08:00
imClumsyPanda
33b978b5c4 update README.md 2023-07-17 21:39:10 +08:00
imClumsyPanda
a54b73aaf9
Update args.py 2023-07-17 21:26:13 +08:00
glide-the
aa944f6ee7
Merge pull request #852 from benjaminhuo/master
Fix LocalDocQA object has no attribute llm when adding docs
2023-07-17 21:25:17 +08:00
hzg0601
6f967a069d udpate 2023-07-17 15:07:52 +08:00
Benjamin Huo
4e6edecd9e Fix LocalDocQA object has no attribute llm when adding docs
Signed-off-by: Benjamin Huo <benjamin@kubesphere.io>
2023-07-16 11:39:46 +08:00
glide-the
c5026fb4e7 参数校验 2023-07-16 02:19:34 +08:00
glide-the
22d08f5ec5 必要参数校验 2023-07-16 02:17:52 +08:00
glide-the
1e2124ff54 参数校验 2023-07-16 01:31:28 +08:00
glide-the
c389f1a33a 增加fastchat打字机输出 2023-07-16 01:29:51 +08:00
liunux4odoo
5cbb86a823
rewrite streamlit ui with streamlit-chatbox;fix bugs (#850) 2023-07-15 22:05:57 +08:00
taokuizu
df3744f501
fix Non-UTF-8 code starting with \xe5 (#849) 2023-07-15 21:08:47 +08:00
taokuizu
3b93902670
修改README.md,添加支持的LLM(bloomz-7b1,bloom-3b,baichuan-7b,vicuna-13b-delta-v1.1) (#845) 2023-07-15 00:29:16 +08:00
imClumsyPanda
1cd4ba8a51
Update README.md 2023-07-14 18:43:24 +08:00
imClumsyPanda
3107f777fa
Add files via upload 2023-07-14 18:42:57 +08:00
hzg0601
db0fcf4e03 print error 2023-07-14 15:10:33 +08:00
hzg0601
760abab1d7 Merge branch 'dev' of github.com:hzg0601/langchain-ChatGLM-annotation into dev
merge upstream dev
2023-07-14 13:45:48 +08:00
hzg0601
3d082bf566 在FAQ中给出加载量化版本失败的原因和解决方案 2023-07-14 13:45:07 +08:00
hzg0601
57cb6b05de add moss-int4 2023-07-13 22:21:00 +08:00
zg h
43d1bf4fb3 支持命令行输入ptuning路径 2023-07-13 22:10:54 +08:00
hzg0601
f68d347c25 add ptuning-v2 dir 2023-07-13 21:22:35 +08:00
glide-the
c5bc21781c 修改模型生成的调用方式,兼容Chain调用
修改模型切换的bug
2023-07-12 23:09:28 +08:00
Zhi-guo Huang
ca13ab8173
测试OPENAI接口成功 (#813) 2023-07-11 23:40:49 +08:00
hzg0601
1940da0adf 测试openai接口成功 2023-07-11 23:35:24 +08:00
imClumsyPanda
979dfa1976 Merge remote-tracking branch 'origin/dev' into dev 2023-07-11 21:49:02 +08:00
imClumsyPanda
2371feaa4f update README.md 2023-07-11 21:48:50 +08:00
hzg0601
a8e820359a Merge branch 'dev' of github.com:hzg0601/langchain-ChatGLM-annotation into dev
merge dev.
2023-07-11 21:44:59 +08:00
hzg0601
48ce8b1c84 pull dev 2023-07-11 21:43:26 +08:00
Zhi-guo Huang
64f22a9e53
修改默认的多卡部署方案,基本保证针对新模型也不会失败 (#788)
* 修复 bing_search.py的typo;更新model_config.py中Bing Subscription Key申请方式及注意事项

* 更新FAQ,增加了[Errno 110] Connection timed out的原因与解决方案

* 修改loader.py中load_in_8bit失败的原因和详细解决方案

* update loader.py

* stream_chat_bing

* 修改stream_chat的接口,在请求体中选择knowledge_base_id;增加stream_chat_bing接口

* 优化cli_demo.py的逻辑:支持 输入提示;多输入;重新输入

* update cli_demo.py

* 按照review建议进行修改

* 修改默认的多卡部署方案,基本保证针对新模型也不会失败

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-07-11 20:24:49 +08:00
imClumsyPanda
e02f49a49e
Merge branch 'dev' into dev 2023-07-11 20:24:18 +08:00
imClumsyPanda
3a6a6fa8f6 update model_config.py 2023-07-11 20:19:50 +08:00
imClumsyPanda
7480005822 Merge branch 'master' into dev 2023-07-11 20:18:40 +08:00
imClumsyPanda
2d1ad18a4f update README.md 2023-07-11 20:18:24 +08:00
NieLamu
ff5f73e041
feat: fastapi 接口优化 (#684)
1. 接口增加参数校验,防止攻击
2. 优化接口参数和逻辑
3. 规范接口错误响应
4. 增加接口描述

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-07-11 19:52:52 +08:00
Zhi-guo Huang
a5ca4bf26a
1.增加对llama-cpp模型的支持;2.增加对bloom/chatyuan/baichuan模型的支持;3. 修复多GPU部署的bug;4. 修复了moss_llm.py的bug;5. 增加对openai支持(没有api,未测试);6. 支持在多卡情况自定义设备GPU (#664)
* 修复 bing_search.py的typo;更新model_config.py中Bing Subscription Key申请方式及注意事项

* 更新FAQ,增加了[Errno 110] Connection timed out的原因与解决方案

* 修改loader.py中load_in_8bit失败的原因和详细解决方案

* update loader.py

* stream_chat_bing

* 修改stream_chat的接口,在请求体中选择knowledge_base_id;增加stream_chat_bing接口

* 优化cli_demo.py的逻辑:支持 输入提示;多输入;重新输入

* update cli_demo.py

* add bloom-3b,bloom-7b1,ggml-vicuna-13b-1.1

* 1.增加对llama-cpp模型的支持;2.增加对bloom模型的支持;3. 修复多GPU部署的bug;4. 增加对openai支持(没有api,未测试);5.增加了llama-cpp模型部署的说明

* llama模型兼容性说明

* modified:   ../configs/model_config.py
	modified:   ../docs/INSTALL.md
在install.md里增加对llama-cpp模型调用的说明

* 修改llama_llm.py以适应llama-cpp模型

* 完成llama-cpp模型的支持;

* make fastchat and openapi compatiable

* 1. 修复/增加对chatyuan,bloom,baichuan-7等模型的支持;2. 修复了moss_llm.py的bug;

* set default model be chatglm-6b

* 在多卡情况下也支持自定义GPU设备

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-07-11 19:36:50 +08:00
kztao
cf0f1d6625
Update README.md, 0.1.16版本已经支持删除知识库中的文件 (#792)
* Update README.md

* fix:The knowledge base name cannot be empty.

* Update webui.py

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-07-11 19:20:47 +08:00
kztao
c564c91a82
fix:The knowledge base name cannot be empty. (#793)
* fix:The knowledge base name cannot be empty.

* Update webui.py

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-07-11 19:18:24 +08:00
imClumsyPanda
80af725a41
Update README.md 2023-07-11 19:15:09 +08:00
imClumsyPanda
f0ea1c1bb0
Add files via upload 2023-07-11 19:14:41 +08:00
ysyx2008
5f0697799a
解决 image_loader.py 运行时报错“ModuleNotFoundError: No module named 'configs'”的问题。 (#795) 2023-07-11 19:12:46 +08:00
imClumsyPanda
a8a3ea9ca2
Update README.md 2023-07-07 10:27:00 +08:00
imClumsyPanda
af4ddc8923
Add files via upload 2023-07-07 10:26:23 +08:00
hzg0601
300d287d61 修改默认的多卡部署方案,基本保证针对新模型也不会失败 2023-07-06 04:47:44 +08:00
imClumsyPanda
e68bc53cab
Update README.md 2023-07-05 09:32:40 +08:00
imClumsyPanda
de98919fe6
Add files via upload 2023-07-05 09:32:05 +08:00
Fan
10abb8d781
添加启动API的参数,支持https、wss方式API调用 (#728)
* update README.md

* 添加启动API的参数,支持https、wss方式API调用。(CA证书自备)
添加启动API服务的markdown说明文档。

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
Co-authored-by: 一帆 <zhang.f@digitalcnzz.com>
2023-07-04 19:52:17 +08:00
stc2001
7217e3391d
Update model_config.py (#768)
添加ChatGLM2-6b-int4和ChatGLM2-6b-int8
2023-07-04 19:04:57 +08:00
imClumsyPanda
967ac2ed2b merge master 2023-07-02 22:18:59 +08:00
imClumsyPanda
80ecc08044 update README.md 2023-07-02 22:16:58 +08:00
Zhi-guo Huang
c52308d605
1. 修改stream_chat的接口,在请求体中选择knowledge_base_id;2. 增加stream_chat_bing接口;3. 增加了调用流式接口的方法说明;4. 优化cli_demo.py的逻辑:支持 输入提示;多输入;重新输入 (#630)
* 修复 bing_search.py的typo;更新model_config.py中Bing Subscription Key申请方式及注意事项

* 更新FAQ,增加了[Errno 110] Connection timed out的原因与解决方案

* 修改loader.py中load_in_8bit失败的原因和详细解决方案

* update loader.py

* stream_chat_bing

* 修改stream_chat的接口,在请求体中选择knowledge_base_id;增加stream_chat_bing接口

* 优化cli_demo.py的逻辑:支持 输入提示;多输入;重新输入

* update cli_demo.py

* 按照review建议进行修改
2023-07-02 21:54:12 +08:00
hzg0601
43fae98bb5 按照review建议进行修改 2023-07-02 20:47:27 +08:00
zzxs
6ab496ea4a
Update api.py (#628)
修复websocket的伪流式输出
2023-07-02 13:42:53 +08:00
imClumsyPanda
b922970ac2
Update README.md 2023-07-01 10:16:47 +08:00
imClumsyPanda
393bd400cb
Add files via upload 2023-07-01 10:16:09 +08:00
Jingsong-Yan
421ce3da3a
Add device_map config to support chatglm2-6b (#734)
chatglm-6b和chatglm2-6b的参数命名不一致,本次提交旨在解决chatglm2-6b device_map 创建的问题。在chatglm_auto_configure_device_map 函数中新增了chatglm2-6b device_map 创建的相关代码。
2023-06-30 21:08:38 +08:00
neverless00
51ed739d6c
fix 2 bugs on streamlit demo (#719) 2023-06-30 21:01:41 +08:00
jinke
3c66fc3b18
向Readme添加Docker整合包描述 (#746) 2023-06-30 07:19:07 +08:00
imClumsyPanda
1612c89160
Update README.md 2023-06-29 12:53:27 +08:00
imClumsyPanda
2bda2cf7a6
Update README.md 2023-06-29 12:52:51 +08:00
imClumsyPanda
46bd13d9db
Add files via upload 2023-06-29 12:50:52 +08:00
imClumsyPanda
1ec8f33db8
Update README.md 2023-06-27 16:13:15 +08:00
imClumsyPanda
c69e63a442
Add files via upload 2023-06-27 16:11:45 +08:00
allseeeeeee
521d9e2f98
Dev streaming oom (#722) 2023-06-26 19:12:50 +08:00
imClumsyPanda
d0b746c54f update README.md 2023-06-25 17:55:00 +08:00
imClumsyPanda
623d3d44ec Merge branch 'master' into dev 2023-06-25 17:05:05 +08:00
imClumsyPanda
eaf46a04e3 Add chatglm2-6b configs 2023-06-25 17:04:16 +08:00
imClumsyPanda
fc57d76c3c
Update README.md 2023-06-22 10:39:18 +08:00
imClumsyPanda
bf87e791f3
Add files via upload 2023-06-22 10:38:54 +08:00
fxjhello
6195a5974a
Merge pull request #651 from sivdead/fix/kbs_interface_adjust
前端知识库相关接口报错修复
2023-06-20 19:01:48 +08:00
fxjhello
6e666237cd
Merge pull request #679 from hzhaoy/master
Fix #675: 解决因vue前端代码有误导致镜像构建失败的问题
2023-06-20 18:59:21 +08:00
超能刚哥
d24d736c38
Merge pull request #1 from imClumsyPanda/dev
Dev
2023-06-20 17:37:59 +08:00
Elwin
8d01bc9170
Merge branch 'imClumsyPanda:master' into master 2023-06-20 16:27:24 +08:00
hzhaoy
1a0eadccb2 Fix #675: 解决因vue前端代码有误导致镜像构建失败的问题 2023-06-20 15:54:11 +08:00
LuoQianhong
241e19a9af
Merge branch 'dev' into fix/kbs_interface_adjust 2023-06-20 09:18:14 +08:00
imClumsyPanda
7b4884a2db update README.md 2023-06-19 23:02:56 +08:00
TOMCAT 007
ef5bab1d92 错误操作撤销了#653,补充提交 2023-06-19 21:16:51 +08:00
imClumsyPanda
11c35722ba update QR Code 2023-06-19 20:51:18 +08:00
fengyunzaidushi
d7d235463e
整理了下issue的问题,方便新手入门 (#669)
* Create ceshi

* Delete ceshi

* Create ceshi

* langchain-问题整理

下一步分类

* Delete ceshi
2023-06-19 19:33:11 +08:00
imClumsyPanda
6e953da07b
Merge branch 'dev' into master 2023-06-18 21:54:53 +08:00
imClumsyPanda
017b34647e update requirements.txt and model_config.py 2023-06-18 21:52:56 +08:00
imClumsyPanda
f6218316e3 update requirements.txt and model_config.py 2023-06-18 21:52:49 +08:00
kiddog99
25b46a7b9e
标题增强 (#631)
* Add files via upload

* Update local_doc_qa.py

* Update model_config.py

* Update zh_title_enhance.py

* Add files via upload

* Update README.md

* fix bugs in MyFAISS.delete_doc

* fix:前端知识库获取失败.

* update zh_title_enhance.py

* update zh_title_enhance.py

* Update zh_title_enhance.py

* add test/textsplitter

* add test_zh_title_enhance.py

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
Co-authored-by: JZF <jiangzhifeng_jzf@163.com>
Co-authored-by: fxjhello <127916299+fxjhello@users.noreply.github.com>
2023-06-18 21:45:06 +08:00
超能刚哥
41d8846e13
移除EventSourceResponse引用 2023-06-18 17:37:26 +08:00
超能刚哥
6023426344
去除多余依赖 2023-06-18 17:36:46 +08:00
超能刚哥
d61ff37f45
增加sse_starlette依赖包 2023-06-18 17:35:55 +08:00
超能刚哥
f21e00bf16
LLM对话和知识库对话接口增加流式输出功能 2023-06-18 17:30:41 +08:00
fxjhello
3f7e81585e
Merge pull request #657 from imClumsyPanda/revert-653-dev-1
Revert 653 dev 1
2023-06-17 20:30:04 +08:00
fxjhello
409a302f9b
Revert "fix:前端知识库获取失败. 修改获取及删除接口至knowledge_base" 2023-06-17 20:29:25 +08:00
fxjhello
6981bdee62
Merge pull request #653 from 1729457433/dev-1
fix:前端知识库获取失败. 修改获取及删除接口至knowledge_base
2023-06-17 20:29:17 +08:00
fxjhello
5eab13c911
Merge pull request #636 from hzhaoy/master
解决vue前端镜像构建失败的问题
2023-06-17 20:28:54 +08:00
敬文 | 罗千洪
3efd408f5a fix(前端): 删除知识库改为使用删除知识库接口 2023-06-17 16:33:43 +08:00
JZF
91c647812f fix:前端知识库获取失败. 2023-06-17 11:29:55 +08:00
敬文 | 罗千洪
7cbdc6702e fix(前端): 查询切换到知识库tab时,应该调用查询知识库列表接口而不是文件列表接口;删除文件改为使用DELETE方法,参数按api.py改动调整为QueryParam 2023-06-17 02:46:45 +08:00
imClumsyPanda
2a964f298c fix bugs in MyFAISS.delete_doc 2023-06-16 23:52:28 +08:00
imClumsyPanda
2282320d41 fix bugs in MyFAISS.delete_doc 2023-06-16 23:51:20 +08:00
bright.python
2311fb007d
Update MyFAISS.py (#648)
防止i不存在时候错误,
langchain-ChatGLM/vectorstores/MyFAISS.py", line 55, in similarity_search_with_score_by_vector
    _id = self.index_to_docstore_id[i]
KeyError: 4
2023-06-16 23:47:31 +08:00
imClumsyPanda
1eba834985
Update README.md 2023-06-16 15:26:26 +08:00
imClumsyPanda
3743f6f5c6
Add files via upload 2023-06-16 15:25:19 +08:00
hzg0601
ba336440aa Merge branch 'dev' of github.com:imClumsyPanda/langchain-ChatGLM into dev
pull for 2023--6-15
2023-06-15 13:53:22 +08:00
hzg0601
c42c0cbf87 update cli_demo.py 2023-06-15 13:46:11 +08:00
hzg0601
b262612248 优化cli_demo.py的逻辑:支持 输入提示;多输入;重新输入 2023-06-15 13:15:00 +08:00
hzhaoy
e177b0bbc8 Fix #635: 解决vue前端镜像构建失败的问题 2023-06-15 11:36:57 +08:00
imClumsyPanda
3d95706d5c fix bugs in webui.py 2023-06-15 01:00:45 +08:00
imClumsyPanda
5f652183f4 fix bugs in webui.py 2023-06-15 00:38:38 +08:00
imClumsyPanda
a62617f394 Merge remote-tracking branch 'origin/dev' into dev 2023-06-15 00:26:45 +08:00
imClumsyPanda
b674c9a524 fix bugs in pdf_loader.py and image_loader.py 2023-06-15 00:26:27 +08:00
imClumsyPanda
ed7c54858a add delete knowledge base and delete files from knowledge base to webui 2023-06-15 00:21:41 +08:00
Zhi-guo Huang
a70df98825
更新FAQ,model_config.py,bing_search.py文件,增加bing搜索问答相关问题的原因和可能解决方案,修复了一些typo;修改loader.py中load_in_8bit失败的原因和详细解决方案 (#610)
* 修复 bing_search.py的typo;更新model_config.py中Bing Subscription Key申请方式及注意事项

* 更新FAQ,增加了[Errno 110] Connection timed out的原因与解决方案

* 修改loader.py中load_in_8bit失败的原因和详细解决方案

* update loader.py
2023-06-14 21:31:26 +08:00
imClumsyPanda
331f39cde7 merge master 2023-06-14 21:21:56 +08:00
imClumsyPanda
58d6a9a098 update MyFAISS with method mentioned in https://github.com/imClumsyPanda/langchain-ChatGLM/issues/613#issuecomment-1590460465 2023-06-14 21:20:52 +08:00
imClumsyPanda
a55aab498f Merge branch 'master' of https://github.com/imClumsyPanda/langchain-ChatGLM 2023-06-14 21:09:30 +08:00
imClumsyPanda
40101dbb1f
Update README.md 2023-06-14 17:26:56 +08:00
imClumsyPanda
5c81671cf7
Add files via upload 2023-06-14 17:25:57 +08:00
hzg0601
660f8c6715 修改stream_chat的接口,在请求体中选择knowledge_base_id;增加stream_chat_bing接口 2023-06-14 11:17:21 +08:00
hzg0601
987f5518f2 stream_chat_bing 2023-06-14 08:55:27 +08:00
hzg0601
b63c74212f update loader.py 2023-06-14 08:22:05 +08:00
imClumsyPanda
11dd2b5b84 update api.py 2023-06-14 00:35:33 +08:00
imClumsyPanda
a887df1715 add knowledge_base folder and move vector_store and content inside 2023-06-13 23:54:29 +08:00
hzg0601
f7e7d318d8 修改loader.py中load_in_8bit失败的原因和详细解决方案 2023-06-13 23:30:10 +08:00
imClumsyPanda
585b4427ba Merge branch 'master' into dev 2023-06-13 22:40:14 +08:00
imClumsyPanda
fc6d4c33e3 add delete_doc and update_doc to MyFAISS.py 2023-06-13 22:39:41 +08:00
glide-the
0abd2d9992 llama_llm.py 提示词修改 2023-06-13 18:36:07 +08:00
imClumsyPanda
fef22e3133
Update README.md 2023-06-12 21:38:38 +08:00
imClumsyPanda
cb870694df
Add files via upload 2023-06-12 21:38:16 +08:00
glide-the
f1cfd6d688 cli失败的问题 2023-06-12 20:38:06 +08:00
glide-the
7e89f5b69b cli失败的问题 2023-06-12 20:35:29 +08:00
glide-the
ff3fc48a31
Merge pull request #599 from hzg0601/dev
修复[bug] #598 #601,解决通过cli.py启动api、cli失败的问题
修改cli_demo启动顺序的问题
2023-06-12 20:29:44 +08:00
Li Xing
0f0c4d740a
Update README.md (#608) 2023-06-12 20:09:14 +08:00
hzg0601
4054e46cab 更新FAQ,增加了[Errno 110] Connection timed out的原因与解决方案 2023-06-12 16:28:40 +08:00
hzg0601
eb620ddefc 修复 bing_search.py的typo;更新model_config.py中Bing Subscription Key申请方式及注意事项 2023-06-12 16:22:07 +08:00
hzg0601
17f9a00eaf 解决无法从cli.py启动cli_demo的问题 2023-06-12 13:20:23 +08:00
hzg0601
a3ee718ab5 temp 2023-06-12 12:57:41 +08:00
hzg0601
4f7dc28f08 修复通过cli.py启动api的错误 2023-06-12 10:38:08 +08:00
Zhi-guo Huang
453702dbe1
Merge branch 'imClumsyPanda:dev' into dev 2023-06-12 00:42:21 +08:00
imClumsyPanda
ecd7b6133b updata model_config.py 2023-06-12 00:10:47 +08:00
imClumsyPanda
7863e0fea8 updata MyFAISS 2023-06-12 00:06:06 +08:00
Zhi-guo Huang
27a9bf2433
更新FAQ和requirements,解决upload_file接口的两个异常 (#593) 2023-06-11 21:25:02 +08:00
imClumsyPanda
66c4e9de92 Merge branch 'master' into dev 2023-06-11 21:16:08 +08:00
glide-the
ef69c3f5e6 bing搜索agent 2023-06-10 22:26:16 +08:00
glide-the
5afee735a9 bing搜索agent 2023-06-10 22:15:39 +08:00
glide-the
b657eb245f 增加llm打印 2023-06-10 22:14:50 +08:00
hzg0601
0b5ebf667c 更新FAQ和requirements,解决upload_file接口的两个异常 2023-06-10 12:19:29 +08:00
glide-the
b352c29d46 llm 2023-06-09 21:05:10 +08:00
imClumsyPanda
dec0c46816 add support for new embedding models: moka-ai/m3e-base and moka-ai/m3e-small 2023-06-09 19:04:34 +08:00
imClumsyPanda
80faf3a11e
Update README.md 2023-06-09 16:29:24 +08:00
imClumsyPanda
90aead2ecd
Add files via upload 2023-06-09 16:29:02 +08:00
imClumsyPanda
55fa36eef8
Delete 27a1d57131f663c59481e76af66c48fa.jpeg 2023-06-09 16:28:30 +08:00
imClumsyPanda
60ad46c7fb
Add files via upload 2023-06-09 16:27:59 +08:00
glide-the
218aca2e20 删除model_dir和NO_REMOTE_MODEL 2023-06-08 16:51:04 +08:00
imClumsyPanda
f1f742ce44 add self-defined class MyFAISS 2023-06-07 23:18:47 +08:00
imClumsyPanda
43b389aa16
Update README.md 2023-06-07 22:47:08 +08:00
imClumsyPanda
3ecbd5cf21
Add files via upload 2023-06-07 22:46:16 +08:00
imClumsyPanda
89b986c3bc add support for csv file 2023-06-07 22:20:47 +08:00
imClumsyPanda
8b7c2e417c add support for csv file 2023-06-07 22:14:08 +08:00
imClumsyPanda
14c34516ba
Dev (#572)
* feat(webui): update port number in Vite config file from 1002 to 8090

* update chatglm_llm.py

---------

Co-authored-by: NieLamu <mxmxlty@gmail.com>
Co-authored-by: fxjhello <127916299+fxjhello@users.noreply.github.com>
2023-06-07 21:26:31 +08:00
imClumsyPanda
46b872a854 update chatglm_llm.py 2023-06-07 21:25:40 +08:00
imClumsyPanda
bb8224025e Merge branch 'master' into dev 2023-06-07 18:15:27 +08:00
imClumsyPanda
a438b2bb15 Merge branch 'master' into dev 2023-06-07 18:15:03 +08:00
shrimp
57b4f9306d
修复BUG (#570)
一、修复模型历史记录仅一条问题,修改了模型加载代码,已修复。 
二、修复模型历史记录仅一条问题,修改了webui有一个地方有问题,已修复。
三、知识库单条数据入库因知识库名称缓存问题导致的BUG,也已修复。
2023-06-07 18:12:51 +08:00
fxjhello
e5e0706a96
Merge pull request #555 from NieLamu/feat/vue-port
feat(webui): update port number in Vite config file from 1002 to 8090
2023-06-06 18:55:36 +08:00
NieLamu
29c8c7f2c6 feat(webui): update port number in Vite config file from 1002 to 8090 2023-06-06 17:43:29 +08:00
imClumsyPanda
9dee1f28c0
Update README.md 2023-06-06 14:50:44 +08:00
imClumsyPanda
ee867c23a8
Add files via upload 2023-06-06 13:20:46 +08:00
imClumsyPanda
a8dc7e38df
Update README.md 2023-06-05 07:56:34 +08:00
imClumsyPanda
099e8c1d6c
Add files via upload 2023-06-05 07:56:11 +08:00
imClumsyPanda
0f62f197fd
Update README.md 2023-06-04 12:10:08 +08:00
zzxs
dc52bb134d
Update api.py (#540)
修改api部署json解析
2023-06-03 14:20:03 +08:00
imClumsyPanda
33683f447c Merge branch 'master' into dev 2023-06-03 14:17:32 +08:00
郑肖峰
b22e15ab90
Vs refresh (#529)
* Update README.md

* Add files via upload

* Update README.md

* Update README.md

* gradio webui 刷新页面更新知识库列表

* update webui.py

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
Co-authored-by: 扶桑 <fusang@myweimai.com>
2023-06-03 14:15:29 +08:00
imClumsyPanda
82cc85bde4
Update README.md 2023-06-02 14:08:48 +08:00
imClumsyPanda
d819a6d7ce
Update README.md 2023-06-02 14:08:01 +08:00
imClumsyPanda
8fdc877a3e
Add files via upload 2023-06-01 21:48:00 +08:00
imClumsyPanda
b035f2046f
Update README.md 2023-06-01 21:47:06 +08:00
imClumsyPanda
5290730dee update README.md 2023-05-31 23:01:43 +08:00
imClumsyPanda
27ef86f8e6 update streamlit ui 2023-05-31 22:57:18 +08:00
imClumsyPanda
e093f8694a add fastchat.md 2023-05-31 22:56:32 +08:00
imClumsyPanda
20f1daff1a add fastchat.md 2023-05-31 22:50:35 +08:00
imClumsyPanda
23052629ad update requirements.txt 2023-05-31 22:31:54 +08:00
glide-the
ab73f6ad93 适配远程LLM调用 2023-05-31 22:26:39 +08:00
glide-the
24324563d6 适配远程LLM调用 2023-05-31 22:11:28 +08:00
imClumsyPanda
99e9d1d730 update FAQ.md 2023-05-31 21:13:21 +08:00
imClumsyPanda
ae35b049ff update README.md 2023-05-31 21:05:44 +08:00
imClumsyPanda
b1ba2003be update webui.py 2023-05-31 20:55:45 +08:00
imClumsyPanda
a072905893 Merge branch 'master' into dev 2023-05-31 18:06:07 +08:00
imClumsyPanda
5c0c1eed93 update pdf_loader.py 2023-05-31 18:03:37 +08:00
imClumsyPanda
99ee2e9fd8
Update README.md 2023-05-31 16:28:43 +08:00
imClumsyPanda
46a7690df5
Update README.md 2023-05-31 16:28:18 +08:00
imClumsyPanda
ad613a67d6
Add files via upload 2023-05-31 16:27:54 +08:00
glide-the
0f2ea29194 调整项目结构,适配远程LLM调用生成问题。新增fastchat_openai_llm.py实现fastchat openai报文报文形式调用 2023-05-31 00:00:35 +08:00
imClumsyPanda
f5a85a1955 Merge branch 'master' into dev 2023-05-30 23:35:02 +08:00
liunux4odoo
88fee48d8c
use lru_cache to optimize loading of local vector store (#496)
* Add files via upload

* Update README.md

* use lru_cache to optimize loading of local vector store

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
Co-authored-by: liunux <liunux@office>
2023-05-30 23:05:39 +08:00
glide-the
0a605bf4b5 调整项目结构 2023-05-30 20:40:27 +08:00
zhoutongqing
875dae64bf
zhoutongqing:添加重新构建知识库功能 (#418)
Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-30 20:32:42 +08:00
移花香
8477368f9c
delete_docs (#499)
删除文档的时候重新生成知识库(FAISS)内的数据
2023-05-30 19:42:44 +08:00
imClumsyPanda
8d669cdb4c
Update README.md 2023-05-29 22:09:57 +08:00
imClumsyPanda
e07183a08c
Add files via upload 2023-05-29 22:09:11 +08:00
imClumsyPanda
f7044f6fe0 update webui.py 2023-05-29 00:16:16 +08:00
imClumsyPanda
c7106317a0 update webui.py 2023-05-29 00:03:49 +08:00
imClumsyPanda
89fe20b59f update QR Code 2023-05-28 19:22:55 +08:00
imClumsyPanda
486586c647 Merge branch 'master' into dev 2023-05-28 19:22:19 +08:00
Ding Junyao
f7e120fe56
add tree func for reading files in dirs (#471) 2023-05-27 22:00:43 +08:00
liunux4odoo
4295f6069d
添加streamlit ui (#480)
* update QR Code

* Add files via upload

* Update README.md

* add streamlit ui including all functions of webui

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-27 21:58:30 +08:00
imClumsyPanda
c7b069de09
Update README.md 2023-05-27 15:38:45 +08:00
imClumsyPanda
ec3ccd3363
Add files via upload 2023-05-27 15:38:18 +08:00
glide-the
3324c12d69 增加cpu加载模型逻辑 2023-05-26 22:52:55 +08:00
glide-the
561c40afee Merge remote-tracking branch 'origin/dev' into dev 2023-05-26 22:32:25 +08:00
glide-the
994401670b 拓展功能检查依赖提示安装 2023-05-26 22:32:12 +08:00
keenzhu
11bcb58ae6 增加rss订阅,以及添加了依赖文件 2023-05-26 18:50:20 +08:00
keenzhu
9dc9ac6380 添加依赖feedparser 2023-05-26 18:46:18 +08:00
keenzhu
8d4ef39c6c 添加RSS_loader.py用作从RSS订阅知识库 2023-05-26 18:43:55 +08:00
glide-the
1c5f71beee Merge remote-tracking branch 'origin/dev' into dev 2023-05-26 01:49:26 +08:00
glide-the
5f010823aa Build an abstract dialogue model using classes and methods to represent different dialogue elements
Fixes # None

Before submitting
If you want to review, please refer to the quick start example provided in langchain/chains/dialogue_answering/main.py. You may need to set the openaikey and the following startup parameters: --dialogue-path: the location of the dialogue file, --embedding-model: the HuggingFaceEmbeddings model to use (defaults to GanymedeNil/text2vec-large-chinese) if not specified.

Regarding the format of the dialogue file, please refer to the following information:

```text
sun:
Has the offline model been run?

glide-the:
Yes, it has been run, but the results are not very satisfactory.

glide-the:
It lacks chat intelligence and falls far behind in terms of logic and reasoning.

sun:
Are you available for voice chat?

glide-the:
I'm considering using this offline model: https://huggingface.co/chat

glide-the:
voice chat okay.

glide-the:
You can take a look at the dev_agent branch of the langchain-chatglm project.

glide-the:
There's a dialogue model question-answering example under the agent.

sun:
Alright.

glide-the:
The specified chat record file is exported from WeChat.
```
2023-05-26 01:49:07 +08:00
glide-the
cf07c014c4 Build an abstract dialogue model using classes and methods to represent different dialogue elements.
This class serves as a fundamental framework for constructing dialogue models.
2023-05-26 01:47:29 +08:00
glide-the
25e5ab1282 增加call_行为 2023-05-26 01:46:59 +08:00
imClumsyPanda
f0955768f5 update QR Code 2023-05-26 00:24:51 +08:00
imClumsyPanda
3d33191bd7 update chatglm_llm.py 2023-05-25 23:04:53 +08:00
imClumsyPanda
e4df46bcaa merge master 2023-05-25 22:57:51 +08:00
imClumsyPanda
684b893d4e update README.md 2023-05-25 22:45:27 +08:00
imClumsyPanda
a867cca747
Delete qr_code_21.jpg 2023-05-25 22:44:05 +08:00
imClumsyPanda
a1fd0b8750
Update chatglm_llm.py 2023-05-25 22:00:17 +08:00
glide-the
c4ee36b8ac 删除 AnswerResultStream 、generate_with_callback收集器 2023-05-25 21:07:40 +08:00
glide-the
e7b06a9072 删除流式请求中的缓存清理 2023-05-25 20:58:04 +08:00
imClumsyPanda
92185962ce
Update README.md 2023-05-25 12:34:17 +08:00
imClumsyPanda
d0c2cfbd0c
Update README.md 2023-05-25 10:58:31 +08:00
imClumsyPanda
22ac29a665
Update README.md 2023-05-25 10:55:02 +08:00
imClumsyPanda
26070ced34
Add files via upload 2023-05-25 10:54:35 +08:00
imClumsyPanda
67e8416181
Add files via upload 2023-05-25 10:49:10 +08:00
fxjhello
5eccb58759 Merge branch 'dev' of https://github.com/imClumsyPanda/langchain-ChatGLM into dev 2023-05-24 09:24:57 +08:00
fxjhello
46ae480e66 修改dockerfile 2023-05-24 09:24:20 +08:00
imClumsyPanda
bde1585cd5 Merge branch 'master' into dev 2023-05-24 00:21:07 +08:00
imClumsyPanda
52c6f2d29f fix int4 and int8 model init bug 2023-05-24 00:20:03 +08:00
imClumsyPanda
dd40c5d179 Merge branch 'master' into dev 2023-05-24 00:16:03 +08:00
imClumsyPanda
1ee12266e8 更新 requirements.txt 2023-05-24 00:12:59 +08:00
glide-the
a1b1b78108 使用model_config默认配置启动
llama_llm.py 删除流式输出
base.py、shared.py 删除多余代码
fastchat_llm.py 业务实现
2023-05-23 23:10:31 +08:00
zhubao315
eeea00e294
Update Dockerfile-cuda (#446) 2023-05-23 16:14:07 +08:00
imClumsyPanda
3d17478588
Update README.md 2023-05-23 08:35:33 +08:00
imClumsyPanda
42a22c927b
Add files via upload 2023-05-23 08:35:01 +08:00
imClumsyPanda
3fd47b0d40 Merge branch 'master' into dev 2023-05-22 18:19:38 +08:00
imClumsyPanda
78e940f0a7 update README.md 2023-05-22 18:16:31 +08:00
imClumsyPanda
bca32cae83 update local_doc_qa.py 2023-05-22 18:09:23 +08:00
glide-the
6f8da56083
Update loader.py
删除低显存加载参数
2023-05-22 16:12:01 +08:00
fxjhello
52cf43a479 数据格式处理 2023-05-22 14:03:27 +08:00
imClumsyPanda
9f7eb3cea8
更新 requirements.txt 2023-05-22 13:20:18 +08:00
imClumsyPanda
c79058f064
更新 local_doc_qa.py 2023-05-22 13:14:23 +08:00
fxjhello
1e43fcfbe3 Merge branch 'dev' of https://github.com/imClumsyPanda/langchain-ChatGLM into dev 2023-05-22 12:00:07 +08:00
fxjhello
c439e66fa2 前端代理地址修改 2023-05-22 11:59:39 +08:00
imClumsyPanda
ad843a646d update api.py 2023-05-22 11:53:11 +08:00
fxjhello
8742001982 Merge branch 'dev' of https://github.com/imClumsyPanda/langchain-ChatGLM into dev 2023-05-22 11:45:45 +08:00
fxjhello
919a400cec bingsearch前后端修改,history完善 2023-05-22 11:45:41 +08:00
yawudede
4634a578f4
local_doc_qa.py 2023-05-22 10:39:55 +08:00
yawudede
9140a5e70c
local_doc_qa.py 2023-05-22 10:36:41 +08:00
yawudede
037b5e4502
local_doc_qa.py
添加精排
2023-05-22 10:32:58 +08:00
imClumsyPanda
b8272bfe14 update README.md 2023-05-22 00:26:04 +08:00
imClumsyPanda
06f6e1913e merge master 2023-05-22 00:24:07 +08:00
imClumsyPanda
e352a04cbb merge master 2023-05-22 00:18:48 +08:00
imClumsyPanda
d2983e935f update loaders 2023-05-22 00:15:29 +08:00
imClumsyPanda
5acea5e4fc update loaders 2023-05-21 23:52:35 +08:00
imClumsyPanda
68e593a64a update README.md 2023-05-21 23:34:26 +08:00
imClumsyPanda
0f3fc5234d update webui.py and api.py 2023-05-21 23:04:46 +08:00
imClumsyPanda
483b7dd291 update model_config.py 2023-05-21 22:41:22 +08:00
imClumsyPanda
12316d0658 update model_config.py 2023-05-21 22:40:53 +08:00
imClumsyPanda
67e26fe730 update model_config.py 2023-05-21 22:30:28 +08:00
imClumsyPanda
5f38645fa1 update api.py 2023-05-21 22:27:02 +08:00
imClumsyPanda
2707f58aa1 update bing_search.py 2023-05-21 22:08:55 +08:00
imClumsyPanda
9c422cc6bc update bing_search.py 2023-05-21 22:08:38 +08:00
imClumsyPanda
f986b756ff update chinese_text_splitter.py 2023-05-21 21:24:25 +08:00
imClumsyPanda
14295392d0 update loader 2023-05-21 21:21:00 +08:00
fxjhello
6960216125
Merge pull request #425 from mayflyfy/master
修复每次对话携带多余数据的问题
2023-05-21 21:10:25 +08:00
mayfly
e102bbf021
Update index.vue
FIX:修复每次对话携带多余数据的问题
2023-05-21 21:05:05 +08:00
imClumsyPanda
871a871651 update model_loader 2023-05-21 15:30:52 +08:00
imClumsyPanda
3712eec6a9 update pdf_loader.py 2023-05-21 15:05:35 +08:00
imClumsyPanda
d8ae43a897
Update README.md 2023-05-20 22:17:01 +08:00
imClumsyPanda
498c17cd7c
Add files via upload 2023-05-20 22:16:35 +08:00
imClumsyPanda
94b4599cda update requirements.txt 2023-05-20 01:58:08 +08:00
imClumsyPanda
2681728329 update local_doc_qa.py 2023-05-20 01:54:08 +08:00
imClumsyPanda
6d1523728b update pdf_loader.py 2023-05-20 01:25:50 +08:00
imClumsyPanda
e8a37ff4c7 update loader.py 2023-05-20 01:24:35 +08:00
zhenkaivip
9f5d1afc31
fix bug : 1、历史最后一条丢失;2、上下两行连读造成歧义 (#415)
* fix _call bug

* fix

* fix bug : 上下两行连读造成歧义
2023-05-20 01:19:22 +08:00
imClumsyPanda
d5ffdaa281 update loader.py 2023-05-20 00:06:41 +08:00
imClumsyPanda
aa26645407 Merge remote-tracking branch 'origin/dev' into dev 2023-05-19 23:56:43 +08:00
imClumsyPanda
6c251bd2cf update callback.py 2023-05-19 23:56:36 +08:00
glide-the
65412e6cfb moss_llm.py 删除 stopping_criteria 2023-05-19 23:47:13 +08:00
imClumsyPanda
ff7ac0333e update model_config.py 2023-05-19 23:45:01 +08:00
imClumsyPanda
09248391c2 Merge remote-tracking branch 'origin/dev' into dev 2023-05-19 23:42:00 +08:00
imClumsyPanda
e057c88621 update model_config.py 2023-05-19 23:41:52 +08:00
glide-the
62ce5f0775 self.device_map 参数初始化逻辑
LLamaLLM 加载器
2023-05-19 23:38:36 +08:00
imClumsyPanda
49e47231af update model_config.py 2023-05-19 23:16:39 +08:00
imClumsyPanda
7d837078e7 update model_config.py 2023-05-19 23:12:39 +08:00
imClumsyPanda
00d80335fe update loader.py 2023-05-19 22:55:19 +08:00
glide-the
5524c47645
Update moss_llm.py 2023-05-19 17:32:38 +08:00
glide-the
7c74933285
Update api.py 删除默认启动参数 2023-05-19 13:07:59 +08:00
glide-the
d9cc4e918c
Update INSTALL.md 2023-05-19 11:04:28 +08:00
glide-the
75cf9f9b4e ptuning-v2配置 2023-05-18 23:19:23 +08:00
glide-the
55a414ecfa jupyter-notebook:agent测试 2023-05-18 23:07:15 +08:00
glide-the
4c008c25d4 增加项目可选启动项说明、增加项目结构说明
cli_demo.py、api.py: 兼容loader加载器
2023-05-18 22:55:50 +08:00
glide-the
33bbb4779e llm_model_dict 处理了loader的一些预设行为,如加载位置,模型名称,模型处理器实例, 定义checkpoint名称和远程路径
loader.py: 模型重载
定义 generatorAnswer 增加 AnswerResultStream
   定义generate_with_callback收集器,在每次响应时将队列数据同步到AnswerResult
requirements.txt 变更项目依赖
2023-05-18 22:54:41 +08:00
imClumsyPanda
18d6b68643
Update README.md 2023-05-18 14:34:18 +08:00
imClumsyPanda
eef6b340c3
Add files via upload 2023-05-18 14:33:52 +08:00
fxjhello
c3924b2ece
Merge pull request #394 from halfss/dev
bug fixed & ui Moidfy
2023-05-17 21:39:33 +08:00
root
4f88ed796c 1: fixed bug of ui in mobile
2: add backgound image
2023-05-17 10:26:47 +00:00
CHANGXUBO
cb8466900f
Fix MOSS模型BUG (#389) 2023-05-17 13:44:39 +08:00
CHANGXUBO
a5417e1cf5
更新install说明,解决PaddleOCR依赖问题 (#387) 2023-05-17 13:28:10 +08:00
imClumsyPanda
1f5c0b14c5
Update README.md 2023-05-17 08:51:29 +08:00
imClumsyPanda
f9f6b336b3
Add files via upload 2023-05-17 08:48:58 +08:00
halfss
dfcd6f6102
添加bing搜索agent (#378)
* 1: 基于langchain的bing search agent添加bing搜索支持(百度不靠谱,Google不可用)
2: 调整输入框交互模式,对话/知识库/搜索,三选一

* fixed bug of message have no text

---------

Co-authored-by: root <jv.liu@i1368.com>
2023-05-16 23:51:34 +08:00
fxjhello
537269d5c4 打包配置 2023-05-16 13:00:12 +08:00
fxjhello
458ed26b79 前端打包配置 2023-05-16 12:56:47 +08:00
fxjhello
2eadf8d9f5 配置后端地址 2023-05-16 10:24:55 +08:00
fxjhello
5bac7591db 设置api 2023-05-16 10:21:25 +08:00
fxjhello
78c20e33b7 后端地址配置 2023-05-16 10:08:11 +08:00
fxjhello
ff8cecd780
Merge pull request #365 from halfss/dev
add Knowledge Base delete and file delete
2023-05-15 19:54:05 +08:00
imClumsyPanda
228e460b1a update REAMDE.md 2023-05-15 19:51:20 +08:00
imClumsyPanda
7935162f4a Merge branch 'master' into dev 2023-05-15 19:49:56 +08:00
imClumsyPanda
fa431b90ef Merge remote-tracking branch 'origin/dev' into dev 2023-05-15 19:49:14 +08:00
imClumsyPanda
dab0530a2f update REAMDE.md 2023-05-15 19:49:00 +08:00
zqt996
a0cb14de23
添加命令行管理脚本 (#355)
* 添加加命令行工具

* 添加加命令行工具

---------

Co-authored-by: zqt <1178747941@qq.com>
Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-15 19:13:12 +08:00
royd
1678392cee
Update api.py (#357)
更改目前流式对话的传入模式,使其可以支持多轮对话,体现在新增参数:history、knowledge_base_id
2023-05-15 19:11:00 +08:00
imClumsyPanda
0fca4c9590 Merge remote-tracking branch 'origin/dev' into dev 2023-05-15 18:58:51 +08:00
imClumsyPanda
f54effb3ab update webui.py 2023-05-15 18:58:36 +08:00
imClumsyPanda
48ab7c4fa6 update webui.py 2023-05-15 18:45:40 +08:00
root
2563b16af0 add Knowledge Base delete and file delete 2023-05-15 08:29:58 +00:00
imClumsyPanda
f9638a5eac
Update README.md 2023-05-15 15:58:55 +08:00
imClumsyPanda
d647bd8e74
Add files via upload 2023-05-15 15:58:26 +08:00
fxjhello
11f5d387fc
Merge pull request #362 from halfss/dev
fixed bug of upload file use fixed url
2023-05-15 13:04:45 +08:00
root
7fcbec3409 fixed bug of upload file use fixed url 2023-05-15 04:44:28 +00:00
imClumsyPanda
31121945fc update requirements.txt 2023-05-14 00:36:42 +08:00
imClumsyPanda
5284fb2726 Merge branch 'master' into dev 2023-05-14 00:14:43 +08:00
TOMCAT 007
c86dd4dd47 vue页面开发完成 2023-05-13 23:03:07 +08:00
imClumsyPanda
3ff885d0d3 update api.py 2023-05-13 21:35:17 +08:00
fxjhello
fc9d9f3c25 vue页面完成90% 2023-05-13 20:29:27 +08:00
fxjhello
839911a330 Merge branch 'dev' of https://github.com/imClumsyPanda/langchain-ChatGLM into dev 2023-05-13 16:59:56 +08:00
fxjhello
01bf39bc89 文件接口 2023-05-13 16:59:52 +08:00
imClumsyPanda
80854c4bcd update loaders 2023-05-13 12:36:48 +08:00
imClumsyPanda
621a0fe686 update cli_demo.py 2023-05-13 11:45:57 +08:00
imClumsyPanda
144d9a8ca3 Merge branch 'dev' 2023-05-13 11:28:00 +08:00
imClumsyPanda
5b17cfc2e7 update README.md 2023-05-13 11:27:46 +08:00
imClumsyPanda
82f1b7f2e3 Merge branch 'dev' 2023-05-13 11:24:24 +08:00
imClumsyPanda
1a1989d860 update README.md 2023-05-13 11:24:06 +08:00
imClumsyPanda
6a273501ee update loaders 2023-05-13 11:16:51 +08:00
zhenkaivip
d2716addd6
使用paddleocr实现实现UnstructuredPaddlePDFLoader和UnstructuredPaddleImageLoader (#344)
* jpg and png ocr

* fix

* write docs to tmp file

* fix

* image loader

* fix

* fix

* add pdf_loader

* fix

* update INSTALL.md

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-13 11:13:40 +08:00
imClumsyPanda
6e7078cf24 update api.py 2023-05-13 11:02:27 +08:00
imClumsyPanda
ff8182f49a update api.py 2023-05-13 11:01:41 +08:00
imClumsyPanda
37b2fb18b7 update .gitignore 2023-05-13 09:51:46 +08:00
imClumsyPanda
6e23253013 update pdf_loader.py and image_loader.py 2023-05-13 09:50:30 +08:00
imClumsyPanda
bbb1c0707d Merge branch 'dev' of https://github.com/imClumsyPanda/langchain-ChatGLM into dev 2023-05-13 08:46:46 +08:00
zhenkaivip
dd93837343
使用paddleocr实现 (#342)
* jpg and png ocr

* fix

* write docs to tmp file

* fix

* [BUGFIX] local_doc_qa.py line 172: logging have no end args. (#323)

* image loader

* fix

* fix

* update api.py

* update api.py

* update api.py

* update README.md

* update api.py

* add pdf_loader

* fix

---------

Co-authored-by: RainGather <3255329+RainGather@users.noreply.github.com>
Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-13 08:45:17 +08:00
imClumsyPanda
6e022d0d45 update api.py 2023-05-12 22:24:31 +08:00
imClumsyPanda
dafa94efac update README.md 2023-05-12 20:57:16 +08:00
imClumsyPanda
a8ac40163c update api.py 2023-05-12 20:46:51 +08:00
imClumsyPanda
5575079e6b update api.py 2023-05-12 18:23:13 +08:00
imClumsyPanda
8635f63c31 update api.py 2023-05-12 18:13:35 +08:00
RainGather
f173d8b6b1
[BUGFIX] local_doc_qa.py line 172: logging have no end args. (#323) 2023-05-12 07:45:57 +08:00
imClumsyPanda
dcf6e4ffeb update README.md 2023-05-11 18:48:46 +08:00
Tyler Luan
64406cee45
Add MOSS (#317)
* Add MOSS

* Update local_doc_qa.py

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-11 18:42:19 +08:00
imClumsyPanda
d43b383ea5 update api.py 2023-05-11 18:38:41 +08:00
imClumsyPanda
88175c2e32 Merge branch 'master' into dev 2023-05-11 18:38:15 +08:00
imClumsyPanda
f02df58f41 update api.py 2023-05-11 18:37:33 +08:00
RainGather
b0714eed5e
Update chatglm_llm.py (#316) 2023-05-11 14:36:52 +08:00
imClumsyPanda
ecc0c43ab9
Update README.md 2023-05-11 12:43:43 +08:00
imClumsyPanda
4b2dc17d65
Add files via upload 2023-05-11 12:43:18 +08:00
Tyler Luan
8289338c47
Multi-gpu lora load bugfix (#312) 2023-05-11 11:32:17 +08:00
Tyler Luan
31655339f0
chatglm init twice (#313) 2023-05-11 11:31:15 +08:00
imClumsyPanda
5852b4c62e update pdf read strategy 2023-05-11 10:54:45 +08:00
akou
2987c9cd52
增加允许跨域调用API功能 (#279) 2023-05-11 09:32:58 +08:00
imClumsyPanda
e1c56edb6f update README.md 2023-05-11 00:24:57 +08:00
imClumsyPanda
f403ad755c update README.md 2023-05-11 00:09:38 +08:00
imClumsyPanda
cda18c6a60 update README.md 2023-05-11 00:08:39 +08:00
imClumsyPanda
7aae5b4507 update README.md 2023-05-10 23:36:16 +08:00
imClumsyPanda
264981e4b6 update webui.py 2023-05-10 23:21:36 +08:00
imClumsyPanda
9f07ead562 update webui.py 2023-05-10 23:13:52 +08:00
imClumsyPanda
24223cfb6f update webui.py 2023-05-10 23:06:19 +08:00
shrimp
519a77428a
Update webui.py (#309)
修复文件上传BUG
2023-05-10 22:22:30 +08:00
fxjhello
c0a6bdb5d9
Update README.md 2023-05-10 20:36:15 +08:00
imClumsyPanda
02fecb8c53 update webui.py 2023-05-10 18:23:04 +08:00
imClumsyPanda
fbdc62d910 merge master 2023-05-10 17:59:28 +08:00
shrimp
55504fcd4d
新增加知识库测试能力 (#302) 2023-05-10 17:18:20 +08:00
fxjhello
a256f25ea9 xxx 2023-05-10 13:29:10 +08:00
JohnSaxon
466bfb7a3f
logger bug introduced by https://github.com/imClumsyPanda/langchain-ChatGLM/pull/268 , fixed #295 (#297) 2023-05-10 13:28:44 +08:00
fxjhello
3ff1ac6e96 前端修复 2023-05-10 13:19:01 +08:00
fxjhello
7d32a890cd Merge branch 'dev' of https://github.com/imClumsyPanda/langchain-ChatGLM into dev 2023-05-10 13:15:00 +08:00
fxjhello
8612b34415 更新views 2023-05-10 13:13:12 +08:00
imClumsyPanda
980019fb73
Update README.md 2023-05-10 09:41:38 +08:00
imClumsyPanda
6468fe2a2c
Add files via upload 2023-05-10 09:41:11 +08:00
YiiSh
e7f66a6be0
修复默认知识库获取的逻辑 (#293) 2023-05-10 09:30:00 +08:00
imClumsyPanda
b06b711cb3 update content 2023-05-09 20:49:43 +08:00
fxjhello
809eba8c67 增加前端views 2023-05-09 11:46:31 +08:00
imClumsyPanda
c613c41d0e update local_doc_qa.py 2023-05-08 23:49:57 +08:00
imClumsyPanda
e8b2ddea51 update README.md 2023-05-08 23:41:32 +08:00
imClumsyPanda
b4087a7f78 update textsplitter 2023-05-08 19:26:46 +08:00
imClumsyPanda
f7609b37f5 Merge branch 'master' into dev 2023-05-08 19:26:21 +08:00
imClumsyPanda
36050572e6 更新 __init__.py 2023-05-08 19:25:00 +08:00
imClumsyPanda
6be9f18ec9 Update README.md 2023-05-08 19:25:00 +08:00
imClumsyPanda
b9c8468c5f Add files via upload 2023-05-08 19:25:00 +08:00
imClumsyPanda
64275cb703 update textsplitter 2023-05-08 19:23:06 +08:00
CHANGXUBO
47e9bdb122
logging: 格式日志输出 (#268)
* logging: 统一日志格式输出

---------

Co-authored-by: Bob Chang <bob.chang@amway.com>
Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-08 18:29:09 +08:00
imClumsyPanda
eb5f6647b6
更新 __init__.py 2023-05-08 12:08:39 +08:00
imClumsyPanda
85ad6cbe65
Update README.md 2023-05-07 23:28:02 +08:00
imClumsyPanda
bb8f090bbb
Add files via upload 2023-05-07 23:27:37 +08:00
imClumsyPanda
7f25c9fa8e update textsplitter 2023-05-07 12:16:01 +08:00
imClumsyPanda
d898c7dd6c update textsplitter 2023-05-07 12:06:09 +08:00
imClumsyPanda
4150af003a merge master 2023-05-06 23:56:39 +08:00
imClumsyPanda
e2d7452c7b update chinese_text_splitter.py 2023-05-06 23:26:49 +08:00
CHANGXUBO
3111fb56bd
Fix: 将gradio版本升级至3.28.3,修复知识库下拉框change事件获取值不是当前选中值的bug。 (#261)
* webui优化:解决每次页面刷新后都需要重新选择知识库的问题,增加Flagging收集问答效果。

* Fix: 将gradio版本升级至3.28.3,修复知识库下拉框change事件获取值不是当前选中值的bug。

* solve webui confict

---------

Co-authored-by: Bob Chang <bob.chang@amway.com>
Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-06 21:38:15 +08:00
imClumsyPanda
12fa4a2bb7 update cli_demo.py 2023-05-06 19:24:58 +08:00
keenzhu
2c72a00954
Update local_doc_qa.py
增加命令行导入的进度条显示
增加文本提示
2023-05-06 18:39:58 +08:00
keenzhu
26393f488b
Update cli_demo.py
加了一个判断用户输入本地知识路径是否为空的判断,避免误触回车
2023-05-06 18:34:37 +08:00
imClumsyPanda
0a4dd1987d update webui.py 2023-05-06 12:07:32 +08:00
Bob Chang
63453f2340
webui优化:解决每次页面刷新后都需要重新选择知识库的问题,增加Flagging收集问答效果。 (#250)
Co-authored-by: Bob Chang <bob.chang@amway.com>
2023-05-06 11:57:48 +08:00
imClumsyPanda
3adfecaa4d
Update README.md 2023-05-06 10:55:30 +08:00
imClumsyPanda
fb7c9170a4
Add files via upload 2023-05-06 10:55:00 +08:00
royd
23a6b26f3e
增加语义切分模型 (#248) 2023-05-05 23:38:53 +08:00
shrimp
0d9db37f45
完善API接口,完善模型加载 (#247)
* 完善知识库路径问题,完善api接口

统一webui、API接口知识库路径,后续路径如下:
知识库路经就是:/项目代码文件夹/vector_store/'知识库名字'
文件存放路经:/项目代码文件夹/content/'知识库名字'

修复通过api接口创建知识库的BUG,完善API接口功能。

* Update model_config.py


* 完善知识库路径问题,完善api接口 (#245) (#246)

* Fix 知识库无法上载,NLTK_DATA_PATH路径错误 (#236)

* Update chatglm_llm.py (#242)

* 完善知识库路径问题,完善api接口

统一webui、API接口知识库路径,后续路径如下:
知识库路经就是:/项目代码文件夹/vector_store/'知识库名字'
文件存放路经:/项目代码文件夹/content/'知识库名字'

修复通过api接口创建知识库的BUG,完善API接口功能。

* Update model_config.py

---------

Co-authored-by: shrimp <411161555@qq.com>
Co-authored-by: Bob Chang <bob-chang@outlook.com>

* 优化API接口,完善模型top_p参数

优化API接口,知识库非必须选项。
完善模型top_p参数

* 完善API接口,完善模型加载

API接口知识库非必须加载项
完善模型top_p参数。

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
Co-authored-by: Bob Chang <bob-chang@outlook.com>
2023-05-05 22:31:41 +08:00
imClumsyPanda
41cd0fd8ae
完善知识库路径问题,完善api接口 (#245) (#246)
* Fix 知识库无法上载,NLTK_DATA_PATH路径错误 (#236)

* Update chatglm_llm.py (#242)

* 完善知识库路径问题,完善api接口

统一webui、API接口知识库路径,后续路径如下:
知识库路经就是:/项目代码文件夹/vector_store/'知识库名字'
文件存放路经:/项目代码文件夹/content/'知识库名字'

修复通过api接口创建知识库的BUG,完善API接口功能。

* Update model_config.py

---------

Co-authored-by: shrimp <411161555@qq.com>
Co-authored-by: Bob Chang <bob-chang@outlook.com>
2023-05-05 19:32:11 +08:00
imClumsyPanda
6ac8f73a52
Merge branch 'master' into dev 2023-05-05 19:32:02 +08:00
shrimp
7497b261b3
完善知识库路径问题,完善api接口 (#245)
* Fix 知识库无法上载,NLTK_DATA_PATH路径错误 (#236)

* Update chatglm_llm.py (#242)

* 完善知识库路径问题,完善api接口

统一webui、API接口知识库路径,后续路径如下:
知识库路经就是:/项目代码文件夹/vector_store/'知识库名字'
文件存放路经:/项目代码文件夹/content/'知识库名字'

修复通过api接口创建知识库的BUG,完善API接口功能。

* Update model_config.py

---------

Co-authored-by: Bob Chang <bob-chang@outlook.com>
Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-05 18:44:37 +08:00
imClumsyPanda
e629526589
Update chatglm_llm.py (#242) 2023-05-05 15:14:17 +08:00
Bob Chang
51d0b7f855
Fix 知识库无法上载,NLTK_DATA_PATH路径错误 (#236) 2023-05-05 08:21:39 +08:00
imClumsyPanda
fc7197fe5f delete qr code 10 2023-05-04 21:23:24 +08:00
imClumsyPanda
21940a3563 Merge remote-tracking branch 'origin/master' into dev 2023-05-04 21:21:55 +08:00
shrimp
14d998b8e6
可选择lora权重加载 (#231)
* Add files via upload

增加lora权重使用

* Update model_config.py

* Add files via upload

修复一个小错误,少写了模型加载

* 使用lora微调的权重

使用lora微调的权重

* Update model_config.py
2023-05-04 21:01:55 +08:00
Winter
47922d2ee3
fix: 扩展文档的代码逻辑 (#227)
* fix: 扩展文档的代码逻辑

* Update local_doc_qa.py

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-04 20:58:15 +08:00
imClumsyPanda
07ff81a119 update torch_gc 2023-05-04 20:48:36 +08:00
imClumsyPanda
0adcc64dae
Update README.md (#228) 2023-05-04 16:04:24 +08:00
imClumsyPanda
22f35bd726
Add files via upload 2023-05-04 16:03:46 +08:00
miller
09f57741fa
Update INSTALL.md (#223) 2023-05-04 13:34:01 +08:00
imClumsyPanda
b03634fb7c add api.py 2023-05-03 22:35:05 +08:00
imClumsyPanda
2c1fd2bdd5 add api.py 2023-05-03 22:31:28 +08:00
Bing Han
e0cf26019b
Use fastapi to implement API (#209)
* Use fastapi to implement API

* Update model_config.py

---------

Co-authored-by: imClumsyPanda <littlepanda0716@gmail.com>
2023-05-03 21:29:28 +08:00
imClumsyPanda
4e9de7df41 Merge branch 'master' into dev 2023-05-03 13:15:00 +08:00
imClumsyPanda
3f43199449 update utils 2023-05-03 13:14:36 +08:00
imClumsyPanda
8c4b2f9f6d Merge branch 'master' into dev 2023-05-03 11:33:45 +08:00
imClumsyPanda
57d4d0a29e update chatglm_llm.py 2023-05-03 11:29:59 +08:00
imClumsyPanda
e567b862cc update utils 2023-05-03 10:08:35 +08:00
imClumsyPanda
8db6cd5119 update utils 2023-05-03 10:05:08 +08:00
glide-the
a0b312d749 Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
#	configs/model_config.py
2023-05-02 12:43:27 +08:00
imClumsyPanda
4c8429cb15
update README.md (#217) 2023-05-02 10:48:49 +08:00
imClumsyPanda
35aa8119f8 update README.md 2023-05-02 10:48:13 +08:00
imClumsyPanda
a4e67a67b4 update local_doc_qa.py 2023-05-02 01:11:05 +08:00
imClumsyPanda
c98c4888e9 update PROMPT_TEMPLATE 2023-05-02 00:28:09 +08:00
imClumsyPanda
7a406e4263
Dev (#214)
* github: Add issue templates

* supports GPU usage in docker (#197)

* 上下文的prompt模版内容修改

---------

Co-authored-by: Calcitem <calcitem@outlook.com>
Co-authored-by: cocomany <124849750+cocomany@users.noreply.github.com>
Co-authored-by: glide-the <2533736852@qq.com>
2023-05-01 23:55:37 +08:00
imClumsyPanda
4df9d76f8a add streaming option in configs/model_config.py 2023-05-01 23:52:28 +08:00
imClumsyPanda
0e8cc0d16c add streaming option in configs/model_config.py 2023-05-01 23:52:28 +08:00
imClumsyPanda
2ebcd1369e
Update README.md (#213) 2023-05-01 21:42:47 +08:00
imClumsyPanda
b6033cb3d8
Add files via upload 2023-05-01 21:41:54 +08:00
glide-the
bf2466d91c 上下文的prompt模版内容修改 2023-04-30 14:34:41 +08:00
cocomany
7f8fcc81c4
supports GPU usage in docker (#197) 2023-04-29 22:40:35 +08:00
Calcitem
d9dfd1942c
github: Add issue templates (#205) 2023-04-29 22:39:18 +08:00
Calcitem
b95ad4fcbc github: Add issue templates 2023-04-29 01:57:54 +08:00
imClumsyPanda
474e3414c5 update README.md 2023-04-28 19:11:26 +08:00
cocomany
66b104d26a
supports GPU usage in docker (#196)
Co-authored-by: Huaiyong <huaiyong.sun@hpe.com>
2023-04-28 11:24:59 +08:00
364 changed files with 41734 additions and 2006 deletions

19
.dockerignore Normal file
View File

@ -0,0 +1,19 @@
.idea
# Langchain-Chatchat
docs
.github
tests
Dockerfile
.dockerignore
.gitignore
.gitmodules
README.md
README_en.md
README_ja.md
LICENSE
requirements_api.txt
requirements_lite.txt
requirements_webui.txt
# bge-large-zh-v1.5
bge-large-zh-v1.5/README.md
# chatglm3-6b

36
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,36 @@
---
name: Bug 报告 / Bug Report
about: 报告项目中的错误或问题 / Report errors or issues in the project
title: "[BUG] 简洁阐述问题 / Concise description of the issue"
labels: bug
assignees: ''
---
**问题描述 / Problem Description**
用简洁明了的语言描述这个问题 / Describe the problem in a clear and concise manner.
**复现问题的步骤 / Steps to Reproduce**
1. 执行 '...' / Run '...'
2. 点击 '...' / Click '...'
3. 滚动到 '...' / Scroll to '...'
4. 问题出现 / Problem occurs
**预期的结果 / Expected Result**
描述应该出现的结果 / Describe the expected result.
**实际结果 / Actual Result**
描述实际发生的结果 / Describe the actual result.
**环境信息 / Environment Information**
- langchain-ChatGLM 版本/commit 号:(例如v2.0.1 或 commit 123456) / langchain-ChatGLM version/commit number: (e.g., v2.0.1 or commit 123456)
- 是否使用 Docker 部署(是/否):是 / Is Docker deployment used (yes/no): yes
- 使用的模型ChatGLM2-6B / Qwen-7B 等ChatGLM-6B / Model used (ChatGLM2-6B / Qwen-7B, etc.): ChatGLM2-6B
- 使用的 Embedding 模型moka-ai/m3e-base 等moka-ai/m3e-base / Embedding model used (moka-ai/m3e-base, etc.): moka-ai/m3e-base
- 使用的向量库类型 (faiss / milvus / pg_vector 等) faiss / Vector library used (faiss, milvus, pg_vector, etc.): faiss
- 操作系统及版本 / Operating system and version:
- Python 版本 / Python version:
- 其他相关环境信息 / Other relevant environment information:
**附加信息 / Additional Information**
添加与问题相关的任何其他信息 / Add any other information related to the issue.

View File

@ -0,0 +1,23 @@
---
name: 功能请求 / Feature Request
about: 为项目提出新功能或建议 / Propose new features or suggestions for the project
title: "[FEATURE] 简洁阐述功能 / Concise description of the feature"
labels: enhancement
assignees: ''
---
**功能描述 / Feature Description**
用简洁明了的语言描述所需的功能 / Describe the desired feature in a clear and concise manner.
**解决的问题 / Problem Solved**
解释此功能如何解决现有问题或改进项目 / Explain how this feature solves existing problems or improves the project.
**实现建议 / Implementation Suggestions**
如果可能,请提供关于如何实现此功能的建议 / If possible, provide suggestions on how to implement this feature.
**替代方案 / Alternative Solutions**
描述您考虑过的替代方案 / Describe alternative solutions you have considered.
**其他信息 / Additional Information**
添加与功能请求相关的任何其他信息 / Add any other information related to the feature request.

22
.github/workflows/close-issue.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: Close inactive issues
on:
schedule:
- cron: "30 21 * * *"
jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
days-before-issue-close: 14
stale-issue-label: "stale"
stale-issue-message: "这个问题已经被标记为 `stale` ,因为它已经超过 30 天没有任何活动。"
close-issue-message: "这个问题已经被自动关闭,因为它被标为 `stale` 后超过 14 天没有任何活动。"
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}

155
.github/workflows/docker-build.yaml vendored Normal file
View File

@ -0,0 +1,155 @@
name: docker-build
on:
push:
branches:
- master
paths-ignore:
- 'README.md'
- 'README_en.md'
- 'README_ja.md'
env:
TZ: Asia/Shanghai
jobs:
docker-build:
runs-on: ubuntu-latest
# if: github.event.pull_request.merged == true
steps:
- name: Optimize Disk Space
uses: hugoalh/disk-space-optimizer-ghaction@v0.8.0
with:
operate_sudo: "True"
general_include: ".+"
general_exclude: |-
^GCC$
^G\+\+$
Clang
LLVM
docker_include: ".+"
docker_prune: "True"
docker_clean: "True"
apt_prune: "True"
apt_clean: "True"
homebrew_prune: "True"
homebrew_clean: "True"
npm_prune: "True"
npm_clean: "True"
os_swap: "True"
- name: Remove Unnecessary Tools And Files
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get remove -y '^dotnet-.*' '^llvm-.*' 'php.*' azure-cli google-chrome-stable firefox powershell mono-devel
sudo apt-get autoremove --purge -y
sudo find /var/log -name "*.gz" -type f -delete
sudo rm -rf /var/cache/apt/archives
sudo rm -rf /tmp/*
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /etc/mysql /etc/php
sudo -E apt-get -y purge azure-cli* docker* ghc* zulu* hhvm* llvm* firefox* google* dotnet* aspnetcore* powershell* openjdk* adoptopenjdk* mysql* php* mongodb* moby* snap* || true
sudo rm -rf /etc/apt/sources.list.d/* /usr/local/lib/android /opt/ghc /usr/share/dotnet /usr/local/graalvm /usr/local/.ghcup \
/usr/local/share/powershell /usr/local/share/chromium /usr/local/lib/node_modules
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /etc/mysql /etc/php
sudo -E apt-get -y purge azure-cli* docker* ghc* zulu* hhvm* llvm* firefox* google* dotnet* aspnetcore* powershell* openjdk* adoptopenjdk* mysql* php* mongodb* moby* snap* || true
sudo -E apt-get -qq update
sudo -E apt-get -qq install libfuse-dev $(curl -fsSL git.io/depends-ubuntu-2204)
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo apt-get clean
rm -rf /opt/hostedtoolcache
sudo timedatectl set-timezone "$TZ"
- name: Free Up Disk Space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 62464 # 给 / 预留 61GiB 空间( docker 预留)
swap-size-mb: 1
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get Latest Release
id: get_version
run: |
VERSION=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r .tag_name)
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Set Image Tag
id: imageTag
run: echo "::set-output name=image_tag::$RELEASE_VERSION-$(date +%Y%m%d)-$(git rev-parse --short HEAD)"
- name: Set Up QEMU
uses: docker/setup-qemu-action@v2
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Clone Model
run: |
sudo mkdir -p $GITHUB_WORKSPACE/bge-large-zh-v1.5
cd $GITHUB_WORKSPACE/bge-large-zh-v1.5
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/.gitattributes &> /dev/null
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/config.json &> /dev/null
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/config_sentence_transformers.json &> /dev/null
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/modules.json &> /dev/null
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/pytorch_model.bin &> /dev/null
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/sentence_bert_config.json &> /dev/null
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/special_tokens_map.json &> /dev/null
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/tokenizer.json &> /dev/null
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/tokenizer_config.json &> /dev/null
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/vocab.txt &> /dev/null
sudo mkdir -p $GITHUB_WORKSPACE/bge-large-zh-v1.5/1_Pooling
cd $GITHUB_WORKSPACE/bge-large-zh-v1.5/1_Pooling
sudo wget https://huggingface.co/BAAI/bge-large-zh-v1.5/resolve/main/1_Pooling/config.json &> /dev/null
sudo mkdir -p $GITHUB_WORKSPACE/chatglm3-6b
cd $GITHUB_WORKSPACE/chatglm3-6b
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/config.json &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/configuration_chatglm.py &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/model-00001-of-00007.safetensors &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/model-00002-of-00007.safetensors &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/model-00003-of-00007.safetensors &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/model-00004-of-00007.safetensors &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/model-00005-of-00007.safetensors &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/model-00006-of-00007.safetensors &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/model-00007-of-00007.safetensors &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/model.safetensors.index.json &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/modeling_chatglm.py &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/pytorch_model.bin.index.json &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/quantization.py &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/special_tokens_map.json &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/tokenization_chatglm.py &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/tokenizer.model &> /dev/null
sudo wget https://huggingface.co/THUDM/chatglm3-6b/resolve/main/tokenizer_config.json &> /dev/null
du -sh $GITHUB_WORKSPACE
du -sh $GITHUB_WORKSPACE/*
du -sh $GITHUB_WORKSPACE/bge-large-zh-v1.5/*
du -sh $GITHUB_WORKSPACE/chatglm3-6b/*
- name: Show Runner Disk
run: df -hT
- name: Docker Build
run: |
docker build -t uswccr.ccs.tencentyun.com/chatchat/chatchat:${{ steps.imageTag.outputs.image_tag }} -f Dockerfile .
- name: Show Images Size
run: docker images
- name: Login To Tencent CCR
uses: docker/login-action@v2
with:
registry: uswccr.ccs.tencentyun.com
username: ${{ secrets.CCR_REGISTRY_USERNAME }}
password: ${{ secrets.CCR_REGISTRY_PASSWORD }}
- name: Docker Push
run: docker push uswccr.ccs.tencentyun.com/chatchat/chatchat:${{ steps.imageTag.outputs.image_tag }}
# - name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Update README.md
run: |
sed -i "s|uswccr.ccs.tencentyun.com/chatchat/chatchat:[^ ]*|uswccr.ccs.tencentyun.com/chatchat/chatchat:${{ steps.imageTag.outputs.image_tag }}|g" README.md
sed -i "s|uswccr.ccs.tencentyun.com/chatchat/chatchat:[^ ]*|uswccr.ccs.tencentyun.com/chatchat/chatchat:${{ steps.imageTag.outputs.image_tag }}|g" README_en.md
sed -i "s|uswccr.ccs.tencentyun.com/chatchat/chatchat:[^ ]*|uswccr.ccs.tencentyun.com/chatchat/chatchat:${{ steps.imageTag.outputs.image_tag }}|g" README_ja.md
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "feat:update docker image:tag"
- name: Push README.md
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_PAT }}
branch: ${{ github.ref }}

32
.gitignore vendored
View File

@ -1,6 +1,17 @@
*.log
*.log.*
*.bak
logs
/knowledge_base/*
!/knowledge_base/samples
/knowledge_base/samples/vector_store
/configs/*.py
.vscode/
# below are standard python ignore files
# Byte-compiled / optimized / DLL files
__pycache__/
*/**/__pycache__/
*.py[cod]
*$py.class
@ -86,21 +97,21 @@ ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
@ -159,12 +170,11 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
.pytest_cache
.DS_Store
# Test File
test.py
configs/*.py
# Other files
output/*
log/*
.chroma
vector_store/*
llm/*
embedding/*

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "knowledge_base/samples/content/wiki"]
path = knowledge_base/samples/content/wiki
url = https://github.com/chatchat-space/Langchain-Chatchat.wiki.git

View File

@ -1,22 +0,0 @@
# 贡献指南
欢迎!我们是一个非常友好的社区,非常高兴您想要帮助我们让这个应用程序变得更好。但是,请您遵循一些通用准则以保持组织有序。
1. 确保为您要修复的错误或要添加的功能创建了一个[问题](https://github.com/imClumsyPanda/langchain-ChatGLM/issues),尽可能保持它们小。
2. 请使用 `git pull --rebase` 来拉取和衍合上游的更新。
3. 将提交合并为格式良好的提交。在提交说明中单独一行提到要解决的问题,如`Fix #<bug>`(有关更多可以使用的关键字,请参见[将拉取请求链接到问题](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue))。
4. 推送到`dev`。在说明中提到正在解决的问题。
---
# Contribution Guide
Welcome! We're a pretty friendly community, and we're thrilled that you want to help make this app even better. However, we ask that you follow some general guidelines to keep things organized around here.
1. Make sure an [issue](https://github.com/imClumsyPanda/langchain-ChatGLM/issues) is created for the bug you're about to fix, or feature you're about to add. Keep them as small as possible.
2. Please use `git pull --rebase` to fetch and merge updates from the upstream.
3. Rebase commits into well-formatted commits. Mention the issue being resolved in the commit message on a line all by itself like `Fixes #<bug>` (refer to [Linking a pull request to an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) for more keywords you can use).
4. Push into `dev`. Mention which bug is being resolved in the description.

View File

@ -1,36 +1,27 @@
FROM python:3.8
MAINTAINER "chatGLM"
COPY agent /chatGLM/agent
COPY chains /chatGLM/chains
COPY configs /chatGLM/configs
COPY content /chatGLM/content
COPY models /chatGLM/models
COPY nltk_data /chatGLM/content
COPY requirements.txt /chatGLM/
COPY cli_demo.py /chatGLM/
COPY textsplitter /chatGLM/
COPY webui.py /chatGLM/
WORKDIR /chatGLM
RUN pip install --user torch torchvision tensorboard cython -i https://pypi.tuna.tsinghua.edu.cn/simple
# RUN pip install --user 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
# RUN pip install --user 'git+https://github.com/facebookresearch/fvcore'
# install detectron2
# RUN git clone https://github.com/facebookresearch/detectron2
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
CMD ["python","-u", "webui.py"]
# Base Image
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
# Labels
LABEL maintainer=chatchat
# Environment Variables
ENV HOME=/Langchain-Chatchat
# Commands
WORKDIR /
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
apt-get update -y && \
apt-get install -y --no-install-recommends python3.11 python3-pip curl libgl1 libglib2.0-0 jq && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm -f /usr/bin/python3 && \
ln -s /usr/bin/python3.11 /usr/bin/python3 && \
mkdir -p $HOME
# Copy the application files
COPY . $HOME
WORKDIR $HOME
# Install dependencies from requirements.txt
RUN pip3 install -r requirements.txt -i https://pypi.org/simple && \
python3 copy_config_example.py && \
sed -i 's|MODEL_ROOT_PATH = ""|MODEL_ROOT_PATH = "/Langchain-Chatchat"|' configs/model_config.py && \
python3 init_database.py --recreate-vs
EXPOSE 22 7861 8501
ENTRYPOINT ["python3", "startup.py", "-a"]

303
README.md
View File

@ -1,161 +1,206 @@
# 基于本地知识的 ChatGLM 应用实现
![](img/logo-long-chatchat-trans-v2.png)
🌍 [READ THIS IN ENGLISH](README_en.md)
🌍 [日本語で読む](README_ja.md)
📃 **LangChain-Chatchat** (原 Langchain-ChatGLM)
基于 ChatGLM 等大语言模型与 Langchain 等应用框架实现,开源、可离线部署的检索增强生成(RAG)大模型知识库项目。
### ⚠️ 重要提示
`0.2.10`将会是`0.2.x`系列的最后一个版本,`0.2.x`系列版本将会停止更新和技术支持,全力研发具有更强应用性的 `Langchain-Chatchat 0.3.x`
`0.2.10` 的后续 bug 修复将会直接推送到`master`分支,而不再进行版本更新。
---
## 目录
* [介绍](README.md#介绍)
* [解决的痛点](README.md#解决的痛点)
* [快速上手](README.md#快速上手)
* [1. 环境配置](README.md#1-环境配置)
* [2. 模型下载](README.md#2-模型下载)
* [3. 初始化知识库和配置文件](README.md#3-初始化知识库和配置文件)
* [4. 一键启动](README.md#4-一键启动)
* [5. 启动界面示例](README.md#5-启动界面示例)
* [联系我们](README.md#联系我们)
## 介绍
🌍 [_READ THIS IN ENGLISH_](README_en.md)
🤖️ 一种利用 [langchain](https://github.com/langchain-ai/langchain)
思想实现的基于本地知识库的问答应用,目标期望建立一套对中文场景与开源模型支持友好、可离线运行的知识库问答解决方案。
🤖️ 一种利用 [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B) + [langchain](https://github.com/hwchase17/langchain) 实现的基于本地知识的 ChatGLM 应用。增加 [clue-ai/ChatYuan](https://github.com/clue-ai/ChatYuan) 项目的模型 [ClueAI/ChatYuan-large-v2](https://huggingface.co/ClueAI/ChatYuan-large-v2) 的支持。
💡 受 [GanymedeNil](https://github.com/GanymedeNil) 的项目 [document.ai](https://github.com/GanymedeNil/document.ai)
和 [AlexZhangji](https://github.com/AlexZhangji)
创建的 [ChatGLM-6B Pull Request](https://github.com/THUDM/ChatGLM-6B/pull/216)
启发,建立了全流程可使用开源模型实现的本地知识库问答应用。本项目的最新版本中通过使用 [FastChat](https://github.com/lm-sys/FastChat)
接入 Vicuna, Alpaca, LLaMA, Koala, RWKV 等模型,依托于 [langchain](https://github.com/langchain-ai/langchain)
框架支持通过基于 [FastAPI](https://github.com/tiangolo/fastapi) 提供的 API
调用服务,或使用基于 [Streamlit](https://github.com/streamlit/streamlit) 的 WebUI 进行操作。
💡 受 [GanymedeNil](https://github.com/GanymedeNil) 的项目 [document.ai](https://github.com/GanymedeNil/document.ai) 和 [AlexZhangji](https://github.com/AlexZhangji) 创建的 [ChatGLM-6B Pull Request](https://github.com/THUDM/ChatGLM-6B/pull/216) 启发,建立了全部基于开源模型实现的本地知识问答应用。
✅ 依托于本项目支持的开源 LLM 与 Embedding 模型,本项目可实现全部使用**开源**模型**离线私有部署**。与此同时,本项目也支持
OpenAI GPT API 的调用,并将在后续持续扩充对各类模型及模型 API 的接入。
✅ 本项目中 Embedding 默认选用的是 [GanymedeNil/text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese/tree/main)LLM 默认选用的是 [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B)。依托上述模型,本项目可实现全部使用**开源**模型**离线私有部署**。
⛓️ 本项目实现原理如下图所示,过程包括加载文件 -> 读取文本 -> 文本分割 -> 文本向量化 -> 问句向量化 ->
在文本向量中匹配出与问句向量最相似的 `top k`个 -> 匹配出的文本作为上下文和问题一起添加到 `prompt`中 -> 提交给 `LLM`生成回答。
⛓️ 本项目实现原理如下图所示,过程包括加载文件 -> 读取文本 -> 文本分割 -> 文本向量化 -> 问句向量化 -> 在文本向量中匹配出与问句向量最相似的`top k`个 -> 匹配出的文本作为上下文和问题一起添加到`prompt`中 -> 提交给`LLM`生成回答。
📺 [原理介绍视频](https://www.bilibili.com/video/BV13M4y1e7cN/?share_source=copy_web&vd_source=e6c5aafe684f30fbe41925d61ca6d514)
![实现原理图](img/langchain+chatglm.png)
从文档处理角度来看,实现流程如下:
![实现原理图2](img/langchain+chatglm2.png)
🚩 本项目未涉及微调、训练过程,但可利用微调或训练对本项目效果进行优化。
📓 [ModelWhale 在线运行项目](https://www.heywhale.com/mw/project/643977aa446c45f4592a1e59)
🌐 [AutoDL 镜像](https://www.codewithgpu.com/i/chatchat-space/Langchain-Chatchat/Langchain-Chatchat) 中 `0.2.10`
## 变更日志
版本所使用代码已更新至本项目 `v0.2.10` 版本。
参见 [变更日志](docs/CHANGELOG.md)。
🐳 [Docker 镜像](isafetech/chatchat:0.2.10) 已经更新到 ```0.2.10``` 版本
## 硬件需求
- ChatGLM-6B 模型硬件需求
| **量化等级** | **最低 GPU 显存**(推理) | **最低 GPU 显存**(高效参数微调) |
| -------------- | ------------------------- | --------------------------------- |
| FP16无量化 | 13 GB | 14 GB |
| INT8 | 8 GB | 9 GB |
| INT4 | 6 GB | 7 GB |
- Embedding 模型硬件需求
本项目中默认选用的 Embedding 模型 [GanymedeNil/text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese/tree/main) 约占用显存 3GB也可修改为在 CPU 中运行。
## Docker 部署
```commandline
$ docker build -t chatglm:v1.0 .
$ docker run -d --restart=always --name chatglm -p 7860:7860 -v /www/wwwroot/code/langchain-ChatGLM:/chatGLM chatglm
```
## 开发部署
### 软件需求
本项目已在 Python 3.8 - 3.10CUDA 11.7 环境下完成测试。已在 Windows、ARM 架构的 macOS、Linux 系统中完成测试。
### 从本地加载模型
请参考 [THUDM/ChatGLM-6B#从本地加载模型](https://github.com/THUDM/ChatGLM-6B#从本地加载模型)
### 1. 安装环境
参见 [安装指南](docs/INSTALL.md)。
### 2. 设置模型默认参数
在开始执行 Web UI 或命令行交互前,请先检查 [configs/model_config.py](configs/model_config.py) 中的各项模型参数设计是否符合需求。
### 3. 执行脚本体验 Web UI 或命令行交互
> 注:鉴于环境部署过程中可能遇到问题,建议首先测试命令行脚本。建议命令行脚本测试可正常运行后再运行 Web UI。
执行 [cli_demo.py](cli_demo.py) 脚本体验**命令行交互**
```shell
$ python cli_demo.py
```
或执行 [webui.py](webui.py) 脚本体验 **Web 交互**
🌲 本次更新后同时支持DockerHub、阿里云、腾讯云镜像源
```shell
$ python webui.py
docker run -d --gpus all -p 80:8501 isafetech/chatchat:0.2.10
docker run -d --gpus all -p 80:8501 uswccr.ccs.tencentyun.com/chatchat/chatchat:0.2.10
docker run -d --gpus all -p 80:8501 registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.10
```
注:如未将模型下载至本地,请执行前检查`$HOME/.cache/huggingface/`文件夹剩余空间至少15G。
🧩 本项目有一个非常完整的[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/) README只是一个简单的介绍_
_仅仅是入门教程能够基础运行__。
如果你想要更深入的了解本项目,或者想对本项目做出贡献。请移步 [Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
界面
执行后效果如下图所示:
![webui](img/webui_0419.png)
Web UI 可以实现如下功能:
## 解决的痛点
1. 运行前自动读取`configs/model_config.py``LLM``Embedding`模型枚举及默认模型设置运行模型,如需重新加载模型,可在 `模型配置` 标签页重新选择后点击 `重新加载模型` 进行模型加载;
2. 可手动调节保留对话历史长度、匹配知识库文段数量,可根据显存大小自行调节;
3. 具备模式选择功能,可选择 `LLM对话``知识库问答` 模式进行对话,支持流式对话;
4. 添加 `配置知识库` 功能,支持选择已有知识库或新建知识库,并可向知识库中**新增**上传文件/文件夹,使用文件上传组件选择好文件后点击 `上传文件并加载知识库`,会将所选上传文档数据加载至知识库中,并基于更新后知识库进行问答;
5. 后续版本中将会增加对知识库的修改或删除,及知识库中已导入文件的查看。
该项目是一个可以实现 __完全本地化__推理的知识库增强方案, 重点解决数据安全保护,私域化部署的企业痛点。
本开源方案采用```Apache License```,可以免费商用,无需付费。
### 常见问题
我们支持市面上主流的本地大语言模型和Embedding模型支持开源的本地向量数据库。
支持列表详见[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
参见 [常见问题](docs/FAQ.md)。
## 快速上手
## Demo
### 1. 环境配置
以问题`chatglm-6b 的局限性具体体现在哪里,如何实现改进`为例:
+ 首先,确保你的机器安装了 Python 3.8 - 3.11 (我们强烈推荐使用 Python3.11)。
未使用 langchain 接入本地文档时:
```
$ python --version
Python 3.11.7
```
>ChatGLM-6B 是一个基于 GPT-3 的聊天机器人,它的局限性主要体现在以下几个方面:
>1. 语言模型的精度:GPT-3 是一种大型的语言模型,它的精度比较高,但是仍然有一些局限性。例如,它可能无法准确地理解某些方言、口音或者复杂的句子结构。
>2. 知识图谱的完整性:GPT-3 可以生成一些知识图谱,但是其完整性和准确性可能不够。例如,它可能无法准确地理解某些领域的专业知识和术语。
>3. 对话生成的连贯性:GPT-3 可以生成一些连贯的对话,但是其生成的对话可能不够自然。例如,它可能会生成一些虚假的、不连贯的对话或者误解用户的意图。
>
>为了改进 ChatGLM-6B,可以考虑以下几个方面:
>1. 提高语言模型的精度:可以通过增加训练数据、使用更好的语言模型架构、优化模型训练过程等方式来提高语言模型的精度。
>2. 增强知识图谱的完整性:可以通过增加知识图谱的维度、使用更好的知识图谱构建方法、优化知识图谱的匹配算法等方式来增强知识图谱的完整性。
>3. 提高对话生成的连贯性:可以通过增加对话生成模型的上下文信息、使用更好的上下文信息提取方法、优化对话生成模型的算法等方式来提高对话生成的连贯性。
>4. 引入更多的人类反馈:人类反馈可以帮助 ChatGLM-6B 更好地理解用户的意图和需求,从而提高对话生成的质量和准确性。可以通过引入更多的人类客服、使用人类反馈收集器等方式来引入更多的人类反馈。
接着,创建一个虚拟环境,并在虚拟环境内安装项目的依赖
使用 langchain 接入 ChatGLM-6B 项目的 README.md 文件后 ChatGLM 的回答:
>ChatGLM-6B 是一个基于深度学习的自然语言处理模型,它在回答问题方面表现出色。但是,它也有一些局限性,具体如下:
>1. 语言理解有限:ChatGLM-6B 只学习了中文自然语言,对于其他语言可能会存在理解上的局限性。
>2. 知识储备不足:ChatGLM-6B 的训练数据集只包含了中文语料,因此它可能无法回答一些非中文的问题或者某些特定领域的问题。
>3. 数据量有限:ChatGLM-6B 的训练数据集只有几百万条记录,因此它可能无法回答一些非常具体或者复杂的问题。
>
>为了改进 ChatGLM-6B,可以考虑以下几个方面:
>1. 学习更多的语言知识:可以学习其他语言的自然语言处理技术,扩大语言理解的范围。
>2. 扩大知识储备:可以收集更多的中文语料,或者使用其他语言的数据集来扩充知识储备。
>3. 增加数据量:可以使用更大的数据集来训练 ChatGLM-6B,提高模型的表现。
>4. 引入更多的评估指标:可以引入更多的评估指标来评估模型的表现,从而发现 ChatGLM-6B 存在的不足和局限性。
>5. 改进模型架构:可以改进 ChatGLM-6B 的模型架构,提高模型的性能和表现。例如,可以使用更大的神经网络或者改进的卷积神经网络结构。
```shell
## 路线图
# 拉取仓库
$ git clone https://github.com/chatchat-space/Langchain-Chatchat.git
- [ ] Langchain 应用
- [x] 接入非结构化文档(已支持 md、pdf、docx、txt 文件格式)
- [ ] 搜索引擎与本地网页接入
- [ ] 结构化数据接入(如 csv、Excel、SQL 等)
- [ ] 知识图谱/图数据库接入
- [ ] Agent 实现
- [ ] 增加更多 LLM 模型支持
- [x] [THUDM/chatglm-6b](https://huggingface.co/THUDM/chatglm-6b)
- [x] [THUDM/chatglm-6b-int8](https://huggingface.co/THUDM/chatglm-6b-int8)
- [x] [THUDM/chatglm-6b-int4](https://huggingface.co/THUDM/chatglm-6b-int4)
- [x] [THUDM/chatglm-6b-int4-qe](https://huggingface.co/THUDM/chatglm-6b-int4-qe)
- [x] [ClueAI/ChatYuan-large-v2](https://huggingface.co/ClueAI/ChatYuan-large-v2)
- [ ] 增加更多 Embedding 模型支持
- [x] [nghuyong/ernie-3.0-nano-zh](https://huggingface.co/nghuyong/ernie-3.0-nano-zh)
- [x] [nghuyong/ernie-3.0-base-zh](https://huggingface.co/nghuyong/ernie-3.0-base-zh)
- [x] [shibing624/text2vec-base-chinese](https://huggingface.co/shibing624/text2vec-base-chinese)
- [x] [GanymedeNil/text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese)
- [ ] Web UI
- [x] 利用 gradio 实现 Web UI DEMO
- [x] 添加输出内容及错误提示
- [x] 引用标注
- [ ] 增加知识库管理
- [x] 选择知识库开始问答
- [x] 上传文件/文件夹至知识库
- [ ] 删除知识库中文件
- [ ] 利用 streamlit 实现 Web UI Demo
- [ ] 增加 API 支持
- [ ] 利用 fastapi 实现 API 部署方式
- [ ] 实现调用 API 的 Web UI Demo
# 进入目录
$ cd Langchain-Chatchat
## 项目交流群
![二维码](img/qr_code_9.jpg)
# 安装全部依赖
$ pip install -r requirements.txt
$ pip install -r requirements_api.txt
$ pip install -r requirements_webui.txt
🎉 langchain-ChatGLM 项目交流群,如果你也对本项目感兴趣,欢迎加入群聊参与讨论交流。
# 默认依赖包括基本运行环境FAISS向量库。如果要使用 milvus/pg_vector 等向量库,请将 requirements.txt 中相应依赖取消注释再安装。
```
请注意LangChain-Chatchat `0.2.x` 系列是针对 Langchain `0.0.x` 系列版本的,如果你使用的是 Langchain `0.1.x`
系列版本,需要降级您的`Langchain`版本。
### 2. 模型下载
如需在本地或离线环境下运行本项目,需要首先将项目所需的模型下载至本地,通常开源 LLM 与 Embedding
模型可以从 [HuggingFace](https://huggingface.co/models) 下载。
以本项目中默认使用的 LLM 模型 [THUDM/ChatGLM3-6B](https://huggingface.co/THUDM/chatglm3-6b) 与 Embedding
模型 [BAAI/bge-large-zh](https://huggingface.co/BAAI/bge-large-zh) 为例:
下载模型需要先[安装 Git LFS](https://docs.github.com/zh/repositories/working-with-files/managing-large-files/installing-git-large-file-storage)
,然后运行
```Shell
$ git lfs install
$ git clone https://huggingface.co/THUDM/chatglm3-6b
$ git clone https://huggingface.co/BAAI/bge-large-zh
```
### 3. 初始化知识库和配置文件
按照下列方式初始化自己的知识库和简单的复制配置文件
```shell
$ python copy_config_example.py
$ python init_database.py --recreate-vs
```
### 4. 一键启动
按照以下命令启动项目
```shell
$ python startup.py -a
```
### 5. 启动界面示例
如果正常启动,你将能看到以下界面
1. FastAPI Docs 界面
![](img/fastapi_docs_026.png)
2. Web UI 启动界面示例:
- Web UI 对话界面:
![img](img/LLM_success.png)
- Web UI 知识库管理页面:
![](img/init_knowledge_base.jpg)
### 注意
以上方式只是为了快速上手,如果需要更多的功能和自定义启动方式
,请参考[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
---
## 项目里程碑
+ `2023年4月`: `Langchain-ChatGLM 0.1.0` 发布,支持基于 ChatGLM-6B 模型的本地知识库问答。
+ `2023年8月`: `Langchain-ChatGLM` 改名为 `Langchain-Chatchat``0.2.0` 发布,使用 `fastchat` 作为模型加载方案,支持更多的模型和数据库。
+ `2023年10月`: `Langchain-Chatchat 0.2.5` 发布,推出 Agent 内容,开源项目在`Founder Park & Zhipu AI & Zilliz`
举办的黑客马拉松获得三等奖。
+ `2023年12月`: `Langchain-Chatchat` 开源项目获得超过 **20K** stars.
+ `2024年1月`: `LangChain 0.1.x` 推出,`Langchain-Chatchat 0.2.x` 发布稳定版本`0.2.10`
后将停止更新和技术支持,全力研发具有更强应用性的 `Langchain-Chatchat 0.3.x`
+ 🔥 让我们一起期待未来 Chatchat 的故事 ···
---
## 联系我们
### Telegram
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white "langchain-chatglm")](https://t.me/+RjliQ3jnJ1YyN2E9)
### 项目交流群
<img src="img/qr_code_108.jpg" alt="二维码" width="300" />
🎉 Langchain-Chatchat 项目微信交流群,如果你也对本项目感兴趣,欢迎加入群聊参与讨论交流。
### 公众号
<img src="img/official_wechat_mp_account.png" alt="二维码" width="300" />
🎉 Langchain-Chatchat 项目官方公众号,欢迎扫码关注。

View File

@ -1,219 +1,207 @@
# ChatGLM Application with Local Knowledge Implementation
![](img/logo-long-chatchat-trans-v2.png)
🌍 [中文文档](README.md)
🌍 [日本語で読む](README_ja.md)
📃 **LangChain-Chatchat** (formerly Langchain-ChatGLM):
A LLM application aims to implement knowledge and search engine based QA based on Langchain and open-source or remote
LLM API.
⚠️`0.2.10` will be the last version of the `0.2.x` series. The `0.2.x` series will stop updating and technical support,
and strive to develop `Langchain-Chachat 0.3.x` with stronger applicability.
Subsequent bug fixes for `0.2.10` will be pushed directly to the `master` branch without version updates.
---
## Table of Contents
- [Introduction](README.md#Introduction)
- [Pain Points Addressed](README.md#Pain-Points-Addressed)
- [Quick Start](README.md#Quick-Start)
- [1. Environment Setup](README.md#1-Environment-Setup)
- [2. Model Download](README.md#2-Model-Download)
- [3. Initialize Knowledge Base and Configuration Files](README.md#3-Initialize-Knowledge-Base-and-Configuration-Files)
- [4. One-Click Startup](README.md#4-One-Click-Startup)
- [5. Startup Interface Examples](README.md#5-Startup-Interface-Examples)
- [Contact Us](README.md#Contact-Us)
## Introduction
🤖️ A Q&A application based on local knowledge base implemented using the idea
of [langchain](https://github.com/langchain-ai/langchain). The goal is to build a KBQA(Knowledge based Q&A) solution
that
is friendly to Chinese scenarios and open source models and can run both offline and online.
💡 Inspired by [document.ai](https://github.com/GanymedeNil/document.ai)
and [ChatGLM-6B Pull Request](https://github.com/THUDM/ChatGLM-6B/pull/216) , we build a local knowledge base question
answering application that can be implemented using an open source model or remote LLM api throughout the process. In
the latest version of this project, [FastChat](https://github.com/lm-sys/FastChat) is used to access Vicuna, Alpaca,
LLaMA, Koala, RWKV and many other models. Relying on [langchain](https://github.com/langchain-ai/langchain) , this
project supports calling services through the API provided based on [FastAPI](https://github.com/tiangolo/fastapi), or
using the WebUI based on [Streamlit](https://github.com/streamlit/streamlit).
✅ Relying on the open source LLM and Embedding models, this project can realize full-process **offline private
deployment**. At the same time, this project also supports the call of OpenAI GPT API- and Zhipu API, and will continue
to expand the access to various models and remote APIs in the future.
⛓️ The implementation principle of this project is shown in the graph below. The main process includes: loading files ->
reading text -> text segmentation -> text vectorization -> question vectorization -> matching the `top-k` most similar
to the question vector in the text vector -> The matched text is added to `prompt `as context and question -> submitte
to `LLM` to generate an answer.
📺[video introduction](https://www.bilibili.com/video/BV13M4y1e7cN/?share_source=copy_web&vd_source=e6c5aafe684f30fbe41925d61ca6d514)
![实现原理图](img/langchain+chatglm.png)
The main process analysis from the aspect of document process:
![实现原理图2](img/langchain+chatglm2.png)
🚩 The training or fine-tuning are not involved in the project, but still, one always can improve performance by do
these.
🌐 [AutoDL image](https://www.codewithgpu.com/i/chatchat-space/Langchain-Chatchat/Langchain-Chatchat) is supported, and in `0.2.10` the codes are update to v0.2.10.
🐳 [Docker image](isafetech/chatchat:0.2.10) is supported to ```0.2.10```.
🌲 The latest update also provides support for image sources from DockerHub, Ali Cloud, and Tencent Cloud:
```shell
docker run -d --gpus all -p 80:8501 isafetech/chatchat:0.2.10
docker run -d --gpus all -p 80:8501 uswccr.ccs.tencentyun.com/chatchat/chatchat:0.2.10
docker run -d --gpus all -p 80:8501 registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.10
```
## Pain Points Addressed
This project is a solution for enhancing knowledge bases with fully localized inference, specifically addressing the
pain points of data security and private deployments for businesses.
This open-source solution is under the Apache License and can be used for commercial purposes for free, with no fees
required.
We support mainstream local large prophecy models and Embedding models available in the market, as well as open-source
local vector databases. For a detailed list of supported models and databases, please refer to
our [Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
## Quick Start
### Environment Setup
First, make sure your machine has Python 3.10 installed.
```
$ python --version
Python 3.10.12
```
Then, create a virtual environment and install the project's dependencies within the virtual environment.
```shell
# 拉取仓库
$ git clone https://github.com/chatchat-space/Langchain-Chatchat.git
# 进入目录
$ cd Langchain-Chatchat
# 安装全部依赖
$ pip install -r requirements.txt
$ pip install -r requirements_api.txt
$ pip install -r requirements_webui.txt
# 默认依赖包括基本运行环境FAISS向量库。如果要使用 milvus/pg_vector 等向量库,请将 requirements.txt 中相应依赖取消注释再安装。
```
Please note that the LangChain-Chachat `0.2.x` series is for the Langchain `0.0.x` series version. If you are using the
Langchain `0.1.x` series version, you need to downgrade.
### Model Download
If you need to run this project locally or in an offline environment, you must first download the required models for
the project. Typically, open-source LLM and Embedding models can be downloaded from HuggingFace.
Taking the default LLM model used in this project, [THUDM/chatglm2-6b](https://huggingface.co/THUDM/chatglm2-6b), and
the Embedding model [moka-ai/m3e-base](https://huggingface.co/moka-ai/m3e-base) as examples:
To download the models, you need to first
install [Git LFS](https://docs.github.com/zh/repositories/working-with-files/managing-large-files/installing-git-large-file-storage)
and then run:
```Shell
$ git lfs install
$ git clone https://huggingface.co/THUDM/chatglm2-6b
$ git clone https://huggingface.co/moka-ai/m3e-base
```
### Initializing the Knowledge Base and Config File
Follow the steps below to initialize your own knowledge base and config file:
```shell
$ python copy_config_example.py
$ python init_database.py --recreate-vs
```
### One-Click Launch
To start the project, run the following command:
```shell
$ python startup.py -a
```
### Example of Launch Interface
1. FastAPI docs interface
![](img/fastapi_docs_026.png)
2. webui page
- Web UI dialog page:
![img](img/LLM_success.png)
- Web UI knowledge base management page:
![](img/init_knowledge_base.jpg)
### Note
The above instructions are provided for a quick start. If you need more features or want to customize the launch method,
please refer to the [Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/).
---
## Project Milestones
+ `April 2023`: `Langchain-ChatGLM 0.1.0` released, supporting local knowledge base question and answer based on the
ChatGLM-6B model.
+ `August 2023`: `Langchain-ChatGLM` was renamed to `Langchain-Chatchat`, `0.2.0` was released, using `fastchat` as the
model loading solution, supporting more models and databases.
+ `October 2023`: `Langchain-Chachat 0.2.5` was released, Agent content was launched, and the open source project won
the third prize in the hackathon held by `Founder Park & Zhipu AI & Zilliz`.
+ `December 2023`: `Langchain-Chachat` open source project received more than **20K** stars.
+ `January 2024`: `LangChain 0.1.x` is launched, `Langchain-Chachat 0.2.x` is released. After the stable
version `0.2.10` is released, updates and technical support will be stopped, and all efforts will be made to
develop `Langchain with stronger applicability -Chat 0.3.x`.
+ 🔥 Lets look forward to the future Chatchat stories together···
---
## Contact Us
### Telegram
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white "langchain-chatglm")](https://t.me/+RjliQ3jnJ1YyN2E9)
🌍 [_中文文档_](README.md)
### WeChat Group
🤖️ This is a ChatGLM application based on local knowledge, implemented using [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B) and [langchain](https://github.com/hwchase17/langchain).
<img src="img/qr_code_90.jpg" alt="二维码" width="300" height="300" />
💡 Inspired by [document.ai](https://github.com/GanymedeNil/document.ai) and [Alex Zhangji](https://github.com/AlexZhangji)'s [ChatGLM-6B Pull Request](https://github.com/THUDM/ChatGLM-6B/pull/216), this project establishes a local knowledge question-answering application using open-source models.
### WeChat Official Account
✅ The embeddings used in this project are [GanymedeNil/text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese/tree/main), and the LLM is [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B). Relying on these models, this project enables the use of **open-source** models for **offline private deployment**.
⛓️ The implementation principle of this project is illustrated in the figure below. The process includes loading files -> reading text -> text segmentation -> text vectorization -> question vectorization -> matching the top k most similar text vectors to the question vector -> adding the matched text to `prompt` along with the question as context -> submitting to `LLM` to generate an answer.
![Implementation schematic diagram](img/langchain+chatglm.png)
🚩 This project does not involve fine-tuning or training; however, fine-tuning or training can be employed to optimize the effectiveness of this project.
📓 [ModelWhale online notebook](https://www.heywhale.com/mw/project/643977aa446c45f4592a1e59)
## Changelog
**[2023/04/15]**
1. refactor the project structure to keep the command line demo [cli_demo.py](cli_demo.py) and the Web UI demo [webui.py](webui.py) in the root directory.
2. Improve the Web UI by modifying it to first load the model according to the default option of [configs/model_config.py](configs/model_config.py) after running the Web UI, and adding error messages, etc.
3. Update FAQ.
**[2023/04/12]**
1. Replaced the sample files in the Web UI to avoid issues with unreadable files due to encoding problems in Ubuntu;
2. Replaced the prompt template in `knowledge_based_chatglm.py` to prevent confusion in the content returned by ChatGLM, which may arise from the prompt template containing Chinese and English bilingual text.
**[2023/04/11]**
1. Added Web UI V0.1 version (thanks to [@liangtongt](https://github.com/liangtongt));
2. Added Frequently Asked Questions in `README.md` (thanks to [@calcitem](https://github.com/calcitem) and [@bolongliu](https://github.com/bolongliu));
3. Enhanced automatic detection for the availability of `cuda`, `mps`, and `cpu` for LLM and Embedding model running devices;
4. Added a check for `filepath` in `knowledge_based_chatglm.py`. In addition to supporting single file import, it now supports a single folder path as input. After input, it will traverse each file in the folder and display a command-line message indicating the success of each file load.
5. **[2023/04/09]**
1. Replaced the previously selected `ChatVectorDBChain` with `RetrievalQA` in `langchain`, effectively reducing the issue of stopping due to insufficient video memory after asking 2-3 times;
2. Added `EMBEDDING_MODEL`, `VECTOR_SEARCH_TOP_K`, `LLM_MODEL`, `LLM_HISTORY_LEN`, `REPLY_WITH_SOURCE` parameter value settings in `knowledge_based_chatglm.py`;
3. Added `chatglm-6b-int4` and `chatglm-6b-int4-qe`, which require less GPU memory, as LLM model options;
4. Corrected code errors in `README.md` (thanks to [@calcitem](https://github.com/calcitem)).
**[2023/04/07]**
1. Resolved the issue of doubled video memory usage when loading the ChatGLM model (thanks to [@suc16](https://github.com/suc16) and [@myml](https://github.com/myml));
2. Added a mechanism to clear video memory;
3. Added `nghuyong/ernie-3.0-nano-zh` and `nghuyong/ernie-3.0-base-zh` as Embedding model options, which consume less video memory resources than `GanymedeNil/text2vec-large-chinese` (thanks to [@lastrei](https://github.com/lastrei)).
## How to Use
### Hardware Requirements
- ChatGLM-6B Model Hardware Requirements
| **Quantization Level** | **Minimum GPU Memory** (inference) | **Minimum GPU Memory** (efficient parameter fine-tuning) |
| -------------- | ------------------------- | --------------------------------- |
| FP16 (no quantization) | 13 GB | 14 GB |
| INT8 | 8 GB | 9 GB |
| INT4 | 6 GB | 7 GB |
- Embedding Model Hardware Requirements
The default Embedding model [GanymedeNil/text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese/tree/main) in this project occupies around 3GB of video memory and can also be configured to run on a CPU.
### Software Requirements
This repository has been tested with Python 3.8 and CUDA 11.7 environments.
### 1. Setting up the environment
* Environment check
```shell
# First, make sure your machine has Python 3.8 or higher installed
$ python --version
Python 3.8.13
# If your version is lower, you can use conda to install the environment
$ conda create -p /your_path/env_name python=3.8
# Activate the environment
$ source activate /your_path/env_name
# Deactivate the environment
$ source deactivate /your_path/env_name
# Remove the environment
$ conda env remove -p /your_path/env_name
```
* Project dependencies
```shell
# Clone the repository
$ git clone https://github.com/imClumsyPanda/langchain-ChatGLM.git
# Install dependencies
$ pip install -r requirements.txt
```
Note: When using langchain.document_loaders.UnstructuredFileLoader for unstructured file integration, you may need to install other dependency packages according to the documentation. Please refer to [langchain documentation](https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html).
### 2. Run Scripts to Experience Web UI or Command Line Interaction
Execute [webui.py](webui.py) script to experience **Web interaction** <img src="https://img.shields.io/badge/Version-0.1-brightgreen">
```commandline
python webui.py
```
Note: Before executing, check the remaining space in the `$HOME/.cache/huggingface/` folder, at least 15G.
The resulting interface is shown below:
![webui](img/webui_0419.png)
The Web UI supports the following features:
1. Automatically reads the `LLM` and `embedding` model enumerations in `configs/model_config.py`, allowing you to select and reload the model by clicking `重新加载模型`.
2. The length of retained dialogue history can be manually adjusted according to the available video memory.
3. Adds a file upload function. Select the uploaded file through the drop-down box, click `加载文件` to load the file, and change the loaded file at any time during the process.
Alternatively, execute the [knowledge_based_chatglm.py](https://chat.openai.com/chat/cli_demo.py) script to experience **command line interaction**:
```commandline
python knowledge_based_chatglm.py
```
### FAQ
Q1: What file formats does this project support?
A1: Currently, this project has been tested with txt, docx, and md file formats. For more file formats, please refer to the [langchain documentation](https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html). It is known that if the document contains special characters, there might be issues with loading the file.
Q2: How can I resolve the `detectron2` dependency issue when reading specific file formats?
A2: As the installation process for this package can be problematic and it is only required for some file formats, it is not included in `requirements.txt`. You can install it with the following command:
```commandline
pip install "detectron2@git+https://github.com/facebookresearch/detectron2.git@v0.6#egg=detectron2"
```
Q3: How can I solve the `Resource punkt not found.` error?
A3: Unzip the `packages/tokenizers` folder from https://github.com/nltk/nltk_data/raw/gh-pages/packages/tokenizers/punkt.zip, and place it in the `nltk_data/tokenizers` storage path.
The `nltk_data` storage path can be found using `nltk.data.path`.
Q4: How can I solve the `Resource averaged_perceptron_tagger not found.` error?
A4: Download https://github.com/nltk/nltk_data/blob/gh-pages/packages/taggers/averaged_perceptron_tagger.zip, extract it, and place it in the `nltk_data/taggers` storage path.
The `nltk_data` storage path can be found using `nltk.data.path`.
Q5: Can this project run in Google Colab?
A5: You can try running the chatglm-6b-int4 model in Google Colab. Please note that if you want to run the Web UI in Colab, you need to set the `share` parameter in `demo.queue(concurrency_count=3).launch(server_name='0.0.0.0', share=False, inbrowser=False)` to `True`.
This issue is related to the system environment. For more details, please refer to [Issues with installing packages using pip in Anaconda](docs/Issue-with-Installing-Packages-Using-pip-in-Anaconda.md).
## DEMO
Using the question "What are the limitations of ChatGLM-6B and how can they be improved?" as an example:
Without using langchain to access local documents:
> ChatGLM-6B is a chatbot based on GPT-3, and its limitations are mainly reflected in the following aspects:
>
> 1. Language model accuracy: Although GPT-3 is a large language model with relatively high accuracy, it still has some limitations. For instance, it may not be able to accurately understand certain dialects, accents, or complex sentence structures.
> 2. Completeness of the knowledge graph: GPT-3 can generate some knowledge graphs, but its completeness and accuracy may not be sufficient. For example, it may struggle to accurately understand specific domain expertise and terminology.
> 3. Coherence of dialogue generation: While GPT-3 can generate somewhat coherent dialogues, they may not always be natural. For instance, it may generate false, incoherent dialogue or misinterpret the user's intent.
>
> To improve ChatGLM-6B, consider the following aspects:
>
> 1. Enhance the accuracy of the language model: The accuracy of the language model can be improved by increasing the training data, using better language model architectures, and optimizing the model training process.
> 2. Strengthen the integrity of the knowledge graph: The integrity of the knowledge graph can be enhanced by increasing its dimensions, employing better knowledge graph construction methods, and optimizing the knowledge graph's matching algorithm.
> 3. Boost the coherence of dialogue generation: The coherence of dialogue generation can be improved by augmenting the context information of the dialogue generation model, utilizing better context information extraction methods, and optimizing the dialogue generation model's algorithm.
> 4. Incorporate more human feedback: Human feedback can help ChatGLM-6B better understand users' intentions and needs, thereby improving the quality and accuracy of dialogue generation. More human feedback can be introduced by involving more human agents and using human feedback collectors.
ChatGLM's answer after using LangChain to access the README.md file of the ChatGLM-6B project:
>ChatGLM-6B is a deep learning-based natural language processing model that excels at answering questions. However, it also has some limitations, as follows:
>1. Limited language understanding: ChatGLM-6B has been primarily trained on Chinese natural language, and its understanding of other languages may be limited.
>2. Insufficient knowledge base: The training dataset of ChatGLM-6B contains only a Chinese corpus, so it may not be able to answer non-Chinese questions or queries in specific domains.
>3. Limited data volume: ChatGLM-6B's training dataset has only a few million records, which may hinder its ability to answer very specific or complex questions.
>
>To improve ChatGLM-6B, consider the following aspects:
>1. Expand language knowledge: Learn natural language processing techniques in other languages to broaden the model's language understanding capabilities.
>2. Broaden the knowledge base: Collect more Chinese corpora or use datasets in other languages to expand the model's knowledge base.
>3. Increase data volume: Use larger datasets to train ChatGLM-6B, which can improve the model's performance.
>4. Introduce more evaluation metrics: Incorporate additional evaluation metrics to assess the model's performance, which can help identify the shortcomings and limitations of ChatGLM-6B.
>5. Enhance the model architecture: Improve ChatGLM-6B's model architecture to boost its performance and capabilities. For example, employ larger neural networks or refined convolutional neural network structures.
## Roadmap
- [x] Implement LangChain + ChatGLM-6B for local knowledge application
- [x] Unstructured file access based on langchain
- [x].md
- [x].pdf
- [x].docx
- [x].txt
- [ ] Add support for more LLM models
- [x] THUDM/chatglm-6b
- [x] THUDM/chatglm-6b-int4
- [x] THUDM/chatglm-6b-int4-qe
- [ ] Add Web UI DEMO
- [x] Implement Web UI DEMO using Gradio
- [x] Add output and error messages
- [x] Citation callout
- [ ] Knowledge base management
- [x] QA based on selected knowledge base
- [x] Add files/folder to knowledge base
- [ ] Add files/folder to knowledge base
- [ ] Implement Web UI DEMO using Streamlit
- [ ] Add support for API deployment
- [x] Use fastapi to implement API
- [ ] Implement Web UI DEMO for API calls
<img src="img/official_wechat_mp_account.png" alt="图片" width="900" height="300" />

200
README_ja.md Normal file
View File

@ -0,0 +1,200 @@
![](img/logo-long-chatchat-trans-v2.png)
🌍 [中文文档](README.md)
🌍 [READ THIS IN ENGLISH](README_en.md)
📃 **LangChain-Chatchat** (旧名 Langchain-ChatGLM)
ChatGLM などの大規模な言語モデルや Langchain などのアプリケーション フレームワークに基づいた、オープン
ソースのオフライン展開可能な検索拡張生成 (RAG) 大規模モデル ナレッジ ベース プロジェクトです。
⚠️`0.2.10``0.2.x` シリーズの最終バージョンとなり、`0.2.x`
シリーズはアップデートと技術サポートを終了し、より適用性の高い `Langchain-Chachat 0.3.x` の開発に努めます。 。
`0.2.10` のその後のバグ修正は、バージョン更新なしで `master` ブランチに直接プッシュされます。
---
## 目次
- [イントロ](README_ja.md#イントロ)
- [ペインポイントへの対応](README_ja.md#ペインポイントへの対応)
- [クイックスタート](README_ja.md#クイックスタート)
- [1. 環境セットアップ](README_ja.md#環境セットアップ)
- [2. モデルをダウンロード](README_ja.md#モデルをダウンロード)
- [3. ナレッジベースと設定ファイルの初期化](README_ja.md#ナレッジベースと設定ファイルの初期化)
- [4. ワンクリック起動](README_ja.md#ワンクリック起動)
- [5. 起動インターフェースの例](README_ja.md#起動インターフェースの例)
- [お問い合わせ](README_ja.md#お問い合わせ)
## イントロ
🤖️ [langchain](https://github.com/hwchase17/langchain) のアイデアを用いて実装された、ローカルナレッジベースに基づく Q&A
アプリケーション。
目標は、中国のシナリオとオープンソースモデルに親和性があり、オフラインとオンラインの両方で実行可能な KBQAナレッジベースの
Q&Aソリューションを構築することです。
💡 [document.ai](https://github.com/GanymedeNil/document.ai)
と [ChatGLM-6B Pull Request](https://github.com/THUDM/ChatGLM-6B/pull/216) に触発され、
プロセス全体を通してオープンソースモデルまたはリモート LLM api を使用して実装することができるローカルナレッジベースの質問応答アプリケーションを構築します。
このプロジェクトの最新バージョンでは、[FastChat](https://github.com/lm-sys/FastChat)
を使用して、Vicuna、Alpaca、LLaMA、Koala、RWKV、その他多くのモデルにアクセスしています。
このプロジェクトは [langchain](https://github.com/langchain-ai/langchain)
に依存し、[FastAPI](https://github.com/tiangolo/fastapi) に基づいて提供されるAPIを通してサービスを呼び出したり、
[Streamlit](https://github.com/streamlit/streamlit) に基づいて WebUI を使ったりすることをサポートしています。
✅ オープンソースの LLM と Embedding モデルに依存して、このプロジェクトはフルプロセスの **オフラインプライベートデプロイメント
** を実現することができます。
同時に、本プロジェクトは OpenAI GPT API や Zhipu API の呼び出しにも対応しており、今後も様々な機種やリモート API
へのアクセスを拡大していきます。
⛓️ このプロジェクトの実施原則を下のグラフに示します。主なプロセスは以下の通りです:
ファイルの読み込み -> テキストの読み込み -> テキストのセグメンテーション -> テキストのベクトル化 -> 質問のベクトル化 ->
質問ベクトルと最も似ている `top-k` をテキストベクトルでマッチング ->
マッチしたテキストをコンテキストと質問として `prompt` に追加 -> 回答を生成するために `LLM` に送信。
📺[video introduction](https://www.bilibili.com/video/BV13M4y1e7cN/?share_source=copy_web&vd_source=e6c5aafe684f30fbe41925d61ca6d514)
![实现原理图](img/langchain+chatglm.png)
文書プロセスの側面からの主なプロセス分析:
![实现原理图2](img/langchain+chatglm2.png)
🚩 トレーニングやファインチューニングはプロジェクトには含まれないが、これらを行うことで必ずパフォーマンスを向上させることができます。
🌐 [AutoDL イメージ](registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.5)がサポートされ、`0.2.10` では v0.2.10
にアップデートされました。
🐳 [Docker イメージ](isafetech/chatchat:0.2.10)
🌲 今回のアップデートにより、DockerHub、阿里雲、騰訊のクラウドにも対応しました。より広範なクラウド環境で利用可能となりました。
```shell
docker run -d --gpus all -p 80:8501 isafetech/chatchat:0.2.10
docker run -d --gpus all -p 80:8501 uswccr.ccs.tencentyun.com/chatchat/chatchat:0.2.10
docker run -d --gpus all -p 80:8501 registry.cn-beijing.aliyuncs.com/chatchat/chatchat:0.2.10
```
## ペインポイントへの対応
このプロジェクトは、完全にローカライズされた推論によってナレッジベースを強化するソリューションであり、特にデータセキュリティと企業向けのプライベートな展開の問題に取り組んでいます。
このオープンソースソリューションは Apache ライセンスに基づき、無償で商用利用できます。
私たちは、市場で入手可能な主流のローカル大予言モデルや Embedding モデル、オープンソースのローカルベクターデータベースをサポートしています。
対応機種とデータベースの詳細については、[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/) をご参照ください。
## クイックスタート
### 環境セットアップ
まず、マシンにPython 3.10がインストールされていることを確認してください。
```
$ python --version
Python 3.11.7
```
次に、仮想環境を作成し、プロジェクトの依存関係を仮想環境内にインストールする。
```shell
# リポジトリをクローン
$ git clone https://github.com/chatchat-space/Langchain-Chatchat.git
# ディレクトリに移動
$ cd Langchain-Chatchat
# すべての依存関係をインストール
$ pip install -r requirements.txt
$ pip install -r requirements_api.txt
$ pip install -r requirements_webui.txt
# デフォルトの依存関係には、基本的な実行環境(FAISS ベクターライブラリ)が含まれます。milvus/pg_vector などのベクターライブラリを使用する場合は、requirements.txt 内の対応する依存関係のコメントを解除してからインストールしてください。
```
LangChain-Chachat `0.2.x` シリーズは Langchain `0.0.x` シリーズ用です。Langchain `0.1.x` シリーズをお使いの場合は、ダウングレードする必要があります。
### モデルをダウンロード
このプロジェクトをローカルまたはオフライン環境で実行する必要がある場合は、まずプロジェクトに必要なモデルをダウンロードする必要があります。
通常、オープンソースの LLM と Embedding モデルは Hugging Face からダウンロードできる。
このプロジェクトで使用されているデフォルトの LLM
モデルである [THUDM/chatglm2-6b](https://huggingface.co/THUDM/chatglm2-6b)と、Embedding
モデル [moka-ai/m3e-base](https://huggingface.co/moka-ai/m3e-base) を例にとると、次のようになります:
モデルをダウンロードするには、まず [Git LFS](https://docs.github.com/zh/repositories/working-with-files/managing-large-files/installing-git-large-file-storage)
をインストールし、次のように実行する必要があります:
```Shell
$ git lfs install
$ git clone https://huggingface.co/THUDM/chatglm2-6b
$ git clone https://huggingface.co/moka-ai/m3e-base
```
### ナレッジベースと設定ファイルの初期化
以下の手順に従って、ナレッジベースと設定ファイルを初期化してください:
```shell
$ python copy_config_example.py
$ python init_database.py --recreate-vs
```
### ワンクリック起動
プロジェクトを開始するには、次のコマンドを実行します:
```shell
$ python startup.py -a
```
### 起動インターフェースの例
1. FastAPI docs インターフェース
![](img/fastapi_docs_026.png)
2. webui ページ
- Web UI ダイアログページ:
![img](img/LLM_success.png)
- Web UI ナレッジベースマネジメントページ:
![](img/init_knowledge_base.jpg)
### 注
上記の手順はクイックスタートのために提供されています。より多くの機能が必要な場合や、起動方法をカスタマイズしたい場合は、[Wiki](https://github.com/chatchat-space/Langchain-Chatchat/wiki/)
を参照してください。
---
## プロジェクトのマイルストーン
+ `2023 年 4 月`: `Langchain-ChatGLM 0.1.0` がリリースされ、ChatGLM-6B モデルに基づくローカル ナレッジ ベースの質問と回答がサポートされました。
+ `2023 年 8 月`: `Langchain-ChatGLM``Langchain-Chatchat` に名前変更され、モデル読み込みソリューションとして `fastchat` を使用し、より多くのモデルとデータベースをサポートする `0.2.0` がリリースされました。
+ `2023 年 10 月`: `Langchain-Chachat 0.2.5` リリース、エージェント コンテンツ、オープンソース プロジェクトを`Founder Park & Zhipu AI & Zilliz`で開始
開催したハッカソンでは3位に入賞しました。
+ `2023 年 12 月`: `Langchain-Chachat`オープンソース プロジェクトは **20,000** つ以上のスターを獲得しました。
+ `2024 年 1 月`: `LangChain 0.1.x` がリリースされ、`Langchain-Chachat 0.2.x` が安定版 `0.2.10` をリリースしました。
今後はアップデートと技術サポートを停止し、より適用性の高い`Langchain-Chachat 0.3.x`の開発に努める予定です。
+ 🔥 これからのChatchatストーリーを一緒に楽しみにしましょう···
---
## お問い合わせ
### Telegram
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white "langchain-chatglm")](https://t.me/+RjliQ3jnJ1YyN2E9)
### WeChat グループ
<img src="img/qr_code_90.jpg" alt="二维码" width="300" height="300" />
### WeChat 公式アカウント
<img src="img/official_wechat_mp_account.png" alt="图片" width="900" height="300" />

View File

@ -1 +0,0 @@
from .chatglm_with_shared_memory_openai_llm import *

View File

@ -0,0 +1,22 @@
from server.utils import get_ChatOpenAI
from configs.model_config import LLM_MODELS, TEMPERATURE
from langchain.chains import LLMChain
from langchain.prompts.chat import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
)
model = get_ChatOpenAI(model_name=LLM_MODELS[0], temperature=TEMPERATURE)
human_prompt = "{input}"
human_message_template = HumanMessagePromptTemplate.from_template(human_prompt)
chat_prompt = ChatPromptTemplate.from_messages(
[("human", "我们来玩成语接龙,我先来,生龙活虎"),
("ai", "虎头虎脑"),
("human", "{input}")])
chain = LLMChain(prompt=chat_prompt, llm=model, verbose=True)
print(chain({"input": "恼羞成怒"}))

View File

@ -1,215 +0,0 @@
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
from langchain.vectorstores import FAISS
from langchain.document_loaders import UnstructuredFileLoader
from models.chatglm_llm import ChatGLM
from configs.model_config import *
import datetime
from textsplitter import ChineseTextSplitter
from typing import List, Tuple
from langchain.docstore.document import Document
import numpy as np
# return top-k text chunk from vector store
VECTOR_SEARCH_TOP_K = 6
# LLM input history length
LLM_HISTORY_LEN = 3
def load_file(filepath):
if filepath.lower().endswith(".md"):
loader = UnstructuredFileLoader(filepath, mode="elements")
docs = loader.load()
elif filepath.lower().endswith(".pdf"):
loader = UnstructuredFileLoader(filepath)
textsplitter = ChineseTextSplitter(pdf=True)
docs = loader.load_and_split(textsplitter)
else:
loader = UnstructuredFileLoader(filepath, mode="elements")
textsplitter = ChineseTextSplitter(pdf=False)
docs = loader.load_and_split(text_splitter=textsplitter)
return docs
def generate_prompt(related_docs: List[str],
query: str,
prompt_template=PROMPT_TEMPLATE) -> str:
context = "\n".join([doc.page_content for doc in related_docs])
prompt = prompt_template.replace("{question}", query).replace("{context}", context)
return prompt
def get_docs_with_score(docs_with_score):
docs=[]
for doc, score in docs_with_score:
doc.metadata["score"] = score
docs.append(doc)
return docs
def seperate_list(ls: List[int]) -> List[List[int]]:
lists = []
ls1 = [ls[0]]
for i in range(1, len(ls)):
if ls[i-1] + 1 == ls[i]:
ls1.append(ls[i])
else:
lists.append(ls1)
ls1 = [ls[i]]
lists.append(ls1)
return lists
def similarity_search_with_score_by_vector(
self,
embedding: List[float],
k: int = 4,
) -> List[Tuple[Document, float]]:
scores, indices = self.index.search(np.array([embedding], dtype=np.float32), k)
docs = []
id_set = set()
for j, i in enumerate(indices[0]):
if i == -1:
# This happens when not enough docs are returned.
continue
_id = self.index_to_docstore_id[i]
doc = self.docstore.search(_id)
id_set.add(i)
docs_len = len(doc.page_content)
for k in range(1, max(i, len(docs)-i)):
for l in [i+k, i-k]:
if 0 <= l < len(self.index_to_docstore_id):
_id0 = self.index_to_docstore_id[l]
doc0 = self.docstore.search(_id0)
if docs_len + len(doc0.page_content) > self.chunk_size:
break
elif doc0.metadata["source"] == doc.metadata["source"]:
docs_len += len(doc0.page_content)
id_set.add(l)
id_list = sorted(list(id_set))
id_lists = seperate_list(id_list)
for id_seq in id_lists:
for id in id_seq:
if id == id_seq[0]:
_id = self.index_to_docstore_id[id]
doc = self.docstore.search(_id)
else:
_id0 = self.index_to_docstore_id[id]
doc0 = self.docstore.search(_id0)
doc.page_content += doc0.page_content
if not isinstance(doc, Document):
raise ValueError(f"Could not find document for id {_id}, got {doc}")
docs.append((doc, scores[0][j]))
return docs
class LocalDocQA:
llm: object = None
embeddings: object = None
top_k: int = VECTOR_SEARCH_TOP_K
chunk_size: int = CHUNK_SIZE
def init_cfg(self,
embedding_model: str = EMBEDDING_MODEL,
embedding_device=EMBEDDING_DEVICE,
llm_history_len: int = LLM_HISTORY_LEN,
llm_model: str = LLM_MODEL,
llm_device=LLM_DEVICE,
top_k=VECTOR_SEARCH_TOP_K,
use_ptuning_v2: bool = USE_PTUNING_V2
):
self.llm = ChatGLM()
self.llm.load_model(model_name_or_path=llm_model_dict[llm_model],
llm_device=llm_device,
use_ptuning_v2=use_ptuning_v2)
self.llm.history_len = llm_history_len
self.embeddings = HuggingFaceEmbeddings(model_name=embedding_model_dict[embedding_model],
model_kwargs={'device': embedding_device})
self.top_k = top_k
def init_knowledge_vector_store(self,
filepath: str or List[str],
vs_path: str or os.PathLike = None):
loaded_files = []
if isinstance(filepath, str):
if not os.path.exists(filepath):
print("路径不存在")
return None
elif os.path.isfile(filepath):
file = os.path.split(filepath)[-1]
try:
docs = load_file(filepath)
print(f"{file} 已成功加载")
loaded_files.append(filepath)
except Exception as e:
print(e)
print(f"{file} 未能成功加载")
return None
elif os.path.isdir(filepath):
docs = []
for file in os.listdir(filepath):
fullfilepath = os.path.join(filepath, file)
try:
docs += load_file(fullfilepath)
print(f"{file} 已成功加载")
loaded_files.append(fullfilepath)
except Exception as e:
print(e)
print(f"{file} 未能成功加载")
else:
docs = []
for file in filepath:
try:
docs += load_file(file)
print(f"{file} 已成功加载")
loaded_files.append(file)
except Exception as e:
print(e)
print(f"{file} 未能成功加载")
if len(docs) > 0:
if vs_path and os.path.isdir(vs_path):
vector_store = FAISS.load_local(vs_path, self.embeddings)
vector_store.add_documents(docs)
else:
if not vs_path:
vs_path = f"""{VS_ROOT_PATH}{os.path.splitext(file)[0]}_FAISS_{datetime.datetime.now().strftime("%Y%m%d_%H%M%S")}"""
vector_store = FAISS.from_documents(docs, self.embeddings)
vector_store.save_local(vs_path)
return vs_path, loaded_files
else:
print("文件均未成功加载,请检查依赖包或替换为其他文件再次上传。")
return None, loaded_files
def get_knowledge_based_answer(self,
query,
vs_path,
chat_history=[],
streaming=True):
self.llm.streaming = streaming
vector_store = FAISS.load_local(vs_path, self.embeddings)
FAISS.similarity_search_with_score_by_vector = similarity_search_with_score_by_vector
vector_store.chunk_size=self.chunk_size
related_docs_with_score = vector_store.similarity_search_with_score(query,
k=self.top_k)
related_docs = get_docs_with_score(related_docs_with_score)
prompt = generate_prompt(related_docs, query)
if streaming:
for result, history in self.llm._call(prompt=prompt,
history=chat_history):
history[-1][0] = query
response = {"query": query,
"result": result,
"source_documents": related_docs}
yield response, history
else:
result, history = self.llm._call(prompt=prompt,
history=chat_history)
history[-1][0] = query
response = {"query": query,
"result": result,
"source_documents": related_docs}
return response, history

View File

@ -1,34 +0,0 @@
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
from typing import Any, List
class MyEmbeddings(HuggingFaceEmbeddings):
def __init__(self, **kwargs: Any):
super().__init__(**kwargs)
def embed_documents(self, texts: List[str]) -> List[List[float]]:
"""Compute doc embeddings using a HuggingFace transformer model.
Args:
texts: The list of texts to embed.
Returns:
List of embeddings, one for each text.
"""
texts = list(map(lambda x: x.replace("\n", " "), texts))
embeddings = self.client.encode(texts, normalize_embeddings=True)
return embeddings.tolist()
def embed_query(self, text: str) -> List[float]:
"""Compute query embeddings using a HuggingFace transformer model.
Args:
text: The text to embed.
Returns:
Embeddings for the text.
"""
text = text.replace("\n", " ")
embedding = self.client.encode(text, normalize_embeddings=True)
return embedding.tolist()

View File

@ -1,121 +0,0 @@
from langchain.vectorstores import FAISS
from typing import Any, Callable, List, Optional, Tuple, Dict
from langchain.docstore.document import Document
from langchain.docstore.base import Docstore
from langchain.vectorstores.utils import maximal_marginal_relevance
from langchain.embeddings.base import Embeddings
import uuid
from langchain.docstore.in_memory import InMemoryDocstore
import numpy as np
def dependable_faiss_import() -> Any:
"""Import faiss if available, otherwise raise error."""
try:
import faiss
except ImportError:
raise ValueError(
"Could not import faiss python package. "
"Please install it with `pip install faiss` "
"or `pip install faiss-cpu` (depending on Python version)."
)
return faiss
class FAISSVS(FAISS):
def __init__(self,
embedding_function: Callable[..., Any],
index: Any,
docstore: Docstore,
index_to_docstore_id: Dict[int, str]):
super().__init__(embedding_function, index, docstore, index_to_docstore_id)
def max_marginal_relevance_search_by_vector(
self, embedding: List[float], k: int = 4, fetch_k: int = 20, **kwargs: Any
) -> List[Tuple[Document, float]]:
"""Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Args:
embedding: Embedding to look up documents similar to.
k: Number of Documents to return. Defaults to 4.
fetch_k: Number of Documents to fetch to pass to MMR algorithm.
Returns:
List of Documents with scores selected by maximal marginal relevance.
"""
scores, indices = self.index.search(np.array([embedding], dtype=np.float32), fetch_k)
# -1 happens when not enough docs are returned.
embeddings = [self.index.reconstruct(int(i)) for i in indices[0] if i != -1]
mmr_selected = maximal_marginal_relevance(
np.array([embedding], dtype=np.float32), embeddings, k=k
)
selected_indices = [indices[0][i] for i in mmr_selected]
selected_scores = [scores[0][i] for i in mmr_selected]
docs = []
for i, score in zip(selected_indices, selected_scores):
if i == -1:
# This happens when not enough docs are returned.
continue
_id = self.index_to_docstore_id[i]
doc = self.docstore.search(_id)
if not isinstance(doc, Document):
raise ValueError(f"Could not find document for id {_id}, got {doc}")
docs.append((doc, score))
return docs
def max_marginal_relevance_search(
self,
query: str,
k: int = 4,
fetch_k: int = 20,
**kwargs: Any,
) -> List[Tuple[Document, float]]:
"""Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.
Args:
query: Text to look up documents similar to.
k: Number of Documents to return. Defaults to 4.
fetch_k: Number of Documents to fetch to pass to MMR algorithm.
Returns:
List of Documents with scores selected by maximal marginal relevance.
"""
embedding = self.embedding_function(query)
docs = self.max_marginal_relevance_search_by_vector(embedding, k, fetch_k)
return docs
@classmethod
def __from(
cls,
texts: List[str],
embeddings: List[List[float]],
embedding: Embeddings,
metadatas: Optional[List[dict]] = None,
**kwargs: Any,
) -> FAISS:
faiss = dependable_faiss_import()
index = faiss.IndexFlatIP(len(embeddings[0]))
index.add(np.array(embeddings, dtype=np.float32))
# # my code, for speeding up search
# quantizer = faiss.IndexFlatL2(len(embeddings[0]))
# index = faiss.IndexIVFFlat(quantizer, len(embeddings[0]), 100)
# index.train(np.array(embeddings, dtype=np.float32))
# index.add(np.array(embeddings, dtype=np.float32))
documents = []
for i, text in enumerate(texts):
metadata = metadatas[i] if metadatas else {}
documents.append(Document(page_content=text, metadata=metadata))
index_to_id = {i: str(uuid.uuid4()) for i in range(len(documents))}
docstore = InMemoryDocstore(
{index_to_id[i]: doc for i, doc in enumerate(documents)}
)
return cls(embedding.embed_query, index, docstore, index_to_id)

View File

@ -1,52 +0,0 @@
import os
import pinecone
from tqdm import tqdm
from langchain.llms import OpenAI
from langchain.text_splitter import SpacyTextSplitter
from langchain.document_loaders import TextLoader
from langchain.document_loaders import DirectoryLoader
from langchain.indexes import VectorstoreIndexCreator
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Pinecone
#一些配置文件
openai_key="你的key" # 注册 openai.com 后获得
pinecone_key="你的key" # 注册 app.pinecone.io 后获得
pinecone_index="你的库" #app.pinecone.io 获得
pinecone_environment="你的Environment" # 登录pinecone后在indexes页面 查看Environment
pinecone_namespace="你的Namespace" #如果不存在自动创建
#科学上网你懂得
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:7890'
#初始化pinecone
pinecone.init(
api_key=pinecone_key,
environment=pinecone_environment
)
index = pinecone.Index(pinecone_index)
#初始化OpenAI的embeddings
embeddings = OpenAIEmbeddings(openai_api_key=openai_key)
#初始化text_splitter
text_splitter = SpacyTextSplitter(pipeline='zh_core_web_sm',chunk_size=1000,chunk_overlap=200)
# 读取目录下所有后缀是txt的文件
loader = DirectoryLoader('../docs', glob="**/*.txt", loader_cls=TextLoader)
#读取文本文件
documents = loader.load()
# 使用text_splitter对文档进行分割
split_text = text_splitter.split_documents(documents)
try:
for document in tqdm(split_text):
# 获取向量并储存到pinecone
Pinecone.from_documents([document], embeddings, index_name=pinecone_index)
except Exception as e:
print(f"Error: {e}")
quit()

View File

@ -1,43 +0,0 @@
from configs.model_config import *
from chains.local_doc_qa import LocalDocQA
import os
import nltk
nltk.data.path = [os.path.join(os.path.dirname(__file__), "nltk_data")] + nltk.data.path
# return top-k text chunk from vector store
VECTOR_SEARCH_TOP_K = 6
# 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 请输入问题:")
last_print_len = 0
for resp, history in local_doc_qa.get_knowledge_based_answer(query=query,
vs_path=vs_path,
chat_history=history,
streaming=True):
print(resp["result"][last_print_len:], end="", flush=True)
last_print_len = len(resp["result"])
if REPLY_WITH_SOURCE:
source_text = [f"""出处 [{inum + 1}] {os.path.split(doc.metadata['source'])[-1]}\n\n{doc.page_content}\n\n"""
# f"""相关度:{doc.metadata['score']}\n\n"""
for inum, doc in
enumerate(resp["source_documents"])]
print("\n\n" + "\n\n".join(source_text))

0
common/__init__.py Normal file
View File

8
configs/__init__.py Normal file
View File

@ -0,0 +1,8 @@
from .basic_config import *
from .model_config import *
from .kb_config import *
from .server_config import *
from .prompt_config import *
VERSION = "v0.2.10"

View File

@ -0,0 +1,32 @@
import logging
import os
import langchain
import tempfile
import shutil
# 是否显示详细日志
log_verbose = False
langchain.verbose = False
# 通常情况下不需要更改以下内容
# 日志格式
LOG_FORMAT = "%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s"
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logging.basicConfig(format=LOG_FORMAT)
# 日志存储路径
LOG_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "logs")
if not os.path.exists(LOG_PATH):
os.mkdir(LOG_PATH)
# 临时文件目录,主要用于文件对话
BASE_TEMP_DIR = os.path.join(tempfile.gettempdir(), "chatchat")
try:
shutil.rmtree(BASE_TEMP_DIR)
except Exception:
pass
os.makedirs(BASE_TEMP_DIR, exist_ok=True)

View File

@ -0,0 +1,146 @@
import os
# 默认使用的知识库
DEFAULT_KNOWLEDGE_BASE = "samples"
# 默认向量库/全文检索引擎类型。可选faiss, milvus(离线) & zilliz(在线), pgvector, chromadb 全文检索引擎es
DEFAULT_VS_TYPE = "faiss"
# 缓存向量库数量针对FAISS
CACHED_VS_NUM = 1
# 缓存临时向量库数量针对FAISS用于文件对话
CACHED_MEMO_VS_NUM = 10
# 知识库中单段文本长度(不适用MarkdownHeaderTextSplitter)
CHUNK_SIZE = 250
# 知识库中相邻文本重合长度(不适用MarkdownHeaderTextSplitter)
OVERLAP_SIZE = 50
# 知识库匹配向量数量
VECTOR_SEARCH_TOP_K = 3
# 知识库匹配的距离阈值一般取值范围在0-1之间SCORE越小距离越小从而相关度越高。
# 但有用户报告遇到过匹配分值超过1的情况为了兼容性默认设为1在WEBUI中调整范围为0-2
SCORE_THRESHOLD = 1.0
# 默认搜索引擎。可选bing, duckduckgo, metaphor
DEFAULT_SEARCH_ENGINE = "duckduckgo"
# 搜索引擎匹配结题数量
SEARCH_ENGINE_TOP_K = 3
# Bing 搜索必备变量
# 使用 Bing 搜索需要使用 Bing Subscription Key,需要在azure port中申请试用bing search
# 具体申请方式请见
# https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/create-bing-search-service-resource
# 使用python创建bing api 搜索实例详见:
# https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/quickstarts/rest/python
BING_SEARCH_URL = "https://api.bing.microsoft.com/v7.0/search"
# 注意不是bing Webmaster Tools的api key
# 此外如果是在服务器上报Failed to establish a new connection: [Errno 110] Connection timed out
# 是因为服务器加了防火墙需要联系管理员加白名单如果公司的服务器的话就别想了GG
BING_SUBSCRIPTION_KEY = ""
# metaphor搜索需要KEY
METAPHOR_API_KEY = ""
# 心知天气 API KEY用于天气Agent。申请https://www.seniverse.com/
SENIVERSE_API_KEY = ""
# 是否开启中文标题加强,以及标题增强的相关配置
# 通过增加标题判断判断哪些文本为标题并在metadata中进行标记
# 然后将文本与往上一级的标题进行拼合,实现文本信息的增强。
ZH_TITLE_ENHANCE = False
# PDF OCR 控制:只对宽高超过页面一定比例(图片宽/页面宽,图片高/页面高)的图片进行 OCR。
# 这样可以避免 PDF 中一些小图片的干扰,提高非扫描版 PDF 处理速度
PDF_OCR_THRESHOLD = (0.6, 0.6)
# 每个知识库的初始化介绍用于在初始化知识库时显示和Agent调用没写则没有介绍不会被Agent调用。
KB_INFO = {
"知识库名称": "知识库介绍",
"samples": "关于本项目issue的解答",
}
# 通常情况下不需要更改以下内容
# 知识库默认存储路径
KB_ROOT_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "knowledge_base")
if not os.path.exists(KB_ROOT_PATH):
os.mkdir(KB_ROOT_PATH)
# 数据库默认存储路径。
# 如果使用sqlite可以直接修改DB_ROOT_PATH如果使用其它数据库请直接修改SQLALCHEMY_DATABASE_URI。
DB_ROOT_PATH = os.path.join(KB_ROOT_PATH, "info.db")
SQLALCHEMY_DATABASE_URI = f"sqlite:///{DB_ROOT_PATH}"
# 可选向量库类型及对应配置
kbs_config = {
"faiss": {
},
"milvus": {
"host": "127.0.0.1",
"port": "19530",
"user": "",
"password": "",
"secure": False,
},
"zilliz": {
"host": "in01-a7ce524e41e3935.ali-cn-hangzhou.vectordb.zilliz.com.cn",
"port": "19530",
"user": "",
"password": "",
"secure": True,
},
"pg": {
"connection_uri": "postgresql://postgres:postgres@127.0.0.1:5432/langchain_chatchat",
},
"es": {
"host": "127.0.0.1",
"port": "9200",
"index_name": "test_index",
"user": "",
"password": ""
},
"milvus_kwargs":{
"search_params":{"metric_type": "L2"}, #在此处增加search_params
"index_params":{"metric_type": "L2","index_type": "HNSW"} # 在此处增加index_params
},
"chromadb": {}
}
# TextSplitter配置项如果你不明白其中的含义就不要修改。
text_splitter_dict = {
"ChineseRecursiveTextSplitter": {
"source": "huggingface", # 选择tiktoken则使用openai的方法
"tokenizer_name_or_path": "",
},
"SpacyTextSplitter": {
"source": "huggingface",
"tokenizer_name_or_path": "gpt2",
},
"RecursiveCharacterTextSplitter": {
"source": "tiktoken",
"tokenizer_name_or_path": "cl100k_base",
},
"MarkdownHeaderTextSplitter": {
"headers_to_split_on":
[
("#", "head1"),
("##", "head2"),
("###", "head3"),
("####", "head4"),
]
},
}
# TEXT_SPLITTER 名称
TEXT_SPLITTER_NAME = "ChineseRecursiveTextSplitter"
# Embedding模型定制词语的词表文件
EMBEDDING_KEYWORD_FILE = "embedding_keywords.txt"

View File

@ -1,45 +0,0 @@
import torch.cuda
import torch.backends
import os
embedding_model_dict = {
"ernie-tiny": "nghuyong/ernie-3.0-nano-zh",
"ernie-base": "nghuyong/ernie-3.0-base-zh",
"text2vec-base": "shibing624/text2vec-base-chinese",
"text2vec": "GanymedeNil/text2vec-large-chinese",
}
# Embedding model name
EMBEDDING_MODEL = "text2vec"
# Embedding running device
EMBEDDING_DEVICE = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
# supported LLM models
llm_model_dict = {
"chatyuan": "ClueAI/ChatYuan-large-v2",
"chatglm-6b-int4-qe": "THUDM/chatglm-6b-int4-qe",
"chatglm-6b-int4": "THUDM/chatglm-6b-int4",
"chatglm-6b-int8": "THUDM/chatglm-6b-int8",
"chatglm-6b": "THUDM/chatglm-6b",
}
# LLM model name
LLM_MODEL = "chatglm-6b"
# Use p-tuning-v2 PrefixEncoder
USE_PTUNING_V2 = False
# LLM running device
LLM_DEVICE = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
VS_ROOT_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "vector_store", "")
UPLOAD_ROOT_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "content", "")
# 基于上下文的prompt模版请务必保留"{question}"和"{context}"
PROMPT_TEMPLATE = """基于以下已知信息,简洁和专业的来回答用户的问题,问题是"{question}"。如果无法从中得到答案,请说 "根据已知信息无法回答该问题""没有提供足够的相关信息",不允许在答案中添加编造成分,答案请使用中文。已知内容如下:
{context} """
# 匹配后单段上下文长度
CHUNK_SIZE = 500

View File

@ -0,0 +1,327 @@
import os
# 可以指定一个绝对路径统一存放所有的Embedding和LLM模型。
# 每个模型可以是一个单独的目录,也可以是某个目录下的二级子目录。
# 如果模型目录名称和 MODEL_PATH 中的 key 或 value 相同,程序会自动检测加载,无需修改 MODEL_PATH 中的路径。
MODEL_ROOT_PATH = ""
# 选用的 Embedding 名称
EMBEDDING_MODEL = "bge-large-zh-v1.5"
# Embedding 模型运行设备。设为 "auto" 会自动检测(会有警告),也可手动设定为 "cuda","mps","cpu","xpu" 其中之一。
EMBEDDING_DEVICE = "auto"
# 选用的reranker模型
RERANKER_MODEL = "bge-reranker-large"
# 是否启用reranker模型
USE_RERANKER = False
RERANKER_MAX_LENGTH = 1024
# 如果需要在 EMBEDDING_MODEL 中增加自定义的关键字时配置
EMBEDDING_KEYWORD_FILE = "keywords.txt"
EMBEDDING_MODEL_OUTPUT_PATH = "output"
# 要运行的 LLM 名称,可以包括本地模型和在线模型。列表中本地模型将在启动项目时全部加载。
# 列表中第一个模型将作为 API 和 WEBUI 的默认模型。
# 在这里我们使用目前主流的两个离线模型其中chatglm3-6b 为默认加载模型。
# 如果你的显存不足,可使用 Qwen-1_8B-Chat, 该模型 FP16 仅需 3.8G显存。
LLM_MODELS = ["chatglm3-6b", "zhipu-api", "openai-api"]
Agent_MODEL = None
# LLM 模型运行设备。设为"auto"会自动检测(会有警告),也可手动设定为 "cuda","mps","cpu","xpu" 其中之一。
LLM_DEVICE = "auto"
HISTORY_LEN = 3
MAX_TOKENS = 2048
TEMPERATURE = 0.7
ONLINE_LLM_MODEL = {
"openai-api": {
"model_name": "gpt-4",
"api_base_url": "https://api.openai.com/v1",
"api_key": "",
"openai_proxy": "",
},
# 智谱AI API,具体注册及api key获取请前往 http://open.bigmodel.cn
"zhipu-api": {
"api_key": "",
"version": "glm-4",
"provider": "ChatGLMWorker",
},
# 具体注册及api key获取请前往 https://api.minimax.chat/
"minimax-api": {
"group_id": "",
"api_key": "",
"is_pro": False,
"provider": "MiniMaxWorker",
},
# 具体注册及api key获取请前往 https://xinghuo.xfyun.cn/
"xinghuo-api": {
"APPID": "",
"APISecret": "",
"api_key": "",
"version": "v3.5", # 你使用的讯飞星火大模型版本,可选包括 "v3.5","v3.0", "v2.0", "v1.5"
"provider": "XingHuoWorker",
},
# 百度千帆 API申请方式请参考 https://cloud.baidu.com/doc/WENXINWORKSHOP/s/4lilb2lpf
"qianfan-api": {
"version": "ERNIE-Bot", # 注意大小写。当前支持 "ERNIE-Bot" 或 "ERNIE-Bot-turbo" 更多的见官方文档。
"version_url": "", # 也可以不填写version直接填写在千帆申请模型发布的API地址
"api_key": "",
"secret_key": "",
"provider": "QianFanWorker",
},
# 火山方舟 API文档参考 https://www.volcengine.com/docs/82379
"fangzhou-api": {
"version": "", # 对应火山方舟的 endpoint_id
"version_url": "",
"api_key": "",
"secret_key": "",
"provider": "FangZhouWorker",
},
# 阿里云通义千问 API文档参考 https://help.aliyun.com/zh/dashscope/developer-reference/api-details
"qwen-api": {
"version": "qwen-max",
"api_key": "",
"provider": "QwenWorker",
"embed_model": "text-embedding-v1" # embedding 模型名称
},
# 百川 API申请方式请参考 https://www.baichuan-ai.com/home#api-enter
"baichuan-api": {
"version": "Baichuan2-53B",
"api_key": "",
"secret_key": "",
"provider": "BaiChuanWorker",
},
# Azure API
"azure-api": {
"deployment_name": "", # 部署容器的名字
"resource_name": "", # https://{resource_name}.openai.azure.com/openai/ 填写resource_name的部分其他部分不要填写
"api_version": "", # API的版本不是模型版本
"api_key": "",
"provider": "AzureWorker",
},
# 昆仑万维天工 API https://model-platform.tiangong.cn/
"tiangong-api": {
"version": "SkyChat-MegaVerse",
"api_key": "",
"secret_key": "",
"provider": "TianGongWorker",
},
# Gemini API https://makersuite.google.com/app/apikey
"gemini-api": {
"api_key": "",
"provider": "GeminiWorker",
},
# Claude API : https://www.anthropic.com/api
# Available models:
# Claude 3 Opus: claude-3-opus-20240229
# Claude 3 Sonnet claude-3-sonnet-20240229
# Claude 3 Haiku claude-3-haiku-20240307
"claude-api": {
"api_key": "",
"version": "2023-06-01",
"model_name":"claude-3-opus-20240229",
"provider": "ClaudeWorker",
}
}
# 在以下字典中修改属性值以指定本地embedding模型存储位置。支持3种设置方法
# 1、将对应的值修改为模型绝对路径
# 2、不修改此处的值以 text2vec 为例):
# 2.1 如果{MODEL_ROOT_PATH}下存在如下任一子目录:
# - text2vec
# - GanymedeNil/text2vec-large-chinese
# - text2vec-large-chinese
# 2.2 如果以上本地路径不存在则使用huggingface模型
MODEL_PATH = {
"embed_model": {
"ernie-tiny": "nghuyong/ernie-3.0-nano-zh",
"ernie-base": "nghuyong/ernie-3.0-base-zh",
"text2vec-base": "shibing624/text2vec-base-chinese",
"text2vec": "GanymedeNil/text2vec-large-chinese",
"text2vec-paraphrase": "shibing624/text2vec-base-chinese-paraphrase",
"text2vec-sentence": "shibing624/text2vec-base-chinese-sentence",
"text2vec-multilingual": "shibing624/text2vec-base-multilingual",
"text2vec-bge-large-chinese": "shibing624/text2vec-bge-large-chinese",
"m3e-small": "moka-ai/m3e-small",
"m3e-base": "moka-ai/m3e-base",
"m3e-large": "moka-ai/m3e-large",
"bge-small-zh": "BAAI/bge-small-zh",
"bge-base-zh": "BAAI/bge-base-zh",
"bge-large-zh": "BAAI/bge-large-zh",
"bge-large-zh-noinstruct": "BAAI/bge-large-zh-noinstruct",
"bge-base-zh-v1.5": "BAAI/bge-base-zh-v1.5",
"bge-large-zh-v1.5": "BAAI/bge-large-zh-v1.5",
"bge-m3": "BAAI/bge-m3",
"piccolo-base-zh": "sensenova/piccolo-base-zh",
"piccolo-large-zh": "sensenova/piccolo-large-zh",
"nlp_gte_sentence-embedding_chinese-large": "damo/nlp_gte_sentence-embedding_chinese-large",
"text-embedding-ada-002": "your OPENAI_API_KEY",
},
"llm_model": {
"chatglm2-6b": "THUDM/chatglm2-6b",
"chatglm2-6b-32k": "THUDM/chatglm2-6b-32k",
"chatglm3-6b": "THUDM/chatglm3-6b",
"chatglm3-6b-32k": "THUDM/chatglm3-6b-32k",
"Orion-14B-Chat": "OrionStarAI/Orion-14B-Chat",
"Orion-14B-Chat-Plugin": "OrionStarAI/Orion-14B-Chat-Plugin",
"Orion-14B-LongChat": "OrionStarAI/Orion-14B-LongChat",
"Llama-2-7b-chat-hf": "meta-llama/Llama-2-7b-chat-hf",
"Llama-2-13b-chat-hf": "meta-llama/Llama-2-13b-chat-hf",
"Llama-2-70b-chat-hf": "meta-llama/Llama-2-70b-chat-hf",
"Qwen-1_8B-Chat": "Qwen/Qwen-1_8B-Chat",
"Qwen-7B-Chat": "Qwen/Qwen-7B-Chat",
"Qwen-14B-Chat": "Qwen/Qwen-14B-Chat",
"Qwen-72B-Chat": "Qwen/Qwen-72B-Chat",
# Qwen1.5 模型 VLLM可能出现问题
"Qwen1.5-0.5B-Chat": "Qwen/Qwen1.5-0.5B-Chat",
"Qwen1.5-1.8B-Chat": "Qwen/Qwen1.5-1.8B-Chat",
"Qwen1.5-4B-Chat": "Qwen/Qwen1.5-4B-Chat",
"Qwen1.5-7B-Chat": "Qwen/Qwen1.5-7B-Chat",
"Qwen1.5-14B-Chat": "Qwen/Qwen1.5-14B-Chat",
"Qwen1.5-72B-Chat": "Qwen/Qwen1.5-72B-Chat",
"baichuan-7b-chat": "baichuan-inc/Baichuan-7B-Chat",
"baichuan-13b-chat": "baichuan-inc/Baichuan-13B-Chat",
"baichuan2-7b-chat": "baichuan-inc/Baichuan2-7B-Chat",
"baichuan2-13b-chat": "baichuan-inc/Baichuan2-13B-Chat",
"internlm-7b": "internlm/internlm-7b",
"internlm-chat-7b": "internlm/internlm-chat-7b",
"internlm2-chat-7b": "internlm/internlm2-chat-7b",
"internlm2-chat-20b": "internlm/internlm2-chat-20b",
"BlueLM-7B-Chat": "vivo-ai/BlueLM-7B-Chat",
"BlueLM-7B-Chat-32k": "vivo-ai/BlueLM-7B-Chat-32k",
"Yi-34B-Chat": "https://huggingface.co/01-ai/Yi-34B-Chat",
"agentlm-7b": "THUDM/agentlm-7b",
"agentlm-13b": "THUDM/agentlm-13b",
"agentlm-70b": "THUDM/agentlm-70b",
"falcon-7b": "tiiuae/falcon-7b",
"falcon-40b": "tiiuae/falcon-40b",
"falcon-rw-7b": "tiiuae/falcon-rw-7b",
"aquila-7b": "BAAI/Aquila-7B",
"aquilachat-7b": "BAAI/AquilaChat-7B",
"open_llama_13b": "openlm-research/open_llama_13b",
"vicuna-13b-v1.5": "lmsys/vicuna-13b-v1.5",
"koala": "young-geng/koala",
"mpt-7b": "mosaicml/mpt-7b",
"mpt-7b-storywriter": "mosaicml/mpt-7b-storywriter",
"mpt-30b": "mosaicml/mpt-30b",
"opt-66b": "facebook/opt-66b",
"opt-iml-max-30b": "facebook/opt-iml-max-30b",
"gpt2": "gpt2",
"gpt2-xl": "gpt2-xl",
"gpt-j-6b": "EleutherAI/gpt-j-6b",
"gpt4all-j": "nomic-ai/gpt4all-j",
"gpt-neox-20b": "EleutherAI/gpt-neox-20b",
"pythia-12b": "EleutherAI/pythia-12b",
"oasst-sft-4-pythia-12b-epoch-3.5": "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",
"dolly-v2-12b": "databricks/dolly-v2-12b",
"stablelm-tuned-alpha-7b": "stabilityai/stablelm-tuned-alpha-7b",
},
"reranker": {
"bge-reranker-large": "BAAI/bge-reranker-large",
"bge-reranker-base": "BAAI/bge-reranker-base",
}
}
# 通常情况下不需要更改以下内容
# nltk 模型存储路径
NLTK_DATA_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "nltk_data")
# 使用VLLM可能导致模型推理能力下降无法完成Agent任务
VLLM_MODEL_DICT = {
"chatglm2-6b": "THUDM/chatglm2-6b",
"chatglm2-6b-32k": "THUDM/chatglm2-6b-32k",
"chatglm3-6b": "THUDM/chatglm3-6b",
"chatglm3-6b-32k": "THUDM/chatglm3-6b-32k",
"Llama-2-7b-chat-hf": "meta-llama/Llama-2-7b-chat-hf",
"Llama-2-13b-chat-hf": "meta-llama/Llama-2-13b-chat-hf",
"Llama-2-70b-chat-hf": "meta-llama/Llama-2-70b-chat-hf",
"Qwen-1_8B-Chat": "Qwen/Qwen-1_8B-Chat",
"Qwen-7B-Chat": "Qwen/Qwen-7B-Chat",
"Qwen-14B-Chat": "Qwen/Qwen-14B-Chat",
"Qwen-72B-Chat": "Qwen/Qwen-72B-Chat",
"baichuan-7b-chat": "baichuan-inc/Baichuan-7B-Chat",
"baichuan-13b-chat": "baichuan-inc/Baichuan-13B-Chat",
"baichuan2-7b-chat": "baichuan-inc/Baichuan-7B-Chat",
"baichuan2-13b-chat": "baichuan-inc/Baichuan-13B-Chat",
"BlueLM-7B-Chat": "vivo-ai/BlueLM-7B-Chat",
"BlueLM-7B-Chat-32k": "vivo-ai/BlueLM-7B-Chat-32k",
"internlm-7b": "internlm/internlm-7b",
"internlm-chat-7b": "internlm/internlm-chat-7b",
"internlm2-chat-7b": "internlm/Models/internlm2-chat-7b",
"internlm2-chat-20b": "internlm/Models/internlm2-chat-20b",
"aquila-7b": "BAAI/Aquila-7B",
"aquilachat-7b": "BAAI/AquilaChat-7B",
"falcon-7b": "tiiuae/falcon-7b",
"falcon-40b": "tiiuae/falcon-40b",
"falcon-rw-7b": "tiiuae/falcon-rw-7b",
"gpt2": "gpt2",
"gpt2-xl": "gpt2-xl",
"gpt-j-6b": "EleutherAI/gpt-j-6b",
"gpt4all-j": "nomic-ai/gpt4all-j",
"gpt-neox-20b": "EleutherAI/gpt-neox-20b",
"pythia-12b": "EleutherAI/pythia-12b",
"oasst-sft-4-pythia-12b-epoch-3.5": "OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5",
"dolly-v2-12b": "databricks/dolly-v2-12b",
"stablelm-tuned-alpha-7b": "stabilityai/stablelm-tuned-alpha-7b",
"open_llama_13b": "openlm-research/open_llama_13b",
"vicuna-13b-v1.3": "lmsys/vicuna-13b-v1.3",
"koala": "young-geng/koala",
"mpt-7b": "mosaicml/mpt-7b",
"mpt-7b-storywriter": "mosaicml/mpt-7b-storywriter",
"mpt-30b": "mosaicml/mpt-30b",
"opt-66b": "facebook/opt-66b",
"opt-iml-max-30b": "facebook/opt-iml-max-30b",
}
SUPPORT_AGENT_MODEL = [
"openai-api", # GPT4 模型
"qwen-api", # Qwen Max模型
"zhipu-api", # 智谱AI GLM4模型
"Qwen", # 所有Qwen系列本地模型
"chatglm3-6b",
"internlm2-chat-20b",
"Orion-14B-Chat-Plugin",
]

View File

@ -0,0 +1,127 @@
# prompt模板使用Jinja2语法简单点就是用双大括号代替f-string的单大括号
# 本配置文件支持热加载修改prompt模板后无需重启服务。
# LLM对话支持的变量
# - input: 用户输入内容
# 知识库和搜索引擎对话支持的变量:
# - context: 从检索结果拼接的知识文本
# - question: 用户提出的问题
# Agent对话支持的变量
# - tools: 可用的工具列表
# - tool_names: 可用的工具名称列表
# - history: 用户和Agent的对话历史
# - input: 用户输入内容
# - agent_scratchpad: Agent的思维记录
PROMPT_TEMPLATES = {
"llm_chat": {
"default":
'{{ input }}',
"with_history":
'The following is a friendly conversation between a human and an AI. '
'The AI is talkative and provides lots of specific details from its context. '
'If the AI does not know the answer to a question, it truthfully says it does not know.\n\n'
'Current conversation:\n'
'{history}\n'
'Human: {input}\n'
'AI:',
"py":
'你是一个聪明的代码助手请你给我写出简单的py代码。 \n'
'{{ input }}',
},
"knowledge_base_chat": {
"default":
'<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,'
'不允许在答案中添加编造成分,答案请使用中文。 </指令>\n'
'<已知信息>{{ context }}</已知信息>\n'
'<问题>{{ question }}</问题>\n',
"text":
'<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>\n'
'<已知信息>{{ context }}</已知信息>\n'
'<问题>{{ question }}</问题>\n',
"empty": # 搜不到知识库的时候使用
'请你回答我的问题:\n'
'{{ question }}\n\n',
},
"search_engine_chat": {
"default":
'<指令>这是我搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题。'
'如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 </指令>\n'
'<已知信息>{{ context }}</已知信息>\n'
'<问题>{{ question }}</问题>\n',
"search":
'<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>\n'
'<已知信息>{{ context }}</已知信息>\n'
'<问题>{{ question }}</问题>\n',
},
"agent_chat": {
"default":
'Answer the following questions as best you can. If it is in order, you can use some tools appropriately. '
'You have access to the following tools:\n\n'
'{tools}\n\n'
'Use the following format:\n'
'Question: the input question you must answer1\n'
'Thought: you should always think about what to do and what tools to use.\n'
'Action: the action to take, should be one of [{tool_names}]\n'
'Action Input: the input to the action\n'
'Observation: the result of the action\n'
'... (this Thought/Action/Action Input/Observation can be repeated zero or more times)\n'
'Thought: I now know the final answer\n'
'Final Answer: the final answer to the original input question\n'
'Begin!\n\n'
'history: {history}\n\n'
'Question: {input}\n\n'
'Thought: {agent_scratchpad}\n',
"ChatGLM3":
'You can answer using the tools, or answer directly using your knowledge without using the tools. '
'Respond to the human as helpfully and accurately as possible.\n'
'You have access to the following tools:\n'
'{tools}\n'
'Use a json blob to specify a tool by providing an action key (tool name) '
'and an action_input key (tool input).\n'
'Valid "action" values: "Final Answer" or [{tool_names}]'
'Provide only ONE action per $JSON_BLOB, as shown:\n\n'
'```\n'
'{{{{\n'
' "action": $TOOL_NAME,\n'
' "action_input": $INPUT\n'
'}}}}\n'
'```\n\n'
'Follow this format:\n\n'
'Question: input question to answer\n'
'Thought: consider previous and subsequent steps\n'
'Action:\n'
'```\n'
'$JSON_BLOB\n'
'```\n'
'Observation: action result\n'
'... (repeat Thought/Action/Observation N times)\n'
'Thought: I know what to respond\n'
'Action:\n'
'```\n'
'{{{{\n'
' "action": "Final Answer",\n'
' "action_input": "Final response to human"\n'
'}}}}\n'
'Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. '
'Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.\n'
'history: {history}\n\n'
'Question: {input}\n\n'
'Thought: {agent_scratchpad}',
}
}

View File

@ -0,0 +1,139 @@
import sys
from configs.model_config import LLM_DEVICE
# httpx 请求默认超时时间(秒)。如果加载模型或对话较慢,出现超时错误,可以适当加大该值。
HTTPX_DEFAULT_TIMEOUT = 300.0
# API 是否开启跨域默认为False如果需要开启请设置为True
# is open cross domain
OPEN_CROSS_DOMAIN = False
# 各服务器默认绑定host。如改为"0.0.0.0"需要修改下方所有XX_SERVER的host
DEFAULT_BIND_HOST = "0.0.0.0" if sys.platform != "win32" else "127.0.0.1"
# webui.py server
WEBUI_SERVER = {
"host": DEFAULT_BIND_HOST,
"port": 8501,
}
# api.py server
API_SERVER = {
"host": DEFAULT_BIND_HOST,
"port": 7861,
}
# fastchat openai_api server
FSCHAT_OPENAI_API = {
"host": DEFAULT_BIND_HOST,
"port": 20000,
}
# fastchat model_worker server
# 这些模型必须是在model_config.MODEL_PATH或ONLINE_MODEL中正确配置的。
# 在启动startup.py时可用通过`--model-name xxxx yyyy`指定模型不指定则为LLM_MODELS
FSCHAT_MODEL_WORKERS = {
# 所有模型共用的默认配置,可在模型专项配置中进行覆盖。
"default": {
"host": DEFAULT_BIND_HOST,
"port": 20002,
"device": LLM_DEVICE,
# False,'vllm',使用的推理加速框架,使用vllm如果出现HuggingFace通信问题参见doc/FAQ
# vllm对一些模型支持还不成熟暂时默认关闭
"infer_turbo": False,
# model_worker多卡加载需要配置的参数
# "gpus": None, # 使用的GPU以str的格式指定如"0,1"如失效请使用CUDA_VISIBLE_DEVICES="0,1"等形式指定
# "num_gpus": 1, # 使用GPU的数量
# "max_gpu_memory": "20GiB", # 每个GPU占用的最大显存
# 以下为model_worker非常用参数可根据需要配置
# "load_8bit": False, # 开启8bit量化
# "cpu_offloading": None,
# "gptq_ckpt": None,
# "gptq_wbits": 16,
# "gptq_groupsize": -1,
# "gptq_act_order": False,
# "awq_ckpt": None,
# "awq_wbits": 16,
# "awq_groupsize": -1,
# "model_names": LLM_MODELS,
# "conv_template": None,
# "limit_worker_concurrency": 5,
# "stream_interval": 2,
# "no_register": False,
# "embed_in_truncate": False,
# 以下为vllm_worker配置参数,注意使用vllm必须有gpu仅在Linux测试通过
# tokenizer = model_path # 如果tokenizer与model_path不一致在此处添加
# 'tokenizer_mode':'auto',
# 'trust_remote_code':True,
# 'download_dir':None,
# 'load_format':'auto',
# 'dtype':'auto',
# 'seed':0,
# 'worker_use_ray':False,
# 'pipeline_parallel_size':1,
# 'tensor_parallel_size':1,
# 'block_size':16,
# 'swap_space':4 , # GiB
# 'gpu_memory_utilization':0.90,
# 'max_num_batched_tokens':2560,
# 'max_num_seqs':256,
# 'disable_log_stats':False,
# 'conv_template':None,
# 'limit_worker_concurrency':5,
# 'no_register':False,
# 'num_gpus': 1
# 'engine_use_ray': False,
# 'disable_log_requests': False
},
"chatglm3-6b": {
"device": "cuda",
},
"Qwen1.5-0.5B-Chat": {
"device": "cuda",
},
# 以下配置可以不用修改在model_config中设置启动的模型
"zhipu-api": {
"port": 21001,
},
"minimax-api": {
"port": 21002,
},
"xinghuo-api": {
"port": 21003,
},
"qianfan-api": {
"port": 21004,
},
"fangzhou-api": {
"port": 21005,
},
"qwen-api": {
"port": 21006,
},
"baichuan-api": {
"port": 21007,
},
"azure-api": {
"port": 21008,
},
"tiangong-api": {
"port": 21009,
},
"gemini-api": {
"port": 21010,
},
"claude-api": {
"port": 21011,
},
}
FSCHAT_CONTROLLER = {
"host": DEFAULT_BIND_HOST,
"port": 20001,
"dispatch_method": "shortest_queue",
}

View File

@ -1,152 +0,0 @@
# 基于本地知识的 ChatGLM 应用实现
## 介绍
🌍 [_READ THIS IN ENGLISH_](README_en.md)
🤖️ 一种利用 [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B) + [langchain](https://github.com/hwchase17/langchain) 实现的基于本地知识的 ChatGLM 应用。
💡 受 [GanymedeNil](https://github.com/GanymedeNil) 的项目 [document.ai](https://github.com/GanymedeNil/document.ai) 和 [AlexZhangji](https://github.com/AlexZhangji) 创建的 [ChatGLM-6B Pull Request](https://github.com/THUDM/ChatGLM-6B/pull/216) 启发,建立了全部基于开源模型实现的本地知识问答应用。
✅ 本项目中 Embedding 选用的是 [GanymedeNil/text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese/tree/main)LLM 选用的是 [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B)。依托上述模型,本项目可实现全部使用**开源**模型**离线私有部署**。
⛓️ 本项目实现原理如下图所示,过程包括加载文件 -> 读取文本 -> 文本分割 -> 文本向量化 -> 问句向量化 -> 在文本向量中匹配出与问句向量最相似的`top k`个 -> 匹配出的文本作为上下文和问题一起添加到`prompt`中 -> 提交给`LLM`生成回答。
![实现原理图](img/langchain+chatglm.png)
🚩 本项目未涉及微调、训练过程,但可利用微调或训练对本项目效果进行优化。
## 更新信息
**[2023/04/07]**
1. 解决加载 ChatGLM 模型时发生显存占用为双倍的问题 (感谢 [@suc16](https://github.com/suc16) 和 [@myml](https://github.com/myml))
2. 新增清理显存机制;
3. 新增`nghuyong/ernie-3.0-nano-zh``nghuyong/ernie-3.0-base-zh`作为 Embedding 模型备选项,相比`GanymedeNil/text2vec-large-chinese`占用显存资源更少 (感谢 [@lastrei](https://github.com/lastrei))。
**[2023/04/09]**
1. 使用`langchain`中的`RetrievalQA`替代之前选用的`ChatVectorDBChain`,替换后可以有效减少提问 2-3 次后因显存不足而停止运行的问题;
2. 在`knowledge_based_chatglm.py`中增加`EMBEDDING_MODEL``VECTOR_SEARCH_TOP_K``LLM_MODEL``LLM_HISTORY_LEN``REPLY_WITH_SOURCE`参数值设置;
3. 增加 GPU 显存需求更小的`chatglm-6b-int4``chatglm-6b-int4-qe`作为 LLM 模型备选项;
4. 更正`README.md`中的代码错误(感谢 [@calcitem](https://github.com/calcitem))。
**[2023/04/11]**
1. 加入 Web UI V0.1 版本(感谢 [@liangtongt](https://github.com/liangtongt)
2. `README.md`中增加常见问题(感谢 [@calcitem](https://github.com/calcitem)
3. 增加 LLM 和 Embedding 模型运行设备是否可用`cuda``mps``cpu`的自动判断。
4. 在`knowledge_based_chatglm.py`中增加对`filepath`的判断,在之前支持单个文件导入的基础上,现支持单个文件夹路径作为输入,输入后将会遍历文件夹中各个文件,并在命令行中显示每个文件是否成功加载。
## 使用方式
### 硬件需求
- ChatGLM-6B 模型硬件需求
| **量化等级** | **最低 GPU 显存**(推理) | **最低 GPU 显存**(高效参数微调) |
| -------------- | ------------------------- | --------------------------------- |
| FP16无量化 | 13 GB | 14 GB |
| INT8 | 8 GB | 9 GB |
| INT4 | 6 GB | 7 GB |
- Embedding 模型硬件需求
本项目中默认选用的 Embedding 模型 [GanymedeNil/text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese/tree/main) 约占用显存 3GB也可修改为在 CPU 中运行。
### 软件需求
本项目已在 python 3.8 环境下完成测试。
### 1. 安装 python 依赖包
```commandline
pip install -r requirements.txt
```
注:使用 langchain.document_loaders.UnstructuredFileLoader 进行非结构化文件接入时,可能需要依据文档进行其他依赖包的安装,请参考 [langchain 文档](https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html)
### 2. 执行脚本体验 Web UI 或命令行交互
执行 [webui.py](webui.py) 脚本体验 **Web 交互** <img src="https://img.shields.io/badge/Version-0.1-brightgreen">
```commandline
python webui.py
```
执行后效果如下图所示:
![webui](img/ui1.png)
Web UI 中提供的 API 接口如下图所示:
![webui](img/ui2.png)
Web UI 可以实现如下功能:
1. 自动读取`knowledge_based_chatglm.py``LLM``embedding`模型枚举,选择后点击`setting`进行模型加载,可随时切换模型进行测试
2. 可手动调节保留对话历史长度,可根据显存大小自行调节
3. 添加上传文件功能,通过下拉框选择已上传的文件,点击`loading`加载文件,过程中可随时更换加载的文件
4. 底部添加`use via API`可对接到自己系统
或执行 [knowledge_based_chatglm.py](knowledge_based_chatglm.py) 脚本体验**命令行交互**
```commandline
python knowledge_based_chatglm.py
```
### 常见问题
Q: 本项目支持哪些文件格式?
A: 目前已测试支持 txt、docx、md 格式文件,更多文件格式请参考 [langchain 文档](https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html)。目前已知文档中若含有特殊字符,可能存在文件无法加载的问题。
Q: 读取特定格式文件时遇到缺少`detectron2`时如何解决?
A: 因该包安装过程中遇到问题较多,且仅部分格式文件需要,所以未加入`requirements.txt`。可以通过一下命令安装
```commandline
pip install "detectron2@git+https://github.com/facebookresearch/detectron2.git@v0.6#egg=detectron2"
```
Q: `Resource punkt not found.` 如何解决?
A: https://github.com/nltk/nltk_data/raw/gh-pages/packages/tokenizers/punkt.zip 中的 `packages/tokenizers` 解压,放到 `Searched in:` 对应目录下。
Q: `Resource averaged_perceptron_tagger not found.` 如何解决?
A: 将 https://github.com/nltk/nltk_data/blob/gh-pages/packages/taggers/averaged_perceptron_tagger.zip 下载,解压放到 `Searched in:` 对应目录下。
Q: 本项目可否在 colab 中运行?
A: 可以尝试使用 chatglm-6b-int4 模型在 colab 中运行,需要注意的是,如需在 colab 中运行 Web UI需将`webui.py`中`demo.queue(concurrency_count=3).launch(
server_name='0.0.0.0', share=False, inbrowser=False)`中参数`share`设置为`True`。
## DEMO
以问题`chatglm-6b 的局限性具体体现在哪里,如何实现改进`为例
未使用 langchain 接入本地文档时:
>ChatGLM-6B 是一个基于 GPT-3 的聊天机器人,它的局限性主要体现在以下几个方面:
>1. 语言模型的精度:GPT-3 是一种大型的语言模型,它的精度比较高,但是仍然有一些局限性。例如,它可能无法准确地理解某些方言、口音或者复杂的句子结构。
>2. 知识图谱的完整性:GPT-3 可以生成一些知识图谱,但是其完整性和准确性可能不够。例如,它可能无法准确地理解某些领域的专业知识和术语。
>3. 对话生成的连贯性:GPT-3 可以生成一些连贯的对话,但是其生成的对话可能不够自然。例如,它可能会生成一些虚假的、不连贯的对话或者误解用户的意图。
>
>为了改进 ChatGLM-6B,可以考虑以下几个方面:
>1. 提高语言模型的精度:可以通过增加训练数据、使用更好的语言模型架构、优化模型训练过程等方式来提高语言模型的精度。
>2. 增强知识图谱的完整性:可以通过增加知识图谱的维度、使用更好的知识图谱构建方法、优化知识图谱的匹配算法等方式来增强知识图谱的完整性。
>3. 提高对话生成的连贯性:可以通过增加对话生成模型的上下文信息、使用更好的上下文信息提取方法、优化对话生成模型的算法等方式来提高对话生成的连贯性。
>4. 引入更多的人类反馈:人类反馈可以帮助 ChatGLM-6B 更好地理解用户的意图和需求,从而提高对话生成的质量和准确性。可以通过引入更多的人类客服、使用人类反馈收集器等方式来引入更多的人类反馈。
使用 langchain 接入 ChatGLM-6B 项目的 README.md 文件后 ChatGLM 的回答:
>ChatGLM-6B 是一个基于深度学习的自然语言处理模型,它在回答问题方面表现出色。但是,它也有一些局限性,具体如下:
>1. 语言理解有限:ChatGLM-6B 只学习了中文自然语言,对于其他语言可能会存在理解上的局限性。
>2. 知识储备不足:ChatGLM-6B 的训练数据集只包含了中文语料,因此它可能无法回答一些非中文的问题或者某些特定领域的问题。
>3. 数据量有限:ChatGLM-6B 的训练数据集只有几百万条记录,因此它可能无法回答一些非常具体或者复杂的问题。
>
>为了改进 ChatGLM-6B,可以考虑以下几个方面:
>1. 学习更多的语言知识:可以学习其他语言的自然语言处理技术,扩大语言理解的范围。
>2. 扩大知识储备:可以收集更多的中文语料,或者使用其他语言的数据集来扩充知识储备。
>3. 增加数据量:可以使用更大的数据集来训练 ChatGLM-6B,提高模型的表现。
>4. 引入更多的评估指标:可以引入更多的评估指标来评估模型的表现,从而发现 ChatGLM-6B 存在的不足和局限性。
>5. 改进模型架构:可以改进 ChatGLM-6B 的模型架构,提高模型的性能和表现。例如,可以使用更大的神经网络或者改进的卷积神经网络结构。
## 路线图
- [x] 实现 langchain + ChatGLM-6B 本地知识应用
- [x] 基于 langchain 实现非结构化文件接入
- [ ] 基于 langchain 实现更多类型本地知识文件接入
- [ ] 增加 Web UI DEMO
- [x] 利用 gradio 实现 Web UI DEMO
- [ ] 添加模型加载进度条
- [ ] 添加输出内容及错误提示
- [ ] 国际化语言切换
- [ ] 引用标注
- [ ] 添加插件系统可基础lora训练等
- [ ] 利用 fastapi 实现 API 部署方式,并实现调用 API 的 web ui DEMO
## 项目交流群
![二维码](img/qr_code.jpg)
🎉 langchain-ChatGLM 项目交流群,如果你也对本项目感兴趣,欢迎加入群聊参与讨论交流。

12
copy_config_example.py Normal file
View File

@ -0,0 +1,12 @@
# 用于批量将configs下的.example文件复制并命名为.py文件
import os
import shutil
if __name__ == "__main__":
files = os.listdir("configs")
src_files = [os.path.join("configs", file) for file in files if ".example" in file]
for src_file in src_files:
tar_file = src_file.replace(".example", "")
shutil.copy(src_file, tar_file)

View File

@ -1,32 +0,0 @@
## 变更日志
**[2023/04/15]**
1. 重构项目结构,在根目录下保留命令行 Demo [cli_demo.py](../cli_demo.py) 和 Web UI Demo [webui.py](../webui.py)
2. 对 Web UI 进行改进,修改为运行 Web UI 后首先按照 [configs/model_config.py](../configs/model_config.py) 默认选项加载模型,并增加报错提示信息等;
3. 对常见问题进行补充说明。
**[2023/04/12]**
1. 替换 Web UI 中的样例文件,避免出现 Ubuntu 中出现因文件编码无法读取的问题;
2. 替换`knowledge_based_chatglm.py`中的 prompt 模版,避免出现因 prompt 模版包含中英双语导致 chatglm 返回内容错乱的问题。
**[2023/04/11]**
1. 加入 Web UI V0.1 版本(感谢 [@liangtongt](https://github.com/liangtongt)
2. `README.md`中增加常见问题(感谢 [@calcitem](https://github.com/calcitem) 和 [@bolongliu](https://github.com/bolongliu)
3. 增加 LLM 和 Embedding 模型运行设备是否可用`cuda``mps``cpu`的自动判断。
4. 在`knowledge_based_chatglm.py`中增加对`filepath`的判断,在之前支持单个文件导入的基础上,现支持单个文件夹路径作为输入,输入后将会遍历文件夹中各个文件,并在命令行中显示每个文件是否成功加载。
**[2023/04/09]**
1. 使用`langchain`中的`RetrievalQA`替代之前选用的`ChatVectorDBChain`,替换后可以有效减少提问 2-3 次后因显存不足而停止运行的问题;
2. 在`knowledge_based_chatglm.py`中增加`EMBEDDING_MODEL``VECTOR_SEARCH_TOP_K``LLM_MODEL``LLM_HISTORY_LEN``REPLY_WITH_SOURCE`参数值设置;
3. 增加 GPU 显存需求更小的`chatglm-6b-int4``chatglm-6b-int4-qe`作为 LLM 模型备选项;
4. 更正`README.md`中的代码错误(感谢 [@calcitem](https://github.com/calcitem))。
**[2023/04/07]**
1. 解决加载 ChatGLM 模型时发生显存占用为双倍的问题 (感谢 [@suc16](https://github.com/suc16) 和 [@myml](https://github.com/myml))
2. 新增清理显存机制;
3. 新增`nghuyong/ernie-3.0-nano-zh``nghuyong/ernie-3.0-base-zh`作为 Embedding 模型备选项,相比`GanymedeNil/text2vec-large-chinese`占用显存资源更少 (感谢 [@lastrei](https://github.com/lastrei))。

29
docs/ES部署指南.md Normal file
View File

@ -0,0 +1,29 @@
# 实现基于ES的数据插入、检索、删除、更新
```shell
author: 唐国梁Tommy
e-mail: flytang186@qq.com
如果遇到任何问题,可以与我联系,我这边部署后服务是没有问题的。
```
## 第1步ES docker部署
```shell
docker network create elastic
docker run -id --name elasticsearch --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" -e "xpack.security.http.ssl.enabled=false" -t docker.elastic.co/elasticsearch/elasticsearch:8.8.2
```
### 第2步Kibana docker部署
**注意Kibana版本与ES保持一致**
```shell
docker pull docker.elastic.co/kibana/kibana:{version}
docker run --name kibana --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:{version}
```
### 第3步核心代码
```shell
1. 核心代码路径
server/knowledge_base/kb_service/es_kb_service.py
2. 需要在 configs/model_config.py 中 配置 ES参数IP PORT
```

View File

@ -1,121 +0,0 @@
### 常见问题
Q1: 本项目支持哪些文件格式?
A1: 目前已测试支持 txt、docx、md、pdf 格式文件,更多文件格式请参考 [langchain 文档](https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html)。目前已知文档中若含有特殊字符,可能存在文件无法加载的问题。
---
Q2: 执行 `pip install -r requirements.txt` 过程中,安装 `detectron2` 时发生报错怎么办?
A2: 如果不需要对 `pdf` 格式文件读取,可不安装 `detectron2`;如需对 `pdf` 文件进行高精度文本提取,建议按照如下方法安装:
```commandline
$ git clone https://github.com/facebookresearch/detectron2.git
$ cd detectron2
$ pip install -e .
```
---
Q3: 使用过程中 Python 包`nltk`发生了`Resource punkt not found.`报错,该如何解决?
A3: 方法一https://github.com/nltk/nltk_data/raw/gh-pages/packages/tokenizers/punkt.zip 中的 `packages/tokenizers` 解压,放到 `nltk_data/tokenizers` 存储路径下。
`nltk_data` 存储路径可以通过 `nltk.data.path` 查询。
方法二执行python代码
```
import nltk
nltk.download()
```
---
Q4: 使用过程中 Python 包`nltk`发生了`Resource averaged_perceptron_tagger not found.`报错,该如何解决?
A4: 方法一:将 https://github.com/nltk/nltk_data/blob/gh-pages/packages/taggers/averaged_perceptron_tagger.zip 下载,解压放到 `nltk_data/taggers` 存储路径下。
`nltk_data` 存储路径可以通过 `nltk.data.path` 查询。
方法二执行python代码
```
import nltk
nltk.download()
```
---
Q5: 本项目可否在 colab 中运行?
A5: 可以尝试使用 chatglm-6b-int4 模型在 colab 中运行,需要注意的是,如需在 colab 中运行 Web UI需将`webui.py`中`demo.queue(concurrency_count=3).launch(
server_name='0.0.0.0', share=False, inbrowser=False)`中参数`share`设置为`True`。
---
Q6: 在 Anaconda 中使用 pip 安装包无效如何解决?
A6: 此问题是系统环境问题,详细见 [在Anaconda中使用pip安装包无效问题](在Anaconda中使用pip安装包无效问题.md)
---
Q7: 本项目中所需模型如何下载至本地?
A7: 本项目中使用的模型均为`huggingface.com`中可下载的开源模型,以默认选择的`chatglm-6b``text2vec-large-chinese`模型为例,下载模型可执行如下代码:
```shell
# 安装 git lfs
$ git lfs install
# 下载 LLM 模型
$ git clone https://huggingface.co/THUDM/chatglm-6b /your_path/chatglm-6b
# 下载 Embedding 模型
$ git clone https://huggingface.co/GanymedeNil/text2vec-large-chinese /your_path/text2vec
# 模型需要更新时,可打开模型所在文件夹后拉取最新模型文件/代码
$ git pull
```
---
Q8: `huggingface.com`中模型下载速度较慢怎么办?
A8: 可使用本项目用到的模型权重文件百度网盘地址:
- ernie-3.0-base-zh.zip 链接: https://pan.baidu.com/s/1CIvKnD3qzE-orFouA8qvNQ?pwd=4wih
- ernie-3.0-nano-zh.zip 链接: https://pan.baidu.com/s/1Fh8fgzVdavf5P1omAJJ-Zw?pwd=q6s5
- text2vec-large-chinese.zip 链接: https://pan.baidu.com/s/1sMyPzBIXdEzHygftEoyBuA?pwd=4xs7
- chatglm-6b-int4-qe.zip 链接: https://pan.baidu.com/s/1DDKMOMHtNZccOOBGWIOYww?pwd=22ji
- chatglm-6b-int4.zip 链接: https://pan.baidu.com/s/1pvZ6pMzovjhkA6uPcRLuJA?pwd=3gjd
- chatglm-6b.zip 链接: https://pan.baidu.com/s/1B-MpsVVs1GHhteVBetaquw?pwd=djay
---
Q9: 下载完模型后,如何修改代码以执行本地模型?
A9: 模型下载完成后,请在 [configs/model_config.py](../configs/model_config.py) 文件中,对`embedding_model_dict``llm_model_dict`参数进行修改,如把`llm_model_dict`
```python
embedding_model_dict = {
"ernie-tiny": "nghuyong/ernie-3.0-nano-zh",
"ernie-base": "nghuyong/ernie-3.0-base-zh",
"text2vec": "GanymedeNil/text2vec-large-chinese"
}
```
修改为
```python
embedding_model_dict = {
"ernie-tiny": "nghuyong/ernie-3.0-nano-zh",
"ernie-base": "nghuyong/ernie-3.0-base-zh",
"text2vec": "/Users/liuqian/Downloads/ChatGLM-6B/text2vec-large-chinese"
}
```
---
Q10: 执行`python cli_demo.py`过程中,显卡内存爆了,提示"OutOfMemoryError: CUDA out of memory"
A10: 将 `VECTOR_SEARCH_TOP_K``LLM_HISTORY_LEN` 的值调低,比如 `VECTOR_SEARCH_TOP_K = 5``LLM_HISTORY_LEN = 2`,这样由 `query``context` 拼接得到的 `prompt` 会变短,会减少内存的占用。
---

View File

@ -1,32 +0,0 @@
# 安装
## 环境检查
```shell
# 首先,确信你的机器安装了 Python 3.8 及以上版本
$ python --version
Python 3.8.13
# 如果低于这个版本可使用conda安装环境
$ conda create -p /your_path/env_name python=3.8
# 激活环境
$ source activate /your_path/env_name
# 关闭环境
$ source deactivate /your_path/env_name
# 删除环境
$ conda env remove -p /your_path/env_name
```
## 项目依赖
```shell
# 拉取仓库
$ git clone https://github.com/imClumsyPanda/langchain-ChatGLM.git
# 安装依赖
$ pip install -r requirements.txt
```
注:使用 `langchain.document_loaders.UnstructuredFileLoader` 进行非结构化文件接入时,可能需要依据文档进行其他依赖包的安装,请参考 [langchain 文档](https://python.langchain.com/en/latest/modules/indexes/document_loaders/examples/unstructured_file.html)。

View File

@ -1,114 +0,0 @@
## Issue with Installing Packages Using pip in Anaconda
## Problem
Recently, when running open-source code, I encountered an issue: after creating a virtual environment with conda and switching to the new environment, using pip to install packages would be "ineffective." Here, "ineffective" means that the packages installed with pip are not in this new environment.
------
## Analysis
1. First, create a test environment called test: `conda create -n test`
2. Activate the test environment: `conda activate test`
3. Use pip to install numpy: `pip install numpy`. You'll find that numpy already exists in the default environment.
```powershell
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: numpy in c:\programdata\anaconda3\lib\site-packages (1.20.3)
```
4. Check the information of pip: `pip show pip`
```powershell
Name: pip
Version: 21.2.4
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig@python.org
License: MIT
Location: c:\programdata\anaconda3\lib\site-packages
Requires:
Required-by:
```
5. We can see that the current pip is in the default conda environment. This explains why the package is not in the new virtual environment when we directly use pip to install packages - because the pip being used belongs to the default environment, the installed package either already exists or is installed directly into the default environment.
------
## Solution
1. We can directly use the conda command to install new packages, but sometimes conda may not have certain packages/libraries, so we still need to use pip to install.
2. We can first use the conda command to install the pip package for the current virtual environment, and then use pip to install new packages.
```powershell
# Use conda to install the pip package
(test) PS C:\Users\Administrator> conda install pip
Collecting package metadata (current_repodata.json): done
Solving environment: done
....
done
# Display the information of the current pip, and find that pip is in the test environment
(test) PS C:\Users\Administrator> pip show pip
Name: pip
Version: 21.2.4
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig@python.org
License: MIT
Location: c:\programdata\anaconda3\envs\test\lib\site-packages
Requires:
Required-by:
# Now use pip to install the numpy package, and it is installed successfully
(test) PS C:\Users\Administrator> pip install numpy
Looking in indexes:
https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numpy
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4b/23/140ec5a509d992fe39db17200e96c00fd29603c1531ce633ef93dbad5e9e/numpy-1.22.2-cp39-cp39-win_amd64.whl (14.7 MB)
Installing collected packages: numpy
Successfully installed numpy-1.22.2
# Use pip list to view the currently installed packages, no problem
(test) PS C:\Users\Administrator> pip list
Package Version
------------ ---------
certifi 2021.10.8
numpy 1.22.2
pip 21.2.4
setuptools 58.0.4
wheel 0.37.1
wincertstore 0.2
```
## Supplement
1. The reason I didn't notice this problem before might be because the packages installed in the virtual environment were of a specific version, which overwrote the packages in the default environment. The main issue was actually a lack of careful observation:), otherwise, I could have noticed `Successfully uninstalled numpy-xxx` **default version** and `Successfully installed numpy-1.20.3` **specified version**.
2. During testing, I found that if the Python version is specified when creating a new package, there shouldn't be this issue. I guess this is because pip will be installed in the virtual environment, while in our case, including pip, no packages were installed, so the default environment's pip was used.
3. There's a question: I should have specified the Python version when creating a new virtual environment before, but I still used the default environment's pip package. However, I just couldn't reproduce the issue successfully on two different machines, which led to the second point mentioned above.
4. After encountering the problem mentioned in point 3, I solved it by using `python -m pip install package-name`, adding `python -m` before pip. As for why, you can refer to the answer on [StackOverflow](https://stackoverflow.com/questions/41060382/using-pip-to-install-packages-to-anaconda-environment):
>1. If you have a non-conda pip as your default pip but conda python as your default python (as below):
>
>```shell
>>which -a pip
>/home/<user>/.local/bin/pip
>/home/<user>/.conda/envs/newenv/bin/pip
>/usr/bin/pip
>
>>which -a python
>/home/<user>/.conda/envs/newenv/bin/python
>/usr/bin/python
>```
>
>2. Then, instead of calling `pip install <package>` directly, you can use the module flag -m in python so that it installs with the anaconda python
>
>```shell
>python -m pip install <package>
>```
>
>3. This will install the package to the anaconda library directory rather than the library directory associated with the (non-anaconda) pip
>4. The reason for doing this is as follows: the pip command references a specific pip file/shortcut (which -a pip will tell you which one). Similarly, the python command references a specific python file (which -a python will tell you which one). For one reason or another, these two commands can become out of sync, so your "default" pip is in a different folder than your default python and therefore is associated with different versions of python.
>5. In contrast, the python -m pip construct does not use the shortcut that the pip command points to. Instead, it asks python to find its pip version and use that version to install a package.

View File

@ -1,125 +0,0 @@
## 在 Anaconda 中使用 pip 安装包无效问题
## 问题
最近在跑开源代码的时候遇到的问题:使用 conda 创建虚拟环境并切换到新的虚拟环境后,再使用 pip 来安装包会“无效”。这里的“无效”指的是使用 pip 安装的包不在这个新的环境中。
------
## 分析
1、首先创建一个测试环境 test`conda create -n test`
2、激活该测试环境`conda activate test`
3、使用 pip 安装 numpy`pip install numpy`,会发现 numpy 已经存在默认的环境中
```powershell
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: numpy in c:\programdata\anaconda3\lib\site-packages (1.20.3)
```
4、这时候看一下 pip 的信息,`pip show pip`
```powershell
Name: pip
Version: 21.2.4
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig@python.org
License: MIT
Location: c:\programdata\anaconda3\lib\site-packages
Requires:
Required-by:
```
5、可以发现当前 pip 是在默认的 conda 环境中。这也就解释了当我们直接使用 pip 安装包时为什么包不在这个新的虚拟环境中,因为使用的 pip 属于默认环境,安装的包要么已经存在,要么直接装到默认环境中去了。
------
## 解决
1、我们可以直接使用 conda 命令安装新的包,但有些时候 conda 可能没有某些包/库,所以还是得用 pip 安装
2、我们可以先使用 conda 命令为当前虚拟环境安装 pip 包,再使用 pip 安装新的包
```powershell
# 使用 conda 安装 pip 包
(test) PS C:\Users\Administrator> conda install pip
Collecting package metadata (current_repodata.json): done
Solving environment: done
....
done
# 显示当前 pip 的信息,发现 pip 在测试环境 test 中
(test) PS C:\Users\Administrator> pip show pip
Name: pip
Version: 21.2.4
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: distutils-sig@python.org
License: MIT
Location: c:\programdata\anaconda3\envs\test\lib\site-packages
Requires:
Required-by:
# 再使用 pip 安装 numpy 包,成功安装
(test) PS C:\Users\Administrator> pip install numpy
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numpy
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4b/23/140ec5a509d992fe39db17200e96c00fd29603c1531ce633ef93dbad5e9e/numpy-1.22.2-cp39-cp39-win_amd64.whl (14.7 MB)
Installing collected packages: numpy
Successfully installed numpy-1.22.2
# 使用 pip list 查看当前安装的包,没有问题
(test) PS C:\Users\Administrator> pip list
Package Version
------------ ---------
certifi 2021.10.8
numpy 1.22.2
pip 21.2.4
setuptools 58.0.4
wheel 0.37.1
wincertstore 0.2
```
------
## 补充
1、之前没有发现这个问题可能时因为在虚拟环境中安装的包是指定版本的覆盖了默认环境中的包。其实主要还是观察不仔细不然可以发现 `Successfully uninstalled numpy-xxx`【默认版本】 以及 `Successfully installed numpy-1.20.3`【指定版本】
2、测试时发现如果在新建包的时候指定了 python 版本的话应该是没有这个问题的,猜测时因为会在虚拟环境中安装好 pip ,而我们这里包括 pip 在内啥包也没有装,所以使用的是默认环境的 pip
3、有个问题之前我在创建新的虚拟环境时应该指定了 python 版本,但还是使用的默认环境的 pip 包,但是刚在在两台机器上都没有复现成功,于是有了上面的第 2 点
4、出现了第 3 点的问题后,我当时是使用 `python -m pip install package-name` 解决的,在 pip 前面加上了 python -m。至于为什么可以参考 [StackOverflow](https://stackoverflow.com/questions/41060382/using-pip-to-install-packages-to-anaconda-environment) 上的回答:
> 1、如果你有一个非 conda 的 pip 作为你的默认 pip但是 conda 的 python 是你的默认 python如下
>
> ```shell
> >which -a pip
> /home/<user>/.local/bin/pip
> /home/<user>/.conda/envs/newenv/bin/pip
> /usr/bin/pip
>
> >which -a python
> /home/<user>/.conda/envs/newenv/bin/python
> /usr/bin/python
> ```
>
> 2、然后而不是直接调用 `pip install <package>`,你可以在 python 中使用模块标志 -m以便它使用 anaconda python 进行安装
>
> ```shell
>python -m pip install <package>
> ```
>
> 3、这将把包安装到 anaconda 库目录而不是与非anaconda pip 关联的库目录
>
> 4、这样做的原因如下命令 pip 引用了一个特定的 pip 文件 / 快捷方式which -a pip 会告诉你是哪一个)。类似地,命令 python 引用一个特定的 python 文件which -a python 会告诉你是哪个)。由于这样或那样的原因,这两个命令可能变得不同步,因此你的“默认” pip 与你的默认 python 位于不同的文件夹中,因此与不同版本的 python 相关联。
>
> 5、与此相反python -m pip 构造不使用 pip 命令指向的快捷方式。相反,它要求 python 找到它的pip 版本,并使用该版本安装一个包。
-

View File

@ -0,0 +1,84 @@
## 指定制定列的csv文件加载器
from langchain.document_loaders import CSVLoader
import csv
from io import TextIOWrapper
from typing import Dict, List, Optional
from langchain.docstore.document import Document
from langchain.document_loaders.helpers import detect_file_encodings
class FilteredCSVLoader(CSVLoader):
def __init__(
self,
file_path: str,
columns_to_read: List[str],
source_column: Optional[str] = None,
metadata_columns: List[str] = [],
csv_args: Optional[Dict] = None,
encoding: Optional[str] = None,
autodetect_encoding: bool = False,
):
super().__init__(
file_path=file_path,
source_column=source_column,
metadata_columns=metadata_columns,
csv_args=csv_args,
encoding=encoding,
autodetect_encoding=autodetect_encoding,
)
self.columns_to_read = columns_to_read
def load(self) -> List[Document]:
"""Load data into document objects."""
docs = []
try:
with open(self.file_path, newline="", encoding=self.encoding) as csvfile:
docs = self.__read_file(csvfile)
except UnicodeDecodeError as e:
if self.autodetect_encoding:
detected_encodings = detect_file_encodings(self.file_path)
for encoding in detected_encodings:
try:
with open(
self.file_path, newline="", encoding=encoding.encoding
) as csvfile:
docs = self.__read_file(csvfile)
break
except UnicodeDecodeError:
continue
else:
raise RuntimeError(f"Error loading {self.file_path}") from e
except Exception as e:
raise RuntimeError(f"Error loading {self.file_path}") from e
return docs
def __read_file(self, csvfile: TextIOWrapper) -> List[Document]:
docs = []
csv_reader = csv.DictReader(csvfile, **self.csv_args) # type: ignore
for i, row in enumerate(csv_reader):
content = []
for col in self.columns_to_read:
if col in row:
content.append(f'{col}:{str(row[col])}')
else:
raise ValueError(f"Column '{self.columns_to_read[0]}' not found in CSV file.")
content = '\n'.join(content)
# Extract the source if available
source = (
row.get(self.source_column, None)
if self.source_column is not None
else self.file_path
)
metadata = {"source": source, "row": i}
for col in self.metadata_columns:
if col in row:
metadata[col] = row[col]
doc = Document(page_content=content, metadata=metadata)
docs.append(doc)
return docs

View File

@ -0,0 +1,4 @@
from .mypdfloader import RapidOCRPDFLoader
from .myimgloader import RapidOCRLoader
from .mydocloader import RapidOCRDocLoader
from .mypptloader import RapidOCRPPTLoader

View File

@ -0,0 +1,71 @@
from langchain.document_loaders.unstructured import UnstructuredFileLoader
from typing import List
import tqdm
class RapidOCRDocLoader(UnstructuredFileLoader):
def _get_elements(self) -> List:
def doc2text(filepath):
from docx.table import _Cell, Table
from docx.oxml.table import CT_Tbl
from docx.oxml.text.paragraph import CT_P
from docx.text.paragraph import Paragraph
from docx import Document, ImagePart
from PIL import Image
from io import BytesIO
import numpy as np
from rapidocr_onnxruntime import RapidOCR
ocr = RapidOCR()
doc = Document(filepath)
resp = ""
def iter_block_items(parent):
from docx.document import Document
if isinstance(parent, Document):
parent_elm = parent.element.body
elif isinstance(parent, _Cell):
parent_elm = parent._tc
else:
raise ValueError("RapidOCRDocLoader parse fail")
for child in parent_elm.iterchildren():
if isinstance(child, CT_P):
yield Paragraph(child, parent)
elif isinstance(child, CT_Tbl):
yield Table(child, parent)
b_unit = tqdm.tqdm(total=len(doc.paragraphs)+len(doc.tables),
desc="RapidOCRDocLoader block index: 0")
for i, block in enumerate(iter_block_items(doc)):
b_unit.set_description(
"RapidOCRDocLoader block index: {}".format(i))
b_unit.refresh()
if isinstance(block, Paragraph):
resp += block.text.strip() + "\n"
images = block._element.xpath('.//pic:pic') # 获取所有图片
for image in images:
for img_id in image.xpath('.//a:blip/@r:embed'): # 获取图片id
part = doc.part.related_parts[img_id] # 根据图片id获取对应的图片
if isinstance(part, ImagePart):
image = Image.open(BytesIO(part._blob))
result, _ = ocr(np.array(image))
if result:
ocr_result = [line[1] for line in result]
resp += "\n".join(ocr_result)
elif isinstance(block, Table):
for row in block.rows:
for cell in row.cells:
for paragraph in cell.paragraphs:
resp += paragraph.text.strip() + "\n"
b_unit.update(1)
return resp
text = doc2text(self.file_path)
from unstructured.partition.text import partition_text
return partition_text(text=text, **self.unstructured_kwargs)
if __name__ == '__main__':
loader = RapidOCRDocLoader(file_path="../tests/samples/ocr_test.docx")
docs = loader.load()
print(docs)

View File

@ -0,0 +1,25 @@
from typing import List
from langchain.document_loaders.unstructured import UnstructuredFileLoader
from document_loaders.ocr import get_ocr
class RapidOCRLoader(UnstructuredFileLoader):
def _get_elements(self) -> List:
def img2text(filepath):
resp = ""
ocr = get_ocr()
result, _ = ocr(filepath)
if result:
ocr_result = [line[1] for line in result]
resp += "\n".join(ocr_result)
return resp
text = img2text(self.file_path)
from unstructured.partition.text import partition_text
return partition_text(text=text, **self.unstructured_kwargs)
if __name__ == "__main__":
loader = RapidOCRLoader(file_path="../tests/samples/ocr_test.jpg")
docs = loader.load()
print(docs)

View File

@ -0,0 +1,87 @@
from typing import List
from langchain.document_loaders.unstructured import UnstructuredFileLoader
import cv2
from PIL import Image
import numpy as np
from configs import PDF_OCR_THRESHOLD
from document_loaders.ocr import get_ocr
import tqdm
class RapidOCRPDFLoader(UnstructuredFileLoader):
def _get_elements(self) -> List:
def rotate_img(img, angle):
'''
img --image
angle --rotation angle
return--rotated img
'''
h, w = img.shape[:2]
rotate_center = (w/2, h/2)
#获取旋转矩阵
# 参数1为旋转中心点;
# 参数2为旋转角度,正值-逆时针旋转;负值-顺时针旋转
# 参数3为各向同性的比例因子,1.0原图2.0变成原来的2倍0.5变成原来的0.5倍
M = cv2.getRotationMatrix2D(rotate_center, angle, 1.0)
#计算图像新边界
new_w = int(h * np.abs(M[0, 1]) + w * np.abs(M[0, 0]))
new_h = int(h * np.abs(M[0, 0]) + w * np.abs(M[0, 1]))
#调整旋转矩阵以考虑平移
M[0, 2] += (new_w - w) / 2
M[1, 2] += (new_h - h) / 2
rotated_img = cv2.warpAffine(img, M, (new_w, new_h))
return rotated_img
def pdf2text(filepath):
import fitz # pyMuPDF里面的fitz包不要与pip install fitz混淆
import numpy as np
ocr = get_ocr()
doc = fitz.open(filepath)
resp = ""
b_unit = tqdm.tqdm(total=doc.page_count, desc="RapidOCRPDFLoader context page index: 0")
for i, page in enumerate(doc):
b_unit.set_description("RapidOCRPDFLoader context page index: {}".format(i))
b_unit.refresh()
text = page.get_text("")
resp += text + "\n"
img_list = page.get_image_info(xrefs=True)
for img in img_list:
if xref := img.get("xref"):
bbox = img["bbox"]
# 检查图片尺寸是否超过设定的阈值
if ((bbox[2] - bbox[0]) / (page.rect.width) < PDF_OCR_THRESHOLD[0]
or (bbox[3] - bbox[1]) / (page.rect.height) < PDF_OCR_THRESHOLD[1]):
continue
pix = fitz.Pixmap(doc, xref)
samples = pix.samples
if int(page.rotation)!=0: #如果Page有旋转角度则旋转图片
img_array = np.frombuffer(pix.samples, dtype=np.uint8).reshape(pix.height, pix.width, -1)
tmp_img = Image.fromarray(img_array);
ori_img = cv2.cvtColor(np.array(tmp_img),cv2.COLOR_RGB2BGR)
rot_img = rotate_img(img=ori_img, angle=360-page.rotation)
img_array = cv2.cvtColor(rot_img, cv2.COLOR_RGB2BGR)
else:
img_array = np.frombuffer(pix.samples, dtype=np.uint8).reshape(pix.height, pix.width, -1)
result, _ = ocr(img_array)
if result:
ocr_result = [line[1] for line in result]
resp += "\n".join(ocr_result)
# 更新进度
b_unit.update(1)
return resp
text = pdf2text(self.file_path)
from unstructured.partition.text import partition_text
return partition_text(text=text, **self.unstructured_kwargs)
if __name__ == "__main__":
loader = RapidOCRPDFLoader(file_path="/Users/tonysong/Desktop/test.pdf")
docs = loader.load()
print(docs)

View File

@ -0,0 +1,59 @@
from langchain.document_loaders.unstructured import UnstructuredFileLoader
from typing import List
import tqdm
class RapidOCRPPTLoader(UnstructuredFileLoader):
def _get_elements(self) -> List:
def ppt2text(filepath):
from pptx import Presentation
from PIL import Image
import numpy as np
from io import BytesIO
from rapidocr_onnxruntime import RapidOCR
ocr = RapidOCR()
prs = Presentation(filepath)
resp = ""
def extract_text(shape):
nonlocal resp
if shape.has_text_frame:
resp += shape.text.strip() + "\n"
if shape.has_table:
for row in shape.table.rows:
for cell in row.cells:
for paragraph in cell.text_frame.paragraphs:
resp += paragraph.text.strip() + "\n"
if shape.shape_type == 13: # 13 表示图片
image = Image.open(BytesIO(shape.image.blob))
result, _ = ocr(np.array(image))
if result:
ocr_result = [line[1] for line in result]
resp += "\n".join(ocr_result)
elif shape.shape_type == 6: # 6 表示组合
for child_shape in shape.shapes:
extract_text(child_shape)
b_unit = tqdm.tqdm(total=len(prs.slides),
desc="RapidOCRPPTLoader slide index: 1")
# 遍历所有幻灯片
for slide_number, slide in enumerate(prs.slides, start=1):
b_unit.set_description(
"RapidOCRPPTLoader slide index: {}".format(slide_number))
b_unit.refresh()
sorted_shapes = sorted(slide.shapes,
key=lambda x: (x.top, x.left)) # 从上到下、从左到右遍历
for shape in sorted_shapes:
extract_text(shape)
b_unit.update(1)
return resp
text = ppt2text(self.file_path)
from unstructured.partition.text import partition_text
return partition_text(text=text, **self.unstructured_kwargs)
if __name__ == '__main__':
loader = RapidOCRPPTLoader(file_path="../tests/samples/ocr_test.pptx")
docs = loader.load()
print(docs)

18
document_loaders/ocr.py Normal file
View File

@ -0,0 +1,18 @@
from typing import TYPE_CHECKING
if TYPE_CHECKING:
try:
from rapidocr_paddle import RapidOCR
except ImportError:
from rapidocr_onnxruntime import RapidOCR
def get_ocr(use_cuda: bool = True) -> "RapidOCR":
try:
from rapidocr_paddle import RapidOCR
ocr = RapidOCR(det_use_cuda=use_cuda, cls_use_cuda=use_cuda, rec_use_cuda=use_cuda)
except ImportError:
from rapidocr_onnxruntime import RapidOCR
ocr = RapidOCR()
return ocr

0
embeddings/__init__.py Normal file
View File

View File

@ -0,0 +1,79 @@
'''
该功能是为了将关键词加入到embedding模型中以便于在embedding模型中进行关键词的embedding
该功能的实现是通过修改embedding模型的tokenizer来实现的
该功能仅仅对EMBEDDING_MODEL参数对应的的模型有效输出后的模型保存在原本模型
感谢@CharlesJu1和@charlesyju的贡献提出了想法和最基础的PR
保存的模型的位置位于原本嵌入模型的目录下模型的名称为原模型名称+Merge_Keywords_时间戳
'''
import sys
sys.path.append("..")
import os
import torch
from datetime import datetime
from configs import (
MODEL_PATH,
EMBEDDING_MODEL,
EMBEDDING_KEYWORD_FILE,
)
from safetensors.torch import save_model
from sentence_transformers import SentenceTransformer
from langchain_core._api import deprecated
@deprecated(
since="0.3.0",
message="自定义关键词 Langchain-Chatchat 0.3.x 重写, 0.2.x中相关功能将废弃",
removal="0.3.0"
)
def get_keyword_embedding(bert_model, tokenizer, key_words):
tokenizer_output = tokenizer(key_words, return_tensors="pt", padding=True, truncation=True)
input_ids = tokenizer_output['input_ids']
input_ids = input_ids[:, 1:-1]
keyword_embedding = bert_model.embeddings.word_embeddings(input_ids)
keyword_embedding = torch.mean(keyword_embedding, 1)
return keyword_embedding
def add_keyword_to_model(model_name=EMBEDDING_MODEL, keyword_file: str = "", output_model_path: str = None):
key_words = []
with open(keyword_file, "r") as f:
for line in f:
key_words.append(line.strip())
st_model = SentenceTransformer(model_name)
key_words_len = len(key_words)
word_embedding_model = st_model._first_module()
bert_model = word_embedding_model.auto_model
tokenizer = word_embedding_model.tokenizer
key_words_embedding = get_keyword_embedding(bert_model, tokenizer, key_words)
embedding_weight = bert_model.embeddings.word_embeddings.weight
embedding_weight_len = len(embedding_weight)
tokenizer.add_tokens(key_words)
bert_model.resize_token_embeddings(len(tokenizer), pad_to_multiple_of=32)
embedding_weight = bert_model.embeddings.word_embeddings.weight
with torch.no_grad():
embedding_weight[embedding_weight_len:embedding_weight_len + key_words_len, :] = key_words_embedding
if output_model_path:
os.makedirs(output_model_path, exist_ok=True)
word_embedding_model.save(output_model_path)
safetensors_file = os.path.join(output_model_path, "model.safetensors")
metadata = {'format': 'pt'}
save_model(bert_model, safetensors_file, metadata)
print("save model to {}".format(output_model_path))
def add_keyword_to_embedding_model(path: str = EMBEDDING_KEYWORD_FILE):
keyword_file = os.path.join(path)
model_name = MODEL_PATH["embed_model"][EMBEDDING_MODEL]
model_parent_directory = os.path.dirname(model_name)
current_time = datetime.now().strftime('%Y%m%d_%H%M%S')
output_model_name = "{}_Merge_Keywords_{}".format(EMBEDDING_MODEL, current_time)
output_model_path = os.path.join(model_parent_directory, output_model_name)
add_keyword_to_model(model_name, keyword_file, output_model_path)

View File

@ -0,0 +1,3 @@
Langchain-Chatchat
数据科学与大数据技术
人工智能与先进计算

BIN
img/LLM_success.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

BIN
img/agent_continue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

BIN
img/agent_success.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
img/chatchat-qrcode.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
img/docker_logs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
img/fastapi_docs_026.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
img/init_knowledge_base.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
img/langchain+chatglm2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
img/official_account_qr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

9
img/partners/autodl.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 123 KiB

9
img/partners/aws.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 42 KiB

55
img/partners/chatglm.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -0,0 +1,9 @@
<svg width="654" height="213" viewBox="0 0 654 213" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect x="654" width="213" height="654" transform="rotate(90 654 0)" fill="url(#pattern0)"/>
<defs>
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
<use xlink:href="#image0_237_57" transform="matrix(0.0204695 0 0 0.00666667 -0.00150228 0)"/>
</pattern>
<image id="image0_237_57" width="49" height="150" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADEAAACWCAYAAAB3hWBKAAAMyElEQVR4Ae1de5AcRRk/AR88C2MgIdzdfB0jIioFIoggGkoeCbnt3lAVtUALygdCUSWI0X8M3LcHiUHkEQoIuem7aKR4pCJSFFqQ6cvyCMnMXngVBORhBaG0ohaiIgqCrPX1bO/OzM7uzcztZAO1VzU1szPf1/39+uvn933d19fX+9vNSgAFuwo53J/rVYDzcoWNAtaiYNVcLw5X5guCA+YKgAoodxAFODdXEByeKhVA5KyJ/nlI2mh1CfZaAOSzLeka/GMB+uqIGDgpVwBTJX7VabP2DQqEAlZNxUPfUcCWOh9nz685pu/9SfhyoRnh1tF1YQSrljhckCSjUsFaGORDbn0zCV8uNCVuLQoLw3iSjLCvbw/k7I0GL9yehC8XmpKArzYEYdWSsBYnzQgFbG/wwmNJ+TpOh8I6qyGI7ipXJMkEl/R9ADm8XuflbHMSvlxoRoasz9cFaQyIG1CwpSXOTsUizG+6CoNDyOGuEB+H1bkImCRRnN+3Fwp4NSRQA0ziUb40NPjlJPnlRlPi7IfTAsHZxtyES5qw7mkEjGcCwmErnt4/I2leudONFAePGebwIxRsHQoot5/1snuwAMVqX9/7chesl0GvBHolkK0E/JEbHsvUQ+mJI7s0W84d4kLBrsgqvOEr8S6CuJLP3D88G822Fu8qCBSDp5jSnM69uyA4403CF+C8pklf3EQw8O6KM5jVodqdPpkR0f/pCAgvfSpd5qBZ7LBgf68D4ewPXRYpW/YoGK0fGtPuxXMPy5ZSF7lKnH0nBEKw5V0UJ1vWP1k0+GEU7M06EM52rl/St2e21LrERdNp5DBRB6HNkmyy/VQ8YqAuwLldEt/PFgV7KQQg2D6SPnPA7oLg7K0eCF39uqwJmjIkMCK3NkiTobkI87tanXqZ90qggyWAwjoh7ay1iZ73z+ugSOmTQs52TruLFdb16XPuIEcPRH1Ef7drgrNfYhGO6mDlyD8p5OzqYBvK3f2bB6QrxJyBIAgU8Os88sk9TW01r7cH9iaZfnLPtNMZlDhcFNRGiVtndzqP3NPDAhwfBIEcbss9005ngBzOD4EQsL3TeaRKjxpmqqVoyH9dt5K8nCrTThOjYH8Ol2pdsIYZp9GI499x9lCn5UqVXidAkNknVaadJp4WCA7vIGc3dN3EQ9EDWZanJW79AAtweKcLtZfebl8COhClEf6GyNkXd3uhowKWBHw/1I1ytixKQ79rJs1ADC27IY6uK+90Iwz09a3cU9TLhMAK2NIVgeMy7YGIK5VuvOtpohulHpdnTxNxpdKNd+8NTTQNdjDWZE8twvwSt04OjRMcnoqja3q3aHBu7sqJaiIkaGAQzPw+7/0TVEI9EEk01dNEwtaECw/tb2qMgVCfaX/bFQ07IdYeWa8EeiVQKwHPkWd5jv2Yp2Q1y+UqO1VcrA5jHbI+E1XANUv6976cs49H30/521P28iyCB3nSgKDdAcjhGdrysGLxoR8pcRg2/g3kek/g2JRCBwk2bx7b33PsN4ICZXlOCuL6hfM+iII9iQXrKvKfLz/TOgQ53IHcGiH3gJ67cUgHYlKNn5JF6ChPUhBITkoBt+s9S4IVDIgVC2cfhILdqCPg0oJwHVtEBfIc+1bPsTHNVdk0/qWghuOekVujyOFvtXC9paUACEM/wgdPxNQglH1kGIT9rEmwk3cSGDn7J1UhSrdm/73N98TC9rotWMAqFDCeKu9yubyXq+zX6kAcO5e42BJnS5DD76khN4GgNYuxTgrr+tQgKEHPkffUQShZdTeu/ViqkkhAjEsO2g85PIoCtmFhzj6hNiEaWz5x8dzDUlcnDULJc4IgqMtNIFdqkuWczdJBkxzWxIEg+zAKeDgTCNe95QBX2W8ZIK6yd1aruEdqKRMw4BA7DnXgpLW83sVSb0VB9gJeoB1jmUBQ3p6S6w0IuruOPZ6md5p07MQxgCVh/RiFv+EW+cAc3eUW4Sg9htBgl7ZhEwDXketcZf87CCL1s2MnjovVRmsOjw4PDX4hqjzaeJgpViRYlVILb+ZaKUBEBe/I7/cKCMdz7Punc1UmxrobK94RdfYS6ZVAcwnQIDfpyKOp349envqFnvc0c+0mb6rr1+/pKftbniNfatXNViZkwYi7rbzmcG9ibNhVtuMq2f0dYdu2rdnHVbLcSvjG+9EhA0Kvyc0YoWS1smn0k+ZbqztNAmk2G/yOHH5LE0K9VY4miNMY7G5oCNraUBDUxBP3rTs4yOM6csoTVPAMmE1L0RAIAb/Rs1oOm0pF9o1Ma+xtD645xHXk2xGB3nYd6dbGjf+Zb0EQJIir5IvmmzchrwkKF33WEz86/4azv4QCxAS8ghyuq81uz/dBMBnlb/vbVfapdUH0xE8+75btfsMUnFNNbhoLHRHjOnKz4XWVbBsDSNUEuXUmctiEgt2NBbgYOdw6zFkFOXvePxsHVmbShKdk0QhC94qyv24A0N1z5L8a3xttwv9m32u+UQMP8sU96+qkjQRwszZgC1iJAu7V6wwdGNkpEBtHQ+HSSUFQ1YsTPPiuFQgU7EF/1ad3mXmp1xNRTXhKnhPM2HPs101pR9uE58hJ88117LuCfHHPbUAsR84kcrYZs6yxPWWfZAShu+vYz2wv37ifEaKVJlw1dnKIT9lTHm7VGoR1gh9nW6tOaRdFNQtgvQfygcintWmTbE/K/m9dWLJHKblS91pKvlN/T+DV2MkGeNy91uv8DMmyQcYCDj/3Sx5eoLN0/P2vGdsEZegp+86gQBmeH48TPPguBMKYZ/SdPYcF9hXk8B9/fU222JRdLGXkKnuWp+xnMwhfpTaTZLSmfHR14mx9GJw/YlNb8Pf7ZVxjayDa4iE3pAHiKrmjokaPDQrV7lkfbCUGjwjSoICV2kCweNbByNktmU37wUQrE6MnuI5c6jpylPr+6GqP5lgVx76WeiqyHgZ5e8+9EnivlQD1MtHVXOLfajz/KJt2BV4pr53tKntjmp6pmdb+abs8cv/mOfbWZqFaL47iabsIgqpQvFC7BoQ+wm+6Gw1p/bCrQGARDtQW8YUzDjDVCzl8DTmbJDcwXSjgMhrZzfdE94oaOzsKgpyRiZhTEmERgLyjwwKepg2HtZDuJ5Gzh5DDtTWX1x30nCrpaHUiB0uqBFIQ+yDgduSwAgXs8H3X7GrtFi4CUFKXFwc+Smc+p0i2r69mb/qr0QZZyLdsWb93qkQSEl9esBg5VIgcOawmrdQOyaINuNlBUIKekmMGRO1eTChXYrIRAZ/THiEOt2FhzkwdFsFhgg7ZpcMTzflQmTRBUjQ55B05mVi6hIR+xABc45/WAjv02qEIByJnzyGHX+lzaykSjo5+TeuMJxl2lNd+yHXkK0Ft0Gw2oXypyHDhjAP0sZXcuoQYa435d/6GXCjTnY62bErUc6QKCpjPc7LBjsyVly6YfSyFP5SEdSEumjWXutkmoaMvPEfelI/gwQGxPQhtPKPqQtE0ZLqkSBs6Pj8mmDI23slV8qJug9ANm8P9NEaEo6Dh1ZBZk2jiqlNFyQXdBmFqhx6hBazS1g2KuqGD2Ws9lqGJvZMdKfGUOsa5kog34VTcN+EPfNYISoez0wZ16mp7Z8+aUundd0UJuI59fDDgpOLYF0wnkmZbec3MYHrk58gdh+vYF0d7KPIGPVKWmU4D2urYnwin136c6AjAOBAkhO8JGrskrVZ2KxCmNEkrW8tr9XQ4SantliA0GDIOK/t71Wp1yrPCOw0CFw3OHSlA+7DUmOr0qNFC891+cCqtaGd8wI/tqanbBA1qtDCK07Q+fJezZTRvarlXPDp/Ik8oRSe7jvxjMwhZJQ+Rq+wLW2kliyboQAZcNPApWi8gHdAQ2aukTfv6ZHl2ZBxQ8jmHJoHGnas9Rc0ru3rkPrl5Kw+MD0QTnSaIZ7RVQx99DDf7R73qY5BfjjrrQ/lGq1PUotFOK7Xg3+8GE8wGAm5Czo6subkuQw4LdOg1nVdLz4K9aIJ/g3nVn6cCQYSkFfJLxFYv3R3LstFKJhCC3ehPAMlLCpdhgZ1mQJQEnN5qt34qEIaYZq0to20c+Q9vQn67uWHLtv/2KvQPbDg80hEQUZ+0AWDuNa/q6lZa8ZSM9m5tQVC6tLXAaEI3Yq0JHa28gbRCFkCTf+w9SXWKY2yrlZRdLPKp2gT8qa0JMysIAvbEfev2dZVN4UQh33VYS1OPE4Eu9nHqZmv7Ye9Gzh7wn+FhFHBnXGHqd9MBYRKd3CRPJI9pWHhjLEgAol6dAv8aKDhWcLZMN/QhdpzJM3TvBAhKkEycrrJXNWslAQgKD2qxvdPvbtkyvculZtIMAcjjh6vGjwitvROusVvJQiYdY8psRfOuff9/T15+hUcbNtcAAAAASUVORK5CYII="/>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
img/qr_code_100.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

BIN
img/qr_code_101.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

BIN
img/qr_code_102.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

BIN
img/qr_code_103.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

BIN
img/qr_code_104.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

BIN
img/qr_code_105.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

BIN
img/qr_code_106.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

BIN
img/qr_code_106_2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

BIN
img/qr_code_107.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

BIN
img/qr_code_108.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 274 KiB

BIN
img/qr_code_90.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

BIN
img/qr_code_90.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

BIN
img/qr_code_91.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

BIN
img/qr_code_92.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

BIN
img/qr_code_93.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

BIN
img/qr_code_94.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 KiB

BIN
img/qr_code_95.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

BIN
img/qr_code_96.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

BIN
img/qr_code_97.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

BIN
img/qr_code_98.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

BIN
img/qr_code_99.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

BIN
img/qrcode_90_2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 900 KiB

120
init_database.py Normal file
View File

@ -0,0 +1,120 @@
import sys
sys.path.append(".")
from server.knowledge_base.migrate import (create_tables, reset_tables, import_from_db,
folder2db, prune_db_docs, prune_folder_files)
from configs.model_config import NLTK_DATA_PATH, EMBEDDING_MODEL
import nltk
nltk.data.path = [NLTK_DATA_PATH] + nltk.data.path
from datetime import datetime
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(
"--create-tables",
action="store_true",
help=("create empty tables if not existed")
)
parser.add_argument(
"--clear-tables",
action="store_true",
help=("create empty tables, or drop the database tables before recreate vector stores")
)
parser.add_argument(
"--import-db",
help="import tables from specified sqlite database"
)
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",
"--increment",
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 incrementally.
'''
)
)
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(
"-n",
"--kb-name",
type=str,
nargs="+",
default=[],
help=("specify knowledge base names to operate on. default is all folders exist in KB_ROOT_PATH.")
)
parser.add_argument(
"-e",
"--embed-model",
type=str,
default=EMBEDDING_MODEL,
help=("specify embeddings model.")
)
args = parser.parse_args()
start_time = datetime.now()
if args.create_tables:
create_tables() # confirm tables exist
if args.clear_tables:
reset_tables()
print("database tables reset")
if args.recreate_vs:
create_tables()
print("recreating all vector stores")
folder2db(kb_names=args.kb_name, mode="recreate_vs", embed_model=args.embed_model)
elif args.import_db:
import_from_db(args.import_db)
elif args.update_in_db:
folder2db(kb_names=args.kb_name, mode="update_in_db", embed_model=args.embed_model)
elif args.increment:
folder2db(kb_names=args.kb_name, mode="increment", embed_model=args.embed_model)
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}")

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Some files were not shown because too many files have changed in this diff Show More