比较提交

..

236 次代码提交

作者 SHA1 备注 提交日期
binary-husky
62d14cfa3f Merge pull request #695 from Undertone0809/master
fix: resolve keyerror 'serialized_input' for mac/windows platform
2023-05-06 22:29:39 +08:00
binary-husky
bd6ec158d4 Merge branch 'master' into master 2023-05-06 22:29:28 +08:00
binary-husky
d2f04e2dd2 Update requirements.txt 2023-05-06 22:28:37 +08:00
binary-husky
b47054c479 Update requirements.txt 2023-05-06 22:18:23 +08:00
Zeeland
15c40bdaff fix: resolve keyerror 'serialized_input' for windows platform 2023-05-06 17:05:24 +08:00
binary-husky
44a71fdbf1 Update README.md 2023-05-06 10:32:36 +08:00
binary-husky
996a0486af Update README.md 2023-05-06 10:30:27 +08:00
binary-husky
a15eb56ee8 Update README.md 2023-05-05 18:22:52 +08:00
binary-husky
daef87da41 Update README.md 2023-05-05 18:19:42 +08:00
binary-husky
0b4d68fbee Update README.md 2023-05-05 18:17:52 +08:00
binary-husky
9f3d67e7bd Update docker-compose.yml 2023-05-05 17:59:14 +08:00
binary-husky
47866ebe0e Update docker-compose.yml 2023-05-05 17:58:41 +08:00
binary-husky
48a352bfd1 Update version 2023-05-05 17:53:08 +08:00
binary-husky
01ce265d77 Update version 2023-05-05 17:52:10 +08:00
binary-husky
478f3a737c 修改rwkv的reset接口 2023-05-05 17:12:02 +08:00
binary-husky
b49ea55e24 Update README.md 2023-05-05 15:25:55 +08:00
binary-husky
7608c6c7ab Update README.md 2023-05-05 04:43:14 +08:00
binary-husky
ba6d91c5cc Update README.md 2023-05-05 04:42:42 +08:00
binary-husky
5de85153ba Update README.md 2023-05-05 04:35:15 +08:00
binary-husky
59a4bca053 加入LLAMA + 盘古 + RWKV本地模型 2023-05-05 04:31:31 +08:00
binary-husky
1034769c78 Update README.md 2023-05-05 00:34:20 +08:00
binary-husky
947f50b516 Update README.md 2023-05-05 00:32:49 +08:00
binary-husky
1434a28fa8 avoid dummy 2023-05-05 00:29:51 +08:00
binary-husky
78757411ca upload docker compose 2023-05-05 00:26:03 +08:00
binary-husky
9b8e7e933b Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-05-04 23:29:25 +08:00
binary-husky
6da3289830 改进环境变量的读取 2023-05-04 23:29:19 +08:00
binary-husky
f6da72c9eb Merge pull request #678 from gwj12345/master
补充了"不能正常加载ChatGLM的参数"的解决方法
2023-05-04 22:59:31 +08:00
gwj1139
c17882af8a 补充了"不能正常加载ChatGLM的参数"的解决方法
补充了"不能正常加载ChatGLM的参数"的解决方法
2023-05-04 14:08:40 +08:00
binary-husky
9f7cf7c4d8 Merge pull request #677 from binary-husky/add-waifu
add waifu option
2023-05-04 02:39:44 +08:00
binary-husky
97de15dfbe add waifu 2023-05-04 02:34:17 +08:00
binary-husky
93801ff772 Merge pull request #674 from LiZheGuang/master
feat:把原有的解析react替换成解析整个前端
2023-05-04 01:37:14 +08:00
binary-husky
13f99fcab0 修改提示 2023-05-04 01:36:09 +08:00
binary-husky
30d16989b7 Merge pull request #662 from sperjar/master
自动编译Docker镜像并上传到ghcr
2023-05-04 01:32:52 +08:00
binary-husky
1a796a5ade Merge branch 'master' into sperjar-master 2023-05-04 01:32:20 +08:00
binary-husky
b7d3ed7135 rm docker image yml 2023-05-04 01:30:24 +08:00
LiZheGuang
5a1bbb3874 feat: 🎸 修改解析react文件 2023-05-03 01:41:31 +08:00
ZheGuangLi
3d3e54f0d1 Merge branch 'binary-husky:master' into master 2023-05-03 01:40:08 +08:00
LiZheGuang
bf75b29314 feat: 🎸 替换react 解析所有常见的前端项目 包含VUE 2023-05-03 01:38:40 +08:00
binary-husky
79cd98fc24 Merge pull request #672 from Keldos-Li/fixHTML
fix: specify encoding when saving HTML
2023-05-02 23:46:16 +08:00
Keldos
4b4836099d fix: specify encoding when saving HTML
Solve the possible issue of displaying garbled codes in macOS
2023-05-02 21:49:57 +08:00
binary-husky
b25d3e274a Update README.md 2023-05-02 18:18:34 +08:00
binary-husky
a96bf9af2f Update README.md 2023-05-02 17:33:59 +08:00
binary-husky
a69ef7f8c5 env read failure reminder 2023-05-02 15:33:07 +08:00
Your Name
896077009a 增加通用性 2023-05-02 14:54:51 +08:00
Your Name
988c5c24da Merge branch 'master' of https://github.com/sperjar/gpt_academic into sperjar-master 2023-05-02 14:26:46 +08:00
ReeInk
8865b232ca 修复:读取环境变量重定向URL格式 2023-05-02 00:12:35 +08:00
binary-husky
815d949e12 Update README.md 2023-05-01 23:36:26 +08:00
binary-husky
33cd7068fb Update config.py 2023-05-01 23:28:28 +08:00
binary-husky
96aceedd25 Merge pull request #666 from mldljyh/ko
Add a link  to the Korean version of gpt_academic (ko_gpt_academic) on the README.
2023-05-01 20:52:57 +08:00
jy.hyun
c2d8bfd8c7 fix README ko 2023-05-01 11:35:38 +09:00
jy.hyun
d85f9ee41b Add README ko 2023-05-01 11:34:02 +09:00
ReeInk
e5e3e0aa43 读取环境变量作为配置 2023-04-30 17:30:31 +08:00
ReeInk
f187a23dc1 Revert "加载环境变量作为配置"
This reverts commit 601c36e607.
2023-04-30 14:34:35 +08:00
ReeInk
601c36e607 加载环境变量作为配置 2023-04-29 19:55:40 +08:00
ReeInk
15b7cd6193 feat: build docker image automatically 2023-04-29 18:10:27 +08:00
binary-husky
9d3b01af75 尝试加入jittor本地模型 2023-04-29 16:46:59 +08:00
binary-husky
61ad51cf15 更新提示 2023-04-29 04:05:13 +08:00
binary-husky
920dccd076 修正提示 2023-04-29 04:03:06 +08:00
binary-husky
8fd21feb75 修改说明 2023-04-29 03:45:48 +08:00
binary-husky
c960b34fac 增加了对Azure密钥的识别 2023-04-29 03:22:31 +08:00
binary-husky
9ad00c78ba 临时修复超链接显示为公式的问题 2023-04-29 03:02:19 +08:00
binary-husky
4c3eeee00d Update README.md 2023-04-29 02:21:06 +08:00
binary-husky
a6393d4d05 Update README.md 2023-04-29 02:19:24 +08:00
binary-husky
92f3c078b5 让保存的html对话文件能够显示代码高亮 2023-04-29 02:04:08 +08:00
binary-husky
c53320182a 修复newbing引用样式 2023-04-29 01:51:11 +08:00
binary-husky
1788cb4a89 3.32 2023-04-29 00:50:19 +08:00
binary-husky
6a268e17cd 修复公式重复显示的bug 2023-04-29 00:48:48 +08:00
binary-husky
dbd8a80970 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-29 00:00:32 +08:00
binary-husky
6c17f3e9c8 添加历史存档读取的功能 2023-04-29 00:00:26 +08:00
binary-husky
730940b60d 修正多GPU选择的说明 2023-04-28 12:18:12 +08:00
binary-husky
71ba23b24a Update README.md 2023-04-28 11:18:54 +08:00
binary-husky
c12ac066b6 Update README.md 2023-04-28 11:18:02 +08:00
binary-husky
b6119ed827 Update README.md 2023-04-28 11:04:08 +08:00
Your Name
a219512045 fix auto upgrade issue 2023-04-27 21:26:01 +08:00
Your Name
dfa31a8c16 3.31 2023-04-27 21:15:22 +08:00
Your Name
984c7e9e12 修正自动更新路径 2023-04-27 21:11:15 +08:00
binary-husky
86b654d6be Update README.md 2023-04-27 20:30:03 +08:00
binary-husky
8c16cda3e8 Update README.md 2023-04-27 20:07:33 +08:00
binary-husky
c295bb4f04 ChatGLM加线程锁提高并发稳定性 2023-04-27 20:01:36 +08:00
binary-husky
8720f79310 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-27 19:59:01 +08:00
binary-husky
24bb174b63 Update README.md 2023-04-27 11:35:53 +08:00
binary-husky
bb788b9259 Update README.md 2023-04-27 11:33:37 +08:00
binary-husky
69540d07c5 修改dockerfile 2023-04-27 11:22:02 +08:00
binary-husky
34b767d1fd thread lock in chatglm 2023-04-27 11:17:19 +08:00
binary-husky
abd81cc215 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-27 10:58:51 +08:00
binary-husky
1eb0174dff 新增DARK_MODE选项,可选择默认颜色模式 2023-04-27 10:58:45 +08:00
binary-husky
c23db4b4f9 Update README.md 2023-04-26 23:04:58 +08:00
binary-husky
6538c58b8e Update README.md 2023-04-25 18:30:11 +08:00
binary-husky
e35eb9048e Update README.md 2023-04-25 16:48:08 +08:00
binary-husky
a0fa64de47 Update README.md 2023-04-25 16:46:36 +08:00
binary-husky
e04946c816 Update README.md 2023-04-25 16:45:53 +08:00
binary-husky
231c9c2e57 Update README.md 2023-04-25 16:11:35 +08:00
binary-husky
48555f570c Update README.md 2023-04-25 16:11:00 +08:00
binary-husky
7c9195ddd2 Update README.md 2023-04-25 15:50:35 +08:00
binary-husky
5500fbe682 Update README.md 2023-04-25 15:49:57 +08:00
binary-husky
5a83b3b096 version 3.3 2023-04-24 21:10:01 +08:00
binary-husky
4783fd6f37 UP 2023-04-24 21:02:16 +08:00
binary-husky
9a4b56277c Function Refector 2023-04-24 20:59:10 +08:00
binary-husky
5eea959103 Markdown翻译支持github url 2023-04-24 20:51:34 +08:00
binary-husky
856df8fb62 验证对话上下文 2023-04-24 20:18:32 +08:00
binary-husky
8e59412c47 修正newbing交互的不合理代码 2023-04-24 20:14:23 +08:00
binary-husky
8f571ff68f Merge branch 'v3.3' 2023-04-24 19:58:07 +08:00
binary-husky
b6d2766e59 改善功能 2023-04-24 19:54:28 +08:00
binary-husky
73ce471a0e max_worker_limit 2023-04-24 19:24:19 +08:00
binary-husky
4e113139c8 Merge branch 'master' into v3.3 2023-04-24 19:09:44 +08:00
binary-husky
e4c4b28ddf Update README.md 2023-04-24 18:20:33 +08:00
binary-husky
081acc6404 修复颜色 2023-04-24 17:42:24 +08:00
binary-husky
1a999497d7 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-24 17:33:23 +08:00
binary-husky
6137963355 拯救一下之前的灾难性的代码配色 2023-04-24 17:33:18 +08:00
binary-husky
22bffdb737 Update README.md 2023-04-24 12:25:10 +08:00
binary-husky
75adcbffeb Update README.md 2023-04-24 12:24:46 +08:00
binary-husky
4451770061 Update README.md 2023-04-24 12:24:29 +08:00
binary-husky
09c413a272 Update README.md 2023-04-24 12:17:58 +08:00
binary-husky
ddb6c90a8f Update README.md 2023-04-24 12:17:04 +08:00
binary-husky
71590426f9 Update README.md 2023-04-24 12:16:49 +08:00
binary-husky
b3e5cdb3a5 加一些注释 2023-04-24 12:08:42 +08:00
binary-husky
6595ab813e 修正计数错误 2023-04-24 11:54:15 +08:00
binary-husky
d1efbd26da 修正prompt 2023-04-24 11:48:39 +08:00
binary-husky
f04683732e 待调查的BUG 2023-04-24 11:39:40 +08:00
binary-husky
cb0241db78 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-24 11:34:53 +08:00
binary-husky
a097b6cd03 减少每次处理的论文数 2023-04-24 11:34:47 +08:00
Your Name
487ffe7888 Merge remote-tracking branch 'origin/master' into v3.3 2023-04-24 02:07:07 +08:00
binary-husky
51424a7d08 Update README.md 2023-04-24 01:57:13 +08:00
binary-husky
06e8e8f9a6 Update README.md 2023-04-24 01:55:53 +08:00
binary-husky
0512b311f8 Update README.md 2023-04-24 01:55:10 +08:00
binary-husky
81d53d0726 Update README.md 2023-04-24 01:47:35 +08:00
binary-husky
a141c5ccdc Update README.md 2023-04-24 01:46:58 +08:00
binary-husky
e361d741c3 Update README.md 2023-04-24 01:44:30 +08:00
binary-husky
f5bc58dbde Update README.md 2023-04-24 01:41:47 +08:00
Your Name
e7b73f3041 update readme 2023-04-24 00:43:57 +08:00
Your Name
ed8db8c8ae README 2023-04-23 23:49:55 +08:00
Your Name
df97213d3b version 3.3 2023-04-23 23:43:07 +08:00
Your Name
97443d1f83 移除依赖 2023-04-23 23:40:18 +08:00
Your Name
59bed52faf 修改依赖的引用方式 2023-04-23 23:39:54 +08:00
Your Name
3814c3a915 修改依赖 2023-04-23 23:36:55 +08:00
Your Name
d98d0a291e 移动函数位置 2023-04-23 23:34:13 +08:00
Your Name
ee94fa6dc4 拆分成两个文件 2023-04-23 23:32:35 +08:00
Your Name
d2e46f6684 更新提示 2023-04-23 23:26:23 +08:00
Your Name
5948dcacd5 加线程锁 2023-04-23 23:25:49 +08:00
Your Name
3041858e7f 优化提示 2023-04-23 23:16:25 +08:00
Your Name
9c2a6bc413 优化错误提示 2023-04-23 23:13:00 +08:00
Your Name
1cf8b6c6c8 修复细节 2023-04-23 22:47:45 +08:00
Your Name
781ef4487c 修复一些细节 2023-04-23 22:44:18 +08:00
Your Name
4a494354b1 显示newbing回复的网址 2023-04-23 22:34:24 +08:00
Your Name
385c775aa5 支持3.10以下的python版本使用newbing 2023-04-23 20:54:57 +08:00
binary-husky
518385dea2 add newbing, testing 2023-04-23 19:17:09 +08:00
binary-husky
4d1eea7bd5 更新说明 2023-04-23 18:40:58 +08:00
binary-husky
9cb51ccc70 restore default model 2023-04-23 18:38:05 +08:00
binary-husky
94dc398163 restore default model 2023-04-23 18:37:15 +08:00
binary-husky
65317e33af Merge branch 'newbing' into v3.3 2023-04-23 18:35:21 +08:00
binary-husky
06fbdf43af 更正部分注释 2023-04-23 18:34:16 +08:00
binary-husky
ab61418410 better traceback 2023-04-23 18:13:30 +08:00
binary-husky
0785ff2aed 微调对话裁剪 2023-04-23 17:45:56 +08:00
binary-husky
676fe40d39 优化chatgpt对话的截断策略 2023-04-23 17:32:44 +08:00
binary-husky
0b89673ee9 Merge pull request #571 from codycjy/notebook_args
feat(jupyter): use args to disable Markdown parse
2023-04-23 11:24:41 +08:00
binary-husky
2f4e050612 Update README.md 2023-04-23 11:22:35 +08:00
binary-husky
87d963bda5 UP 2023-04-23 11:19:16 +08:00
binary-husky
07807e4653 插件支持保存对话 2023-04-23 11:17:56 +08:00
binary-husky
2b96217f2b 实现Newbing聊天功能 2023-04-22 21:18:35 +08:00
saltfish
13342c2988 feat(jupter): use args to disable Markdown parse 2023-04-22 21:11:24 +08:00
binary-husky
95f8b2824a Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-22 18:56:07 +08:00
binary-husky
4065d6e234 版本3.2 2023-04-22 18:56:02 +08:00
binary-husky
d3dcd432e8 Update README.md 2023-04-22 18:47:11 +08:00
binary-husky
7d14de79bf Merge pull request #502 from mrhblfx/new_code_fun
解析项目源代码(手动指定和筛选源代码文件类型)
2023-04-22 18:40:47 +08:00
binary-husky
15c6b52b5f 修改README 2023-04-22 18:22:33 +08:00
binary-husky
c0f1b5bc8e 修改说明 2023-04-22 18:21:43 +08:00
mrhblfx
bd62c6be68 使提示更佳全面 2023-04-22 18:20:01 +08:00
binary-husky
70bd21f09a 修改二级路径运行的说明 2023-04-22 18:19:49 +08:00
Your Name
a0f15f1512 修改注释 2023-04-22 18:10:42 +08:00
mrhblfx
4575046ce1 使提示更佳全面 2023-04-22 18:08:27 +08:00
Your Name
33ea7391b5 Merge branch 'subpath' 2023-04-22 18:07:58 +08:00
Your Name
e90eee2d8e 加入subpath支持,但暂不启用 2023-04-22 18:07:24 +08:00
Your Name
7d44210a48 fix apache2 sub-path deploy issue #544 2023-04-22 17:55:50 +08:00
binary-husky
206f4138b6 Merge pull request #544 from yuxiaoyuan0406/suburl
fix apache2 sub-path deploy issue
2023-04-22 17:42:02 +08:00
mrhblfx
6d2807f499 Merge branch 'binary-husky:master' into new_code_fun 2023-04-22 17:38:26 +08:00
Your Name
f1234937c6 add check path back 2023-04-22 17:30:21 +08:00
Your Name
7beea951c6 unifying code 2023-04-22 17:24:22 +08:00
Your Name
6f7e8076c7 Merge branch 'suburl' of https://github.com/yuxiaoyuan0406/chatgpt_academic into yuxiaoyuan0406-suburl 2023-04-22 16:44:15 +08:00
binary-husky
ae24fab441 Merge pull request #562 from codycjy/codycjy
Parse and generate ipynb (Issue #501)
2023-04-22 16:22:03 +08:00
Your Name
880be21bf7 Add test for juptyer notebook plugin 2023-04-22 16:19:36 +08:00
Your Name
559b3cd6bb Merge branch 'codycjy' of https://github.com/codycjy/chatgpt_academic into codycjy-codycjy 2023-04-22 16:02:24 +08:00
binary-husky
9d9df8aa57 Update 解析JupyterNotebook.py 2023-04-22 16:01:32 +08:00
binary-husky
64548d33a9 Update crazy_functional.py 2023-04-22 15:58:43 +08:00
Your Name
c3cafd8d6f 微调界面布局 2023-04-22 15:52:21 +08:00
Your Name
e9a6efef7f 修复非压缩文件上传的读取问题 2023-04-22 15:39:51 +08:00
Your Name
89a75e26c3 修复extract_folder_path被定位到根目录的bug 2023-04-22 15:36:49 +08:00
Your Name
1139d395f2 将高级参数输入通用化(默认隐藏),应用到所有的下拉菜单函数插件中 2023-04-22 15:06:54 +08:00
saltfish
e20070939c Parse and generate ipynb (Issue #501)
Implemented code to parse and generate the ipynb files. The solution addresses Issue #501.
2023-04-22 00:36:28 +08:00
mrhblfx
3236fcca21 update 2023-04-21 21:02:11 +08:00
Your Name
5353eba376 version 3.15 添加联网回答问题 2023-04-21 20:03:38 +08:00
Your Name
7339b06acb Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-21 19:28:37 +08:00
Your Name
ce1fc3a999 修改chatglm不记忆上下文的bug 2023-04-21 19:28:32 +08:00
binary-husky
a9a489231a Update bridge_all.py 2023-04-21 18:56:56 +08:00
binary-husky
e889590a91 Update README.md 2023-04-21 18:49:24 +08:00
Your Name
9481405f6f 更新提示 2023-04-21 18:37:20 +08:00
Your Name
7317d79a3c 更新提醒 2023-04-21 18:28:51 +08:00
Your Name
a46e0111cd Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-21 17:37:56 +08:00
Your Name
01a377d747 还原API_URL的设置 2023-04-21 17:37:48 +08:00
binary-husky
50258b781e Update README.md 2023-04-21 15:47:00 +08:00
binary-husky
dd1ba222ae Update README.md 2023-04-21 15:46:23 +08:00
binary-husky
b7d4adeccc Update README.md 2023-04-21 15:19:19 +08:00
binary-husky
3f82208062 Merge pull request #552 from kuang-da/readme-docker-macos
添加对Windows和MacOs下的docker运行说明
2023-04-21 15:16:18 +08:00
binary-husky
5f319061d7 Update README.md 2023-04-21 15:13:51 +08:00
Da Kuang
2c2a8ea549 Update the readme file section: 安装-方法2:使用Docker 2023-04-21 02:24:39 -04:00
505030475
90e1eef61f 试试联网检索 2023-04-20 23:58:26 +08:00
Your Name
325406a650 联网搜索问题 2023-04-20 22:30:10 +08:00
Your Name
bff4a87914 【单元测试】添加联网回答问题的功能 2023-04-20 22:09:55 +08:00
mrhblfx
de0ed4a6f5 style:accordion of 解析任意code项目 is closed by default 2023-04-20 22:01:27 +08:00
mrhblfx
0ff838443e fix a bug 2023-04-20 21:44:35 +08:00
mrhblfx
cfbfb68618 Merge branch 'master' of github.com:mrhblfx/chatgpt_academic 2023-04-20 21:12:22 +08:00
binary-husky
b42f2f745f Update main.py 2023-04-20 20:36:20 +08:00
yuxiaoyuan0406
9945d5048a 更好的检查子路径逻辑 2023-04-20 18:31:26 +08:00
yuxiaoyuan0406
f0ff1f2c64 添加CUSTOM_PATH来部署到子级路径 2023-04-20 18:22:58 +08:00
yuxiaoyuan0406
7dd73e1330 添加了一个检查path的工具 2023-04-20 18:20:25 +08:00
yuxiaoyuan0406
4cfbacdb26 fix sub-path deploy 2023-04-20 17:21:47 +08:00
binary-husky
3bb4b4c92a Update README.md 2023-04-20 16:33:08 +08:00
binary-husky
bda025bc50 Update README.md 2023-04-20 16:31:26 +08:00
binary-husky
c24ff30f8c Update README.md 2023-04-20 10:40:44 +08:00
binary-husky
53189aea4e Update README.md 2023-04-20 10:38:30 +08:00
binary-husky
4b7a954fc8 Update README.md 2023-04-20 10:22:33 +08:00
binary-husky
2b9261bc39 Update README.md 2023-04-20 10:20:48 +08:00
Your Name
4812513cbc 增添报错信息 2023-04-20 09:45:44 +08:00
Your Name
4bd8475d95 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-19 22:10:32 +08:00
Your Name
ac219f40c5 在chatbot的标签上显示当前的模型选择 2023-04-19 22:10:26 +08:00
mrhblfx
26af2b1bb4 update by pull 2023-04-19 18:26:48 +08:00
binary-husky
97385c98fc Update README.md 2023-04-19 18:14:13 +08:00
binary-husky
74e3cd4c6f Update README.md 2023-04-19 17:34:45 +08:00
Your Name
205a6952a2 多语言README 2023-04-19 17:04:04 +08:00
Your Name
dd593d9f25 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-19 16:50:22 +08:00
Your Name
5d23420553 多语言README 2023-04-19 16:49:47 +08:00
mrhblfx
20bec70160 Merge branch 'master' of github.com:mrhblfx/chatgpt_academic 2023-04-18 23:40:51 +08:00
mrhblfx
9b5f088793 Changed matching rules 2023-04-18 23:31:12 +08:00
mrhblfx
3a561a70db Reduced one parameter 2023-04-18 23:30:19 +08:00
mrhblfx
11e33ec657 Reduced one input box 2023-04-18 23:29:18 +08:00
mrhblfx
d1926725d3 Add parsing arbitrary code items 2023-04-16 23:33:43 +08:00
mrhblfx
2f9a4e1618 Add parsing arbitrary code items 2023-04-16 23:00:45 +08:00
共有 50 个文件被更改,包括 8850 次插入529 次删除

2
.gitignore vendored
查看文件

@@ -145,3 +145,5 @@ cradle*
debug* debug*
private* private*
crazy_functions/test_project/pdf_and_word crazy_functions/test_project/pdf_and_word
crazy_functions/test_samples
request_llm/jittorllms

233
README.md
查看文件

@@ -1,10 +1,15 @@
> **Note**
>
> 安装依赖时,请严格选择requirements.txt中**指定的版本**。
>
> `pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/`
>
# <img src="docs/logo.png" width="40" > GPT 学术优化 (GPT Academic)
# <img src="docs/logo.png" width="40" > ChatGPT 学术优化 **如果喜欢这个项目,请给它一个Star;如果你发明了更好用的快捷键或函数插件,欢迎发pull requests**
**如果喜欢这个项目,请给它一个Star;如果你发明了更好用的快捷键或函数插件,欢迎发issue或者pull requests** If you like this project, please give it a Star. If you've come up with more useful academic shortcuts or functional plugins, feel free to open an issue or pull request. We also have a README in [English|](docs/README_EN.md)[日本語|](docs/README_JP.md)[한국어|](https://github.com/mldljyh/ko_gpt_academic)[Русский|](docs/README_RS.md)[Français](docs/README_FR.md) translated by this project itself.
If you like this project, please give it a Star. If you've come up with more useful academic shortcuts or functional plugins, feel free to open an issue or pull request. We also have a [README in English](img/README_EN.md) translated by this project itself.
> **Note** > **Note**
> >
@@ -12,38 +17,39 @@ If you like this project, please give it a Star. If you've come up with more use
> >
> 2.本项目中每个文件的功能都在自译解[`self_analysis.md`](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A)详细说明。随着版本的迭代,您也可以随时自行点击相关函数插件,调用GPT重新生成项目的自我解析报告。常见问题汇总在[`wiki`](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)当中。 > 2.本项目中每个文件的功能都在自译解[`self_analysis.md`](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A)详细说明。随着版本的迭代,您也可以随时自行点击相关函数插件,调用GPT重新生成项目的自我解析报告。常见问题汇总在[`wiki`](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)当中。
> >
> 3.本项目兼容并鼓励尝试国产大语言模型chatglm和RWKV, 盘古等等。已支持OpenAI和API2D的api-key共存,可在配置文件中填写如`API_KEY="openai-key1,openai-key2,api2d-key3"`。需要临时更换`API_KEY`时,在输入区输入临时的`API_KEY`然后回车键提交后即可生效。
<div align="center"> <div align="center">
功能 | 描述 功能 | 描述
--- | --- --- | ---
一键润色 | 支持一键润色、一键查找论文语法错误 一键润色 | 支持一键润色、一键查找论文语法错误
一键中英互译 | 一键中英互译 一键中英互译 | 一键中英互译
一键代码解释 | 可以正确显示代码、解释代码 一键代码解释 | 显示代码、解释代码、生成代码、给代码加注释
[自定义快捷键](https://www.bilibili.com/video/BV14s4y1E7jN) | 支持自定义快捷键 [自定义快捷键](https://www.bilibili.com/video/BV14s4y1E7jN) | 支持自定义快捷键
[配置代理服务器](https://www.bilibili.com/video/BV1rc411W7Dr) | 支持配置代理服务器 模块化设计 | 支持自定义强大的[函数插件](https://github.com/binary-husky/chatgpt_academic/tree/master/crazy_functions),插件支持[热更新](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97)
模块化设计 | 支持自定义高阶的函数插件与[函数插件],插件支持[热更新](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97)
[自我程序剖析](https://www.bilibili.com/video/BV1cj411A7VW) | [函数插件] [一键读懂](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A)本项目的源代码 [自我程序剖析](https://www.bilibili.com/video/BV1cj411A7VW) | [函数插件] [一键读懂](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A)本项目的源代码
[程序剖析](https://www.bilibili.com/video/BV1cj411A7VW) | [函数插件] 一键可以剖析其他Python/C/C++/Java/Lua/...项目树 [程序剖析](https://www.bilibili.com/video/BV1cj411A7VW) | [函数插件] 一键可以剖析其他Python/C/C++/Java/Lua/...项目树
读论文 | [函数插件] 一键解读latex论文全文并生成摘要 读论文、[翻译](https://www.bilibili.com/video/BV1KT411x7Wn)论文 | [函数插件] 一键解读latex/pdf论文全文并生成摘要
Latex全文翻译、润色 | [函数插件] 一键翻译或润色latex论文 Latex全文[翻译](https://www.bilibili.com/video/BV1nk4y1Y7Js/)、[润色](https://www.bilibili.com/video/BV1FT411H7c5/) | [函数插件] 一键翻译或润色latex论文
批量注释生成 | [函数插件] 一键批量生成函数注释 批量注释生成 | [函数插件] 一键批量生成函数注释
Markdown[中英互译](https://www.bilibili.com/video/BV1yo4y157jV/) | [函数插件] 看到上面5种语言的[README](https://github.com/binary-husky/chatgpt_academic/blob/master/docs/README_EN.md)了吗?
chat分析报告生成 | [函数插件] 运行后自动生成总结汇报 chat分析报告生成 | [函数插件] 运行后自动生成总结汇报
[arxiv小助手](https://www.bilibili.com/video/BV1LM4y1279X) | [函数插件] 输入arxiv文章url即可一键翻译摘要+下载PDF
[PDF论文全文翻译功能](https://www.bilibili.com/video/BV1KT411x7Wn) | [函数插件] PDF论文提取题目&摘要+翻译全文(多线程) [PDF论文全文翻译功能](https://www.bilibili.com/video/BV1KT411x7Wn) | [函数插件] PDF论文提取题目&摘要+翻译全文(多线程)
[谷歌学术统合小助手](https://www.bilibili.com/video/BV19L411U7ia) | [函数插件] 给定任意谷歌学术搜索页面URL,让gpt帮你选择有趣的文章 [Arxiv小助手](https://www.bilibili.com/video/BV1LM4y1279X) | [函数插件] 输入arxiv文章url即可一键翻译摘要+下载PDF
公式/图片/表格显示 | 可以同时显示公式的tex形式和渲染形式,支持公式、代码高亮 [谷歌学术统合小助手](https://www.bilibili.com/video/BV19L411U7ia) | [函数插件] 给定任意谷歌学术搜索页面URL,让gpt帮你[写relatedworks](https://www.bilibili.com/video/BV1GP411U7Az/)
多线程函数插件支持 | 支持多线调用chatgpt,一键处理海量文本或程序 互联网信息聚合+GPT | [函数插件] 一键[让GPT先从互联网获取信息](https://www.bilibili.com/video/BV1om4y127ck),再回答问题,让信息永不过时
公式/图片/表格显示 | 可以同时显示公式的[tex形式和渲染形式](https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png),支持公式、代码高亮
多线程函数插件支持 | 支持多线调用chatgpt,一键处理[海量文本](https://www.bilibili.com/video/BV1FT411H7c5/)或程序
启动暗色gradio[主题](https://github.com/binary-husky/chatgpt_academic/issues/173) | 在浏览器url后面添加```/?__dark-theme=true```可以切换dark主题 启动暗色gradio[主题](https://github.com/binary-husky/chatgpt_academic/issues/173) | 在浏览器url后面添加```/?__dark-theme=true```可以切换dark主题
[多LLM模型](https://www.bilibili.com/video/BV1wT411p7yf)支持,[API2D](https://api2d.com/)接口支持 | 同时被GPT3.5、GPT4和[清华ChatGLM](https://github.com/THUDM/ChatGLM-6B)伺候的感觉一定会很不错吧? [多LLM模型](https://www.bilibili.com/video/BV1wT411p7yf)支持,[API2D](https://api2d.com/)接口支持 | 同时被GPT3.5、GPT4和[清华ChatGLM](https://github.com/THUDM/ChatGLM-6B)伺候的感觉一定会很不错吧?
huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/gpt-academic) | 登陆huggingface后复制[此空间](https://huggingface.co/spaces/qingxu98/gpt-academic) 更多LLM模型接入,支持[huggingface部署](https://huggingface.co/spaces/qingxu98/gpt-academic) | 新加入Newbing测试接口(新必应AI)
…… | …… …… | ……
</div> </div>
- 新界面修改config.py中的LAYOUT选项即可实现“左右布局”和“上下布局”的切换 - 新界面(修改`config.py`中的LAYOUT选项即可实现“左右布局”和“上下布局”的切换
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" > <img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
</div> </div>
@@ -74,9 +80,6 @@ huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" > <img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
</div> </div>
多种大语言模型混合调用[huggingface测试版](https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta)huggingface版不支持chatglm
--- ---
## 安装-方法1直接运行 (Windows, Linux or MacOS) ## 安装-方法1直接运行 (Windows, Linux or MacOS)
@@ -87,34 +90,32 @@ git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic cd chatgpt_academic
``` ```
2. 配置API_KEY和代理设置 2. 配置API_KEY
在`config.py`中,配置API KEY等设置,[特殊网络环境设置](https://github.com/binary-husky/gpt_academic/issues/1) 。
在`config.py`中,配置 海外Proxy 和 OpenAI API KEY,说明如下
```
1. 如果你在国内,需要设置海外代理才能够顺利使用 OpenAI API,设置方法请仔细阅读config.py1.修改其中的USE_PROXY为True; 2.按照说明修改其中的proxies
2. 配置 OpenAI API KEY。你需要在 OpenAI 官网上注册并获取 API KEY。一旦你拿到了 API KEY,在 config.py 文件里配置好即可。
3. 与代理网络有关的issue网络超时、代理不起作用汇总到 https://github.com/binary-husky/chatgpt_academic/issues/1
```
P.S. 程序运行时会优先检查是否存在名为`config_private.py`的私密配置文件,并用其中的配置覆盖`config.py`的同名配置。因此,如果您能理解我们的配置读取逻辑,我们强烈建议您在`config.py`旁边创建一个名为`config_private.py`的新配置文件,并把`config.py`中的配置转移(复制)到`config_private.py`中。`config_private.py`不受git管控,可以让您的隐私信息更加安全。 P.S. 程序运行时会优先检查是否存在名为`config_private.py`的私密配置文件,并用其中的配置覆盖`config.py`的同名配置。因此,如果您能理解我们的配置读取逻辑,我们强烈建议您在`config.py`旁边创建一个名为`config_private.py`的新配置文件,并把`config.py`中的配置转移(复制)到`config_private.py`中。`config_private.py`不受git管控,可以让您的隐私信息更加安全。
3. 安装依赖 3. 安装依赖
```sh ```sh
# (选择一)推荐 # (选择I: 如熟悉pythonpython版本3.9以上,越新越好)
python -m pip install -r requirements.txt python -m pip install -r requirements.txt
# 备注使用官方pip源或者阿里pip源,其他pip源如一些大学的pip有可能出问题,临时换源方法python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
# (选择二)如果您使用anaconda,步骤也是类似的 # (选择II: 如不熟悉python使用anaconda,步骤也是类似的
# 选择二.1conda create -n gptac_venv python=3.11 # II-1conda create -n gptac_venv python=3.11
# 选择二.2conda activate gptac_venv # II-2conda activate gptac_venv
# 选择二.3python -m pip install -r requirements.txt # II-3python -m pip install -r requirements.txt
# 备注使用官方pip源或者阿里pip源,其他pip源如一些大学的pip有可能出问题,临时换源方法
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
``` ```
如果需要支持清华ChatGLM,需要额外安装更多依赖熟悉python者、电脑配置不佳者,建议不要尝试 如果需要支持清华ChatGLM后端,需要额外安装更多依赖(前提条件:熟悉python + 电脑配置够强
```sh ```sh
python -m pip install -r request_llm/requirements_chatglm.txt python -m pip install -r request_llm/requirements_chatglm.txt
# 备注:如果遇到"Call ChatGLM fail 不能正常加载ChatGLM的参数" 错误,参考如下:
# 1以上默认安装的为torch+cpu版,使用cuda需要卸载torch重新安装torch+cuda
# 2如因本机配置不够无法加载模型,可以修改request_llm/bridge_chatglm.py中的模型精度, 将 AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True) 都修改为 AutoTokenizer.from_pretrained("THUDM/chatglm-6b-int4", trust_remote_code=True)
``` ```
4. 运行 4. 运行
@@ -124,74 +125,70 @@ python main.py
5. 测试函数插件 5. 测试函数插件
``` ```
- 测试Python项目分析 - 测试函数插件模板函数要求gpt回答历史上的今天发生了什么,您可以根据此函数为模板,实现更复杂的功能
input区域 输入 `./crazy_functions/test_project/python/dqn` , 然后点击 "解析整个Python项目"
- 测试自我代码解读
点击 "[多线程Demo] 解析此项目本身(源码自译解)"
- 测试实验功能模板函数要求gpt回答历史上的今天发生了什么,您可以根据此函数为模板,实现更复杂的功能
点击 "[函数插件模板Demo] 历史上的今天" 点击 "[函数插件模板Demo] 历史上的今天"
- 函数插件区下拉菜单中有更多功能可供选择
``` ```
## 安装-方法2使用docker (Linux) ## 安装-方法2使用Docker
1. 仅ChatGPT推荐大多数人选择 1. 仅ChatGPT推荐大多数人选择
``` sh ``` sh
# 下载项目 # 下载项目
git clone https://github.com/binary-husky/chatgpt_academic.git git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic cd chatgpt_academic
# 配置 海外Proxy 和 OpenAI API KEY # 配置 Proxy”, “API_KEY” 以及 “WEB_PORT” (例如50923) 等
用任意文本编辑器编辑 config.py 用任意文本编辑器编辑 config.py
# 安装 # 安装
docker build -t gpt-academic . docker build -t gpt-academic .
# 运行 #(最后一步-选择1在Linux环境下,用`--net=host`更方便快捷
docker run --rm -it --net=host gpt-academic docker run --rm -it --net=host gpt-academic
#(最后一步-选择2在macOS/windows环境下,只能用-p选项将容器上的端口(例如50923)暴露给主机上的端口
# 测试函数插件 docker run --rm -it -p 50923:50923 gpt-academic
## 测试函数插件模板函数要求gpt回答历史上的今天发生了什么,您可以根据此函数为模板,实现更复杂的功能
点击 "[函数插件模板Demo] 历史上的今天"
## 测试给Latex项目写摘要
input区域 输入 ./crazy_functions/test_project/latex/attention , 然后点击 "读Tex论文写摘要"
## 测试Python项目分析
input区域 输入 ./crazy_functions/test_project/python/dqn , 然后点击 "解析整个Python项目"
函数插件区下拉菜单中有更多功能可供选择
``` ```
2. ChatGPT+ChatGLM需要对docker非常熟悉 + 电脑配置够强) 2. ChatGPT+ChatGLM需要对Docker熟悉 + 读懂Dockerfile + 电脑配置够强)
``` sh ``` sh
# 修改dockerfile # 修改Dockerfile
cd docs && nano Dockerfile+ChatGLM cd docs && nano Dockerfile+ChatGLM
# How to build | 如何构建 Dockerfile+ChatGLM在docs路径下,请先cd docs # 构建 Dockerfile+ChatGLM在docs路径下,请先cd docs
docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM . docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
# How to run | 如何运行 (1) 直接运行: # 运行 (1) 直接运行:
docker run --rm -it --net=host --gpus=all gpt-academic docker run --rm -it --net=host --gpus=all gpt-academic
# How to run | 如何运行 (2) 我想运行之前进容器做一些调整: # 运行 (2) 我想运行之前进容器做一些调整:
docker run --rm -it --net=host --gpus=all gpt-academic bash docker run --rm -it --net=host --gpus=all gpt-academic bash
``` ```
3. ChatGPT + LLAMA + 盘古 + RWKV需要精通Docker
``` sh
1. 修改docker-compose.yml,删除方案一和方案二,保留方案三基于jittor
2. 修改docker-compose.yml中方案三的配置,参考其中注释即可
3. 终端运行 docker-compose up
```
## 安装-方法3其他部署方式
1. 远程云服务器部署 ## 安装-方法3其他部署姿势
1. 如何使用反代URL/微软云AzureAPI
按照`config.py`中的说明配置API_URL_REDIRECT即可。
2. 远程云服务器部署(需要云服务器知识与经验)
请访问[部署wiki-1](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97) 请访问[部署wiki-1](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
2. 使用WSL2Windows Subsystem for Linux 子系统) 3. 使用WSL2Windows Subsystem for Linux 子系统)
请访问[部署wiki-2](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2) 请访问[部署wiki-2](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
4. 如何在二级网址(如`http://localhost/subpath`)下运行
请访问[FastAPI运行说明](docs/WithFastapi.md)
## 安装-代理配置 5. 使用docker-compose运行
1. 常规方法 请阅读docker-compose.yml后,按照其中的提示操作即可
[配置代理](https://github.com/binary-husky/chatgpt_academic/issues/1)
2. 纯新手教程
[纯新手教程](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BB%A3%E7%90%86%E8%BD%AF%E4%BB%B6%E9%97%AE%E9%A2%98%E7%9A%84%E6%96%B0%E6%89%8B%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%EF%BC%88%E6%96%B9%E6%B3%95%E5%8F%AA%E9%80%82%E7%94%A8%E4%BA%8E%E6%96%B0%E6%89%8B%EF%BC%89)
--- ---
## 自定义新的便捷按钮(学术快捷键自定义) ## 自定义新的便捷按钮 / 自定义函数插件
1. 自定义新的便捷按钮(学术快捷键)
任意文本编辑器打开`core_functional.py`,添加条目如下,然后重启程序即可。(如果按钮已经添加成功并可见,那么前缀、后缀都支持热修改,无需重启程序即可生效。) 任意文本编辑器打开`core_functional.py`,添加条目如下,然后重启程序即可。(如果按钮已经添加成功并可见,那么前缀、后缀都支持热修改,无需重启程序即可生效。)
例如 例如
``` ```
@@ -207,64 +204,63 @@ docker run --rm -it --net=host --gpus=all gpt-academic bash
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" > <img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
</div> </div>
2. 自定义函数插件
编写强大的函数插件来执行任何你想得到的和想不到的任务。
本项目的插件编写、调试难度很低,只要您具备一定的python基础知识,就可以仿照我们提供的模板实现自己的插件功能。
详情请参考[函数插件指南](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97)。
--- ---
## 其他功能说明
## 部分功能展示 1. 对话保存功能。在函数插件区调用 `保存当前的对话` 即可将当前对话保存为可读+可复原的html文件,
另外在函数插件区(下拉菜单)调用 `载入对话历史存档` ,即可还原之前的会话。
### 图片显示: Tip不指定文件直接点击 `载入对话历史存档` 可以查看历史html存档缓存,点击 `删除所有本地对话历史记录` 可以删除所有html存档缓存。
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" > <img src="https://user-images.githubusercontent.com/96192199/235222390-24a9acc0-680f-49f5-bc81-2f3161f1e049.png" width="500" >
</div> </div>
### 如果一个程序能够读懂并剖析自己:
<div align="center"> 2. 生成报告。大部分插件都会在执行结束后,生成工作报告
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
</div>
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
</div>
### 其他任意Python/Cpp项目剖析
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
</div>
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
</div>
### Latex论文一键阅读理解与摘要生成
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
</div>
### 自动报告生成
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" > <img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" > <img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" > <img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
</div> </div>
### 模块化功能设计 3. 模块化功能设计,简单的接口却能支持强大的功能
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" > <img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" > <img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
</div> </div>
4. 这是一个能够“自我译解”的开源项目
### 源代码转译英文
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" > <img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="500" >
</div> </div>
## Todo 与 版本规划: 5. 译解其他开源项目,不在话下
- version 3.2+ (todo): 函数插件支持更多参数接口 <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="500" >
</div>
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="500" >
</div>
6. 装饰[live2d](https://github.com/fghrsh/live2d_demo)的小功能(默认关闭,需要修改`config.py`
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/236432361-67739153-73e8-43fe-8111-b61296edabd9.png" width="500" >
</div>
## 版本:
- version 3.5(Todo): 使用自然语言调用本项目的所有函数插件(高优先级)
- version 3.4(Todo): 完善chatglm本地大模型的多线支持
- version 3.3: +互联网信息综合功能
- version 3.2: 函数插件支持更多参数接口 (保存对话功能, 解读任意语言代码+同时询问任意的LLM组合)
- version 3.1: 支持同时问询多个gpt模型支持api2d,支持多个apikey负载均衡 - version 3.1: 支持同时问询多个gpt模型支持api2d,支持多个apikey负载均衡
- version 3.0: 对chatglm和其他小型llm的支持 - version 3.0: 对chatglm和其他小型llm的支持
- version 2.6: 重构了插件结构,提高了交互性,加入更多插件 - version 2.6: 重构了插件结构,提高了交互性,加入更多插件
@@ -276,14 +272,27 @@ docker run --rm -it --net=host --gpus=all gpt-academic bash
- version 2.0: 引入模块化函数插件 - version 2.0: 引入模块化函数插件
- version 1.0: 基础功能 - version 1.0: 基础功能
gpt_academic开发者QQ群-2610599535
## 参考与学习 ## 参考与学习
``` ```
代码中参考了很多其他优秀项目中的设计,主要包括: 代码中参考了很多其他优秀项目中的设计,主要包括:
# 借鉴项目1借鉴了ChuanhuChatGPT中诸多技巧 # 项目1清华ChatGLM-6B
https://github.com/THUDM/ChatGLM-6B
# 项目2清华JittorLLMs
https://github.com/Jittor/JittorLLMs
# 项目3借鉴了ChuanhuChatGPT中诸多技巧
https://github.com/GaiZhenbiao/ChuanhuChatGPT https://github.com/GaiZhenbiao/ChuanhuChatGPT
# 借鉴项目2清华ChatGLM-6B # 项目4ChatPaper
https://github.com/THUDM/ChatGLM-6B https://github.com/kaixindelele/ChatPaper
# 更多:
https://github.com/gradio-app/gradio
https://github.com/fghrsh/live2d_demo
``` ```

查看文件

@@ -56,22 +56,24 @@ def patch_and_restart(path):
""" """
一键更新协议:覆盖和重启 一键更新协议:覆盖和重启
""" """
import distutils from distutils import dir_util
import shutil import shutil
import os import os
import sys import sys
import time import time
import glob
from colorful import print亮黄, print亮绿, print亮红 from colorful import print亮黄, print亮绿, print亮红
# if not using config_private, move origin config.py as config_private.py # if not using config_private, move origin config.py as config_private.py
if not os.path.exists('config_private.py'): if not os.path.exists('config_private.py'):
print亮黄('由于您没有设置config_private.py私密配置,现将您的现有配置移动至config_private.py以防止配置丢失,', print亮黄('由于您没有设置config_private.py私密配置,现将您的现有配置移动至config_private.py以防止配置丢失,',
'另外您可以随时在history子文件夹下找回旧版的程序。') '另外您可以随时在history子文件夹下找回旧版的程序。')
shutil.copyfile('config.py', 'config_private.py') shutil.copyfile('config.py', 'config_private.py')
distutils.dir_util.copy_tree(path+'/chatgpt_academic-master', './') path_new_version = glob.glob(path + '/*-master')[0]
import subprocess dir_util.copy_tree(path_new_version, './')
print亮绿('代码已经更新,即将更新pip包依赖……') print亮绿('代码已经更新,即将更新pip包依赖……')
for i in reversed(range(5)): time.sleep(1); print(i) for i in reversed(range(5)): time.sleep(1); print(i)
try: try:
import subprocess
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt']) subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'])
except: except:
print亮红('pip包依赖安装出现问题,需要手动安装新增的依赖库 `python -m pip install -r requirements.txt`,然后在用常规的`python main.py`的方式启动。') print亮红('pip包依赖安装出现问题,需要手动安装新增的依赖库 `python -m pip install -r requirements.txt`,然后在用常规的`python main.py`的方式启动。')

查看文件

@@ -10,11 +10,11 @@ if USE_PROXY:
# [地址] 懂的都懂,不懂就填localhost或者127.0.0.1肯定错不了localhost意思是代理软件安装在本机上 # [地址] 懂的都懂,不懂就填localhost或者127.0.0.1肯定错不了localhost意思是代理软件安装在本机上
# [端口] 在代理软件的设置里找。虽然不同的代理软件界面不一样,但端口号都应该在最显眼的位置上 # [端口] 在代理软件的设置里找。虽然不同的代理软件界面不一样,但端口号都应该在最显眼的位置上
# 代理网络的地址,打开你的科学上网软件查看代理的协议(socks5/http)、地址(localhost)和端口(11284) # 代理网络的地址,打开你的*学*网软件查看代理的协议(socks5/http)、地址(localhost)和端口(11284)
proxies = { proxies = {
# [协议]:// [地址] :[端口] # [协议]:// [地址] :[端口]
"http": "socks5h://localhost:11284", "http": "socks5h://localhost:11284", # 再例如 "http": "http://127.0.0.1:7890",
"https": "socks5h://localhost:11284", "https": "socks5h://localhost:11284", # 再例如 "https": "http://127.0.0.1:7890",
} }
else: else:
proxies = None proxies = None
@@ -33,6 +33,7 @@ CODE_HIGHLIGHT = True
# 窗口布局 # 窗口布局
LAYOUT = "LEFT-RIGHT" # "LEFT-RIGHT"(左右布局) # "TOP-DOWN"(上下布局) LAYOUT = "LEFT-RIGHT" # "LEFT-RIGHT"(左右布局) # "TOP-DOWN"(上下布局)
DARK_MODE = True # "LEFT-RIGHT"(左右布局) # "TOP-DOWN"(上下布局)
# 发送请求到OpenAI后,等待多久判定为超时 # 发送请求到OpenAI后,等待多久判定为超时
TIMEOUT_SECONDS = 30 TIMEOUT_SECONDS = 30
@@ -45,7 +46,7 @@ MAX_RETRY = 2
# OpenAI模型选择是gpt4现在只对申请成功的人开放,体验gpt-4可以试试api2d # OpenAI模型选择是gpt4现在只对申请成功的人开放,体验gpt-4可以试试api2d
LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓ LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm"] AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm", "newbing"]
# 本地LLM模型如ChatGLM的执行方式 CPU/GPU # 本地LLM模型如ChatGLM的执行方式 CPU/GPU
LOCAL_MODEL_DEVICE = "cpu" # 可选 "cuda" LOCAL_MODEL_DEVICE = "cpu" # 可选 "cuda"
@@ -53,6 +54,24 @@ LOCAL_MODEL_DEVICE = "cpu" # 可选 "cuda"
# 设置gradio的并行线程数不需要修改 # 设置gradio的并行线程数不需要修改
CONCURRENT_COUNT = 100 CONCURRENT_COUNT = 100
# 加一个看板娘装饰
ADD_WAIFU = False
# 设置用户名和密码不需要修改相关功能不稳定,与gradio版本和网络都相关,如果本地使用不建议加这个 # 设置用户名和密码不需要修改相关功能不稳定,与gradio版本和网络都相关,如果本地使用不建议加这个
# [("username", "password"), ("username2", "password2"), ...] # [("username", "password"), ("username2", "password2"), ...]
AUTHENTICATION = [] AUTHENTICATION = []
# 重新URL重新定向,实现更换API_URL的作用常规情况下,不要修改!!
# 高危设置通过修改此设置,您将把您的API-KEY和对话隐私完全暴露给您设定的中间人
# 格式 {"https://api.openai.com/v1/chat/completions": "在这里填写重定向的api.openai.com的URL"}
# 例如 API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions": "https://ai.open.com/api/conversation"}
API_URL_REDIRECT = {}
# 如果需要在二级路径下运行(常规情况下,不要修改!!需要配合修改main.py才能生效!
CUSTOM_PATH = "/"
# 如果需要使用newbing,把newbing的长长的cookie放到这里
NEWBING_STYLE = "creative" # ["creative", "balanced", "precise"]
NEWBING_COOKIES = """
your bing cookies here
"""

查看文件

@@ -11,7 +11,7 @@ def get_crazy_functions():
from crazy_functions.解析项目源代码 import 解析一个C项目 from crazy_functions.解析项目源代码 import 解析一个C项目
from crazy_functions.解析项目源代码 import 解析一个Golang项目 from crazy_functions.解析项目源代码 import 解析一个Golang项目
from crazy_functions.解析项目源代码 import 解析一个Java项目 from crazy_functions.解析项目源代码 import 解析一个Java项目
from crazy_functions.解析项目源代码 import 解析一个Rect项目 from crazy_functions.解析项目源代码 import 解析一个前端项目
from crazy_functions.高级功能函数模板 import 高阶功能模板函数 from crazy_functions.高级功能函数模板 import 高阶功能模板函数
from crazy_functions.代码重写为全英文_多线程 import 全项目切换英文 from crazy_functions.代码重写为全英文_多线程 import 全项目切换英文
from crazy_functions.Latex全文润色 import Latex英文润色 from crazy_functions.Latex全文润色 import Latex英文润色
@@ -19,12 +19,33 @@ def get_crazy_functions():
from crazy_functions.解析项目源代码 import 解析一个Lua项目 from crazy_functions.解析项目源代码 import 解析一个Lua项目
from crazy_functions.解析项目源代码 import 解析一个CSharp项目 from crazy_functions.解析项目源代码 import 解析一个CSharp项目
from crazy_functions.总结word文档 import 总结word文档 from crazy_functions.总结word文档 import 总结word文档
from crazy_functions.解析JupyterNotebook import 解析ipynb文件
from crazy_functions.对话历史存档 import 对话历史存档
from crazy_functions.对话历史存档 import 载入对话历史存档
from crazy_functions.对话历史存档 import 删除所有本地对话历史记录
from crazy_functions.批量Markdown翻译 import Markdown英译中
function_plugins = { function_plugins = {
"解析整个Python项目": { "解析整个Python项目": {
"Color": "stop", # 按钮颜色 "Color": "stop", # 按钮颜色
"Function": HotReload(解析一个Python项目) "Function": HotReload(解析一个Python项目)
}, },
"载入对话历史存档(先上传存档或输入路径)": {
"Color": "stop",
"AsButton":False,
"Function": HotReload(载入对话历史存档)
},
"删除所有本地对话历史记录(请谨慎操作)": {
"AsButton":False,
"Function": HotReload(删除所有本地对话历史记录)
},
"[测试功能] 解析Jupyter Notebook文件": {
"Color": "stop",
"AsButton":False,
"Function": HotReload(解析ipynb文件),
"AdvancedArgs": True, # 调用时,唤起高级参数输入区默认False
"ArgsReminder": "若输入0,则不解析notebook中的Markdown块", # 高级参数输入区的显示提示
},
"批量总结Word文档": { "批量总结Word文档": {
"Color": "stop", "Color": "stop",
"Function": HotReload(总结word文档) "Function": HotReload(总结word文档)
@@ -49,10 +70,10 @@ def get_crazy_functions():
"AsButton": False, # 加入下拉菜单中 "AsButton": False, # 加入下拉菜单中
"Function": HotReload(解析一个Java项目) "Function": HotReload(解析一个Java项目)
}, },
"解析整个React项目": { "解析整个前端项目js,ts,css等": {
"Color": "stop", # 按钮颜色 "Color": "stop", # 按钮颜色
"AsButton": False, # 加入下拉菜单中 "AsButton": False, # 加入下拉菜单中
"Function": HotReload(解析一个Rect项目) "Function": HotReload(解析一个前端项目)
}, },
"解析整个Lua项目": { "解析整个Lua项目": {
"Color": "stop", # 按钮颜色 "Color": "stop", # 按钮颜色
@@ -68,19 +89,29 @@ def get_crazy_functions():
"Color": "stop", # 按钮颜色 "Color": "stop", # 按钮颜色
"Function": HotReload(读文章写摘要) "Function": HotReload(读文章写摘要)
}, },
"Markdown/Readme英译中": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"Color": "stop",
"Function": HotReload(Markdown英译中)
},
"批量生成函数注释": { "批量生成函数注释": {
"Color": "stop", # 按钮颜色 "Color": "stop", # 按钮颜色
"AsButton": False, # 加入下拉菜单中
"Function": HotReload(批量生成函数注释) "Function": HotReload(批量生成函数注释)
}, },
"保存当前的对话": {
"Function": HotReload(对话历史存档)
},
"[多线程Demo] 解析此项目本身(源码自译解)": { "[多线程Demo] 解析此项目本身(源码自译解)": {
"AsButton": False, # 加入下拉菜单中
"Function": HotReload(解析项目本身) "Function": HotReload(解析项目本身)
}, },
"[多线程demo] 把本项目源代码切换成全英文": { "[老旧的Demo] 把本项目源代码切换成全英文": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效 # HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"AsButton": False, # 加入下拉菜单中 "AsButton": False, # 加入下拉菜单中
"Function": HotReload(全项目切换英文) "Function": HotReload(全项目切换英文)
}, },
"[函数插件模板Demo] 历史上的今天": { "[插件demo] 历史上的今天": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效 # HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"Function": HotReload(高阶功能模板函数) "Function": HotReload(高阶功能模板函数)
}, },
@@ -97,7 +128,6 @@ def get_crazy_functions():
from crazy_functions.Latex全文翻译 import Latex中译英 from crazy_functions.Latex全文翻译 import Latex中译英
from crazy_functions.Latex全文翻译 import Latex英译中 from crazy_functions.Latex全文翻译 import Latex英译中
from crazy_functions.批量Markdown翻译 import Markdown中译英 from crazy_functions.批量Markdown翻译 import Markdown中译英
from crazy_functions.批量Markdown翻译 import Markdown英译中
function_plugins.update({ function_plugins.update({
"批量翻译PDF文档多线程": { "批量翻译PDF文档多线程": {
@@ -144,49 +174,67 @@ def get_crazy_functions():
"AsButton": False, # 加入下拉菜单中 "AsButton": False, # 加入下拉菜单中
"Function": HotReload(Latex中文润色) "Function": HotReload(Latex中文润色)
}, },
"[测试功能] Latex项目全文中译英输入路径或上传压缩包": { "Latex项目全文中译英输入路径或上传压缩包": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效 # HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"Color": "stop", "Color": "stop",
"AsButton": False, # 加入下拉菜单中 "AsButton": False, # 加入下拉菜单中
"Function": HotReload(Latex中译英) "Function": HotReload(Latex中译英)
}, },
"[测试功能] Latex项目全文英译中输入路径或上传压缩包": { "Latex项目全文英译中输入路径或上传压缩包": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效 # HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"Color": "stop", "Color": "stop",
"AsButton": False, # 加入下拉菜单中 "AsButton": False, # 加入下拉菜单中
"Function": HotReload(Latex英译中) "Function": HotReload(Latex英译中)
}, },
"[测试功能] 批量Markdown中译英输入路径或上传压缩包": { "批量Markdown中译英输入路径或上传压缩包": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效 # HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"Color": "stop", "Color": "stop",
"AsButton": False, # 加入下拉菜单中 "AsButton": False, # 加入下拉菜单中
"Function": HotReload(Markdown中译英) "Function": HotReload(Markdown中译英)
}, },
"[测试功能] 批量Markdown英译中输入路径或上传压缩包": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"Color": "stop",
"AsButton": False, # 加入下拉菜单中
"Function": HotReload(Markdown英译中)
},
}) })
###################### 第三组插件 ########################### ###################### 第三组插件 ###########################
# [第三组插件]: 尚未充分测试的函数插件,放在这里 # [第三组插件]: 尚未充分测试的函数插件,放在这里
try: from crazy_functions.下载arxiv论文翻译摘要 import 下载arxiv论文并翻译摘要
from crazy_functions.下载arxiv论文翻译摘要 import 下载arxiv论文并翻译摘要 function_plugins.update({
function_plugins.update({ "一键下载arxiv论文并翻译摘要先在input输入编号,如1812.10695": {
"一键下载arxiv论文并翻译摘要先在input输入编号,如1812.10695": { "Color": "stop",
"Color": "stop", "AsButton": False, # 加入下拉菜单中
"AsButton": False, # 加入下拉菜单中 "Function": HotReload(下载arxiv论文并翻译摘要)
"Function": HotReload(下载arxiv论文并翻译摘要) }
} })
})
except Exception as err:
print(f'[下载arxiv论文并翻译摘要] 插件导入失败 {str(err)}')
from crazy_functions.联网的ChatGPT import 连接网络回答问题
function_plugins.update({
"连接网络回答问题(先输入问题,再点击按钮,需要访问谷歌)": {
"Color": "stop",
"AsButton": False, # 加入下拉菜单中
"Function": HotReload(连接网络回答问题)
}
})
from crazy_functions.解析项目源代码 import 解析任意code项目
function_plugins.update({
"解析项目源代码(手动指定和筛选源代码文件类型)": {
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True, # 调用时,唤起高级参数输入区默认False
"ArgsReminder": "输入时用逗号隔开, *代表通配符, 加了^代表不匹配; 不输入代表全部匹配。例如: \"*.c, ^*.cpp, config.toml, ^*.toml\"", # 高级参数输入区的显示提示
"Function": HotReload(解析任意code项目)
},
})
from crazy_functions.询问多个大语言模型 import 同时问询_指定模型
function_plugins.update({
"询问多个GPT模型手动指定询问哪些模型": {
"Color": "stop",
"AsButton": False,
"AdvancedArgs": True, # 调用时,唤起高级参数输入区默认False
"ArgsReminder": "支持任意数量的llm接口,用&符号分隔。例如chatglm&gpt-3.5-turbo&api2d-gpt-4", # 高级参数输入区的显示提示
"Function": HotReload(同时问询_指定模型)
},
})
###################### 第n组插件 ########################### ###################### 第n组插件 ###########################
return function_plugins return function_plugins

查看文件

@@ -12,7 +12,7 @@ def validate_path():
sys.path.append(root_dir_assume) sys.path.append(root_dir_assume)
validate_path() # validate path so you can run from base directory validate_path() # validate path so you can run from base directory
from colorful import *
from toolbox import get_conf, ChatBotWithCookies from toolbox import get_conf, ChatBotWithCookies
proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, CHATBOT_HEIGHT, LAYOUT, API_KEY = \ proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, CHATBOT_HEIGHT, LAYOUT, API_KEY = \
get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'CHATBOT_HEIGHT', 'LAYOUT', 'API_KEY') get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'CHATBOT_HEIGHT', 'LAYOUT', 'API_KEY')
@@ -79,14 +79,52 @@ def test_下载arxiv论文并翻译摘要():
for cookies, cb, hist, msg in 下载arxiv论文并翻译摘要(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port): for cookies, cb, hist, msg in 下载arxiv论文并翻译摘要(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
print(cb) print(cb)
test_解析一个Python项目() def test_联网回答问题():
test_Latex英文润色() from crazy_functions.联网的ChatGPT import 连接网络回答问题
test_Markdown中译英() # txt = "“我们称之为高效”是什么梗?"
test_批量翻译PDF文档() # >> 从第0份、第1份、第2份搜索结果可以看出,“我们称之为高效”是指在游戏社区中,用户们用来形容一些游戏策略或行为非常高效且能够带来好的效果的用语。这个用语最初可能是在群星Stellaris这个游戏里面流行起来的,后来也传播到了其他游戏中,比如巨像Titan等游戏。其中第1份搜索结果中的一篇文章也指出,“我们称之为高效”这 一用语来源于群星Stellaris游戏中的一个情节。
test_谷歌检索小助手() # txt = "为什么说枪毙P社玩家没有一个冤枉的?"
test_总结word文档() # >> 它们都是关于一个知乎用户所发的帖子,引用了一群游戏玩家对于需要对P社玩家进行枪毙的讨论,这个话题的本质是玩家们对于P 社游戏中的政治与历史元素的不同看法,以及其中不少玩家以极端立场宣扬的想法和言论,因此有人就以枪毙这些玩家来回应此类言论。但是这个话题本身并没有实质内容,只是一个玩笑或者恶搞,并不应该被当做真实的态度或者观点,因此这种说法没有实际意义。
test_下载arxiv论文并翻译摘要() # txt = "谁是应急食品?"
test_解析一个Cpp项目() # >> '根据以上搜索结果可以得知,应急食品是“原神”游戏中的角色派蒙的外号。'
# txt = "道路千万条,安全第一条。后面两句是?"
# >> '行车不规范,亲人两行泪。'
# txt = "What is in the canister?"
# >> Rainbow Six Siege 游戏中 Smoke 的 Canister 中装有何种物质相关的官方信息。
# txt = "失败的man是什么?"
# >> 根据第1份搜索结果,可以得知失败的man是指一位在B站购买了蜘蛛侠COS服后穿上后被网友嘲笑的UP主,而“失败的man”是蜘蛛侠英文名“spiderman”的谐音梗,并且网友们还 给这位UP主起了“苍蝇侠”的外号。因此,失败的man是指这位UP主在穿上蜘蛛侠COS服后被网友嘲笑的情况。
# txt = "老六是什么,起源于哪里?"
# >> 老六是网络流行语,最初起源于游戏《CSGO》,指游戏中玩家中独来独往、游离于队伍之外的“自由人”或玩得比较菜或者玩得比较阴险的人 ,后来逐渐演变成指玩得比较阴险的玩家。
# txt = "罗小黑战记因为什么经常被吐槽?"
# >> 3. 更新速度。罗小黑战记的更新时间不定,时而快时而慢,给观众留下了等待的时间过长的印象。
# txt = "沙特、伊朗最近的关系如何?"
# >> 最近在中国的斡旋下,沙特和伊朗于3月10日达成了恢复两国外交关系的协议,这表明两国关系已经重新回到正常化状态。
# txt = "You should have gone for the head. What does that mean?"
# >> The phrase "You should have gone for the head" is a quote from the Marvel movies, Avengers: Infinity War and Avengers: Endgame. It was spoken by the character Thanos in Infinity War and by Thor in Endgame.
txt = "AutoGPT是什么?"
# >> AutoGPT是一个基于GPT-4语言模型的开源应用程序。它可以根据用户需求自主执行任务,包括事件分析、营销方案撰写、代码编程、数学运算等等,并完全不需要用户插手。它可以自己思考,给出实现的步骤和实现细节,甚至可以自问自答执 行任务。最近它在GitHub上爆火,成为了业内最热门的项目之一。
# txt = "钟离带什么圣遗物?"
for cookies, cb, hist, msg in 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
print("当前问答:", cb[-1][-1].replace("\n"," "))
for i, it in enumerate(cb): print亮蓝(it[0]); print亮黄(it[1])
def test_解析ipynb文件():
from crazy_functions.解析JupyterNotebook import 解析ipynb文件
txt = "crazy_functions/test_samples"
for cookies, cb, hist, msg in 解析ipynb文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
print(cb)
# test_解析一个Python项目()
# test_Latex英文润色()
# test_Markdown中译英()
# test_批量翻译PDF文档()
# test_谷歌检索小助手()
# test_总结word文档()
# test_下载arxiv论文并翻译摘要()
# test_解析一个Cpp项目()
# test_联网回答问题()
test_解析ipynb文件()
input("程序完成,回车退出。") input("程序完成,回车退出。")
print("退出。") print("退出。")

查看文件

@@ -1,5 +1,4 @@
import traceback from toolbox import update_ui, get_conf, trimmed_format_exc
from toolbox import update_ui, get_conf
def input_clipping(inputs, history, max_token_limit): def input_clipping(inputs, history, max_token_limit):
import numpy as np import numpy as np
@@ -94,12 +93,12 @@ def request_gpt_model_in_new_thread_with_ui_alive(
continue # 返回重试 continue # 返回重试
else: else:
# 【选择放弃】 # 【选择放弃】
tb_str = '```\n' + traceback.format_exc() + '```' tb_str = '```\n' + trimmed_format_exc() + '```'
mutable[0] += f"[Local Message] 警告,在执行过程中遭遇问题, Traceback\n\n{tb_str}\n\n" mutable[0] += f"[Local Message] 警告,在执行过程中遭遇问题, Traceback\n\n{tb_str}\n\n"
return mutable[0] # 放弃 return mutable[0] # 放弃
except: except:
# 【第三种情况】:其他错误:重试几次 # 【第三种情况】:其他错误:重试几次
tb_str = '```\n' + traceback.format_exc() + '```' tb_str = '```\n' + trimmed_format_exc() + '```'
print(tb_str) print(tb_str)
mutable[0] += f"[Local Message] 警告,在执行过程中遭遇问题, Traceback\n\n{tb_str}\n\n" mutable[0] += f"[Local Message] 警告,在执行过程中遭遇问题, Traceback\n\n{tb_str}\n\n"
if retry_op > 0: if retry_op > 0:
@@ -173,7 +172,7 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
if max_workers == -1: # 读取配置文件 if max_workers == -1: # 读取配置文件
try: max_workers, = get_conf('DEFAULT_WORKER_NUM') try: max_workers, = get_conf('DEFAULT_WORKER_NUM')
except: max_workers = 8 except: max_workers = 8
if max_workers <= 0 or max_workers >= 20: max_workers = 8 if max_workers <= 0: max_workers = 3
# 屏蔽掉 chatglm的多线程,可能会导致严重卡顿 # 屏蔽掉 chatglm的多线程,可能会导致严重卡顿
if not (llm_kwargs['llm_model'].startswith('gpt-') or llm_kwargs['llm_model'].startswith('api2d-')): if not (llm_kwargs['llm_model'].startswith('gpt-') or llm_kwargs['llm_model'].startswith('api2d-')):
max_workers = 1 max_workers = 1
@@ -220,14 +219,14 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
continue # 返回重试 continue # 返回重试
else: else:
# 【选择放弃】 # 【选择放弃】
tb_str = '```\n' + traceback.format_exc() + '```' tb_str = '```\n' + trimmed_format_exc() + '```'
gpt_say += f"[Local Message] 警告,线程{index}在执行过程中遭遇问题, Traceback\n\n{tb_str}\n\n" gpt_say += f"[Local Message] 警告,线程{index}在执行过程中遭遇问题, Traceback\n\n{tb_str}\n\n"
if len(mutable[index][0]) > 0: gpt_say += "此线程失败前收到的回答:\n\n" + mutable[index][0] if len(mutable[index][0]) > 0: gpt_say += "此线程失败前收到的回答:\n\n" + mutable[index][0]
mutable[index][2] = "输入过长已放弃" mutable[index][2] = "输入过长已放弃"
return gpt_say # 放弃 return gpt_say # 放弃
except: except:
# 【第三种情况】:其他错误 # 【第三种情况】:其他错误
tb_str = '```\n' + traceback.format_exc() + '```' tb_str = '```\n' + trimmed_format_exc() + '```'
print(tb_str) print(tb_str)
gpt_say += f"[Local Message] 警告,线程{index}在执行过程中遭遇问题, Traceback\n\n{tb_str}\n\n" gpt_say += f"[Local Message] 警告,线程{index}在执行过程中遭遇问题, Traceback\n\n{tb_str}\n\n"
if len(mutable[index][0]) > 0: gpt_say += "此线程失败前收到的回答:\n\n" + mutable[index][0] if len(mutable[index][0]) > 0: gpt_say += "此线程失败前收到的回答:\n\n" + mutable[index][0]
@@ -564,3 +563,46 @@ def read_and_clean_pdf_text(fp):
# print亮绿('***************************') # print亮绿('***************************')
return meta_txt, page_one_meta return meta_txt, page_one_meta
def get_files_from_everything(txt, type): # type='.md'
"""
这个函数是用来获取指定目录下所有指定类型(如.md的文件,并且对于网络上的文件,也可以获取它。
下面是对每个参数和返回值的说明:
参数
- txt: 路径或网址,表示要搜索的文件或者文件夹路径或网络上的文件。
- type: 字符串,表示要搜索的文件类型。默认是.md。
返回值
- success: 布尔值,表示函数是否成功执行。
- file_manifest: 文件路径列表,里面包含以指定类型为后缀名的所有文件的绝对路径。
- project_folder: 字符串,表示文件所在的文件夹路径。如果是网络上的文件,就是临时文件夹的路径。
该函数详细注释已添加,请确认是否满足您的需要。
"""
import glob, os
success = True
if txt.startswith('http'):
# 网络的远程文件
import requests
from toolbox import get_conf
proxies, = get_conf('proxies')
r = requests.get(txt, proxies=proxies)
with open('./gpt_log/temp'+type, 'wb+') as f: f.write(r.content)
project_folder = './gpt_log/'
file_manifest = ['./gpt_log/temp'+type]
elif txt.endswith(type):
# 直接给定文件
file_manifest = [txt]
project_folder = os.path.dirname(txt)
elif os.path.exists(txt):
# 本地路径,递归搜索
project_folder = txt
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*'+type, recursive=True)]
if len(file_manifest) == 0:
success = False
else:
project_folder = None
file_manifest = []
success = False
return success, file_manifest, project_folder

查看文件

@@ -0,0 +1,143 @@
from toolbox import CatchException, update_ui
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
import re
def write_chat_to_file(chatbot, history=None, file_name=None):
"""
将对话记录history以Markdown格式写入文件中。如果没有指定文件名,则使用当前时间生成文件名。
"""
import os
import time
if file_name is None:
file_name = 'chatGPT对话历史' + time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + '.html'
os.makedirs('./gpt_log/', exist_ok=True)
with open(f'./gpt_log/{file_name}', 'w', encoding='utf8') as f:
from theme import advanced_css
f.write(f'<!DOCTYPE html><head><meta charset="utf-8"><title>对话历史</title><style>{advanced_css}</style></head>')
for i, contents in enumerate(chatbot):
for j, content in enumerate(contents):
try: # 这个bug没找到触发条件,暂时先这样顶一下
if type(content) != str: content = str(content)
except:
continue
f.write(content)
if j == 0:
f.write('<hr style="border-top: dotted 3px #ccc;">')
f.write('<hr color="red"> \n\n')
f.write('<hr color="blue"> \n\n raw chat context:\n')
f.write('<code>')
for h in history:
f.write("\n>>>" + h)
f.write('</code>')
res = '对话历史写入:' + os.path.abspath(f'./gpt_log/{file_name}')
print(res)
return res
def gen_file_preview(file_name):
try:
with open(file_name, 'r', encoding='utf8') as f:
file_content = f.read()
# pattern to match the text between <head> and </head>
pattern = re.compile(r'<head>.*?</head>', flags=re.DOTALL)
file_content = re.sub(pattern, '', file_content)
html, history = file_content.split('<hr color="blue"> \n\n raw chat context:\n')
history = history.strip('<code>')
history = history.strip('</code>')
history = history.split("\n>>>")
return list(filter(lambda x:x!="", history))[0][:100]
except:
return ""
def read_file_to_chat(chatbot, history, file_name):
with open(file_name, 'r', encoding='utf8') as f:
file_content = f.read()
# pattern to match the text between <head> and </head>
pattern = re.compile(r'<head>.*?</head>', flags=re.DOTALL)
file_content = re.sub(pattern, '', file_content)
html, history = file_content.split('<hr color="blue"> \n\n raw chat context:\n')
history = history.strip('<code>')
history = history.strip('</code>')
history = history.split("\n>>>")
history = list(filter(lambda x:x!="", history))
html = html.split('<hr color="red"> \n\n')
html = list(filter(lambda x:x!="", html))
chatbot.clear()
for i, h in enumerate(html):
i_say, gpt_say = h.split('<hr style="border-top: dotted 3px #ccc;">')
chatbot.append([i_say, gpt_say])
chatbot.append([f"存档文件详情?", f"[Local Message] 载入对话{len(html)}条,上下文{len(history)}条。"])
return chatbot, history
@CatchException
def 对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
"""
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
plugin_kwargs 插件模型的参数,暂时没有用武之地
chatbot 聊天显示框的句柄,用于显示给用户
history 聊天历史,前情提要
system_prompt 给gpt的静默提醒
web_port 当前软件运行的端口号
"""
chatbot.append(("保存当前对话",
f"[Local Message] {write_chat_to_file(chatbot, history)},您可以调用“载入对话历史存档”还原当下的对话。\n警告!被保存的对话历史可以被使用该系统的任何人查阅。"))
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
def hide_cwd(str):
import os
current_path = os.getcwd()
replace_path = "."
return str.replace(current_path, replace_path)
@CatchException
def 载入对话历史存档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
"""
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
plugin_kwargs 插件模型的参数,暂时没有用武之地
chatbot 聊天显示框的句柄,用于显示给用户
history 聊天历史,前情提要
system_prompt 给gpt的静默提醒
web_port 当前软件运行的端口号
"""
from .crazy_utils import get_files_from_everything
success, file_manifest, _ = get_files_from_everything(txt, type='.html')
if not success:
if txt == "": txt = '空空如也的输入栏'
import glob
local_history = "<br/>".join(["`"+hide_cwd(f)+f" ({gen_file_preview(f)})"+"`" for f in glob.glob(f'gpt_log/**/chatGPT对话历史*.html', recursive=True)])
chatbot.append([f"正在查找对话历史文件html格式: {txt}", f"找不到任何html文件: {txt}。但本地存储了以下历史文件,您可以将任意一个文件路径粘贴到输入区,然后重试:<br/>{local_history}"])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
try:
chatbot, history = read_file_to_chat(chatbot, history, file_manifest[0])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
except:
chatbot.append([f"载入对话历史文件", f"对话历史文件损坏!"])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
@CatchException
def 删除所有本地对话历史记录(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
"""
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
plugin_kwargs 插件模型的参数,暂时没有用武之地
chatbot 聊天显示框的句柄,用于显示给用户
history 聊天历史,前情提要
system_prompt 给gpt的静默提醒
web_port 当前软件运行的端口号
"""
import glob, os
local_history = "<br/>".join(["`"+hide_cwd(f)+"`" for f in glob.glob(f'gpt_log/**/chatGPT对话历史*.html', recursive=True)])
for f in glob.glob(f'gpt_log/**/chatGPT对话历史*.html', recursive=True):
os.remove(f)
chatbot.append([f"删除所有历史对话文件", f"已删除<br/>{local_history}"])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return

查看文件

@@ -50,7 +50,7 @@ def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
pfg.file_contents.append(file_content) pfg.file_contents.append(file_content)
# <-------- 拆分过长的Markdown文件 ----------> # <-------- 拆分过长的Markdown文件 ---------->
pfg.run_file_split(max_token_limit=2048) pfg.run_file_split(max_token_limit=1500)
n_split = len(pfg.sp_file_contents) n_split = len(pfg.sp_file_contents)
# <-------- 多线程润色开始 ----------> # <-------- 多线程润色开始 ---------->
@@ -84,7 +84,33 @@ def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
def get_files_from_everything(txt):
import glob, os
success = True
if txt.startswith('http'):
# 网络的远程文件
txt = txt.replace("https://github.com/", "https://raw.githubusercontent.com/")
txt = txt.replace("/blob/", "/")
import requests
from toolbox import get_conf
proxies, = get_conf('proxies')
r = requests.get(txt, proxies=proxies)
with open('./gpt_log/temp.md', 'wb+') as f: f.write(r.content)
project_folder = './gpt_log/'
file_manifest = ['./gpt_log/temp.md']
elif txt.endswith('.md'):
# 直接给定文件
file_manifest = [txt]
project_folder = os.path.dirname(txt)
elif os.path.exists(txt):
# 本地路径,递归搜索
project_folder = txt
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.md', recursive=True)]
else:
success = False
return success, file_manifest, project_folder
@CatchException @CatchException
@@ -98,6 +124,7 @@ def Markdown英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
# 尝试导入依赖,如果缺少依赖,则给出安装建议 # 尝试导入依赖,如果缺少依赖,则给出安装建议
try: try:
import tiktoken import tiktoken
import glob, os
except: except:
report_execption(chatbot, history, report_execption(chatbot, history,
a=f"解析项目: {txt}", a=f"解析项目: {txt}",
@@ -105,19 +132,21 @@ def Markdown英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return return
history = [] # 清空历史,以免输入溢出 history = [] # 清空历史,以免输入溢出
import glob, os
if os.path.exists(txt): success, file_manifest, project_folder = get_files_from_everything(txt)
project_folder = txt
else: if not success:
# 什么都没有
if txt == "": txt = '空空如也的输入栏' if txt == "": txt = '空空如也的输入栏'
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}") report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return return
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.md', recursive=True)]
if len(file_manifest) == 0: if len(file_manifest) == 0:
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}") report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return return
yield from 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, language='en->zh') yield from 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, language='en->zh')
@@ -135,6 +164,7 @@ def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
# 尝试导入依赖,如果缺少依赖,则给出安装建议 # 尝试导入依赖,如果缺少依赖,则给出安装建议
try: try:
import tiktoken import tiktoken
import glob, os
except: except:
report_execption(chatbot, history, report_execption(chatbot, history,
a=f"解析项目: {txt}", a=f"解析项目: {txt}",
@@ -142,18 +172,13 @@ def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_p
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return return
history = [] # 清空历史,以免输入溢出 history = [] # 清空历史,以免输入溢出
import glob, os success, file_manifest, project_folder = get_files_from_everything(txt)
if os.path.exists(txt): if not success:
project_folder = txt # 什么都没有
else:
if txt == "": txt = '空空如也的输入栏' if txt == "": txt = '空空如也的输入栏'
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}") report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return return
if txt.endswith('.md'):
file_manifest = [txt]
else:
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.md', recursive=True)]
if len(file_manifest) == 0: if len(file_manifest) == 0:
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}") report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面

查看文件

@@ -0,0 +1,102 @@
from toolbox import CatchException, update_ui
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive, input_clipping
import requests
from bs4 import BeautifulSoup
from request_llm.bridge_all import model_info
def google(query, proxies):
query = query # 在此处替换您要搜索的关键词
url = f"https://www.google.com/search?q={query}"
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36'}
response = requests.get(url, headers=headers, proxies=proxies)
soup = BeautifulSoup(response.content, 'html.parser')
results = []
for g in soup.find_all('div', class_='g'):
anchors = g.find_all('a')
if anchors:
link = anchors[0]['href']
if link.startswith('/url?q='):
link = link[7:]
if not link.startswith('http'):
continue
title = g.find('h3').text
item = {'title': title, 'link': link}
results.append(item)
for r in results:
print(r['link'])
return results
def scrape_text(url, proxies) -> str:
"""Scrape text from a webpage
Args:
url (str): The URL to scrape text from
Returns:
str: The scraped text
"""
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36',
'Content-Type': 'text/plain',
}
try:
response = requests.get(url, headers=headers, proxies=proxies, timeout=8)
if response.encoding == "ISO-8859-1": response.encoding = response.apparent_encoding
except:
return "无法连接到该网页"
soup = BeautifulSoup(response.text, "html.parser")
for script in soup(["script", "style"]):
script.extract()
text = soup.get_text()
lines = (line.strip() for line in text.splitlines())
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
text = "\n".join(chunk for chunk in chunks if chunk)
return text
@CatchException
def 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
"""
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
plugin_kwargs 插件模型的参数,暂时没有用武之地
chatbot 聊天显示框的句柄,用于显示给用户
history 聊天历史,前情提要
system_prompt 给gpt的静默提醒
web_port 当前软件运行的端口号
"""
history = [] # 清空历史,以免输入溢出
chatbot.append((f"请结合互联网信息回答以下问题:{txt}",
"[Local Message] 请注意,您正在调用一个[函数插件]的模板,该模板可以实现ChatGPT联网信息综合。该函数面向希望实现更多有趣功能的开发者,它可以作为创建新功能函数的模板。您若希望分享新的功能模组,请不吝PR"))
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
# ------------- < 第1步爬取搜索引擎的结果 > -------------
from toolbox import get_conf
proxies, = get_conf('proxies')
urls = google(txt, proxies)
history = []
# ------------- < 第2步依次访问网页 > -------------
max_search_result = 5 # 最多收纳多少个网页的结果
for index, url in enumerate(urls[:max_search_result]):
res = scrape_text(url['link'], proxies)
history.extend([f"{index}份搜索结果:", res])
chatbot.append([f"{index}份搜索结果:", res[:500]+"......"])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
# ------------- < 第3步ChatGPT综合 > -------------
i_say = f"从以上搜索结果中抽取信息,然后回答问题:{txt}"
i_say, history = input_clipping( # 裁剪输入,从最长的条目开始裁剪,防止爆token
inputs=i_say,
history=history,
max_token_limit=model_info[llm_kwargs['llm_model']]['max_token']*3//4
)
gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
inputs=i_say, inputs_show_user=i_say,
llm_kwargs=llm_kwargs, chatbot=chatbot, history=history,
sys_prompt="请从给定的若干条搜索结果中抽取信息,对最相关的两个搜索结果进行总结,然后回答问题。"
)
chatbot[-1] = (i_say, gpt_say)
history.append(i_say);history.append(gpt_say)
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新

查看文件

@@ -0,0 +1,145 @@
from toolbox import update_ui
from toolbox import CatchException, report_execption, write_results_to_file
fast_debug = True
class PaperFileGroup():
def __init__(self):
self.file_paths = []
self.file_contents = []
self.sp_file_contents = []
self.sp_file_index = []
self.sp_file_tag = []
# count_token
from request_llm.bridge_all import model_info
enc = model_info["gpt-3.5-turbo"]['tokenizer']
def get_token_num(txt): return len(
enc.encode(txt, disallowed_special=()))
self.get_token_num = get_token_num
def run_file_split(self, max_token_limit=1900):
"""
将长文本分离开来
"""
for index, file_content in enumerate(self.file_contents):
if self.get_token_num(file_content) < max_token_limit:
self.sp_file_contents.append(file_content)
self.sp_file_index.append(index)
self.sp_file_tag.append(self.file_paths[index])
else:
from .crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf
segments = breakdown_txt_to_satisfy_token_limit_for_pdf(
file_content, self.get_token_num, max_token_limit)
for j, segment in enumerate(segments):
self.sp_file_contents.append(segment)
self.sp_file_index.append(index)
self.sp_file_tag.append(
self.file_paths[index] + f".part-{j}.txt")
def parseNotebook(filename, enable_markdown=1):
import json
CodeBlocks = []
with open(filename, 'r', encoding='utf-8', errors='replace') as f:
notebook = json.load(f)
for cell in notebook['cells']:
if cell['cell_type'] == 'code' and cell['source']:
# remove blank lines
cell['source'] = [line for line in cell['source'] if line.strip()
!= '']
CodeBlocks.append("".join(cell['source']))
elif enable_markdown and cell['cell_type'] == 'markdown' and cell['source']:
cell['source'] = [line for line in cell['source'] if line.strip()
!= '']
CodeBlocks.append("Markdown:"+"".join(cell['source']))
Code = ""
for idx, code in enumerate(CodeBlocks):
Code += f"This is {idx+1}th code block: \n"
Code += code+"\n"
return Code
def ipynb解释(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt):
from .crazy_utils import request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency
enable_markdown = plugin_kwargs.get("advanced_arg", "1")
try:
enable_markdown = int(enable_markdown)
except ValueError:
enable_markdown = 1
pfg = PaperFileGroup()
for fp in file_manifest:
file_content = parseNotebook(fp, enable_markdown=enable_markdown)
pfg.file_paths.append(fp)
pfg.file_contents.append(file_content)
# <-------- 拆分过长的IPynb文件 ---------->
pfg.run_file_split(max_token_limit=1024)
n_split = len(pfg.sp_file_contents)
inputs_array = [r"This is a Jupyter Notebook file, tell me about Each Block in Chinese. Focus Just On Code." +
r"If a block starts with `Markdown` which means it's a markdown block in ipynbipynb. " +
r"Start a new line for a block and block num use Chinese." +
f"\n\n{frag}" for frag in pfg.sp_file_contents]
inputs_show_user_array = [f"{f}的分析如下" for f in pfg.sp_file_tag]
sys_prompt_array = ["You are a professional programmer."] * n_split
gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
inputs_array=inputs_array,
inputs_show_user_array=inputs_show_user_array,
llm_kwargs=llm_kwargs,
chatbot=chatbot,
history_array=[[""] for _ in range(n_split)],
sys_prompt_array=sys_prompt_array,
# max_workers=5, # OpenAI所允许的最大并行过载
scroller_max_len=80
)
# <-------- 整理结果,退出 ---------->
block_result = " \n".join(gpt_response_collection)
chatbot.append(("解析的结果如下", block_result))
history.extend(["解析的结果如下", block_result])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
# <-------- 写入文件,退出 ---------->
res = write_results_to_file(history)
chatbot.append(("完成了吗?", res))
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
@CatchException
def 解析ipynb文件(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
chatbot.append([
"函数插件功能?",
"对IPynb文件进行解析。Contributor: codycjy."])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
history = [] # 清空历史
import glob
import os
if os.path.exists(txt):
project_folder = txt
else:
if txt == "":
txt = '空空如也的输入栏'
report_execption(chatbot, history,
a=f"解析项目: {txt}", b=f"找不到本地项目或无权访问: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
if txt.endswith('.ipynb'):
file_manifest = [txt]
else:
file_manifest = [f for f in glob.glob(
f'{project_folder}/**/*.ipynb', recursive=True)]
if len(file_manifest) == 0:
report_execption(chatbot, history,
a=f"解析项目: {txt}", b=f"找不到任何.ipynb文件: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
yield from ipynb解释(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, )

查看文件

@@ -1,5 +1,6 @@
from toolbox import update_ui from toolbox import update_ui
from toolbox import CatchException, report_execption, write_results_to_file from toolbox import CatchException, report_execption, write_results_to_file
from .crazy_utils import input_clipping
def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt): def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt):
import os, copy import os, copy
@@ -11,7 +12,7 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
history_array = [] history_array = []
sys_prompt_array = [] sys_prompt_array = []
report_part_1 = [] report_part_1 = []
assert len(file_manifest) <= 512, "源文件太多超过512个, 请缩减输入文件的数量。或者,您也可以选择删除此行警告,并修改代码拆分file_manifest列表,从而实现分批次处理。" assert len(file_manifest) <= 512, "源文件太多超过512个, 请缩减输入文件的数量。或者,您也可以选择删除此行警告,并修改代码拆分file_manifest列表,从而实现分批次处理。"
############################## <第一步,逐个文件分析,多线程> ################################## ############################## <第一步,逐个文件分析,多线程> ##################################
for index, fp in enumerate(file_manifest): for index, fp in enumerate(file_manifest):
@@ -61,13 +62,15 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
previous_iteration_files.extend([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)]) previous_iteration_files.extend([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
previous_iteration_files_string = ', '.join(previous_iteration_files) previous_iteration_files_string = ', '.join(previous_iteration_files)
current_iteration_focus = ', '.join([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)]) current_iteration_focus = ', '.join([os.path.relpath(fp, project_folder) for index, fp in enumerate(this_iteration_file_manifest)])
i_say = f'根据以上分析,对程序的整体功能和构架重新做出概括。然后用一张markdown表格整理每个文件的功能(包括{previous_iteration_files_string}' i_say = f'用一张Markdown表格简要描述以下文件的功能{previous_iteration_files_string}。根据以上分析,用一句话概括程序的整体功能'
inputs_show_user = f'根据以上分析,对程序的整体功能和构架重新做出概括,由于输入长度限制,可能需要分组处理,本组文件为 {current_iteration_focus} + 已经汇总的文件组。' inputs_show_user = f'根据以上分析,对程序的整体功能和构架重新做出概括,由于输入长度限制,可能需要分组处理,本组文件为 {current_iteration_focus} + 已经汇总的文件组。'
this_iteration_history = copy.deepcopy(this_iteration_gpt_response_collection) this_iteration_history = copy.deepcopy(this_iteration_gpt_response_collection)
this_iteration_history.append(last_iteration_result) this_iteration_history.append(last_iteration_result)
# 裁剪input
inputs, this_iteration_history_feed = input_clipping(inputs=i_say, history=this_iteration_history, max_token_limit=2560)
result = yield from request_gpt_model_in_new_thread_with_ui_alive( result = yield from request_gpt_model_in_new_thread_with_ui_alive(
inputs=i_say, inputs_show_user=inputs_show_user, llm_kwargs=llm_kwargs, chatbot=chatbot, inputs=inputs, inputs_show_user=inputs_show_user, llm_kwargs=llm_kwargs, chatbot=chatbot,
history=this_iteration_history, # 迭代之前的分析 history=this_iteration_history_feed, # 迭代之前的分析
sys_prompt="你是一个程序架构分析师,正在分析一个项目的源代码。") sys_prompt="你是一个程序架构分析师,正在分析一个项目的源代码。")
report_part_2.extend([i_say, result]) report_part_2.extend([i_say, result])
last_iteration_result = result last_iteration_result = result
@@ -180,7 +183,7 @@ def 解析一个Java项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys
@CatchException @CatchException
def 解析一个Rect项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port): def 解析一个前端项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
history = [] # 清空历史,以免输入溢出 history = [] # 清空历史,以免输入溢出
import glob, os import glob, os
if os.path.exists(txt): if os.path.exists(txt):
@@ -194,9 +197,15 @@ def 解析一个Rect项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys
[f for f in glob.glob(f'{project_folder}/**/*.tsx', recursive=True)] + \ [f for f in glob.glob(f'{project_folder}/**/*.tsx', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.json', recursive=True)] + \ [f for f in glob.glob(f'{project_folder}/**/*.json', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.js', recursive=True)] + \ [f for f in glob.glob(f'{project_folder}/**/*.js', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.vue', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.less', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.sass', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.wxml', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.wxss', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.css', recursive=True)] + \
[f for f in glob.glob(f'{project_folder}/**/*.jsx', recursive=True)] [f for f in glob.glob(f'{project_folder}/**/*.jsx', recursive=True)]
if len(file_manifest) == 0: if len(file_manifest) == 0:
report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何Rect文件: {txt}") report_execption(chatbot, history, a=f"解析项目: {txt}", b=f"找不到任何前端相关文件: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return return
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt) yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
@@ -222,8 +231,8 @@ def 解析一个Golang项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return return
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt) yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
@CatchException @CatchException
def 解析一个Lua项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port): def 解析一个Lua项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
history = [] # 清空历史,以免输入溢出 history = [] # 清空历史,以免输入溢出
@@ -243,9 +252,9 @@ def 解析一个Lua项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何lua文件: {txt}") report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何lua文件: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return return
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt) yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
@CatchException @CatchException
def 解析一个CSharp项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port): def 解析一个CSharp项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
history = [] # 清空历史,以免输入溢出 history = [] # 清空历史,以免输入溢出
@@ -263,4 +272,45 @@ def 解析一个CSharp项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, s
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何CSharp文件: {txt}") report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何CSharp文件: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return return
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt) yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)
@CatchException
def 解析任意code项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
txt_pattern = plugin_kwargs.get("advanced_arg")
txt_pattern = txt_pattern.replace("", ",")
# 将要匹配的模式(例如: *.c, *.cpp, *.py, config.toml)
pattern_include = [_.lstrip(" ,").rstrip(" ,") for _ in txt_pattern.split(",") if _ != "" and not _.strip().startswith("^")]
if not pattern_include: pattern_include = ["*"] # 不输入即全部匹配
# 将要忽略匹配的文件后缀(例如: ^*.c, ^*.cpp, ^*.py)
pattern_except_suffix = [_.lstrip(" ^*.,").rstrip(" ,") for _ in txt_pattern.split(" ") if _ != "" and _.strip().startswith("^*.")]
pattern_except_suffix += ['zip', 'rar', '7z', 'tar', 'gz'] # 避免解析压缩文件
# 将要忽略匹配的文件名(例如: ^README.md)
pattern_except_name = [_.lstrip(" ^*,").rstrip(" ,").replace(".", "\.") for _ in txt_pattern.split(" ") if _ != "" and _.strip().startswith("^") and not _.strip().startswith("^*.")]
# 生成正则表达式
pattern_except = '/[^/]+\.(' + "|".join(pattern_except_suffix) + ')$'
pattern_except += '|/(' + "|".join(pattern_except_name) + ')$' if pattern_except_name != [] else ''
history.clear()
import glob, os, re
if os.path.exists(txt):
project_folder = txt
else:
if txt == "": txt = '空空如也的输入栏'
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到本地项目或无权访问: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
# 若上传压缩文件, 先寻找到解压的文件夹路径, 从而避免解析压缩文件
maybe_dir = [f for f in glob.glob(f'{project_folder}/*') if os.path.isdir(f)]
if len(maybe_dir)>0 and maybe_dir[0].endswith('.extract'):
extract_folder_path = maybe_dir[0]
else:
extract_folder_path = project_folder
# 按输入的匹配模式寻找上传的非压缩文件和已解压的文件
file_manifest = [f for pattern in pattern_include for f in glob.glob(f'{extract_folder_path}/**/{pattern}', recursive=True) if "" != extract_folder_path and \
os.path.isfile(f) and (not re.search(pattern_except, f) or pattern.endswith('.' + re.search(pattern_except, f).group().split('.')[-1]))]
if len(file_manifest) == 0:
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何文件: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
yield from 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt)

查看文件

@@ -25,6 +25,35 @@ def 同时问询(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
retry_times_at_unknown_error=0 retry_times_at_unknown_error=0
) )
history.append(txt)
history.append(gpt_say)
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新
@CatchException
def 同时问询_指定模型(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
"""
txt 输入栏用户输入的文本,例如需要翻译的一段话,再例如一个包含了待处理文件的路径
llm_kwargs gpt模型参数,如温度和top_p等,一般原样传递下去就行
plugin_kwargs 插件模型的参数,如温度和top_p等,一般原样传递下去就行
chatbot 聊天显示框的句柄,用于显示给用户
history 聊天历史,前情提要
system_prompt 给gpt的静默提醒
web_port 当前软件运行的端口号
"""
history = [] # 清空历史,以免输入溢出
chatbot.append((txt, "正在同时咨询ChatGPT和ChatGLM……"))
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
# llm_kwargs['llm_model'] = 'chatglm&gpt-3.5-turbo&api2d-gpt-3.5-turbo' # 支持任意数量的llm接口,用&符号分隔
llm_kwargs['llm_model'] = plugin_kwargs.get("advanced_arg", 'chatglm&gpt-3.5-turbo') # 'chatglm&gpt-3.5-turbo' # 支持任意数量的llm接口,用&符号分隔
gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
inputs=txt, inputs_show_user=txt,
llm_kwargs=llm_kwargs, chatbot=chatbot, history=history,
sys_prompt=system_prompt,
retry_times_at_unknown_error=0
)
history.append(txt) history.append(txt)
history.append(gpt_say) history.append(gpt_say)
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新 yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 界面更新

查看文件

@@ -70,6 +70,7 @@ def 谷歌检索小助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
# 尝试导入依赖,如果缺少依赖,则给出安装建议 # 尝试导入依赖,如果缺少依赖,则给出安装建议
try: try:
import arxiv import arxiv
import math
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
except: except:
report_execption(chatbot, history, report_execption(chatbot, history,
@@ -80,25 +81,26 @@ def 谷歌检索小助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, syst
# 清空历史,以免输入溢出 # 清空历史,以免输入溢出
history = [] history = []
meta_paper_info_list = yield from get_meta_information(txt, chatbot, history) meta_paper_info_list = yield from get_meta_information(txt, chatbot, history)
batchsize = 5
for batch in range(math.ceil(len(meta_paper_info_list)/batchsize)):
if len(meta_paper_info_list[:batchsize]) > 0:
i_say = "下面是一些学术文献的数据,提取出以下内容:" + \
"1、英文题目;2、中文题目翻译;3、作者;4、arxiv公开is_paper_in_arxiv;4、引用数量cite;5、中文摘要翻译。" + \
f"以下是信息源:{str(meta_paper_info_list[:batchsize])}"
if len(meta_paper_info_list[:10]) > 0: inputs_show_user = f"请分析此页面中出现的所有文章:{txt},这是第{batch+1}"
i_say = "下面是一些学术文献的数据,请从中提取出以下内容。" + \ gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
"1、英文题目;2、中文题目翻译;3、作者;4、arxiv公开is_paper_in_arxiv;4、引用数量cite;5、中文摘要翻译。" + \ inputs=i_say, inputs_show_user=inputs_show_user,
f"以下是信息源:{str(meta_paper_info_list[:10])}" llm_kwargs=llm_kwargs, chatbot=chatbot, history=[],
sys_prompt="你是一个学术翻译,请从数据中提取信息。你必须使用Markdown表格。你必须逐个文献进行处理。"
)
inputs_show_user = f"请分析此页面中出现的所有文章:{txt}" history.extend([ f"{batch+1}", gpt_say ])
gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive( meta_paper_info_list = meta_paper_info_list[batchsize:]
inputs=i_say, inputs_show_user=inputs_show_user,
llm_kwargs=llm_kwargs, chatbot=chatbot, history=[],
sys_prompt="你是一个学术翻译,请从数据中提取信息。你必须使用Markdown格式。你必须逐个文献进行处理。"
)
history.extend([ "第一批", gpt_say ]) chatbot.append(["状态?",
meta_paper_info_list = meta_paper_info_list[10:] "已经全部完成,您可以试试让AI写一个Related Works,例如您可以继续输入Write a \"Related Works\" section about \"你搜索的研究领域\" for me."])
chatbot.append(["状态?", "已经全部完成"])
msg = '正常' msg = '正常'
yield from update_ui(chatbot=chatbot, history=history, msg=msg) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history, msg=msg) # 刷新界面
res = write_results_to_file(history) res = write_results_to_file(history)

121
docker-compose.yml 普通文件
查看文件

@@ -0,0 +1,121 @@
【请修改完参数后,删除此行】请在以下方案中选择一种,然后删除其他的方案,最后docker-compose up运行 | Please choose from one of these options below, delete other options as well as This Line
## ===================================================
## 【方案一】 如果不需要运行本地模型仅chatgpt类远程服务
## ===================================================
version: '3'
services:
gpt_academic_nolocalllms:
image: fuqingxu/gpt_academic:no-local-llms
environment:
# 请查阅 `config.py` 以查看所有的配置信息
API_KEY: ' sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,fkxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx '
USE_PROXY: ' True '
proxies: ' { "http": "socks5h://localhost:10880", "https": "socks5h://localhost:10880", } '
LLM_MODEL: ' gpt-3.5-turbo '
AVAIL_LLM_MODELS: ' ["gpt-3.5-turbo", "api2d-gpt-4"] '
DEFAULT_WORKER_NUM: ' 10 '
WEB_PORT: ' 22303 '
ADD_WAIFU: ' True '
AUTHENTICATION: ' [("username", "passwd"), ("username2", "passwd2")] '
# 与宿主的网络融合
network_mode: "host"
# 不使用代理网络拉取最新代码
command: >
bash -c " echo '[gpt-academic] 正在从github拉取最新代码...' &&
git checkout master --force &&
git remote set-url origin https://github.com/binary-husky/chatgpt_academic.git &&
git pull &&
python3 -u main.py"
### ===================================================
### 【方案二】 如果需要运行ChatGLM本地模型
### ===================================================
version: '3'
services:
gpt_academic_with_chatglm:
image: fuqingxu/gpt_academic:chatgpt-chatglm-newbing # [option 2] 如果需要运行ChatGLM本地模型
environment:
# 请查阅 `config.py` 以查看所有的配置信息
API_KEY: ' sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,fkxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx '
USE_PROXY: ' True '
proxies: ' { "http": "socks5h://localhost:10880", "https": "socks5h://localhost:10880", } '
LLM_MODEL: ' gpt-3.5-turbo '
AVAIL_LLM_MODELS: ' ["gpt-3.5-turbo", "api2d-gpt-4", "chatglm"] '
LOCAL_MODEL_DEVICE: ' cuda '
DEFAULT_WORKER_NUM: ' 10 '
WEB_PORT: ' 12303 '
ADD_WAIFU: ' True '
AUTHENTICATION: ' [("username", "passwd"), ("username2", "passwd2")] '
# 显卡的使用,nvidia0指第0个GPU
runtime: nvidia
devices:
- /dev/nvidia0:/dev/nvidia0
# 与宿主的网络融合
network_mode: "host"
# 使用代理网络拉取最新代码
# command: >
# bash -c " echo '[gpt-academic] 正在从github拉取最新代码...' &&
# truncate -s -1 /etc/proxychains.conf &&
# echo \"socks5 127.0.0.1 10880\" >> /etc/proxychains.conf &&
# proxychains git pull &&
# python3 -u main.py "
# 不使用代理网络拉取最新代码
command: >
bash -c " echo '[gpt-academic] 正在从github拉取最新代码...' &&
git pull &&
python3 -u main.py"
### ===================================================
### 【方案三】 如果需要运行ChatGPT + LLAMA + 盘古 + RWKV本地模型
### ===================================================
version: '3'
services:
gpt_academic_with_rwkv:
image: fuqingxu/gpt_academic:jittorllms # [option 2] 如果需要运行ChatGLM本地模型
environment:
# 请查阅 `config.py` 以查看所有的配置信息
API_KEY: ' sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,fkxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx '
USE_PROXY: ' True '
proxies: ' { "http": "socks5h://localhost:10880", "https": "socks5h://localhost:10880", } '
LLM_MODEL: ' gpt-3.5-turbo '
AVAIL_LLM_MODELS: ' ["gpt-3.5-turbo", "api2d-gpt-4", "jittorllms_rwkv"] '
LOCAL_MODEL_DEVICE: ' cuda '
DEFAULT_WORKER_NUM: ' 10 '
WEB_PORT: ' 12305 '
ADD_WAIFU: ' True '
# AUTHENTICATION: ' [("username", "passwd"), ("username2", "passwd2")] '
# 显卡的使用,nvidia0指第0个GPU
runtime: nvidia
devices:
- /dev/nvidia0:/dev/nvidia0
# 与宿主的网络融合
network_mode: "host"
# 使用代理网络拉取最新代码
# command: >
# bash -c " truncate -s -1 /etc/proxychains.conf &&
# echo \"socks5 127.0.0.1 10880\" >> /etc/proxychains.conf &&
# echo '[gpt-academic] 正在从github拉取最新代码...' &&
# proxychains git pull &&
# echo '[jittorllms] 正在从github拉取最新代码...' &&
# proxychains git --git-dir=request_llm/jittorllms/.git --work-tree=request_llm/jittorllms pull --force &&
# python3 -u main.py"
# 不使用代理网络拉取最新代码
command: >
bash -c " echo '[gpt-academic] 正在从github拉取最新代码...' &&
git pull &&
echo '[jittorllms] 正在从github拉取最新代码...' &&
git --git-dir=request_llm/jittorllms/.git --work-tree=request_llm/jittorllms pull --force &&
python3 -u main.py"

查看文件

@@ -1,6 +1,6 @@
# How to build | 如何构建: docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM . # How to build | 如何构建: docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
# How to run | 如何运行 (1) 直接运行选择0号GPU: docker run --rm -it --net=host --gpus="0" gpt-academic # How to run | (1) 我想直接一键运行选择0号GPU: docker run --rm -it --net=host --gpus \"device=0\" gpt-academic
# How to run | 如何运行 (2) 我想运行之前进容器做一些调整: docker run --rm -it --net=host --gpus="0" gpt-academic bash # How to run | (2) 我想运行之前进容器做一些调整选择1号GPU: docker run --rm -it --net=host --gpus \"device=1\" gpt-academic bash
# 从NVIDIA源,从而支持显卡运损检查宿主的nvidia-smi中的cuda版本必须>=11.3 # 从NVIDIA源,从而支持显卡运损检查宿主的nvidia-smi中的cuda版本必须>=11.3
FROM nvidia/cuda:11.3.1-runtime-ubuntu20.04 FROM nvidia/cuda:11.3.1-runtime-ubuntu20.04
@@ -14,6 +14,7 @@ RUN apt-get install -y git python python3 python-dev python3-dev --fix-missing
RUN $useProxyNetwork curl cip.cc RUN $useProxyNetwork curl cip.cc
RUN sed -i '$ d' /etc/proxychains.conf RUN sed -i '$ d' /etc/proxychains.conf
RUN sed -i '$ d' /etc/proxychains.conf RUN sed -i '$ d' /etc/proxychains.conf
# 在这里填写主机的代理协议用于从github拉取代码
RUN echo "socks5 127.0.0.1 10880" >> /etc/proxychains.conf RUN echo "socks5 127.0.0.1 10880" >> /etc/proxychains.conf
ARG useProxyNetwork=proxychains ARG useProxyNetwork=proxychains
# # comment out above if you do not need proxy network | 如果不需要翻墙 - 从此行向上删除 # # comment out above if you do not need proxy network | 如果不需要翻墙 - 从此行向上删除
@@ -21,14 +22,15 @@ ARG useProxyNetwork=proxychains
# use python3 as the system default python # use python3 as the system default python
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.8 RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.8
# 下载pytorch
RUN $useProxyNetwork python3 -m pip install torch --extra-index-url https://download.pytorch.org/whl/cu113
# 下载分支 # 下载分支
WORKDIR /gpt WORKDIR /gpt
RUN $useProxyNetwork git clone https://github.com/binary-husky/chatgpt_academic.git RUN $useProxyNetwork git clone https://github.com/binary-husky/chatgpt_academic.git
WORKDIR /gpt/chatgpt_academic WORKDIR /gpt/chatgpt_academic
RUN $useProxyNetwork python3 -m pip install -r requirements.txt RUN $useProxyNetwork python3 -m pip install -r requirements.txt
RUN $useProxyNetwork python3 -m pip install -r request_llm/requirements_chatglm.txt RUN $useProxyNetwork python3 -m pip install -r request_llm/requirements_chatglm.txt
RUN $useProxyNetwork python3 -m pip install torch --extra-index-url https://download.pytorch.org/whl/cu113 RUN $useProxyNetwork python3 -m pip install -r request_llm/requirements_newbing.txt
# 预热CHATGLM参数非必要 可选步骤) # 预热CHATGLM参数非必要 可选步骤)
RUN echo ' \n\ RUN echo ' \n\
@@ -48,6 +50,7 @@ RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()'
# 可同时填写多个API-KEY,支持openai的key和api2d的key共存,用英文逗号分割,例如API_KEY = "sk-openaikey1,fkxxxx-api2dkey2,........" # 可同时填写多个API-KEY,支持openai的key和api2d的key共存,用英文逗号分割,例如API_KEY = "sk-openaikey1,fkxxxx-api2dkey2,........"
# LLM_MODEL 是选择初始的模型 # LLM_MODEL 是选择初始的模型
# LOCAL_MODEL_DEVICE 是选择chatglm等本地模型运行的设备,可选 cpu 和 cuda # LOCAL_MODEL_DEVICE 是选择chatglm等本地模型运行的设备,可选 cpu 和 cuda
# [说明: 以下内容与`config.py`一一对应,请查阅config.py来完成一下配置的填写]
RUN echo ' \n\ RUN echo ' \n\
API_KEY = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,fkxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \n\ API_KEY = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,fkxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \n\
USE_PROXY = True \n\ USE_PROXY = True \n\

查看文件

@@ -1,223 +1,227 @@
# ChatGPT Academic Optimization
> **Note** > **Note**
> >
> This English readme is automatically generated by the markdown translation plugin in this project, and may not be 100% correct. > This English README is automatically generated by the markdown translation plugin in this project, and may not be 100% correct.
> >
# <img src="logo.png" width="40" > ChatGPT Academic Optimization
**If you like this project, please give it a star. If you have come up with more useful academic shortcuts or functional plugins, feel free to open an issue or pull request (to the `dev` branch).** **If you like this project, please give it a Star. If you've come up with more useful academic shortcuts or functional plugins, feel free to open an issue or pull request. We also have a [README in English](docs/README_EN.md) translated by this project itself.**
> **Note** > **Note**
> >
> 1. Please note that only function plugins (buttons) marked in **red** support reading files, and some plugins are located in the **dropdown menu** in the plugin area. Additionally, we welcome and process PRs for any new plugins with the **highest priority**! > 1. Please note that only **functions with red color** supports reading files, some functions are located in the **dropdown menu** of plugins. Additionally, we welcome and prioritize any new plugin PRs with **highest priority**!
> >
> 2. The functions of each file in this project are detailed in the self-translation report [self_analysis.md](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A). With the version iteration, you can click on a relevant function plugin at any time to call GPT to regenerate the self-analysis report for the project. Commonly asked questions are summarized in the [`wiki`](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98). > 2. The functionality of each file in this project is detailed in the self-translation report [`self_analysis.md`](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A) of the project. With the iteration of the version, you can also click on the relevant function plugins at any time to call GPT to regenerate the self-analysis report of the project. The FAQ summary is in the [`wiki`](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98) section.
> >
> 3. If you are not used to the function, comments or interface with some Chinese names, you can click on the relevant function plugin at any time to call ChatGPT to generate the source code of the project in English.
<div align="center"> <div align="center">
Function | Description Function | Description
--- | --- --- | ---
One-click refinement | Supports one-click refinement, one-click searching for grammatical errors in papers. One-Click Polish | Supports one-click polishing and finding grammar errors in academic papers.
One-click translation between Chinese and English | One-click translation between Chinese and English. One-Key Translation Between Chinese and English | One-click translation between Chinese and English.
One-click code interpretation | Can correctly display and interpret the code. One-Key Code Interpretation | Can correctly display and interpret code.
[Custom shortcuts](https://www.bilibili.com/video/BV14s4y1E7jN) | Supports custom shortcuts. [Custom Shortcut Keys](https://www.bilibili.com/video/BV14s4y1E7jN) | Supports custom shortcut keys.
[Configure proxy server](https://www.bilibili.com/video/BV1rc411W7Dr) | Supports configuring proxy server. [Configure Proxy Server](https://www.bilibili.com/video/BV1rc411W7Dr) | Supports configuring proxy servers.
Modular design | Supports custom high-order experimental features and [function plug-ins], and plug-ins support [hot update](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97). Modular Design | Supports custom high-order function plugins and [function plugins], and plugins support [hot updates](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97).
[Self-program analysis](https://www.bilibili.com/video/BV1cj411A7VW) | [Function Plug-in] [One-Key Understanding](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A) the source code of this project. [Self-programming Analysis](https://www.bilibili.com/video/BV1cj411A7VW) | [Function Plugin] [One-Key Read] (https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A) The source code of this project is analyzed.
[Program analysis](https://www.bilibili.com/video/BV1cj411A7VW) | [Function Plug-in] One-click can analyze other Python/C/C++/Java/Golang/Lua/Rect project trees. [Program Analysis](https://www.bilibili.com/video/BV1cj411A7VW) | [Function Plugin] One-click can analyze the project tree of other Python/C/C++/Java/Lua/... projects
Read papers | [Function Plug-in] One-click reads the full text of a latex paper and generates an abstract. Read the Paper | [Function Plugin] One-click interpretation of the full text of latex paper and generation of abstracts
Latex full-text translation/refinement | [Function Plug-in] One-click translates or refines a latex paper. Latex Full Text Translation, Proofreading | [Function Plugin] One-click translation or proofreading of latex papers.
Batch annotation generation | [Function Plug-in] One-click generates function annotations in batches. Batch Comment Generation | [Function Plugin] One-click batch generation of function comments
Chat analysis report generation | [Function Plug-in] Automatically generate summary reports after running. Chat Analysis Report Generation | [Function Plugin] After running, an automatic summary report will be generated
[Arxiv assistant](https://www.bilibili.com/video/BV1LM4y1279X) | [Function Plug-in] Enter the arxiv paper url and you can translate the abstract and download the PDF with one click. [Arxiv Assistant](https://www.bilibili.com/video/BV1LM4y1279X) | [Function Plugin] Enter the arxiv article url to translate the abstract and download the PDF with one click
[PDF paper full-text translation function](https://www.bilibili.com/video/BV1KT411x7Wn) | [Function Plug-in] Extract title and abstract of PDF papers + translate full text (multi-threaded). [Full-text Translation Function of PDF Paper](https://www.bilibili.com/video/BV1KT411x7Wn) | [Function Plugin] Extract the title & abstract of the PDF paper + translate the full text (multithreading)
[Google Scholar integration assistant](https://www.bilibili.com/video/BV19L411U7ia) (Version>=2.45) | [Function Plug-in] Given any Google Scholar search page URL, let GPT help you choose interesting articles. [Google Scholar Integration Assistant](https://www.bilibili.com/video/BV19L411U7ia) | [Function Plugin] Given any Google Scholar search page URL, let gpt help you choose interesting articles.
Formula display | Can simultaneously display the tex form and rendering form of formulas. Formula / Picture / Table Display | Can display both the tex form and the rendering form of formulas at the same time, support formula and code highlighting
Image display | Can display images in Markdown. Multithreaded Function Plugin Support | Supports multi-threaded calling chatgpt, one-click processing of massive text or programs
Multithreaded function plug-in support | Supports multi-threaded calling of chatgpt, one-click processing of massive texts or programs. Start Dark Gradio [Theme](https://github.com/binary-husky/chatgpt_academic/issues/173) | Add ```/?__dark-theme=true``` at the end of the browser url to switch to dark theme
Support for markdown tables output by GPT | Can output markdown tables that support GPT. [Multiple LLM Models](https://www.bilibili.com/video/BV1wT411p7yf) support, [API2D](https://api2d.com/) interface support | It must feel nice to be served by both GPT3.5, GPT4, and [Tsinghua ChatGLM](https://github.com/THUDM/ChatGLM-6B)!
Start dark gradio theme [theme](https://github.com/binary-husky/chatgpt_academic/issues/173) | Add ```/?__dark-theme=true``` to the browser URL to switch to the dark theme. Huggingface non-Science Net [Online Experience](https://huggingface.co/spaces/qingxu98/gpt-academic) | After logging in to huggingface, copy [this space](https://huggingface.co/spaces/qingxu98/gpt-academic)
Huggingface free scientific online experience](https://huggingface.co/spaces/qingxu98/gpt-academic) | After logging in to Huggingface, copy [this space](https://huggingface.co/spaces/qingxu98/gpt-academic). ... | ...
[Mixed support for multiple LLM models](https://www.bilibili.com/video/BV1EM411K7VH/) ([v3.0 branch](https://github.com/binary-husky/chatgpt_academic/tree/v3.0) in testing) | It must feel great to be served by both ChatGPT and [Tsinghua ChatGLM](https://github.com/THUDM/ChatGLM-6B)!
Compatible with [TGUI](https://github.com/oobabooga/text-generation-webui) to access more language models | Access to opt-1.3b, galactica-1.3b and other models ([v3.0 branch](https://github.com/binary-husky/chatgpt_academic/tree/v3.0) under testing).
… | ...
</div> </div>
<!-- - New interface (left: master branch, right: dev development frontier) -->
- New interface (modify the `LAYOUT` option in `config.py` to switch between "left and right layout" and "up and down layout"). - New interface (switch between "left-right layout" and "up-down layout" by modifying the LAYOUT option in config.py)
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" > <img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
</div> </div>
- All buttons are dynamically generated by reading `functional.py`, and custom functions can be added freely, freeing up the clipboard.
- All buttons are dynamically generated by reading functional.py and can add custom functionality at will, freeing up clipboard
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" > <img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
</div> </div>
- Refinement/Correction - Proofreading / correcting
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" > <img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
</div> </div>
- Supports markdown tables output by GPT. - If the output contains formulas, it will be displayed in both the tex form and the rendering form at the same time, which is convenient for copying and reading
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" > <img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
</div> </div>
- If the output contains formulas, both the tex form and the rendering form are displayed simultaneously for easy copying and reading. - Don't want to read the project code? Just take the whole project to chatgpt
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
</div>
- Don't want to read project code? Let chatgpt boast about the whole project.
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" > <img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
</div> </div>
- Multiple large language models mixed calling. ([v3.0 branch](https://github.com/binary-husky/chatgpt_academic/tree/v3.0) in testing) - Multiple major language model mixing calls (ChatGLM + OpenAI-GPT3.5 + [API2D](https://api2d.com/)-GPT4)
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
</div>
Multiple major language model mixing call [huggingface beta version](https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta) (the huggingface version does not support chatglm)
## Running Directly (Windows, Linux or MacOS) ---
### 1. Download the Project ## Installation-Method 1: Run directly (Windows, Linux or MacOS)
1. Download project
```sh ```sh
git clone https://github.com/binary-husky/chatgpt_academic.git git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic cd chatgpt_academic
``` ```
### 2. Configure API_KEY and Proxy Settings 2. Configure API_KEY and proxy settings
In `config.py`, configure the overseas Proxy and OpenAI API KEY, as follows:
```
1. If you are in China, you need to set an overseas proxy to use the OpenAI API smoothly. Please read the instructions in config.py carefully (1. Modify the USE_PROXY to True; 2. Modify the proxies according to the instructions).
2. Configure OpenAI API KEY. You need to register on the OpenAI official website and obtain an API KEY. Once you get the API KEY, configure it in the config.py file.
3. Issues related to proxy network (network timeout, proxy not working) are summarized to https://github.com/binary-husky/chatgpt_academic/issues/1
```
(Note: When the program is running, it will first check whether there is a private configuration file named `config_private.py`, and use the configuration in it to overwrite the same name configuration in `config.py`. Therefore, if you can understand our configuration reading logic, we strongly recommend that you create a new configuration file next to `config.py` named `config_private.py` and transfer (copy) the configuration in `config.py` to `config_private.py`. `config_private.py` is not managed by Git, which can make your privacy information more secure.)
### 3. Install Dependencies In `config.py`, configure the overseas Proxy and OpenAI API KEY as follows:
```
1. If you are in China, you need to set up an overseas proxy to use the OpenAI API smoothly. Please read config.py carefully for setup details (1. Modify USE_PROXY to True; 2. Modify proxies according to the instructions).
2. Configure the OpenAI API KEY. You need to register and obtain an API KEY on the OpenAI website. Once you get the API KEY, you can configure it in the config.py file.
3. Issues related to proxy networks (network timeouts, proxy failures) are summarized at https://github.com/binary-husky/chatgpt_academic/issues/1
```
(P.S. When the program runs, it will first check whether there is a private configuration file named `config_private.py` and use the same-name configuration in `config.py` to overwrite it. Therefore, if you can understand our configuration reading logic, we strongly recommend that you create a new configuration file named `config_private.py` next to `config.py` and transfer (copy) the configuration in `config.py` to` config_private.py`. `config_private.py` is not controlled by git and can make your privacy information more secure.))
3. Install dependencies
```sh ```sh
# (Option 1) Recommended # (Option One) Recommended
python -m pip install -r requirements.txt python -m pip install -r requirements.txt
# (Option 2) If you use anaconda, the steps are also similar: # (Option Two) If you use anaconda, the steps are similar:
# (Option 2.1) conda create -n gptac_venv python=3.11 # (Option Two.1) conda create -n gptac_venv python=3.11
# (Option 2.2) conda activate gptac_venv # (Option Two.2) conda activate gptac_venv
# (Option 2.3) python -m pip install -r requirements.txt # (Option Two.3) python -m pip install -r requirements.txt
# Note: Use the official pip source or the Ali pip source. Other pip sources (such as some university pips) may have problems. Temporary substitution method: # Note: Use official pip source or Ali pip source. Other pip sources (such as some university pips) may have problems, and temporary replacement methods are as follows:
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ # python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
``` ```
### 4. Run If you need to support Tsinghua ChatGLM, you need to install more dependencies (if you are not familiar with python or your computer configuration is not good, we recommend not to try):
```sh
python -m pip install -r request_llm/requirements_chatglm.txt
```
4. Run
```sh ```sh
python main.py python main.py
``` ```
### 5. Test Experimental Features 5. Test function plugins
``` ```
- Test C++ Project Header Analysis - Test Python project analysis
In the input area, enter `./crazy_functions/test_project/cpp/libJPG` , and then click "[Experiment] Parse the entire C++ project (input inputs the root path of the project)" In the input area, enter `./crazy_functions/test_project/python/dqn`, and then click "Analyze the entire Python project"
- Test Writing Abstracts for Latex Projects - Test self-code interpretation
In the input area, enter `./crazy_functions/test_project/latex/attention` , and then click "[Experiment] Read the tex paper and write an abstract (input inputs the root path of the project)" Click "[Multithreading Demo] Interpretation of This Project Itself (Source Code Interpretation)"
- Test Python Project Analysis - Test experimental function template function (requires gpt to answer what happened today in history). You can use this function as a template to implement more complex functions.
In the input area, enter `./crazy_functions/test_project/python/dqn` , and then click "[Experiment] Parse the entire py project (input inputs the root path of the project)" Click "[Function Plugin Template Demo] Today in History"
- Test Self-code Interpretation - There are more functions to choose from in the function plugin area drop-down menu.
Click "[Experiment] Please analyze and deconstruct this project itself"
- Test Experimental Function Template (asking GPT what happened in history today), you can implement more complex functions based on this template function
Click "[Experiment] Experimental function template"
``` ```
## Use Docker (Linux) ## Installation-Method 2: Use Docker (Linux)
1. ChatGPT only (recommended for most people)
``` sh ``` sh
# Download Project # download project
git clone https://github.com/binary-husky/chatgpt_academic.git git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic cd chatgpt_academic
# Configure Overseas Proxy and OpenAI API KEY # configure overseas Proxy and OpenAI API KEY
Configure config.py with any text editor Edit config.py with any text editor
# Installation # Install
docker build -t gpt-academic . docker build -t gpt-academic .
# Run # Run
docker run --rm -it --net=host gpt-academic docker run --rm -it --net=host gpt-academic
# Test Experimental Features # Test function plug-in
## Test Self-code Interpretation ## Test function plugin template function (requires gpt to answer what happened today in history). You can use this function as a template to implement more complex functions.
Click "[Experiment] Please analyze and deconstruct this project itself" Click "[Function Plugin Template Demo] Today in History"
## Test Experimental Function Template (asking GPT what happened in history today), you can implement more complex functions based on this template function ## Test Abstract Writing for Latex Projects
Click "[Experiment] Experimental function template" Enter ./crazy_functions/test_project/latex/attention in the input area, and then click "Read Tex Paper and Write Abstract"
## (Please note that when running in docker, you need to pay extra attention to file access rights issues of the program.)
## Test C++ Project Header Analysis
In the input area, enter ./crazy_functions/test_project/cpp/libJPG , and then click "[Experiment] Parse the entire C++ project (input inputs the root path of the project)"
## Test Writing Abstracts for Latex Projects
In the input area, enter ./crazy_functions/test_project/latex/attention , and then click "[Experiment] Read the tex paper and write an abstract (input inputs the root path of the project)"
## Test Python Project Analysis ## Test Python Project Analysis
In the input area, enter ./crazy_functions/test_project/python/dqn , and then click "[Experiment] Parse the entire py project (input inputs the root path of the project)" Enter ./crazy_functions/test_project/python/dqn in the input area and click "Analyze the entire Python project."
More functions are available in the function plugin area drop-down menu.
``` ```
## Other Deployment Methods 2. ChatGPT+ChatGLM (requires strong familiarity with docker + strong computer configuration)
- Use WSL2 (Windows Subsystem for Linux subsystem)
Please visit [Deploy Wiki-1] (https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
- nginx remote deployment ``` sh
Please visit [Deploy Wiki-2] (https://github.com/binary-husky/chatgpt_academic/wiki/%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E7%9A%84%E6%8C%87%E5%AF%BC) # Modify dockerfile
cd docs && nano Dockerfile+ChatGLM
# How to build | 如何构建 Dockerfile+ChatGLM在docs路径下,请先cd docs
## Customizing New Convenient Buttons (Academic Shortcut Key Customization) docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
Open functional.py and add the entry as follows, and then restart the program. (If the button has been successfully added and is visible, both the prefix and suffix support hot modification and take effect without restarting the program.) # How to run | 如何运行 (1) 直接运行:
docker run --rm -it --net=host --gpus=all gpt-academic
For example, # How to run | 如何运行 (2) 我想运行之前进容器做一些调整:
docker run --rm -it --net=host --gpus=all gpt-academic bash
``` ```
"Super English to Chinese Translation": {
# Prefix, which will be added before your input. For example, it is used to describe your requirements, such as translation, code interpretation, polishing, etc.
"Prefix": "Please translate the following content into Chinese, and then use a markdown table to explain each proprietary term in the text:\n\n", ## Installation-Method 3: Other Deployment Methods
# Suffix, which will be added after your input. For example, in conjunction with the prefix, you can bracket your input in quotes. 1. Remote Cloud Server Deployment
Please visit [Deployment Wiki-1] (https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
2. Use WSL2 (Windows Subsystem for Linux)
Please visit [Deployment Wiki-2](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
## Installation-Proxy Configuration
### Method 1: Conventional method
[Configure Proxy](https://github.com/binary-husky/chatgpt_academic/issues/1)
### Method Two: Step-by-step tutorial for newcomers
[Step-by-step tutorial for newcomers](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BB%A3%E7%90%86%E8%BD%AF%E4%BB%B6%E9%97%AE%E9%A2%98%E7%9A%84%E6%96%B0%E6%89%8B%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%EF%BC%88%E6%96%B9%E6%B3%95%E5%8F%AA%E9%80%82%E7%94%A8%E4%BA%8E%E6%96%B0%E6%89%8B%EF%BC%89)
---
## Customizing Convenient Buttons (Customizing Academic Shortcuts)
Open `core_functional.py` with any text editor and add an item as follows, then restart the program (if the button has been successfully added and visible, both the prefix and suffix support hot modification without the need to restart the program to take effect). For example:
```
"Super English to Chinese translation": {
# Prefix, which will be added before your input. For example, to describe your requirements, such as translation, code interpretation, polishing, etc.
"Prefix": "Please translate the following content into Chinese and use a markdown table to interpret the proprietary terms in the text one by one:\n\n",
# Suffix, which will be added after your input. For example, combined with the prefix, you can put your input content in quotes.
"Suffix": "", "Suffix": "",
}, },
``` ```
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" > <img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
</div> </div>
---
If you invent a more user-friendly academic shortcut key, welcome to post an issue or pull request!
## Configure Proxy
### Method 1: General Method
Modify the port and proxy software corresponding in ```config.py```
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226571294-37a47cd9-4d40-4c16-97a2-d360845406f7.png" width="500" >
<img src="https://user-images.githubusercontent.com/96192199/226838985-e5c95956-69c2-4c23-a4dd-cd7944eeb451.png" width="500" >
</div>
After configuring, you can use the following command to test whether the proxy works. If everything is normal, the code below will output the location of your proxy server: ## Some Function Displays
```
python check_proxy.py
```
### Method Two: Pure Beginner Tutorial
[Pure Beginner Tutorial](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BB%A3%E7%90%86%E8%BD%AF%E4%BB%B6%E9%97%AE%E9%A2%98%E7%9A%84%E6%96%B0%E6%89%8B%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%EF%BC%88%E6%96%B9%E6%B3%95%E5%8F%AA%E9%80%82%E7%94%A8%E4%BA%8E%E6%96%B0%E6%89%8B%EF%BC%89)
## Compatibility Testing
### Image Display: ### Image Display:
You are a professional academic paper translator.
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" > <img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
</div> </div>
### If a program can understand and analyze itself:
### If the program can read and analyze itself:
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" > <img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
@@ -227,7 +231,7 @@ python check_proxy.py
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" > <img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
</div> </div>
### Any other Python/Cpp project analysis: ### Analysis of any Python/Cpp project:
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" > <img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
</div> </div>
@@ -236,59 +240,52 @@ python check_proxy.py
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" > <img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
</div> </div>
### Latex paper reading comprehension and abstract generation with one click ### One-click reading comprehension and summary generation of Latex papers
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" > <img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
</div> </div>
### Automatic Report Generation ### Automatic report generation
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" > <img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" > <img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" > <img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
</div> </div>
### Modular Function Design ### Modular functional design
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" > <img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" > <img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
</div> </div>
### Source code translation to English
### Translating source code to English
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" > <img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
</div> </div>
## Todo and Version Planning: ## Todo and version planning:
- version 3.2+ (todo): Function plugin supports more parameter interfaces
- version 3 (Todo): - version 3.1: Support for inquiring multiple GPT models at the same time! Support for api2d, support for multiple apikeys load balancing
- - Support for gpt4 and other llm - version 3.0: Support for chatglm and other small llms
- version 2.4+ (Todo): - version 2.6: Refactored the plugin structure, improved interactivity, added more plugins
- - Summary of long text and token overflow problems in large project source code - version 2.5: Self-updating, solves the problem of text being too long and token overflowing when summarizing large project source code
- - Implementation of project packaging and deployment - version 2.4: (1) Added PDF full text translation function; (2) Added function to switch input area position; (3) Added vertical layout option; (4) Multi-threaded function plugin optimization.
- - Function plugin parameter interface optimization
- - Self-updating
- version 2.4: (1) Added PDF full-text translation function; (2) Added input area switching function; (3) Added vertical layout option; (4) Optimized multi-threaded function plugin.
- version 2.3: Enhanced multi-threaded interactivity - version 2.3: Enhanced multi-threaded interactivity
- version 2.2: Function plug-in supports hot reloading - version 2.2: Function plugin supports hot reloading
- version 2.1: Collapsible layout - version 2.1: Foldable layout
- version 2.0: Introduction of modular function plugins - version 2.0: Introduction of modular function plugins
- version 1.0: Basic functions - version 1.0: Basic functions
## References and Learning ## Reference and learning
``` ```
The code refers to the design of many other excellent projects, mainly including: The code design of this project has referenced many other excellent projects, including:
# Reference Project 1: Referenced the method of reading OpenAI json, recording historical inquiry records, and using gradio queue in ChuanhuChatGPT # Reference project 1: Borrowed many tips from ChuanhuChatGPT
https://github.com/GaiZhenbiao/ChuanhuChatGPT https://github.com/GaiZhenbiao/ChuanhuChatGPT
# Reference Project 2: # Reference project 2: Tsinghua ChatGLM-6B:
https://github.com/THUDM/ChatGLM-6B https://github.com/THUDM/ChatGLM-6B
``` ```

296
docs/README_FR.md 普通文件
查看文件

@@ -0,0 +1,296 @@
> **Note**
>
> Ce fichier README est généré automatiquement par le plugin de traduction markdown de ce projet et n'est peut - être pas correct à 100%.
>
# <img src="logo.png" width="40" > ChatGPT Optimisation Académique
**Si vous aimez ce projet, donnez-lui une étoile; si vous avez inventé des raccourcis académiques plus utiles ou des plugins fonctionnels, n'hésitez pas à ouvrir une demande ou une demande de traction. Nous avons également un fichier README en [anglais|](docs/README_EN.md)[japonais|](docs/README_JP.md)[russe|](docs/README_RS.md)[français](docs/README_FR.md) traduit par ce projet lui-même.**
> **Note**
>
> 1. Veuillez noter que seuls les plugins de fonction signalés en **rouge** sont capables de lire les fichiers, certains plugins se trouvent dans le **menu déroulant** de la section plugin. Nous sommes également les bienvenus avec la plus haute priorité pour traiter et accepter tout nouveau PR de plugin!
>
> 2. Chaque fichier dans ce projet est expliqué en détail dans l'auto-analyse [self_analysis.md](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A). Avec l'itération des versions, vous pouvez également cliquer sur les plugins fonctionnels pertinents pour appeler GPT et générer un rapport d'auto-analyse projet mis à jour. Les questions fréquemment posées sont résumées dans le [wiki](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98).
>
<div align="center">
Fonctionnalité | Description
--- | ---
Polissage en un clic | Prend en charge la correction en un clic et la recherche d'erreurs de syntaxe dans les documents de recherche.
Traduction Chinois-Anglais en un clic | Une touche pour traduire la partie chinoise en anglais ou celle anglaise en chinois.
Explication de code en un clic | Affiche et explique correctement le code.
[Raccourcis clavier personnalisables](https://www.bilibili.com/video/BV14s4y1E7jN) | Prend en charge les raccourcis clavier personnalisables.
[Configuration du serveur proxy](https://www.bilibili.com/video/BV1rc411W7Dr) | Prend en charge la configuration du serveur proxy.
Conception modulaire | Prend en charge la personnalisation des plugins de fonctions et des [plugins] de fonctions hiérarchiques personnalisés, et les plugins prennent en charge [la mise à jour à chaud](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97).
[Auto-analyse du programme](https://www.bilibili.com/video/BV1cj411A7VW) | [Plugins] [Lire en un clic](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A) le code source de ce projet.
[Analyse de programme](https://www.bilibili.com/video/BV1cj411A7VW) | [Plugins] En un clic, les projets Python/C/C++/Java/Lua/... peuvent être analysés.
Lire le document de recherche | [Plugins] Lisez le résumé de l'article en latex et générer un résumé.
Traduction et polissage de l'article complet en LaTeX | [Plugins] Une touche pour traduire ou corriger en LaTeX
Génération Commentaire de fonction en vrac | [Plugins] Lisez en un clic les fonctions et générez des commentaires de fonction.
Rapport d'analyse automatique des chats générés | [Plugins] Génère un rapport de synthèse après l'exécution.
[Assistant arxiv](https://www.bilibili.com/video/BV1LM4y1279X) | [Plugins] Entrez l'url de l'article arxiv pour traduire le résumé + télécharger le PDF en un clic
[Traduction complète des articles PDF](https://www.bilibili.com/video/BV1KT411x7Wn) | [Plugins] Extraire le titre et le résumé de l'article PDF + Traduire le texte entier (multithread)
[Aide à la recherche Google Academ](https://www.bilibili.com/video/BV19L411U7ia) | [Plugins] Donnez à GPT l'URL de n'importe quelle page de recherche Google Academ pour vous aider à sélectionner des articles intéressants
Affichage de formules/images/tableaux | Afficher la forme traduite et rendue d'une formule en même temps, plusieurs formules et surlignage du code prend en charge
Prise en charge des plugins multithread | Prise en charge de l'appel multithread de chatgpt, traitement en masse de texte ou de programmes en un clic
Activer le thème Gradio sombre [theme](https://github.com/binary-husky/chatgpt_academic/issues/173) au démarrage | Ajoutez ```/?__dark-theme=true``` à l'URL du navigateur pour basculer vers le thème sombre
[Prise en charge de plusieurs modèles LLM](https://www.bilibili.com/video/BV1wT411p7yf), [prise en charge de l'interface API2D](https://api2d.com/) | Comment cela serait-il de se faire servir par GPT3.5, GPT4 et la [ChatGLM de Tsinghua](https://github.com/THUDM/ChatGLM-6B) en même temps?
Expérience en ligne d'huggingface sans science | Après vous être connecté à huggingface, copiez [cet espace](https://huggingface.co/spaces/qingxu98/gpt-academic)
... | ...
</div>
Vous êtes un traducteur professionnel d'articles universitaires en français.
Ceci est un fichier Markdown, veuillez le traduire en français sans modifier les commandes Markdown existantes :
- Nouvelle interface (modifiable en modifiant l'option de mise en page dans config.py pour basculer entre les mises en page gauche-droite et haut-bas)
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
</div>
- Tous les boutons sont générés dynamiquement en lisant functional.py, les utilisateurs peuvent ajouter librement des fonctions personnalisées pour libérer le presse-papiers.
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
</div>
- Correction/amélioration
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
</div>
- Si la sortie contient des formules, elles seront affichées simultanément sous forme de de texte brut et de forme rendue pour faciliter la copie et la lecture.
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
</div>
- Pas envie de lire le code du projet ? Faites votre propre démo avec ChatGPT.
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
</div>
- Utilisation combinée de plusieurs modèles de langage sophistiqués (ChatGLM + OpenAI-GPT3.5 + [API2D](https://api2d.com/)-GPT4)
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
</div>
Utilisation combinée de plusieurs modèles de langage sophistiqués en version de test [huggingface](https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta) (la version huggingface ne prend pas en charge Chatglm).
---
## Installation - Méthode 1 : Exécution directe (Windows, Linux or MacOS)
1. Téléchargez le projet
```sh
git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic
```
2. Configuration de l'API_KEY et des paramètres de proxy
Dans `config.py`, configurez les paramètres de proxy et de clé d'API OpenAI, comme indiqué ci-dessous
```
1. Si vous êtes en Chine, vous devez configurer un proxy étranger pour utiliser l'API OpenAI en toute transparence. Pour ce faire, veuillez lire attentivement le fichier config.py (1. Modifiez l'option USE_PROXY ; 2. Modifiez les paramètres de proxies comme indiqué dans les instructions).
2. Configurez votre clé API OpenAI. Vous devez vous inscrire sur le site web d'OpenAI pour obtenir une clé API. Une fois que vous avez votre clé API, vous pouvez la configurer dans le fichier config.py.
3. Tous les problèmes liés aux réseaux de proxy (temps d'attente, non-fonctionnement des proxies) sont résumés dans https://github.com/binary-husky/chatgpt_academic/issues/1.
```
(Remarque : le programme vérifie d'abord s'il existe un fichier de configuration privé nommé `config_private.py`, et utilise les configurations de celui-ci à la place de celles du fichier `config.py`. Par conséquent, si vous comprenez notre logique de lecture de configuration, nous vous recommandons fortement de créer un nouveau fichier de configuration nommé `config_private.py` à côté de `config.py` et de transférer (copier) les configurations de celui-ci dans `config_private.py`. `config_private.py` n'est pas contrôlé par git et rend vos informations personnelles plus sûres.)
3. Installation des dépendances
```sh
# (Option 1) Recommandé
python -m pip install -r requirements.txt
# (Option 2) Si vous utilisez anaconda, les étapes sont similaires :
# (Option 2.1) conda create -n gptac_venv python=3.11
# (Option 2.2) conda activate gptac_venv
# (Option 2.3) python -m pip install -r requirements.txt
# note : Utilisez la source pip officielle ou la source pip Alibaba. D'autres sources (comme celles des universités) pourraient poser problème. Pour utiliser temporairement une autre source, utilisez :
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
```
Si vous avez besoin de soutenir ChatGLM de Tsinghua, vous devez installer plus de dépendances (si vous n'êtes pas familier avec Python ou que votre ordinateur n'est pas assez performant, nous vous recommandons de ne pas essayer) :
```sh
python -m pip install -r request_llm/requirements_chatglm.txt
```
4. Exécution
```sh
python main.py
```
5. Tester les plugins de fonctions
```
- Test Python Project Analysis
Dans la zone de saisie, entrez `./crazy_functions/test_project/python/dqn`, puis cliquez sur "Parse Entire Python Project"
- Test d'auto-lecture du code
Cliquez sur "[Démo multi-thread] Parser ce projet lui-même (auto-traduction de la source)"
- Test du modèle de fonctionnalité expérimentale (exige une réponse de l'IA à ce qui est arrivé aujourd'hui dans l'histoire). Vous pouvez utiliser cette fonctionnalité comme modèle pour des fonctions plus complexes.
Cliquez sur "[Démo modèle de plugin de fonction] Histoire du Jour"
- Le menu déroulant de la zone de plugin de fonctionnalité contient plus de fonctionnalités à sélectionner.
```
## Installation - Méthode 2 : Utilisation de docker (Linux)
Vous êtes un traducteur professionnel d'articles académiques en français.
1. ChatGPT seul (recommandé pour la plupart des gens)
``` sh
# Télécharger le projet
git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic
# Configurer le proxy outre-mer et la clé API OpenAI
Modifier le fichier config.py avec n'importe quel éditeur de texte
# Installer
docker build -t gpt-academic .
# Exécuter
docker run --rm -it --net=host gpt-academic
# Tester les modules de fonction
## Tester la fonction modèle des modules (requiert la réponse de GPT à "qu'est-ce qui s'est passé dans l'histoire aujourd'hui ?"), vous pouvez utiliser cette fonction en tant que modèle pour implémenter des fonctions plus complexes.
Cliquez sur "[Exemple de modèle de module] Histoire d'aujourd'hui"
## Tester le résumé écrit pour le projet LaTeX
Dans la zone de saisie, tapez ./crazy_functions/test_project/latex/attention, puis cliquez sur "Lire le résumé de l'article de recherche LaTeX"
## Tester l'analyse du projet Python
Dans la zone de saisie, tapez ./crazy_functions/test_project/python/dqn, puis cliquez sur "Analyser l'ensemble du projet Python"
D'autres fonctions sont disponibles dans la liste déroulante des modules de fonction.
```
2. ChatGPT+ChatGLM (nécessite une grande connaissance de docker et une configuration informatique suffisamment puissante)
``` sh
# Modifier le dockerfile
cd docs && nano Dockerfile+ChatGLM
# Comment construire | 如何构建 Dockerfile+ChatGLM在docs路径下,请先cd docs
docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
# Comment exécuter | 如何运行 (1) Directement exécuter :
docker run --rm -it --net=host --gpus=all gpt-academic
# Comment exécuter | 如何运行 (2) Je veux effectuer quelques ajustements dans le conteneur avant de lancer :
docker run --rm -it --net=host --gpus=all gpt-academic bash
```
## Installation - Méthode 3 : Autres méthodes de déploiement
1. Déploiement sur un cloud serveur distant
Veuillez consulter le [wiki de déploiement-1](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
2. Utilisation de WSL2 (Windows Subsystem for Linux)
Veuillez consulter le [wiki de déploiement-2](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
## Configuration de la procuration de l'installation
### Méthode 1 : Méthode conventionnelle
[Configuration de la procuration](https://github.com/binary-husky/chatgpt_academic/issues/1)
### Méthode 2 : Tutoriel pour débutant pur
[Tutoriel pour débutant pur](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BB%A3%E7%90%86%E8%BD%AF%E4%BB%B6%E9%97%AE%E9%A2%98%E7%9A%84%E6%96%B0%E6%89%8B%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%EF%BC%88%E6%96%B9%E6%B3%95%E5%8F%AA%E9%80%82%E7%94%A8%E4%BA%8E%E6%96%B0%E6%89%8B%EF%BC%89)
---
## Personnalisation des nouveaux boutons pratiques (personnalisation des raccourcis académiques)
Ouvrez le fichier `core_functional.py` avec n'importe quel éditeur de texte, ajoutez les éléments suivants, puis redémarrez le programme. (Si le bouton a déjà été ajouté avec succès et est visible, le préfixe et le suffixe pris en charge peuvent être modifiés à chaud sans avoir besoin de redémarrer le programme.)
Par exemple:
```
"Traduction Français-Chinois": {
# Préfixe, qui sera ajouté avant votre saisie. Par exemple, pour décrire votre demande, telle que la traduction, le débogage de code, l'amélioration, etc.
"Prefix": "Veuillez traduire le contenu ci-dessous en chinois, puis expliquer chaque terme propre mentionné dans un tableau Markdown :\n\n",
# Suffixe, qui sera ajouté après votre saisie. Par exemple, en combinaison avec un préfixe, vous pouvez mettre le contenu de votre saisie entre guillemets.
"Suffix": "",
},
```
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
</div>
---
## Présentation de certaines fonctionnalités
### Affichage des images:
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
</div>
### Si un programme peut comprendre et décomposer lui-même :
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
</div>
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
</div>
### Analyse de tout projet Python/Cpp quelconque :
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
</div>
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
</div>
### Lecture et résumé générés automatiquement pour les articles en Latex
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
</div>
### Génération de rapports automatique
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
</div>
### Conception de fonctionnalités modulaires
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
</div>
### Traduction de code source en anglais
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
</div>
## À faire et planification de version :
- version 3.2+ (à faire) : Prise en charge de plus de paramètres d'interface de plugin de fonction
- version 3.1 : Prise en charge de l'interrogation simultanée de plusieurs modèles GPT ! Prise en charge de l'API2d, prise en charge de la répartition de charge de plusieurs clés API
- version 3.0 : Prise en charge de chatglm et d'autres petits llm
- version 2.6 : Réorganisation de la structure du plugin, amélioration de l'interactivité, ajout de plus de plugins
- version 2.5 : Mise à jour automatique, résolution du problème de dépassement de jeton et de texte trop long lors de la compilation du code source complet
- version 2.4 : (1) Ajout de la fonctionnalité de traduction intégrale de PDF ; (2) Ajout d'une fonctionnalité de changement de position de zone de saisie ; (3) Ajout d'une option de disposition verticale ; (4) Optimisation du plugin de fonction multi-thread.
- version 2.3 : Amélioration de l'interactivité multi-thread
- version 2.2 : Prise en charge du rechargement à chaud du plugin de fonction
- version 2.1 : Mise en page pliable
- version 2.0 : Introduction du plugin de fonction modulaire
- version 1.0 : Fonctionnalité de base
## Références et apprentissage
```
De nombreux designs d'autres projets exceptionnels ont été utilisés pour référence dans le code, notamment :
# Projet 1 : De nombreuses astuces ont été empruntées à ChuanhuChatGPT
https://github.com/GaiZhenbiao/ChuanhuChatGPT
# Projet 2 : ChatGLM-6B de Tsinghua :
https://github.com/THUDM/ChatGLM-6B
```

302
docs/README_JP.md 普通文件
查看文件

@@ -0,0 +1,302 @@
> **Note**
>
> このReadmeファイルは、このプロジェクトのmarkdown翻訳プラグインによって自動的に生成されたもので、100%正確ではない可能性があります。
>
# <img src="logo.png" width="40" > ChatGPT 学術最適化
**このプロジェクトが好きだったら、スターをつけてください。もし、より使いやすい学術用のショートカットキーまたはファンクションプラグインを発明した場合は、issueを発行するかpull requestを作成してください。また、このプロジェクト自体によって翻訳されたREADMEは[英語説明書|](docs/README_EN.md)[日本語説明書|](docs/README_JP.md)[ロシア語説明書|](docs/README_RS.md)[フランス語説明書](docs/README_FR.md)もあります。**
> **注意事項**
>
> 1. **赤色**のラベルが付いているファンクションプラグインボタンのみファイルを読み込めます。一部のプラグインはプラグインエリアのドロップダウンメニューにあります。新しいプラグインのPRを歓迎いたします
>
> 2. このプロジェクトの各ファイルの機能は`self_analysis.md`自己解析レポートで詳しく説明されています。バージョンが追加されると、関連するファンクションプラグインをクリックして、GPTを呼び出して自己解析レポートを再生成することができます。一般的な質問は`wiki`にまとめられています。(`https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98`)
<div align="center">
機能 | 説明
--- | ---
ワンクリック整形 | 論文の文法エラーを一括で正確に修正できます。
ワンクリック日英翻訳 | 日英翻訳には、ワンクリックで対応できます。
ワンクリックコード説明 | コードの正しい表示と説明が可能です。
[カスタムショートカットキー](https://www.bilibili.com/video/BV14s4y1E7jN) | カスタムショートカットキーをサポートします。
[プロキシサーバーの設定](https://www.bilibili.com/video/BV1rc411W7Dr) | プロキシサーバーの設定をサポートします。
モジュラーデザイン | カスタム高階関数プラグインと[関数プラグイン]、プラグイン[ホット更新]のサポートが可能です。詳細は[こちら](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97)
[自己プログラム解析](https://www.bilibili.com/video/BV1cj411A7VW) | [関数プラグイン][ワンクリック理解](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A)このプロジェクトのソースコード
[プログラム解析機能](https://www.bilibili.com/video/BV1cj411A7VW) | [関数プラグイン] ワンクリックで別のPython/C/C++/Java/Lua/...プロジェクトツリーを解析できます。
論文読解 | [関数プラグイン] LaTeX論文の全文をワンクリックで解読し、要約を生成します。
LaTeX全文翻訳、整形 | [関数プラグイン] ワンクリックでLaTeX論文を翻訳または整形できます。
注釈生成 | [関数プラグイン] ワンクリックで関数の注釈を大量に生成できます。
チャット分析レポート生成 | [関数プラグイン] 実行後、まとめレポートを自動生成します。
[arxivヘルパー](https://www.bilibili.com/video/BV1LM4y1279X) | [関数プラグイン] 入力したarxivの記事URLで要約をワンクリック翻訳+PDFダウンロードができます。
[PDF論文全文翻訳機能](https://www.bilibili.com/video/BV1KT411x7Wn) | [関数プラグイン] PDF論文タイトルと要約を抽出し、全文を翻訳しますマルチスレッド
[Google Scholar Integratorヘルパー](https://www.bilibili.com/video/BV19L411U7ia) | [関数プラグイン] 任意のGoogle Scholar検索ページURLを指定すると、gptが興味深い記事を選択します。
数式/画像/テーブル表示 | 数式のTex形式とレンダリング形式を同時に表示できます。数式、コードのハイライトをサポートしています。
マルチスレッド関数プラグインサポート | ChatGPTをマルチスレッドで呼び出すことができ、大量のテキストやプログラムを簡単に処理できます。
ダークグラジオ[テーマ](https://github.com/binary-husky/chatgpt_academic/issues/173)の起動 | 「/?__dark-theme=true」というURLをブラウザに追加することで、ダークテーマに切り替えることができます。
[多数のLLMモデル](https://www.bilibili.com/video/BV1wT411p7yf)をサポート、[API2D](https://api2d.com/)インターフェースをサポート | GPT3.5、GPT4、[清華ChatGLM](https://github.com/THUDM/ChatGLM-6B)による同時サポートは、とても素晴らしいですね!
huggingface免科学上网[オンライン版](https://huggingface.co/spaces/qingxu98/gpt-academic) | huggingfaceにログイン後、[このスペース](https://huggingface.co/spaces/qingxu98/gpt-academic)をコピーしてください。
...... | ......
</div>
- 新しいインターフェースconfig.pyのLAYOUTオプションを変更するだけで、「左右レイアウト」と「上下レイアウト」を切り替えることができます
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
</div>
- すべてのボタンは、functional.pyを読み込んで動的に生成されます。カスタム機能を自由に追加して、クリップボードを解放します
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
</div>
- 色を修正/修正
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
</div>
- 出力に数式が含まれている場合、TeX形式とレンダリング形式の両方が表示され、コピーと読み取りが容易になります
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
</div>
- プロジェクトのコードを見るのが面倒?chatgptに整備されたプロジェクトを直接与えましょう
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
</div>
- 多数の大規模言語モデルの混合呼び出し(ChatGLM + OpenAI-GPT3.5 + [API2D](https://api2d.com/)-GPT4)
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
</div>
多数の大規模言語モデルの混合呼び出し[huggingfaceテスト版](https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta)(huggigface版はchatglmをサポートしていません)
---
## インストール-方法1直接運転 (Windows、LinuxまたはMacOS)
1. プロジェクトをダウンロードします。
```sh
git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic
```
2. API_KEYとプロキシ設定を構成する
`config.py`で、海外のProxyとOpenAI API KEYを構成して説明します。
```
1.あなたが中国にいる場合、OpenAI APIをスムーズに使用するには海外プロキシを設定する必要があります。構成の詳細については、config.py1.その中のUSE_PROXYをTrueに変更し、2.手順に従ってプロキシを変更する)を詳細に読んでください。
2. OpenAI API KEYを構成する。OpenAIのウェブサイトでAPI KEYを取得してください。一旦API KEYを手に入れると、config.pyファイルで設定するだけです。
3.プロキシネットワークに関連する問題(ネットワークタイムアウト、プロキシが動作しないをhttps://github.com/binary-husky/chatgpt_academic/issues/1にまとめました。
```
(P.S. プログラム実行時にconfig.pyの隣にconfig_private.pyという名前のプライバシー設定ファイルを作成し、同じ名前の設定を上書きするconfig_private.pyが存在するかどうかを優先的に確認します。そのため、私たちの構成読み取りロジックを理解できる場合は、config.pyの隣にconfig_private.pyという名前の新しい設定ファイルを作成し、その中のconfig.pyから設定を移動してください。config_private.pyはgitで保守されていないため、プライバシー情報をより安全にすることができます。)
3. 依存関係をインストールします。
```sh
# 選択肢があります。
python -m pip install -r requirements.txt
# (選択肢2) もしAnacondaを使用する場合、手順は同様です
# (選択肢2.1) conda create -n gptac_venv python=3.11
# (選択肢2.2) conda activate gptac_venv
# (選択肢2.3) python -m pip install -r requirements.txt
# 注: 公式のpipソースまたはAlibabaのpipソースを使用してください。 別のpipソース一部の大学のpipは問題が発生する可能性があります。 一時的なソースの切り替え方法:
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
```
もしあなたが清華ChatGLMをサポートする必要がある場合、さらに多くの依存関係をインストールする必要がありますPythonに慣れない方やコンピューターの設定が十分でない方は、試みないことをお勧めします
```sh
python -m pip install -r request_llm/requirements_chatglm.txt
```
4. 実行
```sh
python main.py
```
5. 関数プラグインのテスト
```
- Pythonプロジェクト分析のテスト
入力欄に `./crazy_functions/test_project/python/dqn` と入力し、「Pythonプロジェクト全体の解析」をクリックします。
- 自己コード解読のテスト
「[マルチスレッドデモ] このプロジェクト自体を解析します(ソースを翻訳して解読します)」をクリックします。
- 実験的な機能テンプレート関数のテストGPTが「今日の歴史」に何が起こったかを回答することが求められます。この関数をテンプレートとして使用して、より複雑な機能を実装できます。
「[関数プラグインテンプレートデモ] 今日の歴史」をクリックします。
- 関数プラグインエリアのドロップダウンメニューには他にも選択肢があります。
```
## インストール方法2Dockerを使用するLinux
1. ChatGPTのみ大多数の人にお勧めです
``` sh
# プロジェクトのダウンロード
git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic
# 海外プロキシとOpenAI API KEYの設定
config.pyを任意のテキストエディタで編集する
# インストール
docker build -t gpt-academic .
# 実行
docker run --rm -it --net=host gpt-academic
# 関数プラグインのテスト
## 関数プラグインテンプレート関数のテストGPTが「今日の歴史」に何が起こったかを回答することが求められます。この関数をテンプレートとして使用して、より複雑な機能を実装できます。
「[関数プラグインテンプレートデモ] 今日の歴史」をクリックします。
## Latexプロジェクトの要約を書くテスト
入力欄に./crazy_functions/test_project/latex/attentionと入力し、「テックス論文を読んで要約を書く」をクリックします。
## Pythonプロジェクト分析のテスト
入力欄に./crazy_functions/test_project/python/dqnと入力し、[Pythonプロジェクトの全解析]をクリックします。
関数プラグインエリアのドロップダウンメニューには他にも選択肢があります。
```
2. ChatGPT + ChatGLMDockerに非常に詳しい人+十分なコンピューター設定が必要)
```sh
# Dockerfileの編集
cd docs && nano Dockerfile+ChatGLM
# ビルド方法
docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
# 実行方法 (1) 直接実行:
docker run --rm -it --net=host --gpus=all gpt-academic
# 実行方法 (2) コンテナに入って調整する:
docker run --rm -it --net=host --gpus=all gpt-academic bash
```
## インストール方法3その他のデプロイ方法
1. クラウドサーバーデプロイ
[デプロイwiki-1](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
2. WSL2を使用 (Windows Subsystem for Linux)
[デプロイwiki-2](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
## インストール-プロキシ設定
1. 通常の方法
[プロキシを設定する](https://github.com/binary-husky/chatgpt_academic/issues/1)
2. 初心者向けチュートリアル
[初心者向けチュートリアル](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BB%A3%E7%90%86%E8%BD%AF%E4%BB%B6%E9%97%AE%E9%A2%98%E7%9A%84%E6%96%B0%E6%89%8B%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%EF%BC%88%E6%96%B9%E6%B3%95%E5%8F%AA%E9%80%82%E7%94%A8%E4%BA%8E%E6%96%B0%E6%89%8B%EF%BC%89)
---
## カスタムボタンの追加(学術ショートカットキー)
`core_functional.py`を任意のテキストエディタで開き、以下のエントリーを追加し、プログラムを再起動してください。(ボタンが追加されて表示される場合、前置詞と後置詞はホット編集がサポートされているため、プログラムを再起動せずに即座に有効になります。)
例:
```
"超级英译中": {
# 前置詞 - あなたの要求を説明するために使用されます。翻訳、コードの説明、編集など。
"Prefix": "以下のコンテンツを中国語に翻訳して、マークダウンテーブルを使用して専門用語を説明してください。\n\n",
# 後置詞 - プレフィックスと共に使用すると、入力内容を引用符で囲むことができます。
"Suffix": "",
},
```
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
</div>
---
## いくつかの機能の例
### 画像表示:
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
</div>
### プログラムが自己解析できる場合:
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
</div>
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
</div>
### 他のPython/Cppプロジェクトの解析
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
</div>
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
</div>
### Latex論文の一括読解と要約生成
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
</div>
### 自動報告生成
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
</div>
### モジュール化された機能デザイン
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
</div>
### ソースコードの英語翻訳
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
</div>
## Todo およびバージョン計画:
- version 3.2+ (todo): 関数プラグインがより多くのパラメーターインターフェースをサポートするようになります。
- version 3.1: 複数のgptモデルを同時にクエリし、api2dをサポートし、複数のapikeyの負荷分散をサポートします。
- version 3.0: chatglmおよび他の小型llmのサポート
- version 2.6: プラグイン構造を再構成し、相互作用性を高め、より多くのプラグインを追加しました。
- version 2.5: 自己更新。総括的な大規模プロジェクトのソースコードをまとめた場合、テキストが長すぎる、トークンがオーバーフローする問題を解決します。
- version 2.4: (1)PDF全文翻訳機能を追加。(2)入力エリアの位置を切り替える機能を追加。(3)垂直レイアウトオプションを追加。(4)マルチスレッド関数プラグインの最適化。
- version 2.3: 多スレッドの相互作用性を向上させました。
- version 2.2: 関数プラグインでホットリロードをサポート
- version 2.1: 折りたたみ式レイアウト
- version 2.0: モジュール化された関数プラグインを導入
- version 1.0: 基本機能
## 参考および学習
以下は中国語のマークダウンファイルです。日本語に翻訳してください。既存のマークダウンコマンドを変更しないでください:
```
多くの優秀なプロジェクトの設計を参考にしています。主なものは以下の通りです:
# 参考プロジェクト1ChuanhuChatGPTから多くのテクニックを借用
https://github.com/GaiZhenbiao/ChuanhuChatGPT
# 参考プロジェクト2清華ChatGLM-6B
https://github.com/THUDM/ChatGLM-6B
```

291
docs/README_RS.md 普通文件
查看文件

@@ -0,0 +1,291 @@
> **Note**
>
> Этот файл самовыражения автоматически генерируется модулем перевода markdown в этом проекте и может быть не на 100% правильным.
>
# <img src="logo.png" width="40" > ChatGPT Academic Optimization
**Если вам понравился этот проект, пожалуйста, поставьте ему звезду. Если вы придумали более полезные академические ярлыки или функциональные плагины, не стесняйтесь создавать запросы на изменение или пул-запросы. Мы также имеем [README на английском языке](docs/README_EN.md), переведенный этим же проектом.
> **Примечание**
>
> 1. Пожалуйста, обратите внимание, что только функциonal plugins (buttons) с **красным цветом** могут читать файлы, некоторые из которых находятся в **выпадающем меню** плагинов. Кроме того, мы приветствуем и обрабатываем любые новые плагины с **наивысшим приоритетом**!
>
> 2. Функции каждого файла в этом проекте подробно описаны в собственном анализе [`self_analysis.md`](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A) . При повторных итерациях вы также можете вызывать обновленный отчет функций проекта, щелкнув соответствующий функциональный плагин GPT. Часто задаваемые вопросы собраны в [`wiki`](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98) .
<div align="center">
Функция | Описание
--- | ---
Редактирование одним кликом | Поддержка редактирования одним кликом, поиск грамматических ошибок в академических статьях
Переключение языков "Английский-Китайский" одним кликом | Одним кликом переключайте языки "Английский-Китайский"
Разъяснение программного кода одним кликом | Вы можете правильно отобразить и объяснить программный код.
[Настраиваемые сочетания клавиш](https://www.bilibili.com/video/BV14s4y1E7jN) | Поддержка настраиваемых сочетаний клавиш
[Настройка сервера-прокси](https://www.bilibili.com/video/BV1rc411W7Dr) | Поддержка настройки сервера-прокси
Модульный дизайн | Поддержка настраиваемых функциональных плагинов высших порядков и функциональных плагинов, поддерживающих [горячее обновление](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97)
[Автоанализ программы](https://www.bilibili.com/video/BV1cj411A7VW) | [Функциональный плагин] [Прочтение в один клик](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A) кода программы проекта
[Анализ программы](https://www.bilibili.com/video/BV1cj411A7VW) | [Функциональный плагин] Один клик для проанализирования дерева других проектов Python/C/C++/Java/Lua/...
Чтение статей| [Функциональный плагин] Одним кликом прочитайте весь латех (LaTex) текст статьи и сгенерируйте краткое описание
Перевод и редактирование всех статей из LaTex | [Функциональный плагин] Перевод или редактирование LaTex-статьи всего одним нажатием кнопки
Генерация комментариев в пакетном режиме | [Функциональный плагин] Одним кликом сгенерируйте комментарии к функциям в пакетном режиме
Генерация отчетов пакета CHAT | [Функциональный плагин] Автоматически создавайте сводные отчеты после выполнения
[Помощник по arxiv](https://www.bilibili.com/video/BV1LM4y1279X) | [Функциональный плагин] Введите URL статьи arxiv, чтобы легко перевести резюме и загрузить PDF-файл
[Перевод полного текста статьи в формате PDF](https://www.bilibili.com/video/BV1KT411x7Wn) | [Функциональный плагин] Извлеките заголовок статьи, резюме и переведите весь текст статьи (многопоточно)
[Помощник интеграции Google Scholar](https://www.bilibili.com/video/BV19L411U7ia) | [Функциональный плагин] Дайте GPT выбрать для вас интересные статьи на любой странице поиска Google Scholar.
Отображение формул/изображений/таблиц | Одновременно отображается tex-форма и рендер-форма формул, поддержка формул, высокоскоростных кодов
Поддержка функциональных плагинов многопоточности | Поддержка многопоточной работы с плагинами, обрабатывайте огромные объемы текста или программы одним кликом
Запуск темной темы gradio[подробнее](https://github.com/binary-husky/chatgpt_academic/issues/173) | Добавьте / ?__dark-theme=true в конец URL браузера, чтобы переключиться на темную тему.
[Поддержка нескольких моделей LLM](https://www.bilibili.com/video/BV1wT411p7yf), поддержка API2D | Находиться между GPT3.5, GPT4 и [清华ChatGLM](https://github.com/THUDM/ChatGLM-6B) должно быть очень приятно, не так ли?
Альтернатива huggingface без использования научной сети [Онлайн-эксперимент](https://huggingface.co/spaces/qingxu98/gpt-academic) | Войдите в систему, скопируйте пространство [этот пространственный URL](https://huggingface.co/spaces/qingxu98/gpt-academic)
…… | ……
</div>
- Новый интерфейс (вы можете изменить настройку LAYOUT в config.py, чтобы переключаться между "горизонтальным расположением" и "вертикальным расположением")
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
</div>
Вы профессиональный переводчик научных статей.
- Все кнопки генерируются динамически путем чтения functional.py и могут быть легко настроены под пользовательские потребности, освобождая буфер обмена.
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
</div>
- Редактирование/корректирование
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
</div>
- Если вывод содержит формулы, они отображаются одновременно как в формате tex, так и в рендеринговом формате для удобства копирования и чтения.
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
</div>
- Лень смотреть код проекта? Просто покажите chatgpt.
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
</div>
- Несколько моделей больших языковых моделей смешиваются (ChatGLM + OpenAI-GPT3.5 + [API2D] (https://api2d.com/) -GPT4)
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
</div>
Несколько моделей больших языковых моделей смешиваются в [бета-версии huggingface] (https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta) (huggingface-версия не поддерживает chatglm).
---
## Установка - Метод 1: Запуск (Windows, Linux или MacOS)
1. Скачайте проект
```sh
git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic
```
2. Настройка API_KEY и настройки прокси
В файле `config.py` настройте зарубежный прокси и OpenAI API KEY, пояснения ниже
```
1. Если вы находитесь в Китае, вам нужно настроить зарубежный прокси, чтобы использовать OpenAI API. Пожалуйста, внимательно прочитайте config.py для получения инструкций (1. Измените USE_PROXY на True; 2. Измените прокси в соответствии с инструкциями).
2. Настройка API KEY OpenAI. Вам необходимо зарегистрироваться на сайте OpenAI и получить API KEY. После получения API KEY настройте его в файле config.py.
3. Вопросы, связанные с сетевыми проблемами (тайм-аут сети, прокси не работает), можно найти здесь: https://github.com/binary-husky/chatgpt_academic/issues/1
```
(Примечание: при запуске программы будет проверяться наличие конфиденциального файла конфигурации с именем `config_private.py` и использоваться в нем конфигурация параметров, которая перезаписывает параметры с такими же именами в `config.py`. Поэтому, если вы понимаете логику чтения нашей конфигурации, мы настоятельно рекомендуем вам создать новый файл конфигурации с именем `config_private.py` рядом с `config.py` и переместить (скопировать) настройки из `config.py` в `config_private.py`. `config_private.py` не подвергается контролю git, что делает конфиденциальную информацию более безопасной.)
3. Установить зависимости
```sh
# (Выбор 1) Рекомендуется
python -m pip install -r requirements.txt
# (Выбор 2) Если вы используете anaconda, то шаги будут аналогичны:
# (Шаг 2.1) conda create -n gptac_venv python=3.11
# (Шаг 2.2) conda activate gptac_venv
# (Шаг 2.3) python -m pip install -r requirements.txt
# Примечание: используйте официальный источник pip или источник pip.aliyun.com. Другие источники pip могут вызывать проблемы. временный метод замены источника:
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
```
Если требуется поддержка TUNA ChatGLM, необходимо установить дополнительные зависимости (если вы неудобны с python, необходимо иметь хорошую конфигурацию компьютера):
```sh
python -m pip install -r request_llm/requirements_chatglm.txt
```
4. Запустите
```sh
python main.py
```
5. Тестовые функции плагина
```
- Тестирвоание анализа проекта Python
В основной области введите `./crazy_functions/test_project/python/dqn` , а затем нажмите "Анализировать весь проект Python"
- Тестирование самостоятельного чтения кода
Щелкните " [Демонстрационный режим многопоточности] Проанализируйте сам проект (расшифровка источника кода)"
- Тестирование функций шаблонного плагина (вы можете использовать эту функцию как шаблон для более сложных функций, требующих ответа от gpt в связи с тем, что произошло сегодня в истории)
Щелкните " [Функции шаблонного плагина] День в истории"
- На нижней панели дополнительные функции для выбора
```
## Установка - Метод 2: Использование docker (Linux)
1. Только ChatGPT (рекомендуется для большинства пользователей):
``` sh
# Скачать проект
git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic
# Настроить прокси за границей и OpenAI API KEY
Отредактируйте файл config.py в любом текстовом редакторе.
# Установка
docker build -t gpt-academic .
# Запустить
docker run --rm -it --net=host gpt-academic
# Проверка функциональности плагина
## Проверка шаблонной функции плагина (требуется, чтобы gpt ответил, что произошло "в истории на этот день"), вы можете использовать эту функцию в качестве шаблона для реализации более сложных функций.
Нажмите "[Шаблонный демонстрационный плагин] История на этот день".
## Тест абстрактного резюме для проекта на Latex
В области ввода введите ./crazy_functions/test_project/latex/attention, а затем нажмите "Чтение реферата о тезисах статьи на LaTeX".
## Тестовый анализ проекта на Python
Введите в область ввода ./crazy_functions/test_project/python/dqn, затем нажмите "Проанализировать весь проект на Python".
Выбирайте больше функциональных плагинов в нижнем выпадающем меню.
```
2. ChatGPT + ChatGLM (требуется глубокое знание Docker и достаточно мощное компьютерное оборудование):
``` sh
# Изменение Dockerfile
cd docs && nano Dockerfile+ChatGLM
# Как построить | Как запустить (Dockerfile+ChatGLM в пути docs, сначала перейдите в папку с помощью cd docs)
docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
# Как запустить | Как запустить (2) я хочу войти в контейнер и сделать какие-то настройки до запуска:
docker run --rm -it --net=host --gpus=all gpt-academic bash
```
## Установка-Метод 3: Другие способы развертывания
1. Развертывание на удаленном облачном сервере
Пожалуйста, посетите [Deploy Wiki-1] (https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
2. Использование WSL2 (Windows Subsystem for Linux)
Пожалуйста, посетите [Deploy Wiki-2] (https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
## Установка-Настройки прокси
### Метод 1: Обычный способ
[Конфигурация прокси] (https://github.com/binary-husky/chatgpt_academic/issues/1)
### Метод 2: Руководство новичка
[Руководство новичка] (https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BB%A3%E7%90%86%E8%BD%AF%E4%BB%B6%E9%97%AE%E9%A2%98%E7%9A%84%E6%96%B0%E6%89%8B%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%EF%BC%88%E6%96%B9%E6%B3%95%E5%8F%AA%E9%80%82%E7%94%A8%E4%BA%8E%E6%96%B0%E6%89%8B%EF%BC%89)
---
## Настройка новой удобной кнопки (настройка быстрой клавиши для научной работы)
Откройте `core_functional.py` любым текстовым редактором, добавьте элементы, как показано ниже, затем перезапустите программу. (Если кнопка уже успешно добавлена и видна, то префикс и суффикс поддерживают горячее изменение, чтобы они оказались в действии, не нужно перезапускать программу.)
например
```
"Супер анг-рус": {
# Префикс, будет добавлен перед вашим вводом. Например, используется для описания ваших потребностей, таких как перевод, кодинг, редактирование и т. д.
"Prefix": "Пожалуйста, переведите этот фрагмент на русский язык, а затем создайте пошаговую таблицу в markdown, чтобы объяснить все специализированные термины, которые встречаются в тексте:\n\n",
# Суффикс, будет добавлен после вашего ввода. Например, совместно с префиксом можно обрамить ваш ввод в кавычки.
"Suffix": "",
},
```
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
</div>
---
## Демонстрация некоторых возможностей
### Отображение изображений:
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
</div>
### Если программа может понимать и разбирать сама себя:
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
</div>
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
</div>
### Анализ других проектов на Python/Cpp:
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
</div>
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
</div>
### Генерация понимания и абстрактов с помощью Латех статей в один клик
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
</div>
### Автоматическое создание отчетов
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
<img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
</div>
### Модульный дизайн функций
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
</div>
### Трансляция исходного кода на английский язык
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
</div>
## Todo и планирование версий:
- version 3.2+ (todo): функция плагины поддерживают более многочисленные интерфейсы параметров
- version 3.1: поддержка одновременного опроса нескольких моделей gpt! Поддержка api2d, поддержка балансировки нагрузки множества apikey.
- version 3.0: поддержка chatglm и других маленьких llm
- version 2.6: реструктурировал структуру плагинов, повысил интерактивность, добавил больше плагинов
- version 2.5: само обновление, решение проблемы слишком длинного текста и переполнения токена при переводе всего проекта исходного кода
- version 2.4: (1) добавлена функция перевода всего PDF-документа; (2) добавлена функция изменения положения входной области; (3) добавлена опция вертикального макета; (4) оптимизация функций многопоточности плагина.
- version 2.3: улучшение многопоточной интерактивности
- version 2.2: функция плагинов поддерживает горячую перезагрузку
- version 2.1: блочная раскладка
- version 2.0: модульный дизайн функций плагина
- version 1.0: основные функции
## Ссылки на изучение и обучение
```
В коде использовано много хороших дизайнерских решений из других отличных проектов, в том числе:
# Project1: использование многих приемов из ChuanhuChatGPT
https://github.com/GaiZhenbiao/ChuanhuChatGPT
# Project2: ChatGLM-6B в Тхуде:
https://github.com/THUDM/ChatGLM-6B
```

43
docs/WithFastapi.md 普通文件
查看文件

@@ -0,0 +1,43 @@
# Running with fastapi
We currently support fastapi in order to solve sub-path deploy issue.
1. change CUSTOM_PATH setting in `config.py`
``` sh
nano config.py
```
2. Edit main.py
```diff
auto_opentab_delay()
- demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png")
+ demo.queue(concurrency_count=CONCURRENT_COUNT)
- # 如果需要在二级路径下运行
- # CUSTOM_PATH, = get_conf('CUSTOM_PATH')
- # if CUSTOM_PATH != "/":
- # from toolbox import run_gradio_in_subpath
- # run_gradio_in_subpath(demo, auth=AUTHENTICATION, port=PORT, custom_path=CUSTOM_PATH)
- # else:
- # demo.launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png")
+ 如果需要在二级路径下运行
+ CUSTOM_PATH, = get_conf('CUSTOM_PATH')
+ if CUSTOM_PATH != "/":
+ from toolbox import run_gradio_in_subpath
+ run_gradio_in_subpath(demo, auth=AUTHENTICATION, port=PORT, custom_path=CUSTOM_PATH)
+ else:
+ demo.launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png")
if __name__ == "__main__":
main()
```
3. Go!
``` sh
python main.py
```

查看文件

@@ -157,7 +157,7 @@
## [22/31] 请对下面的程序文件做一个概述: H:\chatgpt_academic_resolve\crazy_functions\解析项目源代码.py ## [22/31] 请对下面的程序文件做一个概述: H:\chatgpt_academic_resolve\crazy_functions\解析项目源代码.py
这个程序文件实现了对一个源代码项目进行分析的功能其中函数`解析项目本身``解析一个Python项目``解析一个C项目的头文件``解析一个C项目``解析一个Java项目``解析一个Rect项目`分别用于解析不同类型的项目函数`解析源代码新`实现了对每一个源代码文件的分析并将分析结果汇总同时还实现了分组和迭代处理提高了效率最后函数`write_results_to_file`将所有分析结果写入文件中间还用到了`request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency``request_gpt_model_in_new_thread_with_ui_alive`来完成请求和响应并用`update_ui`实时更新界面 这个程序文件实现了对一个源代码项目进行分析的功能其中函数`解析项目本身``解析一个Python项目``解析一个C项目的头文件``解析一个C项目``解析一个Java项目``解析前端项目`分别用于解析不同类型的项目函数`解析源代码新`实现了对每一个源代码文件的分析并将分析结果汇总同时还实现了分组和迭代处理提高了效率最后函数`write_results_to_file`将所有分析结果写入文件中间还用到了`request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency``request_gpt_model_in_new_thread_with_ui_alive`来完成请求和响应并用`update_ui`实时更新界面
## [23/31] 请对下面的程序文件做一个概述: H:\chatgpt_academic_resolve\crazy_functions\询问多个大语言模型.py ## [23/31] 请对下面的程序文件做一个概述: H:\chatgpt_academic_resolve\crazy_functions\询问多个大语言模型.py

130
docs/test_markdown_format.py 普通文件
查看文件

@@ -0,0 +1,130 @@
sample = """
[1]: https://baike.baidu.com/item/%E8%B4%A8%E8%83%BD%E6%96%B9%E7%A8%8B/1884527 "质能方程质能方程式_百度百科"
[2]: https://www.zhihu.com/question/348249281 "如何理解质能方程 Emc²? - 知乎"
[3]: https://zhuanlan.zhihu.com/p/32597385 "质能方程的推导与理解 - 知乎 - 知乎专栏"
你好,这是必应。质能方程是描述质量与能量之间的当量关系的方程[^1^][1]。用tex格式,质能方程可以写成$$E=mc^2$$,其中$E$是能量,$m$是质量,$c$是光速[^2^][2] [^3^][3]。
"""
import re
def preprocess_newbing_out(s):
pattern = r'\^(\d+)\^' # 匹配^数字^
pattern2 = r'\[(\d+)\]' # 匹配^数字^
sub = lambda m: '\['+m.group(1)+'\]' # 将匹配到的数字作为替换值
result = re.sub(pattern, sub, s) # 替换操作
if '[1]' in result:
result += '<br/><hr style="border-top: dotted 1px #44ac5c;"><br/><small>' + "<br/>".join([re.sub(pattern2, sub, r) for r in result.split('\n') if r.startswith('[')]) + '</small>'
return result
def close_up_code_segment_during_stream(gpt_reply):
"""
在gpt输出代码的中途输出了前面的```,但还没输出完后面的```),补上后面的```
Args:
gpt_reply (str): GPT模型返回的回复字符串。
Returns:
str: 返回一个新的字符串,将输出代码片段的“后面的```”补上。
"""
if '```' not in gpt_reply:
return gpt_reply
if gpt_reply.endswith('```'):
return gpt_reply
# 排除了以上两个情况,我们
segments = gpt_reply.split('```')
n_mark = len(segments) - 1
if n_mark % 2 == 1:
# print('输出代码片段中!')
return gpt_reply+'\n```'
else:
return gpt_reply
import markdown
from latex2mathml.converter import convert as tex2mathml
from functools import wraps, lru_cache
def markdown_convertion(txt):
"""
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
"""
pre = '<div class="markdown-body">'
suf = '</div>'
if txt.startswith(pre) and txt.endswith(suf):
# print('警告,输入了已经经过转化的字符串,二次转化可能出问题')
return txt # 已经被转化过,不需要再次转化
markdown_extension_configs = {
'mdx_math': {
'enable_dollar_delimiter': True,
'use_gitlab_delimiters': False,
},
}
find_equation_pattern = r'<script type="math/tex(?:.*?)>(.*?)</script>'
def tex2mathml_catch_exception(content, *args, **kwargs):
try:
content = tex2mathml(content, *args, **kwargs)
except:
content = content
return content
def replace_math_no_render(match):
content = match.group(1)
if 'mode=display' in match.group(0):
content = content.replace('\n', '</br>')
return f"<font color=\"#00FF00\">$$</font><font color=\"#FF00FF\">{content}</font><font color=\"#00FF00\">$$</font>"
else:
return f"<font color=\"#00FF00\">$</font><font color=\"#FF00FF\">{content}</font><font color=\"#00FF00\">$</font>"
def replace_math_render(match):
content = match.group(1)
if 'mode=display' in match.group(0):
if '\\begin{aligned}' in content:
content = content.replace('\\begin{aligned}', '\\begin{array}')
content = content.replace('\\end{aligned}', '\\end{array}')
content = content.replace('&', ' ')
content = tex2mathml_catch_exception(content, display="block")
return content
else:
return tex2mathml_catch_exception(content)
def markdown_bug_hunt(content):
"""
解决一个mdx_math的bug单$包裹begin命令时多余<script>
"""
content = content.replace('<script type="math/tex">\n<script type="math/tex; mode=display">', '<script type="math/tex; mode=display">')
content = content.replace('</script>\n</script>', '</script>')
return content
if ('$' in txt) and ('```' not in txt): # 有$标识的公式符号,且没有代码段```的标识
# convert everything to html format
split = markdown.markdown(text='---')
convert_stage_1 = markdown.markdown(text=txt, extensions=['mdx_math', 'fenced_code', 'tables', 'sane_lists'], extension_configs=markdown_extension_configs)
convert_stage_1 = markdown_bug_hunt(convert_stage_1)
# re.DOTALL: Make the '.' special character match any character at all, including a newline; without this flag, '.' will match anything except a newline. Corresponds to the inline flag (?s).
# 1. convert to easy-to-copy tex (do not render math)
convert_stage_2_1, n = re.subn(find_equation_pattern, replace_math_no_render, convert_stage_1, flags=re.DOTALL)
# 2. convert to rendered equation
convert_stage_2_2, n = re.subn(find_equation_pattern, replace_math_render, convert_stage_1, flags=re.DOTALL)
# cat them together
return pre + convert_stage_2_1 + f'{split}' + convert_stage_2_2 + suf
else:
return pre + markdown.markdown(txt, extensions=['fenced_code', 'codehilite', 'tables', 'sane_lists']) + suf
sample = preprocess_newbing_out(sample)
sample = close_up_code_segment_during_stream(sample)
sample = markdown_convertion(sample)
with open('tmp.html', 'w', encoding='utf8') as f:
f.write("""
<head>
<title>My Website</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
""")
f.write(sample)

查看文件

@@ -0,0 +1,23 @@
try {
$("<link>").attr({href: "file=docs/waifu_plugin/waifu.css", rel: "stylesheet", type: "text/css"}).appendTo('head');
$('body').append('<div class="waifu"><div class="waifu-tips"></div><canvas id="live2d" class="live2d"></canvas><div class="waifu-tool"><span class="fui-home"></span> <span class="fui-chat"></span> <span class="fui-eye"></span> <span class="fui-user"></span> <span class="fui-photo"></span> <span class="fui-info-circle"></span> <span class="fui-cross"></span></div></div>');
$.ajax({url: "file=docs/waifu_plugin/waifu-tips.js", dataType:"script", cache: true, success: function() {
$.ajax({url: "file=docs/waifu_plugin/live2d.js", dataType:"script", cache: true, success: function() {
/* 可直接修改部分参数 */
live2d_settings['hitokotoAPI'] = "hitokoto.cn"; // 一言 API
live2d_settings['modelId'] = 5; // 默认模型 ID
live2d_settings['modelTexturesId'] = 1; // 默认材质 ID
live2d_settings['modelStorage'] = false; // 不储存模型 ID
live2d_settings['waifuSize'] = '210x187';
live2d_settings['waifuTipsSize'] = '187x52';
live2d_settings['canSwitchModel'] = true;
live2d_settings['canSwitchTextures'] = true;
live2d_settings['canSwitchHitokoto'] = false;
live2d_settings['canTakeScreenshot'] = false;
live2d_settings['canTurnToHomePage'] = false;
live2d_settings['canTurnToAboutPage'] = false;
/* 在 initModel 前添加 */
initModel("file=docs/waifu_plugin/waifu-tips.json");
}});
}});
} catch(err) { console.log("[Error] JQuery is not defined.") }

二进制文件未显示。

查看文件

@@ -0,0 +1,126 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
<json>
{
"fontFamily": "flat-ui-icons",
"majorVersion": 1,
"minorVersion": 1,
"fontURL": "http://designmodo.com/flat",
"designer": "Sergey Shmidt",
"designerURL": "http://designmodo.com",
"license": "Attribution-NonCommercial-NoDerivs 3.0 Unported",
"licenseURL": "http://creativecommons.org/licenses/by-nc-nd/3.0/",
"version": "Version 1.1",
"fontId": "flat-ui-icons",
"psName": "flat-ui-icons",
"subFamily": "Regular",
"fullName": "flat-ui-icons",
"description": "Generated by IcoMoon"
}
</json>
</metadata>
<defs>
<font id="flat-ui-icons" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" d="" horiz-adv-x="512" />
<glyph unicode="&#xe600;" d="M896 192l-384 512-384-512h768z" />
<glyph unicode="&#xe601;" d="M128 704l384-512 384 512h-768z" />
<glyph unicode="&#xe602;" d="M896 256h-768l384 384 384-384z" />
<glyph unicode="&#xe603;" d="M512 256l-384 384h768l-384-384z" />
<glyph unicode="&#xe604;" d="M896 0l-768 448 768 448v-896z" />
<glyph unicode="&#xe605;" d="M128 896l768-448-768-448v896z" />
<glyph unicode="&#xe606;" d="M224.96 448.768l447.168 447.232 128-131.008-321.152-318.016 321.152-320.896-128.256-128.256-446.912 450.944z" />
<glyph unicode="&#xe607;" d="M353.152-2.112l-128.192 128.256 321.088 320.896-321.152 317.952 128 131.008 447.168-447.232-446.912-450.88z" />
<glyph unicode="&#xe608;" d="M928 351.936h-320v-319.936c0-35.392-28.608-64-64-64h-64c-35.328 0-64 28.608-64 64v319.936h-320c-35.328 0-64 28.736-64 64.064v64.064c0 35.328 28.672 63.872 64 63.872h320v320.064c0 35.328 28.672 64 64 64h64c35.392 0 64-28.672 64-64v-320.064h320c35.392 0 64-28.544 64-63.872v-64.064c0-35.328-28.608-64.064-64-64.064z" />
<glyph unicode="&#xe609;" d="M919.808 764.032c12.48-12.416 12.48-32.832 0-45.248l-248.896-249.024c-12.352-12.416-12.352-32.832 0-45.312l248.768-249.088c12.48-12.416 12.48-32.832 0-45.248l-90.624-90.432c-12.352-12.416-32.768-12.416-45.248 0l-248.64 249.088c-12.416 12.416-32.832 12.416-45.248 0l-248.896-248.896c-12.416-12.48-32.832-12.48-45.248 0l-90.496 90.624c-12.416 12.352-12.416 32.768 0 45.248l248.96 248.896c12.416 12.416 12.416 32.832 0 45.312l-248.768 249.024c-12.416 12.48-12.416 32.832 0 45.248l90.56 90.496c12.416 12.416 32.832 12.416 45.248 0l248.64-249.024c12.416-12.48 32.832-12.48 45.248-0.064l248.832 248.96c12.48 12.352 32.896 12.352 45.248 0l90.56-90.56z" />
<glyph unicode="&#xe60a;" d="M923.136 822.592c-12.352 12.544-32.768 12.544-45.12 0l-476.16-474.496c-12.48-12.544-32.832-12.544-45.248 0l-208.64 212.736c-6.144 6.208-14.272 9.408-22.336 9.472-8.256 0-16.576-3.008-22.848-9.472l-92.16-83.008c-6.144-6.272-9.472-14.144-9.472-22.336 0-8.32 3.328-17.024 9.472-23.232l210.368-220.992c12.416-12.48 32.832-33.024 45.248-45.632l90.432-91.264c12.416-12.48 32.768-12.48 45.248 0l611.712 611.328c12.48 12.48 12.48 33.088 0 45.632l-90.496 91.264z" />
<glyph unicode="&#xe60b;" d="M512 960c-281.6 0-512-230.4-512-512s230.4-512 512-512 512 230.4 512 512c0 281.6-230.4 512-512 512zM512 140.8c-168.96 0-307.2 138.24-307.2 307.2s138.24 307.2 307.2 307.2c168.96 0 307.2-138.24 307.2-307.2 0-168.96-138.24-307.2-307.2-307.2z" />
<glyph unicode="&#xe60c;" d="M512 960c-281.6 0-512-230.4-512-512s230.4-512 512-512 512 230.4 512 512c0 281.6-230.4 512-512 512zM512 140.8c-168.96 0-307.2 138.24-307.2 307.2s138.24 307.2 307.2 307.2c168.96 0 307.2-138.24 307.2-307.2 0-168.96-138.24-307.2-307.2-307.2zM512 601.6c-87.040 0-153.6-66.56-153.6-153.6s66.56-153.6 153.6-153.6 153.6 66.56 153.6 153.6c0 87.040-66.56 153.6-153.6 153.6z" />
<glyph unicode="&#xe60d;" d="M256 960h512c143.36 0 256-112.64 256-256v-512c0-143.36-112.64-256-256-256h-512c-143.36 0-256 112.64-256 256v512c0 143.36 112.64 256 256 256z" />
<glyph unicode="&#xe60e;" d="M768 960h-512c-143.36 0-256-112.64-256-256v-512c0-143.36 112.64-256 256-256h512c143.36 0 256 112.64 256 256v512c0 143.36-112.64 256-256 256zM844.8 550.4l-368.64-368.64c-5.12-5.12-20.48-5.12-25.6 0l-56.32 56.32c-5.12 5.12-20.48 20.48-25.6 25.6l-128 133.12c-5.12 5.12-5.12 10.24-5.12 15.36s0 10.24 5.12 15.36l56.32 51.2c5.12 0 10.24 5.12 10.24 5.12 5.12 0 10.24 0 15.36-5.12l122.88-128c5.12-5.12 20.48-5.12 25.6 0l286.72 286.72c5.12 5.12 20.48 5.12 25.6 0l56.32-56.32c10.24-10.24 10.24-20.48 5.12-30.72z" />
<glyph unicode="&#xe60f;" d="M512 960c-282.752 0-512-229.248-512-512 0-282.688 229.248-512 512-512 282.816 0 512 229.248 512 512 0 282.752-229.184 512-512 512zM576.768 195.136c0-37.056-28.992-67.072-64.768-67.072s-64.768 30.016-64.768 67.072v313.088c0 37.056 28.992 67.072 64.768 67.072s64.768-30.016 64.768-67.072v-313.088zM512 640.32c-35.776 0-64.768 28.608-64.768 63.872s28.992 63.744 64.768 63.744 64.768-28.544 64.768-63.808-28.992-63.808-64.768-63.808z" />
<glyph unicode="&#xe610;" d="M512 960c-282.752 0-512-229.248-512-512s229.248-512 512-512c282.752 0 512 229.248 512 512 0 282.752-229.248 512-512 512zM512 128.064c-35.776 0-64.768 28.544-64.768 63.808 0 35.2 28.992 63.808 64.768 63.808 35.776 0 64.768-28.608 64.768-63.808 0-35.264-28.992-63.808-64.768-63.808zM576.768 387.776c0-37.056-28.992-67.072-64.768-67.072-35.776 0-64.768 30.080-64.768 67.072v313.088c0 37.056 28.992 67.072 64.768 67.072 35.776 0 64.768-30.080 64.768-67.072v-313.088z" />
<glyph unicode="&#xe611;" d="M512-64c-282.752 0-512 229.248-512 512 0 282.688 229.248 512 512 512 282.752 0 512-229.248 512-512 0-282.752-229.248-512-512-512zM512 128.064c35.776 0 64.768 28.544 64.768 63.808 0 35.2-28.992 63.808-64.768 63.808-35.776 0-64.768-28.608-64.768-63.808 0-35.264 28.992-63.808 64.768-63.808zM650.752 724.288c-33.92 27.904-82.24 43.456-140.032 43.456-42.56 0-78.912-7.68-110.144-20.16-16.576-6.72-69.632-39.68-80.64-48.896l32.384-48.32c5.312-9.344 13.952-14.080 25.92-14.080 4.992 0 10.624 1.984 16.96 5.888 4.608 2.88 41.088 21.696 56.512 26.368 32.32 9.6 67.84 5.696 84.16 0.64 22.272-6.848 38.4-19.904 47.36-37.76 5.888-11.776 13.376-44.16-4.224-74.432-14.656-25.088-37.568-44.16-62.848-61.056-13.504-9.216-26.048-18.624-37.376-28.416-0.512 0-1.792-0.96-4.672-3.52 1.408 1.216 3.264 2.304 4.672 3.52 3.2 0.128-30.784-43.328-30.784-83.52 0-42.88 0-64 0-64h128v64c0 33.28 16.128 51.968 16.448 56.704 11.008 7.872 61.056 46.144 72.96 59.904 22.208 25.6 38.592 59.392 38.592 107.008 0 48.832-19.392 88.832-53.248 116.672z" />
<glyph unicode="&#xe612;" d="M512 960c-282.752 0-512-229.184-512-511.936 0-282.816 229.248-512.064 512-512.064 282.752 0 512 229.248 512 512.064 0 282.752-229.248 511.936-512 511.936zM842.88 552.128l-367.296-367.232c-7.488-7.488-19.712-7.488-27.136 0l-54.272 54.784c-7.424 7.552-19.712 19.904-27.136 27.392l-126.336 132.8c-3.712 3.712-5.696 8.96-5.696 13.888 0 4.992 1.984 9.728 5.696 13.504l55.36 49.92c3.776 3.84 8.768 5.632 13.696 5.632 4.864-0.064 9.728-1.984 13.44-5.632l125.248-127.872c7.488-7.616 19.648-7.616 27.136 0l285.888 285.12c7.424 7.488 19.712 7.488 27.136 0l54.336-54.912c7.424-7.488 7.424-19.84-0.064-27.392z" />
<glyph unicode="&#xe613;" d="M874.048 810.048c-199.936 200-524.096 199.936-724.096 0-199.936-199.872-199.936-524.096 0.064-724.032 199.936-199.936 524.096-199.936 724.032-0.064 200 199.936 200 524.16 0 724.096zM747.2 309.056c27.52-27.52 28.224-71.296 1.728-97.856-26.56-26.56-70.4-25.728-97.792 1.728l-139.072 139.008-139.584-139.584c-27.52-27.456-71.296-28.224-97.792-1.728-26.56 26.56-25.728 70.4 1.664 97.856l139.648 139.584-139.648 139.648c-27.456 27.392-28.224 71.168-1.664 97.728 26.496 26.56 70.336 25.792 97.792-1.664l139.584-139.584 139.072 139.072c27.456 27.456 71.232 28.224 97.792 1.664 26.496-26.56 25.728-70.336-1.728-97.792l-139.008-139.072 139.008-139.008z" />
<glyph unicode="&#xe614;" d="M512 960.064c-282.752 0-512-229.312-512-512.064 0-282.816 229.248-512.064 512-512.064s512 229.248 512 512.064c0 282.752-229.248 512.064-512 512.064zM764.224 383.296h-187.392v-187.52c0-36.992-28.992-67.072-64.768-67.072s-64.768 30.080-64.768 67.072v187.52h-188.16c-36.992 0-67.072 28.928-67.072 64.704s30.080 64.768 67.072 64.768h188.16v188.16c0 37.056 28.992 67.072 64.768 67.072s64.768-30.016 64.768-67.072v-188.16h187.456c37.056 0 67.072-29.056 67.072-64.768s-30.016-64.704-67.136-64.704z" />
<glyph unicode="&#xe615;" d="M288 960h-192c-35.328 0-64-28.608-64-64v-896c0-35.392 28.672-64 64-64h192c35.328 0 64 28.608 64 64v896c0 35.392-28.672 64-64 64zM928 960h-192c-35.392 0-64-28.608-64-64v-896c0-35.392 28.608-64 64-64h192c35.392 0 64 28.608 64 64v896c0 35.392-28.608 64-64 64z" />
<glyph unicode="&#xe616;" d="M880 475.776l-832 480c-9.856 5.696-22.144 5.696-32 0-9.856-5.76-16-16.32-16-27.776v-960c0-11.456 6.144-22.016 16-27.712 4.928-2.88 10.496-4.288 16-4.288s11.072 1.408 16 4.288l832 480c9.856 5.696 16 16.256 16 27.712s-6.144 22.016-16 27.776z" />
<glyph unicode="&#xe617;" d="M493.184 896c-48.384 0-63.040-27.84-63.040-27.84s-183.104-216.192-266.56-216.192c-82.176 0-81.344 0-81.344 0-45.44 0-82.24-36.416-82.24-81.28v-244.096c0-44.928 36.8-81.28 82.176-81.28 0 0 1.344 0 82.176 0 81.024 0 269.568-218.88 269.568-218.88 14.912-15.488 35.904-25.152 59.264-25.152 45.376 0 82.176 36.352 82.176 81.28v732.096c0 44.928-36.8 81.344-82.176 81.344zM843.968 817.728l-47.424-70.976c86.656-70.4 142.208-177.728 142.208-298.176s-55.488-227.84-142.208-298.112l47.424-70.976c109.44 85.888 180.032 219.136 180.032 369.088 0 150.016-70.592 283.2-180.032 369.152zM748.8 675.328l-47.872-71.68c41.344-38.912 67.392-93.76 67.392-155.072s-26.048-116.096-67.392-155.072l47.872-71.616c63.872 54.72 104.576 136 104.576 226.688 0 90.816-40.704 171.968-104.576 226.752z" />
<glyph unicode="&#xe618;" d="M492.8 896c-51.2 0-64-25.6-64-25.6s-179.2-217.6-262.4-217.6c-83.2 0-83.2 0-83.2 0-44.8 0-83.2-38.4-83.2-83.2v-243.2c0-44.8 38.4-83.2 83.2-83.2 0 0 0 0 83.2 0 83.2 0 268.8-217.6 268.8-217.6 12.8-12.8 32-25.6 57.6-25.6 44.8 0 83.2 38.4 83.2 83.2v729.6c0 44.8-38.4 83.2-83.2 83.2z" />
<glyph unicode="&#xe619;" d="M832 640l-213.056-208.448-125.696 125.696 210.752 210.688-160 160.064h448v-448l-160 160zM526.976 342.528l-206.976-202.496 167.488-172.032h-455.488v452.288l160-164.288 210.752 210.752 124.224-124.224z" />
<glyph unicode="&#xe61a;" d="M991.936 863.36h-959.872c-17.6 0-32-15.36-32-34.176v-124.672c0-18.048 14.4-32.832 32-32.832h959.872c17.6 0 32 14.72 32 32.832v124.672c0 18.816-14.4 34.176-32 34.176zM991.936 543.36h-959.872c-17.6 0-32-15.36-32-34.24v-124.608c0-18.112 14.4-32.832 32-32.832h959.872c17.6 0 32 14.72 32 32.832v124.672c0 18.816-14.4 34.176-32 34.176zM991.936 223.36h-959.872c-17.6 0-32-15.36-32-34.24v-124.608c0-17.984 14.4-32.768 32-32.768h959.872c17.6 0 32 14.72 32 32.768v124.608c0 18.88-14.4 34.24-32 34.24z" />
<glyph unicode="&#xe61b;" d="M352 896h-320c-19.2 0-32-12.8-32-32v-320c0-19.2 12.8-32 32-32h320c19.2 0 32 12.8 32 32v320c0 19.2-12.8 32-32 32zM352 384h-320c-19.2 0-32-12.8-32-32v-320c0-19.2 12.8-32 32-32h320c19.2 0 32 12.8 32 32v320c0 19.2-12.8 32-32 32zM992 896h-448c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h448c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 640h-448c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h448c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 384h-448c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h448c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 128h-448c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h448c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32z" />
<glyph unicode="&#xe61c;" d="M288 896h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM288 576h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM608 896h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM608 576h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM928 896h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM928 576h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM288 256h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM608 256h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32zM928 256h-192c-19.2 0-32-12.8-32-32v-192c0-19.2 12.8-32 32-32h192c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32z" />
<glyph unicode="&#xe61d;" d="M416 960h-384c-19.2 0-32-12.8-32-32v-384c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32v384c0 19.2-12.8 32-32 32zM992 960h-384c-19.2 0-32-12.8-32-32v-384c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32v384c0 19.2-12.8 32-32 32zM416 384h-384c-19.2 0-32-12.8-32-32v-384c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32v384c0 19.2-12.8 32-32 32zM992 384h-384c-19.2 0-32-12.8-32-32v-384c0-19.2 12.8-32 32-32h384c19.2 0 32 12.8 32 32v384c0 19.2-12.8 32-32 32z" />
<glyph unicode="&#xe61e;" d="M992 896h-768c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h768c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 640h-768c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h768c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 384h-768c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h768c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 128h-768c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h768c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM96 896h-64c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h64c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM96 640h-64c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h64c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM96 384h-64c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h64c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM96 128h-64c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h64c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32z" />
<glyph unicode="&#xe61f;" d="M992 896h-960c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h960c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 640h-960c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h960c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 384h-960c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h960c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 128h-960c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h960c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32z" />
<glyph unicode="&#xe620;" d="M992 832h-640c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h640c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 512h-640c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h640c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM992 192h-640c-19.2 0-32-12.8-32-32v-64c0-19.2 12.8-32 32-32h640c19.2 0 32 12.8 32 32v64c0 19.2-12.8 32-32 32zM256 768c0-70.692-57.308-128-128-128-70.692 0-128 57.308-128 128 0 70.692 57.308 128 128 128 70.692 0 128-57.308 128-128zM256 448c0-70.692-57.308-128-128-128-70.692 0-128 57.308-128 128 0 70.692 57.308 128 128 128 70.692 0 128-57.308 128-128zM256 128c0-70.692-57.308-128-128-128-70.692 0-128 57.308-128 128 0 70.692 57.308 128 128 128 70.692 0 128-57.308 128-128z" />
<glyph unicode="&#xe621;" d="M896 960h-768c-70.656 0-128-57.344-128-128v-768c0-70.656 57.344-128 128-128h768c70.656 0 128 57.344 128 128v768c0 70.656-57.344 128-128 128zM384 895.936c35.328 0 64-28.608 64-63.936 0-35.392-28.672-64-64-64s-64 28.608-64 64c0 35.328 28.672 63.936 64 63.936zM192 895.936c35.328 0 64-28.608 64-63.936 0-35.392-28.672-64-64-64s-64 28.608-64 64c0 35.328 28.672 63.936 64 63.936zM896.064 64h-768.064v640h768.064v-640z" />
<glyph unicode="&#xe622;" d="M938.752 767.744h-106.688v106.624c0 47.104-38.208 85.312-85.312 85.312h-661.44c-47.104 0-85.312-38.208-85.312-85.312v-660.672c0-47.168 37.248-85.376 83.136-85.376h108.864v-106.688c0-47.104 37.248-85.312 83.136-85.312h665.792c45.952 0 83.2 38.208 83.2 85.312v660.736c-0.064 47.104-38.272 85.376-85.376 85.376zM384 895.616c35.328 0 64-28.608 64-63.936 0-35.392-28.672-64-64-64s-64 28.608-64 64c0 35.328 28.672 63.936 64 63.936zM192 895.616c35.328 0 64-28.608 64-63.936 0-35.392-28.672-64-64-64s-64 28.608-64 64c0 35.328 28.672 63.936 64 63.936zM128 255.68l-0.064 448h576.064v-448h-576zM896 63.68h-576v64.64h428.864c45.952 0 83.2 38.208 83.2 85.376v297.984h63.936v-448z" />
<glyph unicode="&#xe623;" d="M768 191.936c-121.6 0-197.888 68.736-256 144.448-58.112-75.712-134.4-144.448-256-144.448-102.848 0-256 68.224-256 256.064 0 187.776 153.152 256 256 256 121.6 0 197.888-68.672 256-144.448 58.112 75.776 134.4 144.448 256 144.448 102.912 0 256-68.224 256-256 0-187.84-153.088-256.064-256-256.064zM256 576c-29.632-0.512-128-11.136-128-128 0-121.856 106.624-128 128-128 78.272 0 123.264 47.808 178.752 128-55.488 80.128-100.48 128-178.752 128zM589.248 448c55.424-80.128 100.352-127.872 178.432-128 30.336 0.448 128.32 11.264 128.32 128 0 121.856-106.624 128-128 128-78.272 0-123.264-47.872-178.752-128z" />
<glyph unicode="&#xe624;" d="M800 512c-22.976 0-59.328 0-96 0v-128c22.656 0 44.8 0 64 0 12.096 0 23.296 0 32 0 123.712 0 224-100.288 224-224s-100.288-224-224-224-224 100.224-224 224c0 22.976 0 59.264 0 96h-128c0-22.656 0-44.864 0-64 0-12.096 0-23.232 0-32 0-123.776-100.288-224-224-224s-224 100.224-224 224 100.288 224 224 224c22.976 0 59.328 0 96 0v128c-22.592 0-44.864 0-64 0-12.096 0-23.232 0-32 0-123.712 0-224 100.224-224 224 0 123.712 100.288 224 224 224s224-100.288 224-224c0-22.976 0-59.328 0-96h128c0 22.592 0 44.864 0 64 0 12.096 0 23.232 0 32 0 123.712 100.288 224 224 224s224-100.288 224-224c0-123.776-100.288-224-224-224zM320 736c0 52.992-43.008 96-96 96s-96-43.008-96-96c0-53.056 43.008-96 96-96 7.744 0 19.52 0 32 0 29.568 0 64 0 64 0s0 69.056 0 96zM320 192c0 29.504 0 64 0 64s-69.056 0-96 0c-52.992 0-96-43.008-96-96s43.008-96 96-96 96 43.008 96 96c0 7.744 0 19.52 0 32zM704 160c0-52.992 43.008-96 96-96s96 43.008 96 96-43.008 96-96 96c-7.744 0-19.52 0-32 0-29.568 0-64 0-64 0s0-69.12 0-96zM576 512h-128v-128h128v128zM800 832c-52.992 0-96-43.008-96-96 0-7.744 0-19.456 0-32 0-29.632 0-64 0-64s69.056 0 96 0c52.992 0 96 42.944 96 96 0 52.992-43.008 96-96 96z" />
<glyph unicode="&#xe625;" d="M801.984 406.4c-28.672 17.664-65.408 7.232-81.92-23.36-0.576-1.024-0.576-2.24-1.152-3.264l-1.472 0.96c-41.984-74.432-117.696-124.736-205.184-124.736s-163.136 50.304-205.184 124.736l-1.408-0.832c-0.704 1.6-0.704 3.456-1.6 5.12-16.576 30.528-53.312 41.024-82.048 23.36s-38.528-56.832-21.952-87.36c1.28-2.24 3.264-3.648 4.672-5.696l-1.088-0.704c53.12-94.208 143.104-161.6 248.576-180.608v-70.016h-120.064c-33.152 0-60.032-28.672-60.032-64 0-35.392 26.88-64 60.032-64h360.128c33.216 0 60.032 28.608 60.032 64 0 35.328-26.816 64-60.032 64h-120v69.952c105.472 19.008 195.456 86.528 248.576 180.672l-0.384 0.256c1.088 1.472 2.624 2.432 3.456 4.096 16.64 30.656 6.784 69.76-21.952 87.424zM512.256 320c99.456 0 180.032 85.952 180.032 192v256c0 106.048-80.64 192-180.032 192-99.456 0-180.096-85.952-180.096-192v-256c0-106.048 80.64-192 180.096-192z" />
<glyph unicode="&#xe626;" d="M948.544 446.848c100.48 102.784 100.352 269.312 0 372.032-51.392 52.48-118.976 78.144-186.24 76.992-94.144-1.536-249.344-128.96-249.344-128.96s-159.616 129.216-256 129.088c-65.728-0.128-131.392-25.856-181.504-77.056-100.416-102.784-100.48-269.248 0-372.032l436.544-446.336 436.544 446.272z" />
<glyph unicode="&#xe627;" d="M512.128 432.064c-87.872 0-159.104 73.728-159.104 164.8 0 91.136 71.232 164.864 159.104 164.864s159.104-73.728 159.104-164.864c0-91.008-71.232-164.8-159.104-164.8zM512.128 960.384c-194.496 0-352.128-163.328-352.128-364.8 0-190.272 159.488-435.776 265.984-555.264 39.808-44.544 86.144-104.704 86.144-104.704s49.792 60.352 92.48 106.304c106.368 114.496 259.648 344.448 259.648 553.6 0 201.536-157.632 364.864-352.128 364.864z" />
<glyph unicode="&#xe628;" d="M960.512 710.272c-21.76 35.968-48.576 71.168-81.344 103.808-33.216 32.896-68.992 59.968-105.6 81.6l64.32 64.32c0 0 93.056 0 139.648-46.528 46.464-46.592 46.464-139.648 46.464-139.648l-63.488-63.552zM387.2 128.768h-194.432v194.432l23.36 23.36c39.552-18.56 78.784-44.928 114.176-80.32 35.392-35.328 61.696-74.688 80.32-114.176l-23.424-23.296zM906.752 656.512l-440-448.32c-22.72 37.632-50.688 74.304-84.992 108.352-34.688 34.432-72.064 62.72-110.336 85.312l449.152 440.896c37.824-17.856 75.456-42.944 109.312-76.864s59.008-71.424 76.864-109.376zM128 832v-767.936h768v319.936l128 127.936v-482.88c0-51.392-41.6-93.056-93.056-93.056h-837.888c-51.392 0-93.056 41.664-93.056 93.056v837.824c0 51.456 41.664 93.12 93.056 93.12h482.944l-128-128h-320z" />
<glyph unicode="&#xe629;" d="M960.256 96.064v-0.768l-256.256 256.256v-127.488c0-70.72-57.344-128.064-128-128.064h-448c-70.656 0-128 57.344-128 128.064v447.872c0 70.72 57.344 128.064 128 128.064h448c70.656 0 128-57.344 128-128.064v-128.576l256 256v0.64c35.392 0 64-28.608 64-64v-576c0-35.264-28.544-63.808-63.744-63.936z" />
<glyph unicode="&#xe62a;" d="M897.024 768h-147.84l-42.88 90.624c-9.792 21.312-45.056 37.376-79.36 37.376h-244.8c-34.304 0-69.568-16.064-79.424-37.376l-41.856-90.624h-132.864c-128 0-128-64-128-64v-640c0 0 0-64 128-64h768c128 0 128 64 128 64v640c0 0 0 64-126.976 64zM512 128.064c-141.376 0-256 114.496-256 255.872 0 141.44 114.624 256.064 256 256.064s256-114.624 256-256.064c0-141.376-114.624-255.872-256-255.872zM512 544c-88.384 0-160-71.616-160-160 0-88.32 71.616-160 160-160s160 71.68 160 160c0 88.384-71.616 160-160 160z" />
<glyph unicode="&#xe62b;" d="M512.064 960c-282.688 0-511.872-229.184-511.872-511.936 0-282.816 229.184-511.936 511.872-511.936 282.752 0 511.936 229.12 511.936 511.936 0 282.752-229.184 511.936-511.936 511.936zM678.976 268.48l-14.848-14.976c-12.416-12.352-33.344-12.992-46.464-1.28l-171.52 147.52c-13.12 11.712-23.040 35.712-22.208 53.248l17.856 283.072c0.896 17.6 16 31.936 33.664 31.936h21.056c17.6 0 32.704-14.336 33.536-31.936l14.656-231.808c0.896-17.536 11.2-42.688 22.848-55.808l112.768-133.568c11.648-12.992 11.136-33.984-1.344-46.4z" />
<glyph unicode="&#xe62c;" d="M512.064 800c-338.944 0-512.96-352.896-512.96-352.896s131.328-352.96 512.96-352.96c345.472 0 512.832 351.616 512.832 351.616s-168.64 354.24-512.832 354.24zM512.832 226.496c-123.968 0-213.504 96.576-213.504 220.608 0 124.096 89.536 220.544 213.504 220.544 123.904 0 213.44-96.448 213.44-220.544 0-124.032-89.6-220.608-213.44-220.608zM512.832 579.456c-70.784-0.128-128.128-61.44-128.128-132.352 0-70.848 57.344-132.352 128.128-132.352s128.064 61.504 128.064 132.352c0 70.912-57.28 132.544-128.064 132.352z" />
<glyph unicode="&#xe62d;" d="M457.856 168.064l289.28-226.496c4.736-3.776 7.616-5.632 10.368-5.632 8 0 10.496 5.504 10.496 14.528v214.4c0 15.104 9.984 27.136 23.36 27.136h105.152c127.488 0 127.36 61.44 127.36 61.44v640.064c0 0 0 66.56-127.872 66.56h-767.936c-128 0-128-66.56-128-66.56v-640.064c0 0-0.064-61.44 128.448-61.44h256c0 0 53.568-1.472 73.344-23.936z" />
<glyph unicode="&#xe62e;" d="M1024 26.752c0-50.176-41.6-90.752-93.12-90.752h-291.264v351.68c0 53.056-38.016 96.128-85.056 96.128h-85.12c-46.976 0-85.12-43.072-85.12-96.128v-351.68h-291.264c-51.392 0-93.056 40.576-93.056 90.752v478.976c0 23.36 9.344 44.48 24.192 60.544l-0.96 1.856 425.92 372.992c34.304 25.152 89.984 25.152 124.288 0l427.264-372.992-0.448-2.368c14.592-16.064 23.744-36.928 23.744-60.032v-478.976z" />
<glyph unicode="&#xe62f;" d="M896-64h-192v128h192.064v640h-768.064v-640h192v-128h-192c-70.656 0-128 57.344-128 128v768c0 70.656 57.344 128 128 128h768c70.656 0 128-57.344 128-128v-768c0-70.656-57.344-128-128-128zM192 895.936c-35.392 0-64-28.608-64-63.936 0-35.392 28.608-64 64-64s64 28.608 64 64c0 35.328-28.608 63.936-64 63.936zM384 895.936c-35.392 0-64-28.608-64-63.936 0-35.392 28.608-64 64-64s64 28.608 64 64c0 35.328-28.608 63.936-64 63.936zM271.936 200.704c-22.208 23.232-22.208 60.864 0 84.16l196.928 209.408c6.144 6.464 13.44 10.496 21.12 13.44 0.064 0.064 0.192 0.064 0.32 0.128 5.888 2.24 11.84 3.456 17.984 3.712 2.24 0.192 4.416 0.384 6.656 0.256 2.752-0.192 5.376-1.024 8-1.6 11.328-2.24 22.272-6.72 30.976-15.872l196.864-209.408c22.272-23.296 22.272-60.928 0-84.16-22.272-23.104-58.304-23.104-80.576 0l-94.208 119.232v-319.936c0-34.176-32.064-64.064-64.64-64.064-32.512 0-63.36 29.888-63.36 64.064v319.936l-95.488-119.296c-22.272-23.168-58.304-23.168-80.576 0z" />
<glyph unicode="&#xe630;" d="M723.392 353.6c-11.328 11.456-15.104 32.704-8.384 47.296 0 0 47.232 102.464 47.232 177.728 0 210.624-170.432 381.376-380.736 381.376s-380.8-170.752-380.8-381.312c0-210.624 170.496-381.376 380.8-381.376 75.2 0 177.408 47.36 177.408 47.36 14.656 6.784 35.968 2.944 47.232-8.448l291.456-291.776c11.456-11.392 30.080-11.392 41.344 0l75.776 75.904c11.456 11.456 11.456 30.144 0 41.472l-291.328 291.776zM381.504 373.376c-113.088 0-205.056 92.032-205.056 205.312 0 113.216 92.032 205.312 205.056 205.312s204.992-92.096 204.992-205.312c0-113.28-91.904-205.312-204.992-205.312z" />
<glyph unicode="&#xe631;" d="M449.024 596.288c106.56 0 193.024 81.344 193.024 181.888-0.064 100.416-86.464 181.824-193.024 181.824s-193.024-81.408-193.024-181.824c0-100.48 86.464-181.888 193.024-181.888zM600.32 583.68c-42.56-29.44-94.592-47.424-151.296-47.424-56.96 0-109.12 18.112-151.744 47.744-173.248-37.312-297.28-136.832-297.28-254.016v-258.88c0-17.152 14.4-31.104 32-31.104h64c17.6 0 32 12.608 32 28.096 0 8.96 0 201.856 0 201.856 0 16.64 9.536 9.984 21.376 9.984 11.776 0 21.312-9.024 21.312-19.968l0.32-179.968c0.896-10.368 9.6-84.416 20.544-86.592 0 0 66.56-57.344 256.448-57.344 191.232 0 256.448 57.344 256.448 57.344 10.944 2.112 19.712 76.16 20.544 86.592l0.32 179.968c0 11.008 9.536 19.968 21.376 19.968 11.776 0 21.312-9.024 21.312-19.968 0 0 0-182.912 0-191.872 0-15.488 14.4-28.096 32-28.096h64c17.6 0 32 14.016 32 31.104v258.88c0 116.864-123.392 216.128-295.68 253.696z" />
<glyph unicode="&#xe632;" d="M896 864c-50.496 0-768 0-768 0-50.496 0-128-41.152-128-90.944v-18.112c0 0 432.768-361.856 512-361.856s512 360.704 512 360.704v19.2c0 49.856-77.504 91.008-128 91.008zM0 608.96v-512.896c0 0 0-64.064 128-64.064h768c128.192 0 128 64.064 128 64.064v514.496c0 0-364.16-324.992-512-324.992-146.304 0-512 323.392-512 323.392z" />
<glyph unicode="&#xe633;" d="M896-64h-768c-35.328 0-64 28.608-64 64.064v447.936c0 35.328 28.672 64 64 64h64v128c0 176.704 143.232 320 320 320s320-143.296 320-320v-128h64c35.392 0 64-28.672 64-64v-447.936c0-35.456-28.608-64.064-64-64.064zM704 640c0 105.984-85.952 192-192 192s-192-86.016-192-192v-128h384v128z" />
<glyph unicode="&#xe634;" d="M767.872 787.008l-0.128-0.064c-0.896 0.64-1.6 1.536-2.624 2.24-29.184 20.032-68.992 12.608-89.024-16.704-19.968-29.312-12.48-69.312 16.64-89.344 0.768-0.64 1.536-0.896 2.24-1.28l-0.256-0.448c82.88-58.048 137.28-154.496 137.28-263.744 0-177.536-143.296-321.472-320-321.472s-320 143.936-320 321.472c0 109.248 54.4 205.696 137.28 263.744l-0.256 0.448c0.704 0.384 1.472 0.64 2.24 1.216 29.184 20.032 36.608 60.032 16.64 89.344-20.032 29.312-59.84 36.8-89.024 16.704-0.96-0.704-1.728-1.536-2.688-2.24l-0.064 0.128c-116.032-81.408-192.128-216.32-192.128-369.344 0-248.576 200.576-450.176 448-450.176s448 201.6 448 450.176c0 153.024-76.096 287.936-192.128 369.344zM512 352c35.392 0 64 28.608 64 64v447.936c0 35.392-28.608 64.064-64 64.064-35.328 0-64-28.672-64-64.064v-447.936c0-35.392 28.672-64 64-64z" />
<glyph unicode="&#xe635;" d="M320 576c-35.328 0-64-28.608-64-64s28.672-64 64-64 64 28.608 64 64-28.672 64-64 64zM512 384c-35.328 0-64-28.608-64-64s28.672-64 64-64 64 28.608 64 64-28.672 64-64 64zM320 384c-35.328 0-64-28.608-64-64s28.672-64 64-64 64 28.608 64 64-28.672 64-64 64zM896 895.936h-128c0 35.392-28.608 64.064-64 64.064s-64-28.672-64-64.064h-256c0 35.392-28.672 64.064-64 64.064s-64-28.672-64-64.064h-128c-70.656 0-128-57.28-128-127.936v-640c0-70.72 57.344-128 128-128h768c70.656 0 128 57.28 128 128v640c0 70.656-57.344 127.936-128 127.936zM896 128h-768v640h128c0-35.392 28.672-64 64-64s64 28.608 64 64h256c0-35.392 28.608-64 64-64s64 28.608 64 64h128v-640zM704 576c-35.392 0-64-28.608-64-64s28.608-64 64-64 64 28.608 64 64-28.608 64-64 64zM512 576c-35.328 0-64-28.608-64-64s28.672-64 64-64 64 28.608 64 64-28.672 64-64 64zM704 384c-35.392 0-64-28.608-64-64s28.608-64 64-64 64 28.608 64 64-28.608 64-64 64z" />
<glyph unicode="&#xe636;" d="M918.272 527.040c-17.344 2.56-35.968 18.304-41.344 35.008l-26.112 63.232c-8.128 15.552-6.272 39.872 4.352 53.952l42.112 56.192c10.624 14.080 9.728 36.352-1.984 49.536l-46.272 46.4c-13.12 11.712-35.52 12.544-49.6 1.984l-56.128-42.24c-14.144-10.496-38.4-12.48-54.016-4.288l-63.168 26.048c-16.832 5.312-32.64 24-35.008 41.472l-9.984 69.504c-2.496 17.408-18.816 33.152-36.352 34.944 0 0-10.816 1.216-32.768 1.216s-32.768-1.216-32.768-1.216c-17.536-1.792-33.92-17.536-36.352-34.944l-9.984-69.504c-2.432-17.472-18.176-36.16-35.008-41.472l-63.168-26.048c-15.552-8.192-39.808-6.208-53.888 4.288l-56.256 42.24c-14.016 10.624-36.416 9.728-49.6-1.984l-46.208-46.272c-11.648-13.184-12.544-35.52-1.984-49.6l42.176-56.192c10.56-14.080 12.48-38.4 4.288-53.952l-26.048-63.296c-5.376-16.704-24-32.448-41.408-35.008l-69.504-9.792c-17.472-2.56-33.216-18.88-35.008-36.416 0 0-1.152-10.88-1.152-32.832 0-21.952 1.152-32.896 1.152-32.896 1.856-17.472 17.6-33.792 35.008-36.288l69.504-9.856c17.408-2.496 36.032-18.304 41.408-35.008l26.112-63.232c8.192-15.616 6.272-39.808-4.288-53.888l-42.176-56.256c-10.56-14.144-13.12-33.28-5.632-42.496 7.424-9.216 28.864-32.064 28.928-32.064 0-0.128 7.232-6.72 16-14.656 8.768-8.064 44.48-19.2 58.56-8.64l56.256 42.112c14.080 10.624 38.336 12.544 53.888 4.352l63.040-25.984c16.832-5.44 32.576-24 35.008-41.472l9.984-69.504c2.432-17.344 18.816-33.28 36.288-35.072 0 0 10.88-1.152 32.832-1.152s32.768 1.152 32.768 1.152c17.472 1.792 33.856 17.664 36.352 35.072l9.984 69.504c2.368 17.472 18.112 36.032 35.008 41.472l63.104 25.984c15.616 8.192 39.872 6.272 54.016-4.224l56.256-42.24c14.144-10.56 36.352-9.664 49.6 1.92l46.272 46.336c11.648 13.184 12.48 35.52 1.856 49.6l-42.112 56.256c-10.624 14.080-12.48 38.272-4.352 53.888l26.112 63.232c5.376 16.768 24 32.512 41.344 35.008l69.504 9.856c17.344 2.496 33.152 18.816 35.008 36.288 0 0 1.152 10.88 1.152 32.896 0 21.952-1.152 32.832-1.152 32.832-1.856 17.536-17.6 33.856-35.008 36.416l-69.44 9.792zM512 320c-70.656 0-128 57.344-128 128 0 70.72 57.344 128 128 128 70.592 0 128-57.344 128-128 0-70.656-57.344-128-128-128z" />
<glyph unicode="&#xe637;" d="M768 697.024v0h128c35.392 0 64-28.672 64-64v-640c0-35.392-28.608-64-64-64h-672c-88.384 0-160 71.616-160 160v703.936c0 88.384 71.616 160.064 160 160.064h672c35.392 0 64-28.672 64-64 0-35.392-28.608-64.064-64-64.064h-640c-35.328 0-64-28.608-64-64s28.672-64 64-64h128v-256l64 64 64-64v256h256z" />
<glyph unicode="&#xe638;" d="M0 64v192h128v-192.128h640v768.128h-640v-192h-128v192c0 70.656 57.344 128 128 128h640c70.72 0 128-57.344 128-128v-768c0-70.72-57.28-128-128-128h-640c-70.656 0-128 57.28-128 128zM264.768 688c23.232 22.272 60.864 22.272 84.096 0l209.408-196.8c6.528-6.208 10.496-13.568 13.504-21.184 0.064-0.128 0.064-0.192 0.128-0.32 2.24-5.824 3.456-11.84 3.648-17.984 0.256-2.24 0.448-4.416 0.256-6.72-0.128-2.688-1.024-5.248-1.664-7.936-2.176-11.264-6.656-22.208-15.872-30.976l-209.408-196.8c-23.232-22.272-60.864-22.272-84.096 0-23.168 22.272-23.168 58.24 0 80.512l119.232 94.208h-320c-34.112 0-64 32.064-64 64.64 0 32.512 29.888 63.36 64 63.36h320l-119.232 95.552c-23.232 22.144-23.232 58.304 0 80.448z" />
<glyph unicode="&#xe639;" d="M928 704h-64v-640c0 0-1.984-128-128-128 0 0-318.016 0-448 0s-128 128-128 128v640h-64c-35.328 0-64 28.672-64 64s28.672 64 64 64h320v32c0 53.056 42.944 96 96 96 52.992 0 96-42.944 96-96v-32h320c35.392 0 64-28.608 64-64s-28.608-64-64-64zM736 704h-448v-640h448v640zM416 640c35.328 0 64-28.672 64-64v-384c0-35.392-28.672-64-64-64s-64 28.608-64 64v384c0 35.328 28.672 64 64 64zM608 640c35.392 0 64-28.672 64-64v-384c0-35.392-28.608-64-64-64s-64 28.608-64 64v384c0 35.328 28.608 64 64 64z" />
<glyph unicode="&#xe63a;" d="M896 768c0 0-278.016 0.064-320 0.064s-89.984 127.936-128 127.936-320 0-320 0c-70.656 0-128-57.28-128-128v-640.064c0-126.656 128-128 128-128h768c70.656 0 128 57.344 128 128v512c0 70.72-57.344 128.064-128 128.064zM896.064 127.936h-768.064v640.064c0 0 214.016 0 254.016 0s89.984-128 128-128c40 0 386.048 0 386.048 0v-512.064z" />
<glyph unicode="&#xe63b;" d="M895.424 960.064h-767.872c-127.296 0-127.552-128.064-127.552-128.064v-511.936c0 0 0.704-128.064 128-128.064h256c0 0 53.568-1.472 73.344-23.936l289.344-226.496c4.736-3.776 7.616-5.632 10.432-5.632 8 0 10.368 5.504 10.368 14.592v214.336c0 15.104 9.984 27.2 23.424 27.2h105.088c125.312 0 128 128.064 128 128.064v511.872c0 0-1.28 128.064-128.576 128.064zM896 320.064h-256v-128l-164.608 128h-347.392v511.936h768v-511.936z" />
<glyph unicode="&#xe63c;" d="M896 63.872h-768v768h320v128l-358.976 0.064c-49.152 0-89.024-39.936-89.024-89.088v-845.952c0-49.152 39.872-89.024 89.024-89.024h845.952c49.152 0 89.024 39.872 89.024 89.024v358.976h-128v-320zM1024 896c0 14.656-6.080 27.52-14.72 38.272-1.344 1.728-2.048 3.712-3.584 5.312-0.192 0.128-0.256 0.384-0.384 0.576-0.384 0.32-0.448 0.832-0.832 1.216-4.096 4.096-9.152 6.528-13.952 9.28-2.112 1.216-3.84 3.008-6.080 3.968-8.704 3.776-17.92 5.376-27.264 5.12-0.128 0-0.256 0.064-0.384 0.064h-313.024c-36.992 0.064-67.008-28.544-67.008-63.808 0-35.2 30.080-63.808 67.136-63.808h161.216l-402.56-403.328c-24.832-24.768-24.832-64.768 0-89.472 24.832-24.768 65.024-24.768 89.792 0l403.968 403.52v-163.2c0-37.056 28.608-67.072 63.872-67.072s63.808 30.016 63.808 67.072v313.024c0 0.64-0.32 1.152-0.32 1.728 0 0.512 0.32 1.024 0.32 1.536z" />
<glyph unicode="&#xe63d;" d="M0 576.448v107.712c0 45.952 38.208 83.136 85.312 83.136h107.392v90.432c0 21.056 21.568 102.208 48.192 102.208h96.384c26.624 0 48.192-81.152 48.192-102.208v-90.432h319.232v90.432c0 21.056 21.632 102.208 48.192 102.208h96.384c26.624 0 48.192-81.152 48.192-102.208v-90.432h41.28c47.168 0 85.376-37.184 85.376-83.136v-107.776h-1024.128zM1024.064 511.36v-492.224c0-45.952-38.208-83.2-85.376-83.2h-853.376c-47.104 0-85.312 37.248-85.312 83.2v492.224h1024.064z" />
<glyph unicode="&#xe63e;" d="M32 447.936c288 32.064 448 192.064 480 480.064 32.064-288 192.064-448 480.128-480.064-288.064-32-448.064-192-480.128-480-32 288-192 448-480 480z" />
<glyph unicode="&#xe63f;" d="M1024 448l-380.8-128-10.304-384-245.696 304.96-387.2-109.376 228.992 316.416-228.992 316.416 387.2-109.312 245.696 304.896 10.304-384 380.8-128z" />
<glyph unicode="&#xe640;" d="M768 223.552c35.392 0 64 28.672 64 64.064s-28.608 64.064-64 64.064-64-28.672-64-64.064 28.608-64.064 64-64.064zM938.752 864h-853.376c-47.168 0-85.376-38.208-85.376-85.376v-661.184c0-47.168 38.208-85.44 85.376-85.44h853.376c47.104 0 85.312 38.272 85.312 85.44v661.184c0 47.168-38.208 85.376-85.312 85.376zM896.064 160.192h-768.064v255.552h768.064v-255.552zM896.064 607.872h-768.064v128.064h768.064v-128.064z" />
<glyph unicode="&#xe641;" d="M939.712 875.712c-112.448 112.448-294.784 112.448-407.296-0.064l-448-448c-112.512-112.512-112.512-294.848-0.064-407.296s294.784-112.512 407.296 0l94.848 92.16c-51.008 1.152-97.536 17.728-136.96 44.672l-48.448-46.4c-62.528-62.528-163.84-62.528-226.304 0-62.464 62.464-62.464 163.84 0.064 226.304l448 448c62.528 62.528 163.84 62.528 226.24 0 62.528-62.528 62.592-163.776 0.064-226.24l-223.232-224.768c-18.752-18.752-49.152-18.752-67.904 0s-18.752 49.152 0 67.904l168.576 170.176c12.48 12.48 12.544 32.768 0 45.248l-45.248 45.248c-12.48 12.48-32.768 12.48-45.248 0l-168.576-170.176c-68.736-68.736-68.736-180.16 0-248.896s180.16-68.736 248.896 0l223.232 224.832c112.448 112.448 112.448 294.848 0.064 407.296z" />
<glyph unicode="&#xe642;" d="M939.648 875.648c-54.464 54.4-126.784 84.352-203.648 84.352-76.928 0-149.248-29.952-203.648-84.352 0 0-181.696-181.632-192.128-191.936-54.208-54.336-84.096-126.72-84.224-204.096 0.128-76.8 30.080-148.992 84.352-203.264l23.36-23.424c6.272-6.272 14.528-9.344 22.656-9.344 8.192 0 16.384 3.136 22.656 9.344l45.248 45.248c12.48 12.48 12.48 32.768 0 45.248l-23.424 23.424c-61.376 61.376-62.208 162.048-1.792 224.512 1.856 1.856 193.856 193.792 193.856 193.792 30.208 30.208 70.336 46.848 113.088 46.848s82.88-16.64 113.152-46.784v-0.064c62.528-62.592 62.528-163.776 0-226.24l-9.856-9.856c15.424-41.6 24.64-86.208 24.704-133.056 0-8.512-1.216-16.704-1.664-25.024l77.312 77.376c112.448 112.512 112.384 294.912 0 407.296zM660.16 643.136c-6.208 6.272-14.464 9.344-22.592 9.344-8.256 0-16.448-3.136-22.656-9.344l-45.248-45.248c-12.544-12.48-12.544-32.768 0-45.248l23.36-23.424c61.376-61.376 62.272-162.048 1.856-224.512-1.856-1.856-193.856-193.792-193.856-193.792-30.144-30.272-70.272-46.912-113.088-46.912-42.688 0-82.816 16.64-113.088 46.784v0.064c-62.528 62.592-62.528 163.776-0.064 226.24l9.92 9.856c-15.488 41.6-24.704 86.208-24.704 133.056 0 8.512 1.152 16.704 1.664 25.024l-77.312-77.376c-112.512-112.512-112.448-294.848 0-407.232 54.464-54.464 126.784-84.416 203.648-84.416s149.184 29.952 203.648 84.352c0 0 181.696 181.632 192.128 191.936 54.208 54.336 84.096 126.72 84.224 204.096-0.128 76.8-30.144 148.992-84.352 203.264l-23.488 23.488z" />
<glyph unicode="&#xe643;" d="M1012.736 484.16l-241.216 352c-11.968 17.408-31.68 27.84-52.8 27.84h-654.72c-35.392 0-64-28.672-64-64v-704c0-35.328 28.608-64 64-64h654.72c21.12 0 40.896 10.368 52.8 27.84l241.216 352c15.040 21.76 15.040 50.56 0 72.32zM736 352c-52.992 0-96 43.008-96 96s43.008 96 96 96 96-43.008 96-96-43.008-96-96-96z" />
<glyph unicode="&#xe644;" d="M842.752 960h-660.544c-47.552 0-86.208-38.144-86.208-64v-853.376c0-68.416 38.656-106.624 86.208-106.624h660.544c47.040 0 85.248 38.208 85.248 85.312v853.376c0 47.168-38.208 85.312-85.248 85.312zM544 128h-256c-35.392 0-64 28.608-64 64s28.608 64 64 64h256c35.392 0 64-28.608 64-64s-28.608-64-64-64zM736 384h-448c-35.392 0-64 28.608-64 64s28.608 64 64 64h448c35.392 0 64-28.608 64-64s-28.608-64-64-64zM736 640h-448c-35.392 0-64 28.608-64 64s28.608 64 64 64h448c35.392 0 64-28.608 64-64s-28.608-64-64-64z" />
<glyph unicode="&#xe645;" d="M938.752 32h-853.376c-47.168 0-85.376 37.248-85.376 83.264v665.472c0 46.016 38.208 83.264 85.376 83.264h853.376c47.104 0 85.312-37.248 85.312-83.264v-665.472c0-46.016-38.208-83.264-85.312-83.264zM896.064 736h-768.064v-511.808c0 0 64 64.064 128 128.064 64 64.064 128 0 128 0l64-64c0 0 118.72 120.768 192 192.128 66.88 66.944 128 0 128 0l128-128.128 0.064 383.744zM320 480c-35.328 0-64 28.672-64 63.936 0 35.392 28.672 64.064 64 64.064s64-28.672 64-64.064c0-35.264-28.672-63.936-64-63.936z" />
<glyph unicode="&#xe646;" d="M928-64h-832c-51.2 0-96 44.8-96 96v832c0 51.2 44.8 96 96 96h825.6c57.6 0 102.4-44.8 102.4-96v-825.6c0-57.6-44.8-102.4-96-102.4zM748.8 768c-121.6 0-172.8-83.2-172.8-166.4v-89.6h-64v-128h64v-384h128v384h128v128h-128v70.4c0 38.4 6.4 57.6 51.2 57.6h76.8v121.6s-38.4 6.4-83.2 6.4z" />
<glyph unicode="&#xe647;" d="M1017.6 646.4c0 83.2-64 147.2-147.2 147.2-115.2 6.4-236.8 6.4-358.4 6.4-121.6 0-243.2 0-358.4-6.4-83.2 0-147.2-64-147.2-147.2-6.4-70.4-6.4-134.4-6.4-198.4s0-128 6.4-198.4c0-83.2 64-147.2 147.2-147.2 115.2-6.4 236.8-6.4 358.4-6.4 121.6 0 243.2 0 358.4 6.4 83.2 0 147.2 64 147.2 147.2 6.4 64 6.4 128 6.4 198.4 0 64 0 128-6.4 198.4zM384 224v448l320-224-320-224z" />
<glyph unicode="&#xe648;" d="M876.8 896c-147.2 6.4-243.2-76.8-294.4-243.2 25.6 12.8 51.2 19.2 76.8 19.2 51.2 0 76.8-32 70.4-89.6 0-38.4-25.6-89.6-70.4-153.6-38.4-70.4-70.4-102.4-96-102.4-25.6 0-51.2 51.2-76.8 160-6.4 25.6-19.2 108.8-38.4 236.8-19.2 115.2-70.4 172.8-147.2 160-32 0-83.2-32-153.6-96-44.8-38.4-96-83.2-147.2-128l51.2-64c44.8 32 70.4 51.2 76.8 51.2 38.4 0 70.4-57.6 96-166.4 32-108.8 57.6-211.2 83.2-313.6 38.4-108.8 89.6-166.4 153.6-166.4 96 0 211.2 89.6 352 275.2 134.4 179.2 204.8 313.6 211.2 416 6.4 134.4-44.8 204.8-147.2 204.8z" />
<glyph unicode="&#xe649;" d="M1024 768c-38.4-19.2-76.8-25.6-121.6-32 44.8 25.6 76.8 64 89.6 115.2-38.4-25.6-83.2-38.4-134.4-51.2-38.4 38.4-96 64-153.6 64-108.8 0-204.8-96-204.8-211.2 0-19.2 0-32 6.4-44.8-172.8 6.4-332.8 89.6-435.2 217.6-19.2-32-25.6-64-25.6-102.4 0-70.4 38.4-134.4 96-172.8-32 0-64 12.8-96 25.6 0-102.4 70.4-185.6 166.4-204.8-19.2-12.8-38.4-12.8-57.6-12.8-12.8 0-25.6 0-38.4 6.4 25.6-83.2 102.4-147.2 198.4-147.2-70.4-57.6-160-89.6-262.4-89.6h-51.2c96-64 204.8-96 320-96 384 0 595.2 320 595.2 595.2v25.6c44.8 32 83.2 70.4 108.8 115.2z" />
<glyph unicode="&#xe64a;" d="M179.2 57.6c76.8 115.2 211.2 185.6 358.4 185.6 134.4 0 256-64 339.2-160 89.6 96 147.2 224 147.2 364.8 0 281.6-230.4 512-512 512s-512-230.4-512-512c0-153.6 70.4-294.4 179.2-390.4zM787.2 294.4c-6.4-19.2-19.2-19.2-38.4-12.8-70.4 32-147.2 51.2-224 51.2-83.2 0-160-19.2-230.4-51.2-6.4-6.4-25.6-6.4-32 19.2-6.4 12.8 6.4 25.6 12.8 32 76.8 38.4 160 57.6 249.6 57.6s172.8-19.2 243.2-51.2c12.8-12.8 25.6-25.6 19.2-44.8zM832 422.4c-6.4-6.4-12.8-12.8-25.6-12.8h-6.4c-83.2 38.4-179.2 64-275.2 64s-185.6-19.2-268.8-57.6h-6.4c-12.8 0-19.2 6.4-25.6 12.8l-6.4 12.8c0 6.4 6.4 19.2 12.8 19.2 89.6 38.4 192 64 300.8 64 108.8 0 211.2-25.6 300.8-64v-38.4zM185.6 633.6c102.4 44.8 217.6 64 339.2 64 115.2 0 230.4-25.6 332.8-64 12.8-6.4 25.6-19.2 25.6-38.4 0-25.6-19.2-44.8-44.8-44.8h-6.4c-96 38.4-198.4 57.6-307.2 57.6s-211.2-19.2-307.2-51.2h-6.4c-25.6 0-44.8 19.2-44.8 44.8 0 6.4 6.4 25.6 19.2 32zM537.6 76.8c-89.6 0-166.4-44.8-211.2-108.8 57.6-19.2 121.6-32 185.6-32 83.2 0 160 19.2 224 51.2-44.8 57.6-115.2 89.6-198.4 89.6z" />
<glyph unicode="&#xe64b;" d="M979.2 371.2c6.4 25.6 6.4 51.2 6.4 76.8 0 262.4-211.2 473.6-473.6 473.6-25.6 0-51.2 0-76.8-6.4-38.4 32-89.6 44.8-147.2 44.8-160 0-288-128-288-288 0-57.6 12.8-108.8 44.8-153.6-6.4-19.2-6.4-44.8-6.4-70.4 0-262.4 211.2-473.6 473.6-473.6 25.6 0 51.2 0 76.8 6.4 44.8-25.6 96-44.8 153.6-44.8 160 0 288 128 288 288-6.4 57.6-19.2 108.8-51.2 147.2zM736 230.4c-19.2-32-51.2-51.2-89.6-70.4-38.4-19.2-83.2-25.6-134.4-25.6-64 0-115.2 12.8-160 32-32 12.8-51.2 38.4-70.4 64-19.2 32-25.6 57.6-25.6 83.2 0 12.8 6.4 25.6 19.2 38.4 12.8 12.8 25.6 19.2 44.8 19.2 12.8 0 25.6-6.4 38.4-12.8 6.4-6.4 12.8-19.2 19.2-38.4 6.4-19.2 19.2-32 25.6-44.8 6.4-12.8 19.2-25.6 38.4-32 19.2-6.4 38.4-12.8 64-12.8 38.4 0 70.4 6.4 89.6 25.6 25.6 19.2 32 38.4 32 57.6 0 19.2-6.4 32-19.2 44.8-6.4 19.2-19.2 25.6-38.4 32-19.2 6.4-51.2 12.8-83.2 19.2-44.8 12.8-83.2 25.6-115.2 38.4-32 12.8-57.6 32-76.8 51.2-19.2 25.6-25.6 57.6-25.6 89.6 0 32 12.8 64 32 89.6 19.2 25.6 44.8 44.8 83.2 57.6 38.4 12.8 76.8 19.2 128 19.2 38.4 0 70.4-6.4 102.4-12.8 25.6-6.4 51.2-19.2 70.4-38.4 19.2-12.8 32-32 44.8-44.8s12.8-32 12.8-51.2c0-12.8-6.4-25.6-19.2-38.4-12.8-12.8-25.6-19.2-44.8-19.2-12.8 0-25.6 6.4-32 12.8-6.4 6.4-19.2 19.2-25.6 32-12.8 25.6-25.6 38.4-44.8 51.2-12.8 12.8-38.4 19.2-76.8 19.2-32 0-57.6-6.4-76.8-19.2-19.2-12.8-32-25.6-32-44.8 0-12.8 6.4-19.2 12.8-32l25.6-19.2c12.8-6.4 25.6-12.8 38.4-12.8 12.8-6.4 32-6.4 64-12.8 32-12.8 64-25.6 96-32 32-6.4 51.2-19.2 76.8-32 19.2-12.8 38.4-32 51.2-51.2 6.4-25.6 12.8-51.2 12.8-76.8 0-38.4-12.8-70.4-32-102.4z" />
<glyph unicode="&#xe64c;" d="M512 960c-281.6 0-512-230.4-512-512 0-211.2 128-390.4 307.2-467.2 0 38.4 0 76.8 6.4 115.2 12.8 38.4 64 281.6 64 281.6s-12.8 32-12.8 76.8c0 76.8 44.8 134.4 96 134.4s70.4-32 70.4-76.8-32-115.2-44.8-179.2c-12.8-57.6 25.6-96 83.2-96 96 0 160 121.6 160 275.2 0 115.2-76.8 198.4-211.2 198.4-153.6 0-249.6-115.2-249.6-243.2 0-44.8 12.8-76.8 32-102.4 6.4-12.8 12.8-12.8 6.4-25.6 0-6.4-6.4-32-12.8-38.4-6.4-12.8-12.8-19.2-25.6-12.8-70.4 32-102.4 108.8-102.4 198.4 0 147.2 121.6 320 364.8 320 198.4 0 326.4-140.8 326.4-294.4 0-198.4-108.8-352-275.2-352-57.6 0-108.8 32-128 64 0 0-32-115.2-38.4-140.8-12.8-38.4-32-76.8-51.2-108.8 51.2-32 96-38.4 147.2-38.4 281.6 0 512 230.4 512 512s-230.4 512-512 512z" />
<glyph unicode="&#xe64d;" d="M256 915.2c-134.4-51.2-224-147.2-249.6-288-12.8-83.2-6.4-172.8 32-249.6 6.4-19.2 19.2-32 32-51.2l19.2-19.2c12.8 6.4 25.6 6.4 32 12.8 44.8 25.6 76.8 64 115.2 96-128 153.6 6.4 332.8 172.8 377.6 160 38.4 371.2-25.6 416-192 19.2-64 6.4-140.8-44.8-192-25.6-25.6-64-44.8-102.4-51.2-25.6-6.4-44.8-6.4-70.4 0-12.8 6.4-25.6 6.4-38.4 6.4-19.2 6.4-38.4 6.4-38.4 25.6v268.8c0 19.2 0 12.8-12.8 19.2-12.8 0-25.6 0-38.4 6.4-38.4 0-83.2 0-121.6-6.4-12.8 0-19.2 0-19.2-19.2v-140.8l6.4-294.4c0-32 0-102.4-32-115.2-38.4-19.2-70.4 19.2-108.8 25.6 6.4-51.2-25.6-147.2 32-172.8 51.2-25.6 115.2-32 172.8-12.8 115.2 38.4 153.6 172.8 140.8 275.2 179.2-51.2 377.6 38.4 454.4 198.4 57.6 115.2 32 262.4-51.2 358.4-166.4 185.6-480 224-697.6 134.4z" />
<glyph unicode="&#xe64e;" d="M928-64h-832c-51.2 0-96 44.8-96 96v832c0 51.2 44.8 96 96 96h825.6c57.6 0 102.4-44.8 102.4-96v-825.6c0-57.6-44.8-102.4-96-102.4zM262.4 768c-44.8 0-76.8-32-76.8-76.8 0-38.4 25.6-76.8 70.4-76.8 44.8 0 70.4 32 70.4 76.8 6.4 44.8-19.2 76.8-64 76.8zM339.2 569.6h-147.2v-441.6h147.2v441.6zM876.8 377.6c0 134.4-64 204.8-160 204.8-76.8 0-108.8-44.8-128-70.4v64h-153.6v-441.6h147.2v236.8c0 12.8 0 25.6 6.4 32 12.8 25.6 32 51.2 76.8 51.2 51.2 0 70.4-38.4 70.4-96v-230.4h147.2v249.6z" />
<glyph unicode="&#xe64f;" d="M0 89.6v0zM236.8 396.8c89.6 0 153.6 96 140.8 211.2-19.2 121.6-108.8 217.6-198.4 217.6-89.6 6.4-153.6-89.6-140.8-211.2 19.2-115.2 108.8-217.6 198.4-217.6zM1024 704v83.2c0 96-76.8 172.8-166.4 172.8h-684.8c-96 0-172.8-76.8-172.8-166.4 57.6 51.2 140.8 96 224 96h358.4l-83.2-70.4h-108.8c70.4-25.6 115.2-115.2 115.2-204.8 0-76.8-44.8-140.8-102.4-185.6-57.6-44.8-70.4-64-70.4-102.4 0-32 64-89.6 96-108.8 96-64 128-128 128-230.4 0-19.2 0-32-6.4-51.2h307.2c96 0 172.8 76.8 172.8 172.8v531.2h-192v-192h-64v192h-198.4v64h192v192h64v-192h192zM185.6 192h64c-25.6 25.6-51.2 57.6-51.2 96 0 25.6 6.4 44.8 19.2 64h-32c-76.8 6.4-140.8 32-185.6 70.4v-275.2c51.2 32 115.2 44.8 185.6 44.8zM6.4 70.4v19.2c-6.4-6.4-6.4-12.8 0-19.2zM454.4 6.4c-12.8 57.6-70.4 89.6-140.8 140.8-25.6 6.4-57.6 12.8-89.6 12.8-89.6 0-172.8-32-217.6-89.6 12.8-76.8 83.2-134.4 166.4-134.4h288v32c0 12.8 0 25.6-6.4 38.4z" />
<glyph unicode="&#xe650;" d="M512 960c-281.6 0-512-230.4-512-512s230.4-512 512-512 512 230.4 512 512-230.4 512-512 512zM825.6 697.6c51.2-64 83.2-140.8 83.2-230.4-57.6 12.8-115.2 19.2-166.4 19.2-38.4 0-76.8-6.4-115.2-12.8l-25.6 64c83.2 32 160 83.2 224 160zM512 844.8c96 0 179.2-32 249.6-89.6-51.2-64-121.6-108.8-198.4-140.8-51.2 108.8-102.4 179.2-134.4 224 25.6 6.4 51.2 6.4 83.2 6.4zM332.8 806.4c32-32 83.2-102.4 147.2-217.6-121.6-38.4-243.2-44.8-320-44.8h-38.4c32 115.2 108.8 211.2 211.2 262.4zM115.2 448c12.8 6.4 25.6 6.4 44.8 6.4 83.2 0 217.6 6.4 364.8 51.2 6.4-19.2 12.8-32 25.6-51.2-102.4-32-179.2-83.2-230.4-134.4-51.2-51.2-89.6-96-108.8-128-64 70.4-96 160-96 256zM512 51.2c-89.6 0-172.8 32-236.8 76.8 12.8 25.6 44.8 70.4 89.6 115.2 51.2 44.8 115.2 96 204.8 128 32-83.2 57.6-185.6 76.8-294.4-38.4-19.2-83.2-25.6-134.4-25.6zM736 121.6c-19.2 102.4-44.8 185.6-76.8 268.8 25.6 6.4 51.2 6.4 83.2 6.4 44.8 0 102.4-6.4 153.6-19.2-12.8-108.8-70.4-198.4-160-256z" />
<glyph unicode="&#xe651;" d="M921.6 678.4h-256v64h256v-64zM499.2 416c12.8-25.6 25.6-57.6 25.6-96s-6.4-70.4-25.6-102.4l-51.2-51.2c-19.2-12.8-44.8-25.6-70.4-32s-57.6-6.4-89.6-6.4h-288v640h307.2c76.8 0 134.4-25.6 166.4-70.4 19.2-25.6 25.6-57.6 25.6-96s-12.8-70.4-32-96c-6.4-12.8-19.2-25.6-44.8-32 32-12.8 57.6-32 76.8-57.6zM147.2 518.4h134.4c25.6 0 51.2 6.4 70.4 12.8 19.2 12.8 25.6 32 25.6 57.6 0 32-12.8 51.2-32 57.6-25.6 6.4-51.2 12.8-83.2 12.8h-115.2v-140.8zM390.4 332.8c0 32-12.8 57.6-38.4 70.4-12.8 6.4-38.4 12.8-64 12.8h-140.8v-172.8h134.4c25.6 0 51.2 6.4 64 12.8 25.6 6.4 44.8 32 44.8 76.8zM1017.6 435.2c6.4-19.2 6.4-51.2 6.4-89.6h-332.8c0-44.8 19.2-76.8 44.8-96 19.2-12.8 38.4-19.2 64-19.2s51.2 6.4 64 19.2c19.2 6.4 25.6 19.2 32 32h121.6c0-25.6-19.2-57.6-44.8-83.2-38.4-44.8-96-64-172.8-64-57.6 0-115.2 19.2-160 57.6-44.8 32-70.4 96-70.4 179.2 0 76.8 19.2 140.8 64 185.6 44.8 44.8 96 64 166.4 64 38.4 0 76.8-6.4 108.8-19.2 32-12.8 57.6-38.4 76.8-70.4 19.2-32 25.6-64 32-96zM902.4 422.4c0 32-12.8 57.6-32 70.4-19.2 19.2-44.8 25.6-70.4 25.6-32 0-51.2-6.4-70.4-25.6-19.2-19.2-25.6-38.4-32-70.4h204.8z" />
<glyph unicode="&#xe652;" d="M565.888 547.328l69.824-33.728 105.408 33.728v61.184c0 126.080-102.784 228.608-229.12 228.608s-229.056-102.592-229.056-228.608v-321.024c0-29.632-24.192-53.696-53.824-53.696s-53.824 24.064-53.824 53.696v134.4h-175.296v-134.4c0-126.080 102.72-228.608 229.12-228.608 126.336 0 229.12 102.592 229.12 228.608v321.024c0 29.568 24.192 53.696 53.824 53.696 29.696 0 53.888-24.128 53.888-53.696l-0.064-61.184zM848.704 421.888v-134.4c0-29.632-24.128-53.696-53.824-53.696-29.696 0-53.888 24.064-53.888 53.696v137.088l-105.344-33.728-69.824 33.728v-137.088c0-126.080 102.784-228.608 229.12-228.608s229.056 102.592 229.056 228.608v134.4h-175.296z" />
<glyph unicode="&#xe653;" d="M608 307.2c-19.2-19.2 0-51.2 0-51.2l128-217.6s19.2-25.6 38.4-25.6 38.4 12.8 38.4 12.8l102.4 147.2s12.8 19.2 12.8 32c0 25.6-32 32-32 32l-243.2 76.8c-6.4 0-25.6 6.4-44.8-6.4zM595.2 416c12.8-19.2 44.8-12.8 44.8-12.8l243.2 70.4s32 12.8 38.4 32c6.4 19.2-6.4 38.4-6.4 38.4l-108.8 134.4s-12.8 19.2-32 19.2c-25.6 0-38.4-25.6-38.4-25.6l-140.8-217.6s-6.4-19.2 0-38.4zM480 499.2c32 6.4 38.4 51.2 38.4 51.2v345.6c-6.4 0-6.4 38.4-25.6 51.2-32 19.2-44.8 6.4-51.2 6.4l-198.4-70.4s-19.2-6.4-32-25.6c-12.8-25.6 12.8-57.6 12.8-57.6l211.2-288s19.2-19.2 44.8-12.8zM435.2 358.4c0 25.6-32 44.8-32 44.8l-217.6 108.8s-32 12.8-44.8 6.4c-19.2-12.8-25.6-25.6-32-32l-12.8-172.8s0-32 6.4-44.8c12.8-19.2 44.8-6.4 44.8-6.4l256 57.6c12.8 0 25.6 6.4 32 38.4zM492.8 262.4c-19.2 12.8-44.8-6.4-44.8-6.4l-172.8-185.6s-19.2-25.6-12.8-44.8c6.4-19.2 12.8-25.6 25.6-32l172.8-51.2s19.2-6.4 38.4 0c19.2 0 12.8 32 12.8 32l6.4 256s0 25.6-25.6 32z" />
<glyph unicode="&#xe654;" d="M518.4 416l115.2-313.6v-6.4c-38.4-12.8-83.2-19.2-128-19.2-38.4 0-76.8 6.4-108.8 12.8l121.6 326.4zM896 448c0-140.8-76.8-256-192-326.4l115.2 332.8c19.2 51.2 32 96 32 134.4v38.4c32-51.2 44.8-115.2 44.8-179.2zM128 448c0 51.2 12.8 108.8 32 153.6l185.6-486.4c-128 57.6-217.6 185.6-217.6 332.8zM192 652.8c70.4 102.4 185.6 166.4 320 166.4 102.4 0 192-38.4 262.4-96h-6.4c-38.4 0-64-32-64-64s19.2-57.6 38.4-89.6c12.8-25.6 32-57.6 32-102.4 0-32-12.8-70.4-32-121.6l-38.4-128-140.8 403.2c25.6 0 44.8 6.4 44.8 6.4 19.2 0 19.2 32 0 32 0 0-64-6.4-102.4-6.4-38.4 0-102.4 6.4-102.4 6.4-19.2 0-25.6-32 0-32 0 0 19.2 0 38.4-6.4l57.6-160-83.2-243.2-140.8 403.2c25.6 6.4 44.8 6.4 44.8 6.4 19.2 0 19.2 32 0 32 0 0-64-6.4-102.4-6.4h-25.6zM851.2 960h-678.4c-96 0-172.8-76.8-172.8-172.8v-678.4c0-96 76.8-172.8 172.8-172.8h678.4c96 0 172.8 76.8 172.8 172.8v678.4c0 96-76.8 172.8-172.8 172.8zM960 448c0-249.6-198.4-448-448-448s-448 198.4-448 448 198.4 448 448 448 448-198.4 448-448z" />
<glyph unicode="&#xe655;" d="M409.6 62.494v343.341h493.929v-439.718l-493.929 96.376zM409.6 839.529l493.929 90.353v-439.718h-493.929v349.365zM331.294 490.165h-331.294v271.059l331.294 60.235v-331.294zM331.294 80.565l-331.294 66.259v259.012h331.294v-325.271z" horiz-adv-x="904" />
<glyph unicode="&#xe656;" d="M64 768c19.2-128 128-659.2 377.6-812.8 38.4-25.6 83.2-19.2 115.2 6.4 121.6 102.4 243.2 275.2 275.2 358.4 64-6.4 108.8 12.8 108.8 12.8v128h-115.2c-140.8 0-236.8 166.4-179.2 313.6 38.4 102.4 108.8 25.6 121.6 0 12.8-32 6.4-115.2-6.4-172.8 19.2-51.2 140.8-76.8 166.4-38.4 32 96 44.8 262.4-38.4 352-57.6 38.4-198.4 70.4-300.8 6.4s-102.4-204.8-96-275.2c6.4-70.4 32-217.6 172.8-300.8 12.8-12.8-153.6-230.4-160-217.6-185.6 179.2-249.6 544-262.4 640h-179.2z" />
<glyph unicode="&#xe657;" d="M576 512v-236.8c0-57.6 0-96 6.4-108.8 6.4-19.2 19.2-32 38.4-44.8 25.6-12.8 51.2-19.2 76.8-19.2 51.2 0 83.2 6.4 134.4 38.4v-153.6c-44.8-19.2-83.2-32-115.2-38.4-38.4-12.8-76.8-12.8-115.2-12.8-44.8 0-76.8 6.4-108.8 19.2-38.4 12.8-64 32-89.6 51.2-25.6 19.2-44.8 44.8-51.2 70.4-12.8 25.6-12.8 57.6-12.8 108.8v352h-147.2v147.2c38.4 12.8 83.2 32 115.2 57.6 25.6 25.6 51.2 51.2 70.4 89.6 19.2 32 32 76.8 38.4 128h160v-256h256v-192h-256z" />
<glyph unicode="&#xe658;" d="M646.4 236.8h-192l-64-300.8h-262.4l25.6 108.8h-153.6l198.4 915.2h448c134.4 0 288-96 236.8-313.6-38.4-192-192-300.8-371.2-300.8h-185.6l-64-300.8h-44.8l-12.8-44.8h134.4l64 300.8h243.2c76.8 0 147.2 25.6 198.4 64l32 25.6c51.2 51.2 83.2 115.2 102.4 192 12.8 76.8 6.4 140.8-32 185.6-19.2 19.2-38.4 38.4-64 51.2 96-38.4 166.4-134.4 134.4-288-38.4-179.2-192-294.4-371.2-294.4zM492.8 524.8c70.4 0 134.4 57.6 153.6 128 19.2 70.4-25.6 128-89.6 128h-128l-64-256h128z" />
<glyph unicode="&#xe659;" d="M780.8 160c-204.8 0-275.2 89.6-313.6 204.8l-38.4 121.6c-25.6 89.6-64 153.6-166.4 153.6-70.4 0-147.2-51.2-147.2-198.4 0-115.2 57.6-185.6 140.8-185.6 89.6 0 153.6 70.4 153.6 70.4l44.8-102.4s-64-64-198.4-64c-166.4 0-256 96-256 275.2 0 192 89.6 300.8 262.4 300.8 153.6 0 236.8-57.6 281.6-211.2l38.4-121.6c25.6-89.6 76.8-147.2 198.4-147.2 76.8 0 121.6 19.2 121.6 64 0 32-19.2 57.6-76.8 76.8l-76.8 19.2c-96 25.6-134.4 76.8-134.4 153.6 0 128 102.4 172.8 211.2 172.8 121.6 0 192-44.8 204.8-153.6l-115.2-12.8c-6.4 51.2-38.4 70.4-89.6 70.4s-83.2-25.6-83.2-64 12.8-57.6 64-70.4l76.8-19.2c89.6-25.6 140.8-70.4 140.8-166.4 0-121.6-96-166.4-243.2-166.4z" />
<glyph unicode="&#xe65a;" d="M928 960h-832c-51.2 0-96-44.8-96-96v-825.6c0-57.6 44.8-102.4 96-102.4h825.6c57.6 0 96 44.8 96 96v832c6.4 51.2-38.4 96-89.6 96zM512 646.4c108.8 0 198.4-89.6 198.4-198.4s-89.6-198.4-198.4-198.4-198.4 89.6-198.4 198.4 89.6 198.4 198.4 198.4zM896 102.4c0-19.2-19.2-38.4-38.4-38.4h-691.2c-19.2 0-38.4 19.2-38.4 38.4v409.6h89.6c-6.4-25.6-6.4-51.2-6.4-76.8 0-166.4 128-307.2 300.8-307.2s300.8 140.8 300.8 307.2c0 25.6-6.4 51.2-12.8 76.8h96v-409.6zM896 678.4c0-19.2-19.2-38.4-38.4-38.4h-115.2c-19.2 0-38.4 19.2-38.4 38.4v115.2c0 19.2 19.2 38.4 38.4 38.4h115.2c19.2 0 38.4-19.2 38.4-38.4v-115.2z" />
<glyph unicode="&#xe65b;" d="M64 960l64-896 384-128 384 128 64 896h-896zM780.8 659.2h-428.8l12.8-115.2h409.6l-32-352-230.4-64-230.4 64-12.8 179.2h115.2v-89.6l128-32 128 32 12.8 147.2h-390.4l-32 345.6h563.2l-12.8-115.2z" />
<glyph unicode="&#xe65c;" d="M0 435.2c0-44.8 6.4-89.6 12.8-128s19.2-70.4 38.4-96c12.8-25.6 32-51.2 57.6-70.4s51.2-38.4 76.8-51.2c25.6-12.8 57.6-25.6 96-32l108.8-19.2s76.8-6.4 121.6-6.4 83.2 0 121.6 6.4 70.4 6.4 108.8 19.2c38.4 6.4 70.4 19.2 96 32s51.2 32 76.8 51.2c25.6 19.2 44.8 44.8 57.6 70.4 12.8 25.6 25.6 57.6 38.4 96 12.8 38.4 12.8 83.2 12.8 128 0 83.2-25.6 153.6-83.2 217.6l6.4 25.6c0 12.8 6.4 25.6 6.4 44.8v64l-19.2 76.8h-32c-12.8 0-25.6-6.4-44.8-6.4-19.2-6.4-38.4-12.8-64-25.6l-76.8-51.2c-51.2 12.8-121.6 19.2-204.8 19.2s-153.6-6.4-198.4-19.2c-32 19.2-57.6 32-83.2 44.8-25.6 12.8-44.8 19.2-64 25.6l-38.4 12.8h-38.4l-19.2-76.8c-6.4-25.6-6.4-44.8 0-64 0-19.2 6.4-32 6.4-44.8 0-12.8 6.4-19.2 6.4-25.6-57.6-64-83.2-134.4-83.2-217.6zM128 307.2c0 44.8 19.2 89.6 64 134.4 12.8 12.8 25.6 19.2 44.8 25.6 19.2 6.4 38.4 12.8 57.6 12.8h64c19.2 0 44.8 0 76.8-6.4h153.6c25.6 0 51.2 6.4 70.4 6.4h64c19.2 0 44.8-6.4 57.6-12.8 19.2-6.4 32-12.8 44.8-25.6 44.8-38.4 64-83.2 64-134.4 0-25.6-6.4-51.2-12.8-76.8l-25.6-57.6c-12.8-12.8-25.6-25.6-44.8-38.4-19.2-12.8-38.4-19.2-57.6-25.6-19.2-6.4-44.8-12.8-70.4-12.8-32 0-57.6-6.4-76.8-6.4-25.6 6.4-57.6 6.4-89.6 6.4h-89.6c-25.6 0-51.2 0-76.8 6.4-32 0-51.2 6.4-70.4 12.8-19.2 6.4-38.4 12.8-57.6 25.6-25.6 12.8-44.8 19.2-51.2 38.4-12.8 12.8-19.2 32-25.6 57.6-12.8 19.2-12.8 44.8-12.8 70.4zM640 320c0-51.2 25.6-96 64-96s64 44.8 64 96-25.6 96-64 96c-32 0-64-44.8-64-96zM256 320c0-51.2 32-96 64-96s64 44.8 64 96-25.6 96-64 96-64-44.8-64-96z" />
<glyph unicode="&#xe65d;" d="M985.6 364.8l-390.4-390.4c-44.8-44.8-121.6-44.8-166.4 0l-396.8 390.4c-44.8 44.8-44.8 121.6 0 166.4l390.4 390.4c51.2 51.2 128 51.2 172.8 6.4l179.2-179.2-262.4-268.8-102.4 102.4c-32 32-83.2 32-108.8 0l-83.2-83.2c-32-32-32-76.8 0-108.8l236.8-236.8c25.6-25.6 57.6-25.6 83.2-19.2 12.8 6.4 19.2 6.4 25.6 19.2l396.8 403.2 19.2-19.2c57.6-51.2 57.6-128 6.4-172.8zM550.4 224c-12.8-12.8-44.8-12.8-44.8-12.8s-32 0-38.4 12.8l-179.2 185.6c-12.8 12.8-12.8 38.4 0 57.6l51.2 51.2c12.8 12.8 44.8 12.8 57.6 0l115.2-121.6 352 352c12.8 12.8 44.8 12.8 57.6 0l51.2-51.2c12.8-12.8 12.8-44.8 0-57.6l-422.4-416z" />
<glyph unicode="&#xe65e;" d="M512 748.8l211.2 179.2 300.8-198.4-204.8-166.4-307.2 185.6zM1024 396.8l-300.8-198.4-211.2 172.8 300.8 185.6 211.2-160zM300.8 198.4l-300.8 198.4 204.8 166.4 307.2-192-211.2-172.8zM0 729.6l300.8 198.4 211.2-179.2-300.8-192-211.2 172.8zM512 332.8l211.2-179.2 89.6 57.6v-64l-300.8-179.2-300.8 179.2v64l89.6-51.2 211.2 172.8z" />
<glyph unicode="&#xe65f;" d="M864 249.6c-38.4 0-64 32-64 64v256c0 38.4 32 64 64 64 38.4 0 64-32 64-64v-256c0-32-25.6-64-64-64zM697.6 102.4h-38.4v-108.8c0-38.4-25.6-64-57.6-64s-57.6 25.6-57.6 64v108.8h-70.4v-108.8c0-38.4-25.6-64-57.6-64s-57.6 25.6-57.6 64v108.8h-32c-19.2 0-38.4 19.2-38.4 44.8v428.8h448v-422.4c0-32-12.8-51.2-38.4-51.2zM736 633.6h-448c0 89.6 32 153.6 76.8 192l-70.4 83.2c-6.4 12.8-6.4 25.6 0 38.4 12.8 12.8 25.6 12.8 38.4 0l83.2-96c32 12.8 64 19.2 96 19.2s70.4-6.4 96-19.2l83.2 96c12.8 12.8 25.6 12.8 38.4 0s12.8-32 0-38.4l-70.4-83.2c44.8-32 76.8-102.4 76.8-192zM441.6 761.6c-12.8 0-25.6-12.8-25.6-32s12.8-32 25.6-32 25.6 12.8 25.6 32-12.8 32-25.6 32zM582.4 761.6c-12.8 0-25.6-12.8-25.6-32s12.8-32 25.6-32 25.6 19.2 25.6 32-12.8 32-25.6 32zM160 249.6c-38.4 0-64 32-64 64v256c0 38.4 25.6 64 64 64s64-32 64-64v-256c0-32-25.6-64-64-64z" />
<glyph unicode="&#xe660;" d="M921.6 211.2c-32-153.6-115.2-211.2-147.2-249.6-32-25.6-121.6-25.6-153.6-6.4-38.4 25.6-134.4 25.6-166.4 0-44.8-32-115.2-19.2-128-12.8-256 179.2-352 716.8 12.8 774.4 64 12.8 134.4-32 134.4-32 51.2-25.6 70.4-12.8 115.2 6.4 96 44.8 243.2 44.8 313.6-76.8-147.2-96-153.6-294.4 19.2-403.2zM716.8 960c12.8-70.4-64-224-204.8-230.4-12.8 38.4 32 217.6 204.8 230.4z" />
</font></defs></svg>

之后

宽度:  |  高度:  |  大小: 56 KiB

二进制文件未显示。

二进制文件未显示。

13
docs/waifu_plugin/jquery-ui.min.js vendored 普通文件

文件差异因一行或多行过长而隐藏

4
docs/waifu_plugin/jquery.min.js vendored 普通文件

文件差异因一行或多行过长而隐藏

4238
docs/waifu_plugin/live2d.js 普通文件

文件差异内容过多而无法显示 加载差异

1
docs/waifu_plugin/source 普通文件
查看文件

@@ -0,0 +1 @@
https://github.com/fghrsh/live2d_demo

查看文件

@@ -0,0 +1,405 @@
window.live2d_settings = Array(); /*
く__,.ヘヽ.    / ,ー、 〉
      ', !-─‐-i / /´
      /`ー'    L//`ヽ、 Live2D 看板娘 参数设置
     /  ,  /|  ,  ,    ', Version 1.4.2
   イ  / /-/  L_ ハ ヽ!  i Update 2018.11.12
    レ ヘ 7イ  レ'ァ-ト、!ハ|  |
     !,/7 '0'   ´0iソ|   |   
     |.从"  _   ,,,, / |./   | 网页添加 Live2D 看板娘
     レ'| i.、,,__ _,.イ /  .i  | https://www.fghrsh.net/post/123.html
      レ'| | / k__/レ'ヽ, ハ. |
       | |/i 〈|/  i ,.ヘ | i | Thanks
      .|/ /    ヘ!   | journey-ad / https://github.com/journey-ad/live2d_src
        kヽ>、ハ   _,.ヘ、   /、! xiazeyu / https://github.com/xiazeyu/live2d-widget.js
       !'〈//´', '7'ーr' Live2d Cubism SDK WebGL 2.1 Projrct & All model authors.
       レ'ヽL__|___i,___,ンレ|
         ト-,/ |___./
         'ー'  !_,.:*********************************************************************************/
// 后端接口
live2d_settings['modelAPI'] = '//live2d.fghrsh.net/api/'; // 自建 API 修改这里
live2d_settings['tipsMessage'] = 'waifu-tips.json'; // 同目录下可省略路径
live2d_settings['hitokotoAPI'] = 'lwl12.com'; // 一言 API,可选 'lwl12.com', 'hitokoto.cn', 'jinrishici.com'(古诗词)
// 默认模型
live2d_settings['modelId'] = 1; // 默认模型 ID,可在 F12 控制台找到
live2d_settings['modelTexturesId'] = 53; // 默认材质 ID,可在 F12 控制台找到
// 工具栏设置
live2d_settings['showToolMenu'] = true; // 显示 工具栏 ,可选 true(真), false(假)
live2d_settings['canCloseLive2d'] = true; // 显示 关闭看板娘 按钮,可选 true(真), false(假)
live2d_settings['canSwitchModel'] = true; // 显示 模型切换 按钮,可选 true(真), false(假)
live2d_settings['canSwitchTextures'] = true; // 显示 材质切换 按钮,可选 true(真), false(假)
live2d_settings['canSwitchHitokoto'] = true; // 显示 一言切换 按钮,可选 true(真), false(假)
live2d_settings['canTakeScreenshot'] = true; // 显示 看板娘截图 按钮,可选 true(真), false(假)
live2d_settings['canTurnToHomePage'] = true; // 显示 返回首页 按钮,可选 true(真), false(假)
live2d_settings['canTurnToAboutPage'] = true; // 显示 跳转关于页 按钮,可选 true(真), false(假)
// 模型切换模式
live2d_settings['modelStorage'] = true; // 记录 ID (刷新后恢复),可选 true(真), false(假)
live2d_settings['modelRandMode'] = 'switch'; // 模型切换,可选 'rand'(随机), 'switch'(顺序)
live2d_settings['modelTexturesRandMode']= 'rand'; // 材质切换,可选 'rand'(随机), 'switch'(顺序)
// 提示消息选项
live2d_settings['showHitokoto'] = true; // 显示一言
live2d_settings['showF12Status'] = true; // 显示加载状态
live2d_settings['showF12Message'] = false; // 显示看板娘消息
live2d_settings['showF12OpenMsg'] = true; // 显示控制台打开提示
live2d_settings['showCopyMessage'] = true; // 显示 复制内容 提示
live2d_settings['showWelcomeMessage'] = true; // 显示进入面页欢迎词
//看板娘样式设置
live2d_settings['waifuSize'] = '280x250'; // 看板娘大小,例如 '280x250', '600x535'
live2d_settings['waifuTipsSize'] = '250x70'; // 提示框大小,例如 '250x70', '570x150'
live2d_settings['waifuFontSize'] = '12px'; // 提示框字体,例如 '12px', '30px'
live2d_settings['waifuToolFont'] = '14px'; // 工具栏字体,例如 '14px', '36px'
live2d_settings['waifuToolLine'] = '20px'; // 工具栏行高,例如 '20px', '36px'
live2d_settings['waifuToolTop'] = '0px' // 工具栏顶部边距,例如 '0px', '-60px'
live2d_settings['waifuMinWidth'] = '768px'; // 面页小于 指定宽度 隐藏看板娘,例如 'disable'(禁用), '768px'
live2d_settings['waifuEdgeSide'] = 'left:0'; // 看板娘贴边方向,例如 'left:0'(靠左 0px), 'right:30'(靠右 30px)
live2d_settings['waifuDraggable'] = 'disable'; // 拖拽样式,例如 'disable'(禁用), 'axis-x'(只能水平拖拽), 'unlimited'(自由拖拽)
live2d_settings['waifuDraggableRevert'] = true; // 松开鼠标还原拖拽位置,可选 true(真), false(假)
// 其他杂项设置
live2d_settings['l2dVersion'] = '1.4.2'; // 当前版本
live2d_settings['l2dVerDate'] = '2018.11.12'; // 版本更新日期
live2d_settings['homePageUrl'] = 'auto'; // 主页地址,可选 'auto'(自动), '{URL 网址}'
live2d_settings['aboutPageUrl'] = 'https://www.fghrsh.net/post/123.html'; // 关于页地址, '{URL 网址}'
live2d_settings['screenshotCaptureName']= 'live2d.png'; // 看板娘截图文件名,例如 'live2d.png'
/****************************************************************************************************/
String.prototype.render = function(context) {
var tokenReg = /(\\)?\{([^\{\}\\]+)(\\)?\}/g;
return this.replace(tokenReg, function (word, slash1, token, slash2) {
if (slash1 || slash2) { return word.replace('\\', ''); }
var variables = token.replace(/\s/g, '').split('.');
var currentObject = context;
var i, length, variable;
for (i = 0, length = variables.length; i < length; ++i) {
variable = variables[i];
currentObject = currentObject[variable];
if (currentObject === undefined || currentObject === null) return '';
}
return currentObject;
});
};
var re = /x/;
console.log(re);
function empty(obj) {return typeof obj=="undefined"||obj==null||obj==""?true:false}
function getRandText(text) {return Array.isArray(text) ? text[Math.floor(Math.random() * text.length + 1)-1] : text}
function showMessage(text, timeout, flag) {
if(flag || sessionStorage.getItem('waifu-text') === '' || sessionStorage.getItem('waifu-text') === null){
if(Array.isArray(text)) text = text[Math.floor(Math.random() * text.length + 1)-1];
if (live2d_settings.showF12Message) console.log('[Message]', text.replace(/<[^<>]+>/g,''));
if(flag) sessionStorage.setItem('waifu-text', text);
$('.waifu-tips').stop();
$('.waifu-tips').html(text).fadeTo(200, 1);
if (timeout === undefined) timeout = 5000;
hideMessage(timeout);
}
}
function hideMessage(timeout) {
$('.waifu-tips').stop().css('opacity',1);
if (timeout === undefined) timeout = 5000;
window.setTimeout(function() {sessionStorage.removeItem('waifu-text')}, timeout);
$('.waifu-tips').delay(timeout).fadeTo(200, 0);
}
function initModel(waifuPath, type) {
/* console welcome message */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('8.d(" ");8.d("\\U,.\\y\\5.\\1\\1\\1\\1/\\1,\\u\\2 \\H\\n\\1\\1\\1\\1\\1\\b \', !-\\r\\j-i\\1/\\1/\\g\\n\\1\\1\\1 \\1 \\a\\4\\f\'\\1\\1\\1 L/\\a\\4\\5\\2\\n\\1\\1 \\1 /\\1 \\a,\\1 /|\\1 ,\\1 ,\\1\\1\\1 \',\\n\\1\\1\\1\\q \\1/ /-\\j/\\1\\h\\E \\9 \\5!\\1 i\\n\\1\\1\\1 \\3 \\6 7\\q\\4\\c\\1 \\3\'\\s-\\c\\2!\\t|\\1 |\\n\\1\\1\\1\\1 !,/7 \'0\'\\1\\1 \\X\\w| \\1 |\\1\\1\\1\\n\\1\\1\\1\\1 |.\\x\\"\\1\\l\\1\\1 ,,,, / |./ \\1 |\\n\\1\\1\\1\\1 \\3\'| i\\z.\\2,,A\\l,.\\B / \\1.i \\1|\\n\\1\\1\\1\\1\\1 \\3\'| | / C\\D/\\3\'\\5,\\1\\9.\\1|\\n\\1\\1\\1\\1\\1\\1 | |/i \\m|/\\1 i\\1,.\\6 |\\F\\1|\\n\\1\\1\\1\\1\\1\\1.|/ /\\1\\h\\G \\1 \\6!\\1\\1\\b\\1|\\n\\1\\1\\1 \\1 \\1 k\\5>\\2\\9 \\1 o,.\\6\\2 \\1 /\\2!\\n\\1\\1\\1\\1\\1\\1 !\'\\m//\\4\\I\\g\', \\b \\4\'7\'\\J\'\\n\\1\\1\\1\\1\\1\\1 \\3\'\\K|M,p,\\O\\3|\\P\\n\\1\\1\\1\\1\\1 \\1\\1\\1\\c-,/\\1|p./\\n\\1\\1\\1\\1\\1 \\1\\1\\1\'\\f\'\\1\\1!o,.:\\Q \\R\\S\\T v"+e.V+" / W "+e.N);8.d(" ");',60,60,'|u3000|uff64|uff9a|uff40|u30fd|uff8d||console|uff8a|uff0f|uff3c|uff84|log|live2d_settings|uff70|u00b4|uff49||u2010||u3000_|u3008||_|___|uff72|u2500|uff67|u30cf|u30fc||u30bd|u4ece|u30d8|uff1e|__|u30a4|k_|uff17_|u3000L_|u3000i|uff1a|u3009|uff34|uff70r|u30fdL__||___i|l2dVerDate|u30f3|u30ce|nLive2D|u770b|u677f|u5a18|u304f__|l2dVersion|FGHRSH|u00b40i'.split('|'),0,{}));
/* 判断 JQuery */
if (typeof($.ajax) != 'function') typeof(jQuery.ajax) == 'function' ? window.$ = jQuery : console.log('[Error] JQuery is not defined.');
/* 加载看板娘样式 */
live2d_settings.waifuSize = live2d_settings.waifuSize.split('x');
live2d_settings.waifuTipsSize = live2d_settings.waifuTipsSize.split('x');
live2d_settings.waifuEdgeSide = live2d_settings.waifuEdgeSide.split(':');
$("#live2d").attr("width",live2d_settings.waifuSize[0]);
$("#live2d").attr("height",live2d_settings.waifuSize[1]);
$(".waifu-tips").width(live2d_settings.waifuTipsSize[0]);
$(".waifu-tips").height(live2d_settings.waifuTipsSize[1]);
$(".waifu-tips").css("top",live2d_settings.waifuToolTop);
$(".waifu-tips").css("font-size",live2d_settings.waifuFontSize);
$(".waifu-tool").css("font-size",live2d_settings.waifuToolFont);
$(".waifu-tool span").css("line-height",live2d_settings.waifuToolLine);
if (live2d_settings.waifuEdgeSide[0] == 'left') $(".waifu").css("left",live2d_settings.waifuEdgeSide[1]+'px');
else if (live2d_settings.waifuEdgeSide[0] == 'right') $(".waifu").css("right",live2d_settings.waifuEdgeSide[1]+'px');
window.waifuResize = function() { $(window).width() <= Number(live2d_settings.waifuMinWidth.replace('px','')) ? $(".waifu").hide() : $(".waifu").show(); };
if (live2d_settings.waifuMinWidth != 'disable') { waifuResize(); $(window).resize(function() {waifuResize()}); }
try {
if (live2d_settings.waifuDraggable == 'axis-x') $(".waifu").draggable({ axis: "x", revert: live2d_settings.waifuDraggableRevert });
else if (live2d_settings.waifuDraggable == 'unlimited') $(".waifu").draggable({ revert: live2d_settings.waifuDraggableRevert });
else $(".waifu").css("transition", 'all .3s ease-in-out');
} catch(err) { console.log('[Error] JQuery UI is not defined.') }
live2d_settings.homePageUrl = live2d_settings.homePageUrl == 'auto' ? window.location.protocol+'//'+window.location.hostname+'/' : live2d_settings.homePageUrl;
if (window.location.protocol == 'file:' && live2d_settings.modelAPI.substr(0,2) == '//') live2d_settings.modelAPI = 'http:'+live2d_settings.modelAPI;
$('.waifu-tool .fui-home').click(function (){
//window.location = 'https://www.fghrsh.net/';
window.location = live2d_settings.homePageUrl;
});
$('.waifu-tool .fui-info-circle').click(function (){
//window.open('https://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-02');
window.open(live2d_settings.aboutPageUrl);
});
if (typeof(waifuPath) == "object") loadTipsMessage(waifuPath); else {
$.ajax({
cache: true,
url: waifuPath == '' ? live2d_settings.tipsMessage : (waifuPath.substr(waifuPath.length-15)=='waifu-tips.json'?waifuPath:waifuPath+'waifu-tips.json'),
dataType: "json",
success: function (result){ loadTipsMessage(result); }
});
}
if (!live2d_settings.showToolMenu) $('.waifu-tool').hide();
if (!live2d_settings.canCloseLive2d) $('.waifu-tool .fui-cross').hide();
if (!live2d_settings.canSwitchModel) $('.waifu-tool .fui-eye').hide();
if (!live2d_settings.canSwitchTextures) $('.waifu-tool .fui-user').hide();
if (!live2d_settings.canSwitchHitokoto) $('.waifu-tool .fui-chat').hide();
if (!live2d_settings.canTakeScreenshot) $('.waifu-tool .fui-photo').hide();
if (!live2d_settings.canTurnToHomePage) $('.waifu-tool .fui-home').hide();
if (!live2d_settings.canTurnToAboutPage) $('.waifu-tool .fui-info-circle').hide();
if (waifuPath === undefined) waifuPath = '';
var modelId = localStorage.getItem('modelId');
var modelTexturesId = localStorage.getItem('modelTexturesId');
if (!live2d_settings.modelStorage || modelId == null) {
var modelId = live2d_settings.modelId;
var modelTexturesId = live2d_settings.modelTexturesId;
} loadModel(modelId, modelTexturesId);
}
function loadModel(modelId, modelTexturesId=0) {
if (live2d_settings.modelStorage) {
localStorage.setItem('modelId', modelId);
localStorage.setItem('modelTexturesId', modelTexturesId);
} else {
sessionStorage.setItem('modelId', modelId);
sessionStorage.setItem('modelTexturesId', modelTexturesId);
} loadlive2d('live2d', live2d_settings.modelAPI+'get/?id='+modelId+'-'+modelTexturesId, (live2d_settings.showF12Status ? console.log('[Status]','live2d','模型',modelId+'-'+modelTexturesId,'加载完成'):null));
}
function loadTipsMessage(result) {
window.waifu_tips = result;
$.each(result.mouseover, function (index, tips){
$(document).on("mouseover", tips.selector, function (){
var text = getRandText(tips.text);
text = text.render({text: $(this).text()});
showMessage(text, 3000);
});
});
$.each(result.click, function (index, tips){
$(document).on("click", tips.selector, function (){
var text = getRandText(tips.text);
text = text.render({text: $(this).text()});
showMessage(text, 3000, true);
});
});
$.each(result.seasons, function (index, tips){
var now = new Date();
var after = tips.date.split('-')[0];
var before = tips.date.split('-')[1] || after;
if((after.split('/')[0] <= now.getMonth()+1 && now.getMonth()+1 <= before.split('/')[0]) &&
(after.split('/')[1] <= now.getDate() && now.getDate() <= before.split('/')[1])){
var text = getRandText(tips.text);
text = text.render({year: now.getFullYear()});
showMessage(text, 6000, true);
}
});
if (live2d_settings.showF12OpenMsg) {
re.toString = function() {
showMessage(getRandText(result.waifu.console_open_msg), 5000, true);
return '';
};
}
if (live2d_settings.showCopyMessage) {
$(document).on('copy', function() {
showMessage(getRandText(result.waifu.copy_message), 5000, true);
});
}
$('.waifu-tool .fui-photo').click(function(){
showMessage(getRandText(result.waifu.screenshot_message), 5000, true);
window.Live2D.captureName = live2d_settings.screenshotCaptureName;
window.Live2D.captureFrame = true;
});
$('.waifu-tool .fui-cross').click(function(){
sessionStorage.setItem('waifu-dsiplay', 'none');
showMessage(getRandText(result.waifu.hidden_message), 1300, true);
window.setTimeout(function() {$('.waifu').hide();}, 1300);
});
window.showWelcomeMessage = function(result) {
var text;
if (window.location.href == live2d_settings.homePageUrl) {
var now = (new Date()).getHours();
if (now > 23 || now <= 5) text = getRandText(result.waifu.hour_tips['t23-5']);
else if (now > 5 && now <= 7) text = getRandText(result.waifu.hour_tips['t5-7']);
else if (now > 7 && now <= 11) text = getRandText(result.waifu.hour_tips['t7-11']);
else if (now > 11 && now <= 14) text = getRandText(result.waifu.hour_tips['t11-14']);
else if (now > 14 && now <= 17) text = getRandText(result.waifu.hour_tips['t14-17']);
else if (now > 17 && now <= 19) text = getRandText(result.waifu.hour_tips['t17-19']);
else if (now > 19 && now <= 21) text = getRandText(result.waifu.hour_tips['t19-21']);
else if (now > 21 && now <= 23) text = getRandText(result.waifu.hour_tips['t21-23']);
else text = getRandText(result.waifu.hour_tips.default);
} else {
var referrer_message = result.waifu.referrer_message;
if (document.referrer !== '') {
var referrer = document.createElement('a');
referrer.href = document.referrer;
var domain = referrer.hostname.split('.')[1];
if (window.location.hostname == referrer.hostname)
text = referrer_message.localhost[0] + document.title.split(referrer_message.localhost[2])[0] + referrer_message.localhost[1];
else if (domain == 'baidu')
text = referrer_message.baidu[0] + referrer.search.split('&wd=')[1].split('&')[0] + referrer_message.baidu[1];
else if (domain == 'so')
text = referrer_message.so[0] + referrer.search.split('&q=')[1].split('&')[0] + referrer_message.so[1];
else if (domain == 'google')
text = referrer_message.google[0] + document.title.split(referrer_message.google[2])[0] + referrer_message.google[1];
else {
$.each(result.waifu.referrer_hostname, function(i,val) {if (i==referrer.hostname) referrer.hostname = getRandText(val)});
text = referrer_message.default[0] + referrer.hostname + referrer_message.default[1];
}
} else text = referrer_message.none[0] + document.title.split(referrer_message.none[2])[0] + referrer_message.none[1];
}
showMessage(text, 6000);
}; if (live2d_settings.showWelcomeMessage) showWelcomeMessage(result);
var waifu_tips = result.waifu;
function loadOtherModel() {
var modelId = modelStorageGetItem('modelId');
var modelRandMode = live2d_settings.modelRandMode;
$.ajax({
cache: modelRandMode == 'switch' ? true : false,
url: live2d_settings.modelAPI+modelRandMode+'/?id='+modelId,
dataType: "json",
success: function(result) {
loadModel(result.model['id']);
var message = result.model['message'];
$.each(waifu_tips.model_message, function(i,val) {if (i==result.model['id']) message = getRandText(val)});
showMessage(message, 3000, true);
}
});
}
function loadRandTextures() {
var modelId = modelStorageGetItem('modelId');
var modelTexturesId = modelStorageGetItem('modelTexturesId');
var modelTexturesRandMode = live2d_settings.modelTexturesRandMode;
$.ajax({
cache: modelTexturesRandMode == 'switch' ? true : false,
url: live2d_settings.modelAPI+modelTexturesRandMode+'_textures/?id='+modelId+'-'+modelTexturesId,
dataType: "json",
success: function(result) {
if (result.textures['id'] == 1 && (modelTexturesId == 1 || modelTexturesId == 0))
showMessage(waifu_tips.load_rand_textures[0], 3000, true);
else showMessage(waifu_tips.load_rand_textures[1], 3000, true);
loadModel(modelId, result.textures['id']);
}
});
}
function modelStorageGetItem(key) { return live2d_settings.modelStorage ? localStorage.getItem(key) : sessionStorage.getItem(key); }
/* 检测用户活动状态,并在空闲时显示一言 */
if (live2d_settings.showHitokoto) {
window.getActed = false; window.hitokotoTimer = 0; window.hitokotoInterval = false;
$(document).mousemove(function(e){getActed = true;}).keydown(function(){getActed = true;});
setInterval(function(){ if (!getActed) ifActed(); else elseActed(); }, 1000);
}
function ifActed() {
if (!hitokotoInterval) {
hitokotoInterval = true;
hitokotoTimer = window.setInterval(showHitokotoActed, 30000);
}
}
function elseActed() {
getActed = hitokotoInterval = false;
window.clearInterval(hitokotoTimer);
}
function showHitokotoActed() {
if ($(document)[0].visibilityState == 'visible') showHitokoto();
}
function showHitokoto() {
switch(live2d_settings.hitokotoAPI) {
case 'lwl12.com':
$.getJSON('https://api.lwl12.com/hitokoto/v1?encode=realjson',function(result){
if (!empty(result.source)) {
var text = waifu_tips.hitokoto_api_message['lwl12.com'][0];
if (!empty(result.author)) text += waifu_tips.hitokoto_api_message['lwl12.com'][1];
text = text.render({source: result.source, creator: result.author});
window.setTimeout(function() {showMessage(text+waifu_tips.hitokoto_api_message['lwl12.com'][2], 3000, true);}, 5000);
} showMessage(result.text, 5000, true);
});break;
case 'fghrsh.net':
$.getJSON('https://api.fghrsh.net/hitokoto/rand/?encode=jsc&uid=3335',function(result){
if (!empty(result.source)) {
var text = waifu_tips.hitokoto_api_message['fghrsh.net'][0];
text = text.render({source: result.source, date: result.date});
window.setTimeout(function() {showMessage(text, 3000, true);}, 5000);
showMessage(result.hitokoto, 5000, true);
}
});break;
case 'jinrishici.com':
$.ajax({
url: 'https://v2.jinrishici.com/one.json',
xhrFields: {withCredentials: true},
success: function (result, status) {
if (!empty(result.data.origin.title)) {
var text = waifu_tips.hitokoto_api_message['jinrishici.com'][0];
text = text.render({title: result.data.origin.title, dynasty: result.data.origin.dynasty, author:result.data.origin.author});
window.setTimeout(function() {showMessage(text, 3000, true);}, 5000);
} showMessage(result.data.content, 5000, true);
}
});break;
default:
$.getJSON('https://v1.hitokoto.cn',function(result){
if (!empty(result.from)) {
var text = waifu_tips.hitokoto_api_message['hitokoto.cn'][0];
text = text.render({source: result.from, creator: result.creator});
window.setTimeout(function() {showMessage(text, 3000, true);}, 5000);
}
showMessage(result.hitokoto, 5000, true);
});
}
}
$('.waifu-tool .fui-eye').click(function (){loadOtherModel()});
$('.waifu-tool .fui-user').click(function (){loadRandTextures()});
$('.waifu-tool .fui-chat').click(function (){showHitokoto()});
}

查看文件

@@ -0,0 +1,116 @@
{
"waifu": {
"console_open_msg": ["哈哈,你打开了控制台,是想要看看我的秘密吗?"],
"copy_message": ["你都复制了些什么呀,转载要记得加上出处哦"],
"screenshot_message": ["照好了嘛,是不是很可爱呢?"],
"hidden_message": ["我们还能再见面的吧…"],
"load_rand_textures": ["我还没有其他衣服呢", "我的新衣服好看嘛"],
"hour_tips": {
"t0-5": ["快睡觉去吧,年纪轻轻小心猝死哦"],
"t5-7": ["早上好!一日之计在于晨,美好的一天就要开始了"],
"t7-11": ["上午好!工作顺利嘛,不要久坐,多起来走动走动哦!"],
"t11-14": ["中午了,工作了一个上午,现在是午餐时间!"],
"t14-17": ["午后很容易犯困呢,今天的运动目标完成了吗?"],
"t17-19": ["傍晚了!窗外夕阳的景色很美丽呢,最美不过夕阳红~"],
"t19-21": ["晚上好,今天过得怎么样?"],
"t21-23": ["已经这么晚了呀,早点休息吧,晚安~"],
"t23-24": ["你是夜猫子呀?这么晚还不睡觉,明天起的来嘛"],
"default": ["嗨~ 快来逗我玩吧!"]
},
"referrer_message": {
"localhost": ["欢迎使用<span style=\"color:rgba(245, 20, 20, 0.62);\">『ChatGPT", "』</span>", " - "],
"baidu": ["Hello! 来自 百度搜索 的朋友<br>你是搜索 <span style=\"color:rgba(245, 20, 20, 0.62);\">", "</span> 找到的我吗?"],
"so": ["Hello! 来自 360搜索 的朋友<br>你是搜索 <span style=\"color:rgba(245, 20, 20, 0.62);\">", "</span> 找到的我吗?"],
"google": ["Hello! 来自 谷歌搜索 的朋友<br>欢迎使用<span style=\"color:rgba(245, 20, 20, 0.62);\">『ChatGPT", "』</span>", " - "],
"default": ["Hello! 来自 <span style=\"color:rgba(245, 20, 20, 0.62);\">", "</span> 的朋友"],
"none": ["欢迎使用<span style=\"color:rgba(245, 20, 20, 0.62);\">『ChatGPT", "』</span>", " - "]
},
"referrer_hostname": {
"example.com": ["示例网站"],
"www.fghrsh.net": ["FGHRSH 的博客"]
},
"model_message": {
"1": ["来自 Potion Maker 的 Pio 酱 ~"],
"2": ["来自 Potion Maker 的 Tia 酱 ~"]
},
"hitokoto_api_message": {
"lwl12.com": ["这句一言来自 <span style=\"color:#0099cc;\">『{source}』</span>", ",是 <span style=\"color:#0099cc;\">{creator}</span> 投稿的", "。"],
"fghrsh.net": ["这句一言出处是 <span style=\"color:#0099cc;\">『{source}』</span>,是 <span style=\"color:#0099cc;\">FGHRSH</span> 在 {date} 收藏的!"],
"jinrishici.com": ["这句诗词出自 <span style=\"color:#0099cc;\">《{title}》</span>,是 {dynasty}诗人 {author} 创作的!"],
"hitokoto.cn": ["这句一言来自 <span style=\"color:#0099cc;\">『{source}』</span>,是 <span style=\"color:#0099cc;\">{creator}</span> 在 hitokoto.cn 投稿的。"]
}
},
"mouseover": [
{ "selector": ".container a[href^='http']", "text": ["要看看 <span style=\"color:#0099cc;\">{text}</span> 么?"] },
{ "selector": ".fui-home", "text": ["点击前往首页,想回到上一页可以使用浏览器的后退功能哦"] },
{ "selector": ".fui-chat", "text": ["一言一语,一颦一笑。一字一句,一颗赛艇。"] },
{ "selector": ".fui-eye", "text": ["嗯··· 要切换 看板娘 吗?"] },
{ "selector": ".fui-user", "text": ["喜欢换装 Play 吗?"] },
{ "selector": ".fui-photo", "text": ["要拍张纪念照片吗?"] },
{ "selector": ".fui-info-circle", "text": ["这里有关于我的信息呢"] },
{ "selector": ".fui-cross", "text": ["你不喜欢我了吗..."] },
{ "selector": "#tor_show", "text": ["翻页比较麻烦吗,点击可以显示这篇文章的目录呢"] },
{ "selector": "#comment_go", "text": ["想要去评论些什么吗?"] },
{ "selector": "#night_mode", "text": ["深夜时要爱护眼睛呀"] },
{ "selector": "#qrcode", "text": ["手机扫一下就能继续看,很方便呢"] },
{ "selector": ".comment_reply", "text": ["要吐槽些什么呢"] },
{ "selector": "#back-to-top", "text": ["回到开始的地方吧"] },
{ "selector": "#author", "text": ["该怎么称呼你呢"] },
{ "selector": "#mail", "text": ["留下你的邮箱,不然就是无头像人士了"] },
{ "selector": "#url", "text": ["你的家在哪里呢,好让我去参观参观"] },
{ "selector": "#textarea", "text": ["认真填写哦,垃圾评论是禁止事项"] },
{ "selector": ".OwO-logo", "text": ["要插入一个表情吗"] },
{ "selector": "#csubmit", "text": ["要[提交]^(Commit)了吗,首次评论需要审核,请耐心等待~"] },
{ "selector": ".ImageBox", "text": ["点击图片可以放大呢"] },
{ "selector": "input[name=s]", "text": ["找不到想看的内容?搜索看看吧"] },
{ "selector": ".previous", "text": ["去上一页看看吧"] },
{ "selector": ".next", "text": ["去下一页看看吧"] },
{ "selector": ".dropdown-toggle", "text": ["这里是菜单"] },
{ "selector": "c-player a.play-icon", "text": ["想要听点音乐吗"] },
{ "selector": "c-player div.time", "text": ["在这里可以调整<span style=\"color:#0099cc;\">播放进度</span>呢"] },
{ "selector": "c-player div.volume", "text": ["在这里可以调整<span style=\"color:#0099cc;\">音量</span>呢"] },
{ "selector": "c-player div.list-button", "text": ["<span style=\"color:#0099cc;\">播放列表</span>里都有什么呢"] },
{ "selector": "c-player div.lyric-button", "text": ["有<span style=\"color:#0099cc;\">歌词</span>的话就能跟着一起唱呢"] },
{ "selector": ".waifu #live2d", "text": [
"别玩了,快去学习!",
"偶尔放松下眼睛吧。",
"看什么看(*^▽^*)",
"焦虑时,吃顿大餐心情就好啦^_^",
"你这个年纪,怎么睡得着觉的你^_^",
"修改ADD_WAIFU=False,我就不再打扰你了~",
"经常去github看看我们的更新吧,也许有好玩的新功能呢。",
"试试本地大模型吧,有的也很强大的哦。",
"很多强大的函数插件隐藏在下拉菜单中呢。",
"红色的插件,使用之前需要把文件上传进去哦。",
"想添加功能按钮吗?读读readme很容易就学会啦。",
"敏感或机密的信息,不可以问chatGPT的哦",
"chatGPT究竟是划时代的创新,还是扼杀创造力的毒药呢?"
] }
],
"click": [
{
"selector": ".waifu #live2d",
"text": [
"是…是不小心碰到了吧",
"萝莉控是什么呀",
"你看到我的小熊了吗",
"再摸的话我可要报警了!⌇●﹏●⌇",
"110吗,这里有个变态一直在摸我(ó﹏ò。)"
]
}
],
"seasons": [
{ "date": "01/01", "text": ["<span style=\"color:#0099cc;\">元旦</span>了呢,新的一年又开始了,今年是{year}年~"] },
{ "date": "02/14", "text": ["又是一年<span style=\"color:#0099cc;\">情人节</span>,{year}年找到对象了嘛~"] },
{ "date": "03/08", "text": ["今天是<span style=\"color:#0099cc;\">妇女节</span>"] },
{ "date": "03/12", "text": ["今天是<span style=\"color:#0099cc;\">植树节</span>,要保护环境呀"] },
{ "date": "04/01", "text": ["悄悄告诉你一个秘密~<span style=\"background-color:#34495e;\">今天是愚人节,不要被骗了哦~</span>"] },
{ "date": "05/01", "text": ["今天是<span style=\"color:#0099cc;\">五一劳动节</span>,计划好假期去哪里了吗~"] },
{ "date": "06/01", "text": ["<span style=\"color:#0099cc;\">儿童节</span>了呢,快活的时光总是短暂,要是永远长不大该多好啊…"] },
{ "date": "09/03", "text": ["<span style=\"color:#0099cc;\">中国人民抗日战争胜利纪念日</span>,铭记历史、缅怀先烈、珍爱和平、开创未来。"] },
{ "date": "09/10", "text": ["<span style=\"color:#0099cc;\">教师节</span>,在学校要给老师问声好呀~"] },
{ "date": "10/01", "text": ["<span style=\"color:#0099cc;\">国庆节</span>,新中国已经成立69年了呢"] },
{ "date": "11/05-11/12", "text": ["今年的<span style=\"color:#0099cc;\">双十一</span>是和谁一起过的呢~"] },
{ "date": "12/20-12/31", "text": ["这几天是<span style=\"color:#0099cc;\">圣诞节</span>,主人肯定又去剁手买买买了~"] }
]
}

290
docs/waifu_plugin/waifu.css 普通文件
查看文件

@@ -0,0 +1,290 @@
.waifu {
position: fixed;
bottom: 0;
z-index: 1;
font-size: 0;
-webkit-transform: translateY(3px);
transform: translateY(3px);
}
.waifu:hover {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.waifu-tips {
opacity: 0;
margin: -20px 20px;
padding: 5px 10px;
border: 1px solid rgba(224, 186, 140, 0.62);
border-radius: 12px;
background-color: rgba(236, 217, 188, 0.5);
box-shadow: 0 3px 15px 2px rgba(191, 158, 118, 0.2);
text-overflow: ellipsis;
overflow: hidden;
position: absolute;
animation-delay: 5s;
animation-duration: 50s;
animation-iteration-count: infinite;
animation-name: shake;
animation-timing-function: ease-in-out;
}
.waifu-tool {
display: none;
color: #aaa;
top: 50px;
right: 10px;
position: absolute;
}
.waifu:hover .waifu-tool {
display: block;
}
.waifu-tool span {
display: block;
cursor: pointer;
color: #5b6c7d;
transition: 0.2s;
}
.waifu-tool span:hover {
color: #34495e;
}
.waifu #live2d{
position: relative;
}
@keyframes shake {
2% {
transform: translate(0.5px, -1.5px) rotate(-0.5deg);
}
4% {
transform: translate(0.5px, 1.5px) rotate(1.5deg);
}
6% {
transform: translate(1.5px, 1.5px) rotate(1.5deg);
}
8% {
transform: translate(2.5px, 1.5px) rotate(0.5deg);
}
10% {
transform: translate(0.5px, 2.5px) rotate(0.5deg);
}
12% {
transform: translate(1.5px, 1.5px) rotate(0.5deg);
}
14% {
transform: translate(0.5px, 0.5px) rotate(0.5deg);
}
16% {
transform: translate(-1.5px, -0.5px) rotate(1.5deg);
}
18% {
transform: translate(0.5px, 0.5px) rotate(1.5deg);
}
20% {
transform: translate(2.5px, 2.5px) rotate(1.5deg);
}
22% {
transform: translate(0.5px, -1.5px) rotate(1.5deg);
}
24% {
transform: translate(-1.5px, 1.5px) rotate(-0.5deg);
}
26% {
transform: translate(1.5px, 0.5px) rotate(1.5deg);
}
28% {
transform: translate(-0.5px, -0.5px) rotate(-0.5deg);
}
30% {
transform: translate(1.5px, -0.5px) rotate(-0.5deg);
}
32% {
transform: translate(2.5px, -1.5px) rotate(1.5deg);
}
34% {
transform: translate(2.5px, 2.5px) rotate(-0.5deg);
}
36% {
transform: translate(0.5px, -1.5px) rotate(0.5deg);
}
38% {
transform: translate(2.5px, -0.5px) rotate(-0.5deg);
}
40% {
transform: translate(-0.5px, 2.5px) rotate(0.5deg);
}
42% {
transform: translate(-1.5px, 2.5px) rotate(0.5deg);
}
44% {
transform: translate(-1.5px, 1.5px) rotate(0.5deg);
}
46% {
transform: translate(1.5px, -0.5px) rotate(-0.5deg);
}
48% {
transform: translate(2.5px, -0.5px) rotate(0.5deg);
}
50% {
transform: translate(-1.5px, 1.5px) rotate(0.5deg);
}
52% {
transform: translate(-0.5px, 1.5px) rotate(0.5deg);
}
54% {
transform: translate(-1.5px, 1.5px) rotate(0.5deg);
}
56% {
transform: translate(0.5px, 2.5px) rotate(1.5deg);
}
58% {
transform: translate(2.5px, 2.5px) rotate(0.5deg);
}
60% {
transform: translate(2.5px, -1.5px) rotate(1.5deg);
}
62% {
transform: translate(-1.5px, 0.5px) rotate(1.5deg);
}
64% {
transform: translate(-1.5px, 1.5px) rotate(1.5deg);
}
66% {
transform: translate(0.5px, 2.5px) rotate(1.5deg);
}
68% {
transform: translate(2.5px, -1.5px) rotate(1.5deg);
}
70% {
transform: translate(2.5px, 2.5px) rotate(0.5deg);
}
72% {
transform: translate(-0.5px, -1.5px) rotate(1.5deg);
}
74% {
transform: translate(-1.5px, 2.5px) rotate(1.5deg);
}
76% {
transform: translate(-1.5px, 2.5px) rotate(1.5deg);
}
78% {
transform: translate(-1.5px, 2.5px) rotate(0.5deg);
}
80% {
transform: translate(-1.5px, 0.5px) rotate(-0.5deg);
}
82% {
transform: translate(-1.5px, 0.5px) rotate(-0.5deg);
}
84% {
transform: translate(-0.5px, 0.5px) rotate(1.5deg);
}
86% {
transform: translate(2.5px, 1.5px) rotate(0.5deg);
}
88% {
transform: translate(-1.5px, 0.5px) rotate(1.5deg);
}
90% {
transform: translate(-1.5px, -0.5px) rotate(-0.5deg);
}
92% {
transform: translate(-1.5px, -1.5px) rotate(1.5deg);
}
94% {
transform: translate(0.5px, 0.5px) rotate(-0.5deg);
}
96% {
transform: translate(2.5px, -0.5px) rotate(-0.5deg);
}
98% {
transform: translate(-1.5px, -1.5px) rotate(-0.5deg);
}
0%, 100% {
transform: translate(0, 0) rotate(0);
}
}
@font-face {
font-family: 'Flat-UI-Icons';
src: url('flat-ui-icons-regular.eot');
src: url('flat-ui-icons-regular.eot?#iefix') format('embedded-opentype'), url('flat-ui-icons-regular.woff') format('woff'), url('flat-ui-icons-regular.ttf') format('truetype'), url('flat-ui-icons-regular.svg#flat-ui-icons-regular') format('svg');
}
[class^="fui-"],
[class*="fui-"] {
font-family: 'Flat-UI-Icons';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.fui-cross:before {
content: "\e609";
}
.fui-info-circle:before {
content: "\e60f";
}
.fui-photo:before {
content: "\e62a";
}
.fui-eye:before {
content: "\e62c";
}
.fui-chat:before {
content: "\e62d";
}
.fui-home:before {
content: "\e62e";
}
.fui-user:before {
content: "\e631";
}

53
main.py
查看文件

@@ -45,7 +45,7 @@ def main():
gr_L1 = lambda: gr.Row().style() gr_L1 = lambda: gr.Row().style()
gr_L2 = lambda scale: gr.Column(scale=scale) gr_L2 = lambda scale: gr.Column(scale=scale)
if LAYOUT == "TOP-DOWN": if LAYOUT == "TOP-DOWN":
gr_L1 = lambda: DummyWith() gr_L1 = lambda: DummyWith()
gr_L2 = lambda scale: gr.Row() gr_L2 = lambda scale: gr.Row()
CHATBOT_HEIGHT /= 2 CHATBOT_HEIGHT /= 2
@@ -56,7 +56,7 @@ def main():
cookies = gr.State({'api_key': API_KEY, 'llm_model': LLM_MODEL}) cookies = gr.State({'api_key': API_KEY, 'llm_model': LLM_MODEL})
with gr_L1(): with gr_L1():
with gr_L2(scale=2): with gr_L2(scale=2):
chatbot = gr.Chatbot() chatbot = gr.Chatbot(label=f"当前模型:{LLM_MODEL}")
chatbot.style(height=CHATBOT_HEIGHT) chatbot.style(height=CHATBOT_HEIGHT)
history = gr.State([]) history = gr.State([])
with gr_L2(scale=1): with gr_L2(scale=1):
@@ -88,9 +88,12 @@ def main():
with gr.Row(): with gr.Row():
with gr.Accordion("更多函数插件", open=True): with gr.Accordion("更多函数插件", open=True):
dropdown_fn_list = [k for k in crazy_fns.keys() if not crazy_fns[k].get("AsButton", True)] dropdown_fn_list = [k for k in crazy_fns.keys() if not crazy_fns[k].get("AsButton", True)]
with gr.Column(scale=1): with gr.Row():
dropdown = gr.Dropdown(dropdown_fn_list, value=r"打开插件列表", label="").style(container=False) dropdown = gr.Dropdown(dropdown_fn_list, value=r"打开插件列表", label="").style(container=False)
with gr.Column(scale=1): with gr.Row():
plugin_advanced_arg = gr.Textbox(show_label=True, label="高级参数输入区", visible=False,
placeholder="这里是特殊函数插件的高级参数输入区").style(container=False)
with gr.Row():
switchy_bt = gr.Button(r"请先从插件列表中选择", variant="secondary") switchy_bt = gr.Button(r"请先从插件列表中选择", variant="secondary")
with gr.Row(): with gr.Row():
with gr.Accordion("点击展开“文件上传区”。上传本地文件可供红色函数插件调用。", open=False) as area_file_up: with gr.Accordion("点击展开“文件上传区”。上传本地文件可供红色函数插件调用。", open=False) as area_file_up:
@@ -100,7 +103,7 @@ def main():
top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.01,interactive=True, label="Top-p (nucleus sampling)",) top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.01,interactive=True, label="Top-p (nucleus sampling)",)
temperature = gr.Slider(minimum=-0, maximum=2.0, value=1.0, step=0.01, interactive=True, label="Temperature",) temperature = gr.Slider(minimum=-0, maximum=2.0, value=1.0, step=0.01, interactive=True, label="Temperature",)
max_length_sl = gr.Slider(minimum=256, maximum=4096, value=512, step=1, interactive=True, label="Local LLM MaxLength",) max_length_sl = gr.Slider(minimum=256, maximum=4096, value=512, step=1, interactive=True, label="Local LLM MaxLength",)
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区", "底部输入区", "输入清除键"], value=["基础功能区", "函数插件区"], label="显示/隐藏功能区") checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区", "底部输入区", "输入清除键", "插件参数区"], value=["基础功能区", "函数插件区"], label="显示/隐藏功能区")
md_dropdown = gr.Dropdown(AVAIL_LLM_MODELS, value=LLM_MODEL, label="更换LLM模型/请求源").style(container=False) md_dropdown = gr.Dropdown(AVAIL_LLM_MODELS, value=LLM_MODEL, label="更换LLM模型/请求源").style(container=False)
gr.Markdown(description) gr.Markdown(description)
@@ -112,7 +115,7 @@ def main():
with gr.Row(): with gr.Row():
resetBtn2 = gr.Button("重置", variant="secondary"); resetBtn2.style(size="sm") resetBtn2 = gr.Button("重置", variant="secondary"); resetBtn2.style(size="sm")
stopBtn2 = gr.Button("停止", variant="secondary"); stopBtn2.style(size="sm") stopBtn2 = gr.Button("停止", variant="secondary"); stopBtn2.style(size="sm")
clearBtn2 = gr.Button("清除", variant="secondary", visible=False); clearBtn.style(size="sm") clearBtn2 = gr.Button("清除", variant="secondary", visible=False); clearBtn2.style(size="sm")
# 功能区显示开关与功能区的互动 # 功能区显示开关与功能区的互动
def fn_area_visibility(a): def fn_area_visibility(a):
ret = {} ret = {}
@@ -122,11 +125,12 @@ def main():
ret.update({area_input_secondary: gr.update(visible=("底部输入区" in a))}) ret.update({area_input_secondary: gr.update(visible=("底部输入区" in a))})
ret.update({clearBtn: gr.update(visible=("输入清除键" in a))}) ret.update({clearBtn: gr.update(visible=("输入清除键" in a))})
ret.update({clearBtn2: gr.update(visible=("输入清除键" in a))}) ret.update({clearBtn2: gr.update(visible=("输入清除键" in a))})
ret.update({plugin_advanced_arg: gr.update(visible=("插件参数区" in a))})
if "底部输入区" in a: ret.update({txt: gr.update(value="")}) if "底部输入区" in a: ret.update({txt: gr.update(value="")})
return ret return ret
checkboxes.select(fn_area_visibility, [checkboxes], [area_basic_fn, area_crazy_fn, area_input_primary, area_input_secondary, txt, txt2, clearBtn, clearBtn2] ) checkboxes.select(fn_area_visibility, [checkboxes], [area_basic_fn, area_crazy_fn, area_input_primary, area_input_secondary, txt, txt2, clearBtn, clearBtn2, plugin_advanced_arg] )
# 整理反复出现的控件句柄组合 # 整理反复出现的控件句柄组合
input_combo = [cookies, max_length_sl, md_dropdown, txt, txt2, top_p, temperature, chatbot, history, system_prompt] input_combo = [cookies, max_length_sl, md_dropdown, txt, txt2, top_p, temperature, chatbot, history, system_prompt, plugin_advanced_arg]
output_combo = [cookies, chatbot, history, status] output_combo = [cookies, chatbot, history, status]
predict_args = dict(fn=ArgsGeneralWrapper(predict), inputs=input_combo, outputs=output_combo) predict_args = dict(fn=ArgsGeneralWrapper(predict), inputs=input_combo, outputs=output_combo)
# 提交按钮、重置按钮 # 提交按钮、重置按钮
@@ -153,17 +157,22 @@ def main():
# 函数插件-下拉菜单与随变按钮的互动 # 函数插件-下拉菜单与随变按钮的互动
def on_dropdown_changed(k): def on_dropdown_changed(k):
variant = crazy_fns[k]["Color"] if "Color" in crazy_fns[k] else "secondary" variant = crazy_fns[k]["Color"] if "Color" in crazy_fns[k] else "secondary"
return {switchy_bt: gr.update(value=k, variant=variant)} ret = {switchy_bt: gr.update(value=k, variant=variant)}
dropdown.select(on_dropdown_changed, [dropdown], [switchy_bt] ) if crazy_fns[k].get("AdvancedArgs", False): # 是否唤起高级插件参数区
ret.update({plugin_advanced_arg: gr.update(visible=True, label=f"插件[{k}]的高级参数说明:" + crazy_fns[k].get("ArgsReminder", [f"没有提供高级参数功能说明"]))})
else:
ret.update({plugin_advanced_arg: gr.update(visible=False, label=f"插件[{k}]不需要高级参数。")})
return ret
dropdown.select(on_dropdown_changed, [dropdown], [switchy_bt, plugin_advanced_arg] )
def on_md_dropdown_changed(k):
return {chatbot: gr.update(label="当前模型:"+k)}
md_dropdown.select(on_md_dropdown_changed, [md_dropdown], [chatbot] )
# 随变按钮的回调函数注册 # 随变按钮的回调函数注册
def route(k, *args, **kwargs): def route(k, *args, **kwargs):
if k in [r"打开插件列表", r"请先从插件列表中选择"]: return if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
yield from ArgsGeneralWrapper(crazy_fns[k]["Function"])(*args, **kwargs) yield from ArgsGeneralWrapper(crazy_fns[k]["Function"])(*args, **kwargs)
click_handle = switchy_bt.click(route,[switchy_bt, *input_combo, gr.State(PORT)], output_combo) click_handle = switchy_bt.click(route,[switchy_bt, *input_combo, gr.State(PORT)], output_combo)
click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot]) click_handle.then(on_report_generated, [file_upload, chatbot], [file_upload, chatbot])
# def expand_file_area(file_upload, area_file_up):
# if len(file_upload)>0: return {area_file_up: gr.update(open=True)}
# click_handle.then(expand_file_area, [file_upload, area_file_up], [area_file_up])
cancel_handles.append(click_handle) cancel_handles.append(click_handle)
# 终止按钮的回调函数注册 # 终止按钮的回调函数注册
stopBtn.click(fn=None, inputs=None, outputs=None, cancels=cancel_handles) stopBtn.click(fn=None, inputs=None, outputs=None, cancels=cancel_handles)
@@ -175,9 +184,11 @@ def main():
print(f"如果浏览器没有自动打开,请复制并转到以下URL") print(f"如果浏览器没有自动打开,请复制并转到以下URL")
print(f"\t(亮色主题): http://localhost:{PORT}") print(f"\t(亮色主题): http://localhost:{PORT}")
print(f"\t(暗色主题): http://localhost:{PORT}/?__dark-theme=true") print(f"\t(暗色主题): http://localhost:{PORT}/?__dark-theme=true")
def open(): def open():
time.sleep(2) # 打开浏览器 time.sleep(2) # 打开浏览器
webbrowser.open_new_tab(f"http://localhost:{PORT}/?__dark-theme=true") DARK_MODE, = get_conf('DARK_MODE')
if DARK_MODE: webbrowser.open_new_tab(f"http://localhost:{PORT}/?__dark-theme=true")
else: webbrowser.open_new_tab(f"http://localhost:{PORT}")
threading.Thread(target=open, name="open-browser", daemon=True).start() threading.Thread(target=open, name="open-browser", daemon=True).start()
threading.Thread(target=auto_update, name="self-upgrade", daemon=True).start() threading.Thread(target=auto_update, name="self-upgrade", daemon=True).start()
threading.Thread(target=warm_up_modules, name="warm-up", daemon=True).start() threading.Thread(target=warm_up_modules, name="warm-up", daemon=True).start()
@@ -185,5 +196,13 @@ def main():
auto_opentab_delay() auto_opentab_delay()
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png") demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png")
# 如果需要在二级路径下运行
# CUSTOM_PATH, = get_conf('CUSTOM_PATH')
# if CUSTOM_PATH != "/":
# from toolbox import run_gradio_in_subpath
# run_gradio_in_subpath(demo, auth=AUTHENTICATION, port=PORT, custom_path=CUSTOM_PATH)
# else:
# demo.launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png")
if __name__ == "__main__": if __name__ == "__main__":
main() main()

查看文件

@@ -1,4 +1,4 @@
# 如何使用其他大语言模型v3.0分支测试中) # 如何使用其他大语言模型
## ChatGLM ## ChatGLM
@@ -15,7 +15,7 @@ LLM_MODEL = "chatglm"
--- ---
## Text-Generation-UI (TGUI) ## Text-Generation-UI (TGUI,调试中,暂不可用)
### 1. 部署TGUI ### 1. 部署TGUI
``` sh ``` sh

查看文件

@@ -1,16 +1,17 @@
""" """
该文件中主要包含2个函数 该文件中主要包含2个函数,是所有LLM的通用接口,它们会继续向下调用更底层的LLM模型,处理多模型并行等细节
不具备多线程能力的函数: 不具备多线程能力的函数:正常对话时使用,具备完备的交互功能,不可多线程
1. predict: 正常对话时使用,具备完备的交互功能,不可多线程 1. predict(...)
具备多线程调用能力的函数 具备多线程调用能力的函数:在函数插件中被调用,灵活而简洁
2. predict_no_ui_long_connection在实验过程中发现调用predict_no_ui处理长文档时,和openai的连接容易断掉,这个函数用stream的方式解决这个问题,同样支持多线程 2. predict_no_ui_long_connection(...)
""" """
import tiktoken import tiktoken
from functools import wraps, lru_cache from functools import lru_cache
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from toolbox import get_conf, trimmed_format_exc
from .bridge_chatgpt import predict_no_ui_long_connection as chatgpt_noui from .bridge_chatgpt import predict_no_ui_long_connection as chatgpt_noui
from .bridge_chatgpt import predict as chatgpt_ui from .bridge_chatgpt import predict as chatgpt_ui
@@ -18,6 +19,9 @@ from .bridge_chatgpt import predict as chatgpt_ui
from .bridge_chatglm import predict_no_ui_long_connection as chatglm_noui from .bridge_chatglm import predict_no_ui_long_connection as chatglm_noui
from .bridge_chatglm import predict as chatglm_ui from .bridge_chatglm import predict as chatglm_ui
from .bridge_newbing import predict_no_ui_long_connection as newbing_noui
from .bridge_newbing import predict as newbing_ui
# from .bridge_tgui import predict_no_ui_long_connection as tgui_noui # from .bridge_tgui import predict_no_ui_long_connection as tgui_noui
# from .bridge_tgui import predict as tgui_ui # from .bridge_tgui import predict as tgui_ui
@@ -42,18 +46,39 @@ class LazyloadTiktoken(object):
def decode(self, *args, **kwargs): def decode(self, *args, **kwargs):
encoder = self.get_encoder(self.model) encoder = self.get_encoder(self.model)
return encoder.decode(*args, **kwargs) return encoder.decode(*args, **kwargs)
# Endpoint 重定向
API_URL_REDIRECT, = get_conf("API_URL_REDIRECT")
openai_endpoint = "https://api.openai.com/v1/chat/completions"
api2d_endpoint = "https://openai.api2d.net/v1/chat/completions"
newbing_endpoint = "wss://sydney.bing.com/sydney/ChatHub"
# 兼容旧版的配置
try:
API_URL, = get_conf("API_URL")
if API_URL != "https://api.openai.com/v1/chat/completions":
openai_endpoint = API_URL
print("警告API_URL配置选项将被弃用,请更换为API_URL_REDIRECT配置")
except:
pass
# 新版配置
if openai_endpoint in API_URL_REDIRECT: openai_endpoint = API_URL_REDIRECT[openai_endpoint]
if api2d_endpoint in API_URL_REDIRECT: api2d_endpoint = API_URL_REDIRECT[api2d_endpoint]
if newbing_endpoint in API_URL_REDIRECT: newbing_endpoint = API_URL_REDIRECT[newbing_endpoint]
# 获取tokenizer
tokenizer_gpt35 = LazyloadTiktoken("gpt-3.5-turbo") tokenizer_gpt35 = LazyloadTiktoken("gpt-3.5-turbo")
tokenizer_gpt4 = LazyloadTiktoken("gpt-4") tokenizer_gpt4 = LazyloadTiktoken("gpt-4")
get_token_num_gpt35 = lambda txt: len(tokenizer_gpt35.encode(txt, disallowed_special=())) get_token_num_gpt35 = lambda txt: len(tokenizer_gpt35.encode(txt, disallowed_special=()))
get_token_num_gpt4 = lambda txt: len(tokenizer_gpt4.encode(txt, disallowed_special=())) get_token_num_gpt4 = lambda txt: len(tokenizer_gpt4.encode(txt, disallowed_special=()))
model_info = { model_info = {
# openai # openai
"gpt-3.5-turbo": { "gpt-3.5-turbo": {
"fn_with_ui": chatgpt_ui, "fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui, "fn_without_ui": chatgpt_noui,
"endpoint": "https://api.openai.com/v1/chat/completions", "endpoint": openai_endpoint,
"max_token": 4096, "max_token": 4096,
"tokenizer": tokenizer_gpt35, "tokenizer": tokenizer_gpt35,
"token_cnt": get_token_num_gpt35, "token_cnt": get_token_num_gpt35,
@@ -62,7 +87,7 @@ model_info = {
"gpt-4": { "gpt-4": {
"fn_with_ui": chatgpt_ui, "fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui, "fn_without_ui": chatgpt_noui,
"endpoint": "https://api.openai.com/v1/chat/completions", "endpoint": openai_endpoint,
"max_token": 8192, "max_token": 8192,
"tokenizer": tokenizer_gpt4, "tokenizer": tokenizer_gpt4,
"token_cnt": get_token_num_gpt4, "token_cnt": get_token_num_gpt4,
@@ -72,7 +97,7 @@ model_info = {
"api2d-gpt-3.5-turbo": { "api2d-gpt-3.5-turbo": {
"fn_with_ui": chatgpt_ui, "fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui, "fn_without_ui": chatgpt_noui,
"endpoint": "https://openai.api2d.net/v1/chat/completions", "endpoint": api2d_endpoint,
"max_token": 4096, "max_token": 4096,
"tokenizer": tokenizer_gpt35, "tokenizer": tokenizer_gpt35,
"token_cnt": get_token_num_gpt35, "token_cnt": get_token_num_gpt35,
@@ -81,7 +106,7 @@ model_info = {
"api2d-gpt-4": { "api2d-gpt-4": {
"fn_with_ui": chatgpt_ui, "fn_with_ui": chatgpt_ui,
"fn_without_ui": chatgpt_noui, "fn_without_ui": chatgpt_noui,
"endpoint": "https://openai.api2d.net/v1/chat/completions", "endpoint": api2d_endpoint,
"max_token": 8192, "max_token": 8192,
"tokenizer": tokenizer_gpt4, "tokenizer": tokenizer_gpt4,
"token_cnt": get_token_num_gpt4, "token_cnt": get_token_num_gpt4,
@@ -96,7 +121,15 @@ model_info = {
"tokenizer": tokenizer_gpt35, "tokenizer": tokenizer_gpt35,
"token_cnt": get_token_num_gpt35, "token_cnt": get_token_num_gpt35,
}, },
# newbing
"newbing": {
"fn_with_ui": newbing_ui,
"fn_without_ui": newbing_noui,
"endpoint": newbing_endpoint,
"max_token": 4096,
"tokenizer": tokenizer_gpt35,
"token_cnt": get_token_num_gpt35,
},
} }
@@ -108,10 +141,7 @@ def LLM_CATCH_EXCEPTION(f):
try: try:
return f(inputs, llm_kwargs, history, sys_prompt, observe_window, console_slience) return f(inputs, llm_kwargs, history, sys_prompt, observe_window, console_slience)
except Exception as e: except Exception as e:
from toolbox import get_conf tb_str = '\n```\n' + trimmed_format_exc() + '\n```\n'
import traceback
proxies, = get_conf('proxies')
tb_str = '\n```\n' + traceback.format_exc() + '\n```\n'
observe_window[0] = tb_str observe_window[0] = tb_str
return tb_str return tb_str
return decorated return decorated
@@ -162,7 +192,7 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history, sys_prompt, obser
def mutex_manager(window_mutex, observe_window): def mutex_manager(window_mutex, observe_window):
while True: while True:
time.sleep(0.5) time.sleep(0.25)
if not window_mutex[-1]: break if not window_mutex[-1]: break
# 看门狗watchdog # 看门狗watchdog
for i in range(n_model): for i in range(n_model):
@@ -190,7 +220,7 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history, sys_prompt, obser
return_string_collect.append( f"{str(models[i])} 说】: <font color=\"{colors[i]}\"> {future.result()} </font>" ) return_string_collect.append( f"{str(models[i])} 说】: <font color=\"{colors[i]}\"> {future.result()} </font>" )
window_mutex[-1] = False # stop mutex thread window_mutex[-1] = False # stop mutex thread
res = '<br/>\n\n---\n\n'.join(return_string_collect) res = '<br/><br/>\n\n---\n\n'.join(return_string_collect)
return res return res

查看文件

@@ -1,6 +1,7 @@
from transformers import AutoModel, AutoTokenizer from transformers import AutoModel, AutoTokenizer
import time import time
import threading
import importlib import importlib
from toolbox import update_ui, get_conf from toolbox import update_ui, get_conf
from multiprocessing import Process, Pipe from multiprocessing import Process, Pipe
@@ -18,6 +19,7 @@ class GetGLMHandle(Process):
self.success = True self.success = True
self.check_dependency() self.check_dependency()
self.start() self.start()
self.threadLock = threading.Lock()
def check_dependency(self): def check_dependency(self):
try: try:
@@ -32,6 +34,7 @@ class GetGLMHandle(Process):
return self.chatglm_model is not None return self.chatglm_model is not None
def run(self): def run(self):
# 子进程执行
# 第一次运行,加载参数 # 第一次运行,加载参数
retry = 0 retry = 0
while True: while True:
@@ -53,17 +56,25 @@ class GetGLMHandle(Process):
self.child.send('[Local Message] Call ChatGLM fail 不能正常加载ChatGLM的参数。') self.child.send('[Local Message] Call ChatGLM fail 不能正常加载ChatGLM的参数。')
raise RuntimeError("不能正常加载ChatGLM的参数") raise RuntimeError("不能正常加载ChatGLM的参数")
# 进入任务等待状态
while True: while True:
# 进入任务等待状态
kwargs = self.child.recv() kwargs = self.child.recv()
# 收到消息,开始请求
try: try:
for response, history in self.chatglm_model.stream_chat(self.chatglm_tokenizer, **kwargs): for response, history in self.chatglm_model.stream_chat(self.chatglm_tokenizer, **kwargs):
self.child.send(response) self.child.send(response)
# # 中途接收可能的终止指令(如果有的话)
# if self.child.poll():
# command = self.child.recv()
# if command == '[Terminate]': break
except: except:
self.child.send('[Local Message] Call ChatGLM fail.') self.child.send('[Local Message] Call ChatGLM fail.')
# 请求处理结束,开始下一个循环
self.child.send('[Finish]') self.child.send('[Finish]')
def stream_chat(self, **kwargs): def stream_chat(self, **kwargs):
# 主进程执行
self.threadLock.acquire()
self.parent.send(kwargs) self.parent.send(kwargs)
while True: while True:
res = self.parent.recv() res = self.parent.recv()
@@ -71,7 +82,7 @@ class GetGLMHandle(Process):
yield res yield res
else: else:
break break
return self.threadLock.release()
global glm_handle global glm_handle
glm_handle = None glm_handle = None
@@ -92,8 +103,8 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history=[], sys_prompt="",
# chatglm 没有 sys_prompt 接口,因此把prompt加入 history # chatglm 没有 sys_prompt 接口,因此把prompt加入 history
history_feedin = [] history_feedin = []
history_feedin.append(["What can I do?", sys_prompt])
for i in range(len(history)//2): for i in range(len(history)//2):
history_feedin.append(["What can I do?", sys_prompt] )
history_feedin.append([history[2*i], history[2*i+1]] ) history_feedin.append([history[2*i], history[2*i+1]] )
watch_dog_patience = 5 # 看门狗 (watchdog) 的耐心, 设置5秒即可 watch_dog_patience = 5 # 看门狗 (watchdog) 的耐心, 设置5秒即可
@@ -130,11 +141,20 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
if "PreProcess" in core_functional[additional_fn]: inputs = core_functional[additional_fn]["PreProcess"](inputs) # 获取预处理函数(如果有的话) if "PreProcess" in core_functional[additional_fn]: inputs = core_functional[additional_fn]["PreProcess"](inputs) # 获取预处理函数(如果有的话)
inputs = core_functional[additional_fn]["Prefix"] + inputs + core_functional[additional_fn]["Suffix"] inputs = core_functional[additional_fn]["Prefix"] + inputs + core_functional[additional_fn]["Suffix"]
# 处理历史信息
history_feedin = [] history_feedin = []
history_feedin.append(["What can I do?", system_prompt] )
for i in range(len(history)//2): for i in range(len(history)//2):
history_feedin.append(["What can I do?", system_prompt] )
history_feedin.append([history[2*i], history[2*i+1]] ) history_feedin.append([history[2*i], history[2*i+1]] )
# 开始接收chatglm的回复
response = "[Local Message]: 等待ChatGLM响应中 ..."
for response in glm_handle.stream_chat(query=inputs, history=history_feedin, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']): for response in glm_handle.stream_chat(query=inputs, history=history_feedin, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
chatbot[-1] = (inputs, response) chatbot[-1] = (inputs, response)
yield from update_ui(chatbot=chatbot, history=history) yield from update_ui(chatbot=chatbot, history=history)
# 总结输出
if response == "[Local Message]: 等待ChatGLM响应中 ...":
response = "[Local Message]: ChatGLM响应异常 ..."
history.extend([inputs, response])
yield from update_ui(chatbot=chatbot, history=history)

查看文件

@@ -21,7 +21,7 @@ import importlib
# config_private.py放自己的秘密如API和代理网址 # config_private.py放自己的秘密如API和代理网址
# 读取时首先看是否存在私密的config_private配置文件不受git管控,如果有,则覆盖原config文件 # 读取时首先看是否存在私密的config_private配置文件不受git管控,如果有,则覆盖原config文件
from toolbox import get_conf, update_ui, is_any_api_key, select_api_key from toolbox import get_conf, update_ui, is_any_api_key, select_api_key, what_keys, clip_history, trimmed_format_exc
proxies, API_KEY, TIMEOUT_SECONDS, MAX_RETRY = \ proxies, API_KEY, TIMEOUT_SECONDS, MAX_RETRY = \
get_conf('proxies', 'API_KEY', 'TIMEOUT_SECONDS', 'MAX_RETRY') get_conf('proxies', 'API_KEY', 'TIMEOUT_SECONDS', 'MAX_RETRY')
@@ -118,7 +118,7 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
""" """
if is_any_api_key(inputs): if is_any_api_key(inputs):
chatbot._cookies['api_key'] = inputs chatbot._cookies['api_key'] = inputs
chatbot.append(("输入已识别为openai的api_key", "api_key已导入")) chatbot.append(("输入已识别为openai的api_key", what_keys(inputs)))
yield from update_ui(chatbot=chatbot, history=history, msg="api_key已导入") # 刷新界面 yield from update_ui(chatbot=chatbot, history=history, msg="api_key已导入") # 刷新界面
return return
elif not is_any_api_key(chatbot._cookies['api_key']): elif not is_any_api_key(chatbot._cookies['api_key']):
@@ -141,11 +141,11 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
try: try:
headers, payload = generate_payload(inputs, llm_kwargs, history, system_prompt, stream) headers, payload = generate_payload(inputs, llm_kwargs, history, system_prompt, stream)
except RuntimeError as e: except RuntimeError as e:
chatbot[-1] = (inputs, f"您提供的api-key不满足要求,不包含任何可用于{llm_kwargs['llm_model']}的api-key。") chatbot[-1] = (inputs, f"您提供的api-key不满足要求,不包含任何可用于{llm_kwargs['llm_model']}的api-key。您可能选择了错误的模型或请求源。")
yield from update_ui(chatbot=chatbot, history=history, msg="api-key不满足要求") # 刷新界面 yield from update_ui(chatbot=chatbot, history=history, msg="api-key不满足要求") # 刷新界面
return return
history.append(inputs); history.append(" ") history.append(inputs); history.append("")
retry = 0 retry = 0
while True: while True:
@@ -198,19 +198,24 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
chunk_decoded = chunk.decode() chunk_decoded = chunk.decode()
error_msg = chunk_decoded error_msg = chunk_decoded
if "reduce the length" in error_msg: if "reduce the length" in error_msg:
chatbot[-1] = (chatbot[-1][0], "[Local Message] Reduce the length. 本次输入过长,或历史数据过长. 历史缓存数据现已释放,您可以请再次尝试.") if len(history) >= 2: history[-1] = ""; history[-2] = "" # 清除当前溢出的输入history[-2] 是本次输入, history[-1] 是本次输出
history = [] # 清除历史 history = clip_history(inputs=inputs, history=history, tokenizer=model_info[llm_kwargs['llm_model']]['tokenizer'],
max_token_limit=(model_info[llm_kwargs['llm_model']]['max_token'])) # history至少释放二分之一
chatbot[-1] = (chatbot[-1][0], "[Local Message] Reduce the length. 本次输入过长, 或历史数据过长. 历史缓存数据已部分释放, 您可以请再次尝试. (若再次失败则更可能是因为输入过长.)")
# history = [] # 清除历史
elif "does not exist" in error_msg: elif "does not exist" in error_msg:
chatbot[-1] = (chatbot[-1][0], f"[Local Message] Model {llm_kwargs['llm_model']} does not exist. 模型不存在或者您没有获得体验资格.") chatbot[-1] = (chatbot[-1][0], f"[Local Message] Model {llm_kwargs['llm_model']} does not exist. 模型不存在, 或者您没有获得体验资格.")
elif "Incorrect API key" in error_msg: elif "Incorrect API key" in error_msg:
chatbot[-1] = (chatbot[-1][0], "[Local Message] Incorrect API key. OpenAI以提供了不正确的API_KEY为由拒绝服务.") chatbot[-1] = (chatbot[-1][0], "[Local Message] Incorrect API key. OpenAI以提供了不正确的API_KEY为由, 拒绝服务.")
elif "exceeded your current quota" in error_msg: elif "exceeded your current quota" in error_msg:
chatbot[-1] = (chatbot[-1][0], "[Local Message] You exceeded your current quota. OpenAI以账户额度不足为由拒绝服务.") chatbot[-1] = (chatbot[-1][0], "[Local Message] You exceeded your current quota. OpenAI以账户额度不足为由, 拒绝服务.")
elif "bad forward key" in error_msg: elif "bad forward key" in error_msg:
chatbot[-1] = (chatbot[-1][0], "[Local Message] Bad forward key. API2D账户额度不足.") chatbot[-1] = (chatbot[-1][0], "[Local Message] Bad forward key. API2D账户额度不足.")
elif "Not enough point" in error_msg:
chatbot[-1] = (chatbot[-1][0], "[Local Message] Not enough point. API2D账户点数不足.")
else: else:
from toolbox import regular_txt_to_markdown from toolbox import regular_txt_to_markdown
tb_str = '```\n' + traceback.format_exc() + '```' tb_str = '```\n' + trimmed_format_exc() + '```'
chatbot[-1] = (chatbot[-1][0], f"[Local Message] 异常 \n\n{tb_str} \n\n{regular_txt_to_markdown(chunk_decoded[4:])}") chatbot[-1] = (chatbot[-1][0], f"[Local Message] 异常 \n\n{tb_str} \n\n{regular_txt_to_markdown(chunk_decoded[4:])}")
yield from update_ui(chatbot=chatbot, history=history, msg="Json异常" + error_msg) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history, msg="Json异常" + error_msg) # 刷新界面
return return

查看文件

@@ -0,0 +1,153 @@
from transformers import AutoModel, AutoTokenizer
import time
import threading
import importlib
from toolbox import update_ui, get_conf
from multiprocessing import Process, Pipe
load_message = "jittorllms尚未加载,加载需要一段时间。注意,取决于`config.py`的配置,jittorllms消耗大量的内存CPU或显存GPU,也许会导致低配计算机卡死 ……"
#################################################################################
class GetGLMHandle(Process):
def __init__(self):
super().__init__(daemon=True)
self.parent, self.child = Pipe()
self.jittorllms_model = None
self.info = ""
self.success = True
self.check_dependency()
self.start()
self.threadLock = threading.Lock()
def check_dependency(self):
try:
import jittor
from .jittorllms.models import get_model
self.info = "依赖检测通过"
self.success = True
except:
self.info = r"缺少jittorllms的依赖,如果要使用jittorllms,除了基础的pip依赖以外,您还需要运行`pip install -r request_llm/requirements_jittorllms.txt`"+\
r"和`git clone https://gitlink.org.cn/jittor/JittorLLMs.git --depth 1 request_llm/jittorllms`两个指令来安装jittorllms的依赖在项目根目录运行这两个指令"
self.success = False
def ready(self):
return self.jittorllms_model is not None
def run(self):
# 子进程执行
# 第一次运行,加载参数
def load_model():
import types
try:
if self.jittorllms_model is None:
device, = get_conf('LOCAL_MODEL_DEVICE')
from .jittorllms.models import get_model
# availabel_models = ["chatglm", "pangualpha", "llama", "chatrwkv"]
args_dict = {'model': 'chatglm', 'RUN_DEVICE':'cpu'}
self.jittorllms_model = get_model(types.SimpleNamespace(**args_dict))
except:
self.child.send('[Local Message] Call jittorllms fail 不能正常加载jittorllms的参数。')
raise RuntimeError("不能正常加载jittorllms的参数")
load_model()
# 进入任务等待状态
while True:
# 进入任务等待状态
kwargs = self.child.recv()
# 收到消息,开始请求
try:
for response, history in self.jittorllms_model.run_web_demo(kwargs['query'], kwargs['history']):
self.child.send(response)
except:
self.child.send('[Local Message] Call jittorllms fail.')
# 请求处理结束,开始下一个循环
self.child.send('[Finish]')
def stream_chat(self, **kwargs):
# 主进程执行
self.threadLock.acquire()
self.parent.send(kwargs)
while True:
res = self.parent.recv()
if res != '[Finish]':
yield res
else:
break
self.threadLock.release()
global glm_handle
glm_handle = None
#################################################################################
def predict_no_ui_long_connection(inputs, llm_kwargs, history=[], sys_prompt="", observe_window=[], console_slience=False):
"""
多线程方法
函数的说明请见 request_llm/bridge_all.py
"""
global glm_handle
if glm_handle is None:
glm_handle = GetGLMHandle()
if len(observe_window) >= 1: observe_window[0] = load_message + "\n\n" + glm_handle.info
if not glm_handle.success:
error = glm_handle.info
glm_handle = None
raise RuntimeError(error)
# jittorllms 没有 sys_prompt 接口,因此把prompt加入 history
history_feedin = []
history_feedin.append(["What can I do?", sys_prompt])
for i in range(len(history)//2):
history_feedin.append([history[2*i], history[2*i+1]] )
watch_dog_patience = 5 # 看门狗 (watchdog) 的耐心, 设置5秒即可
response = ""
for response in glm_handle.stream_chat(query=inputs, history=history_feedin, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
if len(observe_window) >= 1: observe_window[0] = response
if len(observe_window) >= 2:
if (time.time()-observe_window[1]) > watch_dog_patience:
raise RuntimeError("程序终止。")
return response
def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_prompt='', stream = True, additional_fn=None):
"""
单线程方法
函数的说明请见 request_llm/bridge_all.py
"""
chatbot.append((inputs, ""))
global glm_handle
if glm_handle is None:
glm_handle = GetGLMHandle()
chatbot[-1] = (inputs, load_message + "\n\n" + glm_handle.info)
yield from update_ui(chatbot=chatbot, history=[])
if not glm_handle.success:
glm_handle = None
return
if additional_fn is not None:
import core_functional
importlib.reload(core_functional) # 热更新prompt
core_functional = core_functional.get_core_functions()
if "PreProcess" in core_functional[additional_fn]: inputs = core_functional[additional_fn]["PreProcess"](inputs) # 获取预处理函数(如果有的话)
inputs = core_functional[additional_fn]["Prefix"] + inputs + core_functional[additional_fn]["Suffix"]
# 处理历史信息
history_feedin = []
history_feedin.append(["What can I do?", system_prompt] )
for i in range(len(history)//2):
history_feedin.append([history[2*i], history[2*i+1]] )
# 开始接收jittorllms的回复
response = "[Local Message]: 等待jittorllms响应中 ..."
for response in glm_handle.stream_chat(query=inputs, history=history_feedin, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
chatbot[-1] = (inputs, response)
yield from update_ui(chatbot=chatbot, history=history)
# 总结输出
if response == "[Local Message]: 等待jittorllms响应中 ...":
response = "[Local Message]: jittorllms响应异常 ..."
history.extend([inputs, response])
yield from update_ui(chatbot=chatbot, history=history)

查看文件

@@ -0,0 +1,254 @@
"""
========================================================================
第一部分来自EdgeGPT.py
https://github.com/acheong08/EdgeGPT
========================================================================
"""
from .edge_gpt import NewbingChatbot
load_message = "等待NewBing响应。"
"""
========================================================================
第二部分子进程Worker调用主体
========================================================================
"""
import time
import json
import re
import logging
import asyncio
import importlib
import threading
from toolbox import update_ui, get_conf, trimmed_format_exc
from multiprocessing import Process, Pipe
def preprocess_newbing_out(s):
pattern = r'\^(\d+)\^' # 匹配^数字^
sub = lambda m: '('+m.group(1)+')' # 将匹配到的数字作为替换值
result = re.sub(pattern, sub, s) # 替换操作
if '[1]' in result:
result += '\n\n```reference\n' + "\n".join([r for r in result.split('\n') if r.startswith('[')]) + '\n```\n'
return result
def preprocess_newbing_out_simple(result):
if '[1]' in result:
result += '\n\n```reference\n' + "\n".join([r for r in result.split('\n') if r.startswith('[')]) + '\n```\n'
return result
class NewBingHandle(Process):
def __init__(self):
super().__init__(daemon=True)
self.parent, self.child = Pipe()
self.newbing_model = None
self.info = ""
self.success = True
self.local_history = []
self.check_dependency()
self.start()
self.threadLock = threading.Lock()
def check_dependency(self):
try:
self.success = False
import certifi, httpx, rich
self.info = "依赖检测通过,等待NewBing响应。注意目前不能多人同时调用NewBing接口有线程锁,否则将导致每个人的NewBing问询历史互相渗透。调用NewBing时,会自动使用已配置的代理。"
self.success = True
except:
self.info = "缺少的依赖,如果要使用Newbing,除了基础的pip依赖以外,您还需要运行`pip install -r request_llm/requirements_newbing.txt`安装Newbing的依赖。"
self.success = False
def ready(self):
return self.newbing_model is not None
async def async_run(self):
# 读取配置
NEWBING_STYLE, = get_conf('NEWBING_STYLE')
from request_llm.bridge_all import model_info
endpoint = model_info['newbing']['endpoint']
while True:
# 等待
kwargs = self.child.recv()
question=kwargs['query']
history=kwargs['history']
system_prompt=kwargs['system_prompt']
# 是否重置
if len(self.local_history) > 0 and len(history)==0:
await self.newbing_model.reset()
self.local_history = []
# 开始问问题
prompt = ""
if system_prompt not in self.local_history:
self.local_history.append(system_prompt)
prompt += system_prompt + '\n'
# 追加历史
for ab in history:
a, b = ab
if a not in self.local_history:
self.local_history.append(a)
prompt += a + '\n'
# if b not in self.local_history:
# self.local_history.append(b)
# prompt += b + '\n'
# 问题
prompt += question
self.local_history.append(question)
print('question:', prompt)
# 提交
async for final, response in self.newbing_model.ask_stream(
prompt=question,
conversation_style=NEWBING_STYLE, # ["creative", "balanced", "precise"]
wss_link=endpoint, # "wss://sydney.bing.com/sydney/ChatHub"
):
if not final:
print(response)
self.child.send(str(response))
else:
print('-------- receive final ---------')
self.child.send('[Finish]')
# self.local_history.append(response)
def run(self):
"""
这个函数运行在子进程
"""
# 第一次运行,加载参数
self.success = False
self.local_history = []
if (self.newbing_model is None) or (not self.success):
# 代理设置
proxies, = get_conf('proxies')
if proxies is None:
self.proxies_https = None
else:
self.proxies_https = proxies['https']
# cookie
NEWBING_COOKIES, = get_conf('NEWBING_COOKIES')
try:
cookies = json.loads(NEWBING_COOKIES)
except:
self.success = False
tb_str = '\n```\n' + trimmed_format_exc() + '\n```\n'
self.child.send(f'[Local Message] 不能加载Newbing组件。NEWBING_COOKIES未填写或有格式错误。')
self.child.send('[Fail]')
self.child.send('[Finish]')
raise RuntimeError(f"不能加载Newbing组件。NEWBING_COOKIES未填写或有格式错误。")
try:
self.newbing_model = NewbingChatbot(proxy=self.proxies_https, cookies=cookies)
except:
self.success = False
tb_str = '\n```\n' + trimmed_format_exc() + '\n```\n'
self.child.send(f'[Local Message] 不能加载Newbing组件。{tb_str}')
self.child.send('[Fail]')
self.child.send('[Finish]')
raise RuntimeError(f"不能加载Newbing组件。")
self.success = True
try:
# 进入任务等待状态
asyncio.run(self.async_run())
except Exception:
tb_str = '```\n' + trimmed_format_exc() + '```'
self.child.send(f'[Local Message] Newbing失败 {tb_str}.')
self.child.send('[Fail]')
self.child.send('[Finish]')
def stream_chat(self, **kwargs):
"""
这个函数运行在主进程
"""
self.threadLock.acquire()
self.parent.send(kwargs) # 发送请求到子进程
while True:
res = self.parent.recv() # 等待newbing回复的片段
if res == '[Finish]':
break # 结束
elif res == '[Fail]':
self.success = False
break
else:
yield res # newbing回复的片段
self.threadLock.release()
"""
========================================================================
第三部分:主进程统一调用函数接口
========================================================================
"""
global newbing_handle
newbing_handle = None
def predict_no_ui_long_connection(inputs, llm_kwargs, history=[], sys_prompt="", observe_window=None, console_slience=False):
"""
多线程方法
函数的说明请见 request_llm/bridge_all.py
"""
global newbing_handle
if (newbing_handle is None) or (not newbing_handle.success):
newbing_handle = NewBingHandle()
observe_window[0] = load_message + "\n\n" + newbing_handle.info
if not newbing_handle.success:
error = newbing_handle.info
newbing_handle = None
raise RuntimeError(error)
# 没有 sys_prompt 接口,因此把prompt加入 history
history_feedin = []
for i in range(len(history)//2):
history_feedin.append([history[2*i], history[2*i+1]] )
watch_dog_patience = 5 # 看门狗 (watchdog) 的耐心, 设置5秒即可
response = ""
observe_window[0] = "[Local Message]: 等待NewBing响应中 ..."
for response in newbing_handle.stream_chat(query=inputs, history=history_feedin, system_prompt=sys_prompt, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
observe_window[0] = preprocess_newbing_out_simple(response)
if len(observe_window) >= 2:
if (time.time()-observe_window[1]) > watch_dog_patience:
raise RuntimeError("程序终止。")
return preprocess_newbing_out_simple(response)
def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_prompt='', stream = True, additional_fn=None):
"""
单线程方法
函数的说明请见 request_llm/bridge_all.py
"""
chatbot.append((inputs, "[Local Message]: 等待NewBing响应中 ..."))
global newbing_handle
if (newbing_handle is None) or (not newbing_handle.success):
newbing_handle = NewBingHandle()
chatbot[-1] = (inputs, load_message + "\n\n" + newbing_handle.info)
yield from update_ui(chatbot=chatbot, history=[])
if not newbing_handle.success:
newbing_handle = None
return
if additional_fn is not None:
import core_functional
importlib.reload(core_functional) # 热更新prompt
core_functional = core_functional.get_core_functions()
if "PreProcess" in core_functional[additional_fn]: inputs = core_functional[additional_fn]["PreProcess"](inputs) # 获取预处理函数(如果有的话)
inputs = core_functional[additional_fn]["Prefix"] + inputs + core_functional[additional_fn]["Suffix"]
history_feedin = []
for i in range(len(history)//2):
history_feedin.append([history[2*i], history[2*i+1]] )
chatbot[-1] = (inputs, "[Local Message]: 等待NewBing响应中 ...")
response = "[Local Message]: 等待NewBing响应中 ..."
yield from update_ui(chatbot=chatbot, history=history, msg="NewBing响应缓慢,尚未完成全部响应,请耐心完成后再提交新问题。")
for response in newbing_handle.stream_chat(query=inputs, history=history_feedin, system_prompt=system_prompt, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
chatbot[-1] = (inputs, preprocess_newbing_out(response))
yield from update_ui(chatbot=chatbot, history=history, msg="NewBing响应缓慢,尚未完成全部响应,请耐心完成后再提交新问题。")
if response == "[Local Message]: 等待NewBing响应中 ...": response = "[Local Message]: NewBing响应异常,请刷新界面重试 ..."
history.extend([inputs, response])
logging.info(f'[raw_input] {inputs}')
logging.info(f'[response] {response}')
yield from update_ui(chatbot=chatbot, history=history, msg="完成全部响应,请提交新问题。")

409
request_llm/edge_gpt.py 普通文件
查看文件

@@ -0,0 +1,409 @@
"""
========================================================================
第一部分来自EdgeGPT.py
https://github.com/acheong08/EdgeGPT
========================================================================
"""
import argparse
import asyncio
import json
import os
import random
import re
import ssl
import sys
import uuid
from enum import Enum
from typing import Generator
from typing import Literal
from typing import Optional
from typing import Union
import websockets.client as websockets
DELIMITER = "\x1e"
# Generate random IP between range 13.104.0.0/14
FORWARDED_IP = (
f"13.{random.randint(104, 107)}.{random.randint(0, 255)}.{random.randint(0, 255)}"
)
HEADERS = {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9",
"content-type": "application/json",
"sec-ch-ua": '"Not_A Brand";v="99", "Microsoft Edge";v="110", "Chromium";v="110"',
"sec-ch-ua-arch": '"x86"',
"sec-ch-ua-bitness": '"64"',
"sec-ch-ua-full-version": '"109.0.1518.78"',
"sec-ch-ua-full-version-list": '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-model": "",
"sec-ch-ua-platform": '"Windows"',
"sec-ch-ua-platform-version": '"15.0.0"',
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-ms-client-request-id": str(uuid.uuid4()),
"x-ms-useragent": "azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.0 OS/Win32",
"Referer": "https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx",
"Referrer-Policy": "origin-when-cross-origin",
"x-forwarded-for": FORWARDED_IP,
}
HEADERS_INIT_CONVER = {
"authority": "edgeservices.bing.com",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language": "en-US,en;q=0.9",
"cache-control": "max-age=0",
"sec-ch-ua": '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
"sec-ch-ua-arch": '"x86"',
"sec-ch-ua-bitness": '"64"',
"sec-ch-ua-full-version": '"110.0.1587.69"',
"sec-ch-ua-full-version-list": '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-model": '""',
"sec-ch-ua-platform": '"Windows"',
"sec-ch-ua-platform-version": '"15.0.0"',
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "none",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.69",
"x-edge-shopping-flag": "1",
"x-forwarded-for": FORWARDED_IP,
}
def get_ssl_context():
import certifi
ssl_context = ssl.create_default_context()
ssl_context.load_verify_locations(certifi.where())
return ssl_context
class NotAllowedToAccess(Exception):
pass
class ConversationStyle(Enum):
creative = "h3imaginative,clgalileo,gencontentv3"
balanced = "galileo"
precise = "h3precise,clgalileo"
CONVERSATION_STYLE_TYPE = Optional[
Union[ConversationStyle, Literal["creative", "balanced", "precise"]]
]
def _append_identifier(msg: dict) -> str:
"""
Appends special character to end of message to identify end of message
"""
# Convert dict to json string
return json.dumps(msg) + DELIMITER
def _get_ran_hex(length: int = 32) -> str:
"""
Returns random hex string
"""
return "".join(random.choice("0123456789abcdef") for _ in range(length))
class _ChatHubRequest:
"""
Request object for ChatHub
"""
def __init__(
self,
conversation_signature: str,
client_id: str,
conversation_id: str,
invocation_id: int = 0,
) -> None:
self.struct: dict = {}
self.client_id: str = client_id
self.conversation_id: str = conversation_id
self.conversation_signature: str = conversation_signature
self.invocation_id: int = invocation_id
def update(
self,
prompt,
conversation_style,
options,
) -> None:
"""
Updates request object
"""
if options is None:
options = [
"deepleo",
"enable_debug_commands",
"disable_emoji_spoken_text",
"enablemm",
]
if conversation_style:
if not isinstance(conversation_style, ConversationStyle):
conversation_style = getattr(ConversationStyle, conversation_style)
options = [
"nlu_direct_response_filter",
"deepleo",
"disable_emoji_spoken_text",
"responsible_ai_policy_235",
"enablemm",
conversation_style.value,
"dtappid",
"cricinfo",
"cricinfov2",
"dv3sugg",
]
self.struct = {
"arguments": [
{
"source": "cib",
"optionsSets": options,
"sliceIds": [
"222dtappid",
"225cricinfo",
"224locals0",
],
"traceId": _get_ran_hex(32),
"isStartOfSession": self.invocation_id == 0,
"message": {
"author": "user",
"inputMethod": "Keyboard",
"text": prompt,
"messageType": "Chat",
},
"conversationSignature": self.conversation_signature,
"participant": {
"id": self.client_id,
},
"conversationId": self.conversation_id,
},
],
"invocationId": str(self.invocation_id),
"target": "chat",
"type": 4,
}
self.invocation_id += 1
class _Conversation:
"""
Conversation API
"""
def __init__(
self,
cookies,
proxy,
) -> None:
self.struct: dict = {
"conversationId": None,
"clientId": None,
"conversationSignature": None,
"result": {"value": "Success", "message": None},
}
import httpx
self.proxy = proxy
proxy = (
proxy
or os.environ.get("all_proxy")
or os.environ.get("ALL_PROXY")
or os.environ.get("https_proxy")
or os.environ.get("HTTPS_PROXY")
or None
)
if proxy is not None and proxy.startswith("socks5h://"):
proxy = "socks5://" + proxy[len("socks5h://") :]
self.session = httpx.Client(
proxies=proxy,
timeout=30,
headers=HEADERS_INIT_CONVER,
)
for cookie in cookies:
self.session.cookies.set(cookie["name"], cookie["value"])
# Send GET request
response = self.session.get(
url=os.environ.get("BING_PROXY_URL")
or "https://edgeservices.bing.com/edgesvc/turing/conversation/create",
)
if response.status_code != 200:
response = self.session.get(
"https://edge.churchless.tech/edgesvc/turing/conversation/create",
)
if response.status_code != 200:
print(f"Status code: {response.status_code}")
print(response.text)
print(response.url)
raise Exception("Authentication failed")
try:
self.struct = response.json()
except (json.decoder.JSONDecodeError, NotAllowedToAccess) as exc:
raise Exception(
"Authentication failed. You have not been accepted into the beta.",
) from exc
if self.struct["result"]["value"] == "UnauthorizedRequest":
raise NotAllowedToAccess(self.struct["result"]["message"])
class _ChatHub:
"""
Chat API
"""
def __init__(self, conversation) -> None:
self.wss = None
self.request: _ChatHubRequest
self.loop: bool
self.task: asyncio.Task
print(conversation.struct)
self.request = _ChatHubRequest(
conversation_signature=conversation.struct["conversationSignature"],
client_id=conversation.struct["clientId"],
conversation_id=conversation.struct["conversationId"],
)
async def ask_stream(
self,
prompt: str,
wss_link: str,
conversation_style: CONVERSATION_STYLE_TYPE = None,
raw: bool = False,
options: dict = None,
) -> Generator[str, None, None]:
"""
Ask a question to the bot
"""
if self.wss and not self.wss.closed:
await self.wss.close()
# Check if websocket is closed
self.wss = await websockets.connect(
wss_link,
extra_headers=HEADERS,
max_size=None,
ssl=get_ssl_context()
)
await self._initial_handshake()
# Construct a ChatHub request
self.request.update(
prompt=prompt,
conversation_style=conversation_style,
options=options,
)
# Send request
await self.wss.send(_append_identifier(self.request.struct))
final = False
while not final:
objects = str(await self.wss.recv()).split(DELIMITER)
for obj in objects:
if obj is None or not obj:
continue
response = json.loads(obj)
if response.get("type") != 2 and raw:
yield False, response
elif response.get("type") == 1 and response["arguments"][0].get(
"messages",
):
resp_txt = response["arguments"][0]["messages"][0]["adaptiveCards"][
0
]["body"][0].get("text")
yield False, resp_txt
elif response.get("type") == 2:
final = True
yield True, response
async def _initial_handshake(self) -> None:
await self.wss.send(_append_identifier({"protocol": "json", "version": 1}))
await self.wss.recv()
async def close(self) -> None:
"""
Close the connection
"""
if self.wss and not self.wss.closed:
await self.wss.close()
class NewbingChatbot:
"""
Combines everything to make it seamless
"""
def __init__(
self,
cookies,
proxy
) -> None:
if cookies is None:
cookies = {}
self.cookies = cookies
self.proxy = proxy
self.chat_hub: _ChatHub = _ChatHub(
_Conversation(self.cookies, self.proxy),
)
async def ask(
self,
prompt: str,
wss_link: str,
conversation_style: CONVERSATION_STYLE_TYPE = None,
options: dict = None,
) -> dict:
"""
Ask a question to the bot
"""
async for final, response in self.chat_hub.ask_stream(
prompt=prompt,
conversation_style=conversation_style,
wss_link=wss_link,
options=options,
):
if final:
return response
await self.chat_hub.wss.close()
return None
async def ask_stream(
self,
prompt: str,
wss_link: str,
conversation_style: CONVERSATION_STYLE_TYPE = None,
raw: bool = False,
options: dict = None,
) -> Generator[str, None, None]:
"""
Ask a question to the bot
"""
async for response in self.chat_hub.ask_stream(
prompt=prompt,
conversation_style=conversation_style,
wss_link=wss_link,
raw=raw,
options=options,
):
yield response
async def close(self) -> None:
"""
Close the connection
"""
await self.chat_hub.close()
async def reset(self) -> None:
"""
Reset the conversation
"""
await self.close()
self.chat_hub = _ChatHub(_Conversation(self.cookies, self.proxy))

查看文件

@@ -0,0 +1,4 @@
jittor >= 1.3.7.9
jtorch >= 0.1.3
torch
torchvision

查看文件

@@ -0,0 +1,8 @@
BingImageCreator
certifi
httpx
prompt_toolkit
requests
rich
websockets
httpx[socks]

26
request_llm/test_llms.py 普通文件
查看文件

@@ -0,0 +1,26 @@
"""
对各个llm模型进行单元测试
"""
def validate_path():
import os, sys
dir_name = os.path.dirname(__file__)
root_dir_assume = os.path.abspath(os.path.dirname(__file__) + '/..')
os.chdir(root_dir_assume)
sys.path.append(root_dir_assume)
validate_path() # validate path so you can run from base directory
from request_llm.bridge_jittorllms import predict_no_ui_long_connection
llm_kwargs = {
'max_length': 512,
'top_p': 1,
'temperature': 1,
}
result = predict_no_ui_long_connection(inputs="你好",
llm_kwargs=llm_kwargs,
history=[],
sys_prompt="")
print('result')

查看文件

@@ -1,16 +1,17 @@
gradio==3.25.0 gradio==3.28.3
tiktoken>=0.3.3 tiktoken>=0.3.3
requests[socks] requests[socks]
transformers transformers
python-markdown-math python-markdown-math
beautifulsoup4 beautifulsoup4
latex2mathml latex2mathml
python-docx python-docx
mdtex2html mdtex2html
colorama colorama
Markdown Markdown
pygments pygments
pymupdf pymupdf
openai openai
numpy numpy
arxiv arxiv
pymupdf

265
theme.py
查看文件

@@ -1,6 +1,6 @@
import gradio as gr import gradio as gr
from toolbox import get_conf from toolbox import get_conf
CODE_HIGHLIGHT, = get_conf('CODE_HIGHLIGHT') CODE_HIGHLIGHT, ADD_WAIFU = get_conf('CODE_HIGHLIGHT', 'ADD_WAIFU')
# gradio可用颜色列表 # gradio可用颜色列表
# gr.themes.utils.colors.slate (石板色) # gr.themes.utils.colors.slate (石板色)
# gr.themes.utils.colors.gray (灰色) # gr.themes.utils.colors.gray (灰色)
@@ -27,6 +27,7 @@ CODE_HIGHLIGHT, = get_conf('CODE_HIGHLIGHT')
def adjust_theme(): def adjust_theme():
try: try:
color_er = gr.themes.utils.colors.fuchsia color_er = gr.themes.utils.colors.fuchsia
set_theme = gr.themes.Default( set_theme = gr.themes.Default(
@@ -80,6 +81,21 @@ def adjust_theme():
button_cancel_text_color=color_er.c600, button_cancel_text_color=color_er.c600,
button_cancel_text_color_dark="white", button_cancel_text_color_dark="white",
) )
# 添加一个萌萌的看板娘
if ADD_WAIFU:
js = """
<script src="file=docs/waifu_plugin/jquery.min.js"></script>
<script src="file=docs/waifu_plugin/jquery-ui.min.js"></script>
<script src="file=docs/waifu_plugin/autoload.js"></script>
"""
gradio_original_template_fn = gr.routes.templates.TemplateResponse
def gradio_new_template_fn(*args, **kwargs):
res = gradio_original_template_fn(*args, **kwargs)
res.body = res.body.replace(b'</html>', f'{js}</html>'.encode("utf8"))
res.init_headers()
return res
gr.routes.templates.TemplateResponse = gradio_new_template_fn # override gradio template
except: except:
set_theme = None set_theme = None
print('gradio版本较旧, 不能自定义字体和颜色') print('gradio版本较旧, 不能自定义字体和颜色')
@@ -137,6 +153,16 @@ advanced_css = """
/* 行内代码的背景设为淡灰色,设定圆角和间距. */ /* 行内代码的背景设为淡灰色,设定圆角和间距. */
.markdown-body code { .markdown-body code {
display: inline;
white-space: break-spaces;
border-radius: 6px;
margin: 0 2px 0 2px;
padding: .2em .4em .1em .4em;
background-color: rgba(13, 17, 23, 0.95);
color: #c9d1d9;
}
.dark .markdown-body code {
display: inline; display: inline;
white-space: break-spaces; white-space: break-spaces;
border-radius: 6px; border-radius: 6px;
@@ -144,8 +170,19 @@ advanced_css = """
padding: .2em .4em .1em .4em; padding: .2em .4em .1em .4em;
background-color: rgba(175,184,193,0.2); background-color: rgba(175,184,193,0.2);
} }
/* 设定代码块的样式,包括背景颜色、内、外边距、圆角。 */ /* 设定代码块的样式,包括背景颜色、内、外边距、圆角。 */
.markdown-body pre code { .markdown-body pre code {
display: block;
overflow: auto;
white-space: pre;
background-color: rgba(13, 17, 23, 0.95);
border-radius: 10px;
padding: 1em;
margin: 1em 2em 1em 0.5em;
}
.dark .markdown-body pre code {
display: block; display: block;
overflow: auto; overflow: auto;
white-space: pre; white-space: pre;
@@ -160,72 +197,162 @@ advanced_css = """
if CODE_HIGHLIGHT: if CODE_HIGHLIGHT:
advanced_css += """ advanced_css += """
.hll { background-color: #ffffcc } .codehilite .hll { background-color: #6e7681 }
.c { color: #3D7B7B; font-style: italic } /* Comment */ .codehilite .c { color: #8b949e; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */ .codehilite .err { color: #f85149 } /* Error */
.k { color: hsl(197, 94%, 51%); font-weight: bold } /* Keyword */ .codehilite .esc { color: #c9d1d9 } /* Escape */
.o { color: #666666 } /* Operator */ .codehilite .g { color: #c9d1d9 } /* Generic */
.ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ .codehilite .k { color: #ff7b72 } /* Keyword */
.cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ .codehilite .l { color: #a5d6ff } /* Literal */
.cp { color: #9C6500 } /* Comment.Preproc */ .codehilite .n { color: #c9d1d9 } /* Name */
.cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */ .codehilite .o { color: #ff7b72; font-weight: bold } /* Operator */
.c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ .codehilite .x { color: #c9d1d9 } /* Other */
.cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ .codehilite .p { color: #c9d1d9 } /* Punctuation */
.gd { color: #A00000 } /* Generic.Deleted */ .codehilite .ch { color: #8b949e; font-style: italic } /* Comment.Hashbang */
.ge { font-style: italic } /* Generic.Emph */ .codehilite .cm { color: #8b949e; font-style: italic } /* Comment.Multiline */
.gr { color: #E40000 } /* Generic.Error */ .codehilite .cp { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Preproc */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */ .codehilite .cpf { color: #8b949e; font-style: italic } /* Comment.PreprocFile */
.gi { color: #008400 } /* Generic.Inserted */ .codehilite .c1 { color: #8b949e; font-style: italic } /* Comment.Single */
.go { color: #717171 } /* Generic.Output */ .codehilite .cs { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Special */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */ .codehilite .gd { color: #ffa198; background-color: #490202 } /* Generic.Deleted */
.gs { font-weight: bold } /* Generic.Strong */ .codehilite .ge { color: #c9d1d9; font-style: italic } /* Generic.Emph */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */ .codehilite .gr { color: #ffa198 } /* Generic.Error */
.gt { color: #a9dd00 } /* Generic.Traceback */ .codehilite .gh { color: #79c0ff; font-weight: bold } /* Generic.Heading */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */ .codehilite .gi { color: #56d364; background-color: #0f5323 } /* Generic.Inserted */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ .codehilite .go { color: #8b949e } /* Generic.Output */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ .codehilite .gp { color: #8b949e } /* Generic.Prompt */
.kp { color: #008000 } /* Keyword.Pseudo */ .codehilite .gs { color: #c9d1d9; font-weight: bold } /* Generic.Strong */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ .codehilite .gu { color: #79c0ff } /* Generic.Subheading */
.kt { color: #B00040 } /* Keyword.Type */ .codehilite .gt { color: #ff7b72 } /* Generic.Traceback */
.m { color: #666666 } /* Literal.Number */ .codehilite .g-Underline { color: #c9d1d9; text-decoration: underline } /* Generic.Underline */
.s { color: #BA2121 } /* Literal.String */ .codehilite .kc { color: #79c0ff } /* Keyword.Constant */
.na { color: #687822 } /* Name.Attribute */ .codehilite .kd { color: #ff7b72 } /* Keyword.Declaration */
.nb { color: #e5f8c3 } /* Name.Builtin */ .codehilite .kn { color: #ff7b72 } /* Keyword.Namespace */
.nc { color: #ffad65; font-weight: bold } /* Name.Class */ .codehilite .kp { color: #79c0ff } /* Keyword.Pseudo */
.no { color: #880000 } /* Name.Constant */ .codehilite .kr { color: #ff7b72 } /* Keyword.Reserved */
.nd { color: #AA22FF } /* Name.Decorator */ .codehilite .kt { color: #ff7b72 } /* Keyword.Type */
.ni { color: #717171; font-weight: bold } /* Name.Entity */ .codehilite .ld { color: #79c0ff } /* Literal.Date */
.ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ .codehilite .m { color: #a5d6ff } /* Literal.Number */
.nf { color: #f9f978 } /* Name.Function */ .codehilite .s { color: #a5d6ff } /* Literal.String */
.nl { color: #767600 } /* Name.Label */ .codehilite .na { color: #c9d1d9 } /* Name.Attribute */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ .codehilite .nb { color: #c9d1d9 } /* Name.Builtin */
.nt { color: #008000; font-weight: bold } /* Name.Tag */ .codehilite .nc { color: #f0883e; font-weight: bold } /* Name.Class */
.nv { color: #19177C } /* Name.Variable */ .codehilite .no { color: #79c0ff; font-weight: bold } /* Name.Constant */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ .codehilite .nd { color: #d2a8ff; font-weight: bold } /* Name.Decorator */
.w { color: #bbbbbb } /* Text.Whitespace */ .codehilite .ni { color: #ffa657 } /* Name.Entity */
.mb { color: #666666 } /* Literal.Number.Bin */ .codehilite .ne { color: #f0883e; font-weight: bold } /* Name.Exception */
.mf { color: #666666 } /* Literal.Number.Float */ .codehilite .nf { color: #d2a8ff; font-weight: bold } /* Name.Function */
.mh { color: #666666 } /* Literal.Number.Hex */ .codehilite .nl { color: #79c0ff; font-weight: bold } /* Name.Label */
.mi { color: #666666 } /* Literal.Number.Integer */ .codehilite .nn { color: #ff7b72 } /* Name.Namespace */
.mo { color: #666666 } /* Literal.Number.Oct */ .codehilite .nx { color: #c9d1d9 } /* Name.Other */
.sa { color: #BA2121 } /* Literal.String.Affix */ .codehilite .py { color: #79c0ff } /* Name.Property */
.sb { color: #BA2121 } /* Literal.String.Backtick */ .codehilite .nt { color: #7ee787 } /* Name.Tag */
.sc { color: #BA2121 } /* Literal.String.Char */ .codehilite .nv { color: #79c0ff } /* Name.Variable */
.dl { color: #BA2121 } /* Literal.String.Delimiter */ .codehilite .ow { color: #ff7b72; font-weight: bold } /* Operator.Word */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ .codehilite .pm { color: #c9d1d9 } /* Punctuation.Marker */
.s2 { color: #2bf840 } /* Literal.String.Double */ .codehilite .w { color: #6e7681 } /* Text.Whitespace */
.se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */ .codehilite .mb { color: #a5d6ff } /* Literal.Number.Bin */
.sh { color: #BA2121 } /* Literal.String.Heredoc */ .codehilite .mf { color: #a5d6ff } /* Literal.Number.Float */
.si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */ .codehilite .mh { color: #a5d6ff } /* Literal.Number.Hex */
.sx { color: #008000 } /* Literal.String.Other */ .codehilite .mi { color: #a5d6ff } /* Literal.Number.Integer */
.sr { color: #A45A77 } /* Literal.String.Regex */ .codehilite .mo { color: #a5d6ff } /* Literal.Number.Oct */
.s1 { color: #BA2121 } /* Literal.String.Single */ .codehilite .sa { color: #79c0ff } /* Literal.String.Affix */
.ss { color: #19177C } /* Literal.String.Symbol */ .codehilite .sb { color: #a5d6ff } /* Literal.String.Backtick */
.bp { color: #008000 } /* Name.Builtin.Pseudo */ .codehilite .sc { color: #a5d6ff } /* Literal.String.Char */
.fm { color: #0000FF } /* Name.Function.Magic */ .codehilite .dl { color: #79c0ff } /* Literal.String.Delimiter */
.vc { color: #19177C } /* Name.Variable.Class */ .codehilite .sd { color: #a5d6ff } /* Literal.String.Doc */
.vg { color: #19177C } /* Name.Variable.Global */ .codehilite .s2 { color: #a5d6ff } /* Literal.String.Double */
.vi { color: #19177C } /* Name.Variable.Instance */ .codehilite .se { color: #79c0ff } /* Literal.String.Escape */
.vm { color: #19177C } /* Name.Variable.Magic */ .codehilite .sh { color: #79c0ff } /* Literal.String.Heredoc */
.il { color: #666666 } /* Literal.Number.Integer.Long */ .codehilite .si { color: #a5d6ff } /* Literal.String.Interpol */
.codehilite .sx { color: #a5d6ff } /* Literal.String.Other */
.codehilite .sr { color: #79c0ff } /* Literal.String.Regex */
.codehilite .s1 { color: #a5d6ff } /* Literal.String.Single */
.codehilite .ss { color: #a5d6ff } /* Literal.String.Symbol */
.codehilite .bp { color: #c9d1d9 } /* Name.Builtin.Pseudo */
.codehilite .fm { color: #d2a8ff; font-weight: bold } /* Name.Function.Magic */
.codehilite .vc { color: #79c0ff } /* Name.Variable.Class */
.codehilite .vg { color: #79c0ff } /* Name.Variable.Global */
.codehilite .vi { color: #79c0ff } /* Name.Variable.Instance */
.codehilite .vm { color: #79c0ff } /* Name.Variable.Magic */
.codehilite .il { color: #a5d6ff } /* Literal.Number.Integer.Long */
.dark .codehilite .hll { background-color: #2C3B41 }
.dark .codehilite .c { color: #79d618; font-style: italic } /* Comment */
.dark .codehilite .err { color: #FF5370 } /* Error */
.dark .codehilite .esc { color: #89DDFF } /* Escape */
.dark .codehilite .g { color: #EEFFFF } /* Generic */
.dark .codehilite .k { color: #BB80B3 } /* Keyword */
.dark .codehilite .l { color: #C3E88D } /* Literal */
.dark .codehilite .n { color: #EEFFFF } /* Name */
.dark .codehilite .o { color: #89DDFF } /* Operator */
.dark .codehilite .p { color: #89DDFF } /* Punctuation */
.dark .codehilite .ch { color: #79d618; font-style: italic } /* Comment.Hashbang */
.dark .codehilite .cm { color: #79d618; font-style: italic } /* Comment.Multiline */
.dark .codehilite .cp { color: #79d618; font-style: italic } /* Comment.Preproc */
.dark .codehilite .cpf { color: #79d618; font-style: italic } /* Comment.PreprocFile */
.dark .codehilite .c1 { color: #79d618; font-style: italic } /* Comment.Single */
.dark .codehilite .cs { color: #79d618; font-style: italic } /* Comment.Special */
.dark .codehilite .gd { color: #FF5370 } /* Generic.Deleted */
.dark .codehilite .ge { color: #89DDFF } /* Generic.Emph */
.dark .codehilite .gr { color: #FF5370 } /* Generic.Error */
.dark .codehilite .gh { color: #C3E88D } /* Generic.Heading */
.dark .codehilite .gi { color: #C3E88D } /* Generic.Inserted */
.dark .codehilite .go { color: #79d618 } /* Generic.Output */
.dark .codehilite .gp { color: #FFCB6B } /* Generic.Prompt */
.dark .codehilite .gs { color: #FF5370 } /* Generic.Strong */
.dark .codehilite .gu { color: #89DDFF } /* Generic.Subheading */
.dark .codehilite .gt { color: #FF5370 } /* Generic.Traceback */
.dark .codehilite .kc { color: #89DDFF } /* Keyword.Constant */
.dark .codehilite .kd { color: #BB80B3 } /* Keyword.Declaration */
.dark .codehilite .kn { color: #89DDFF; font-style: italic } /* Keyword.Namespace */
.dark .codehilite .kp { color: #89DDFF } /* Keyword.Pseudo */
.dark .codehilite .kr { color: #BB80B3 } /* Keyword.Reserved */
.dark .codehilite .kt { color: #BB80B3 } /* Keyword.Type */
.dark .codehilite .ld { color: #C3E88D } /* Literal.Date */
.dark .codehilite .m { color: #F78C6C } /* Literal.Number */
.dark .codehilite .s { color: #C3E88D } /* Literal.String */
.dark .codehilite .na { color: #BB80B3 } /* Name.Attribute */
.dark .codehilite .nb { color: #82AAFF } /* Name.Builtin */
.dark .codehilite .nc { color: #FFCB6B } /* Name.Class */
.dark .codehilite .no { color: #EEFFFF } /* Name.Constant */
.dark .codehilite .nd { color: #82AAFF } /* Name.Decorator */
.dark .codehilite .ni { color: #89DDFF } /* Name.Entity */
.dark .codehilite .ne { color: #FFCB6B } /* Name.Exception */
.dark .codehilite .nf { color: #82AAFF } /* Name.Function */
.dark .codehilite .nl { color: #82AAFF } /* Name.Label */
.dark .codehilite .nn { color: #FFCB6B } /* Name.Namespace */
.dark .codehilite .nx { color: #EEFFFF } /* Name.Other */
.dark .codehilite .py { color: #FFCB6B } /* Name.Property */
.dark .codehilite .nt { color: #FF5370 } /* Name.Tag */
.dark .codehilite .nv { color: #89DDFF } /* Name.Variable */
.dark .codehilite .ow { color: #89DDFF; font-style: italic } /* Operator.Word */
.dark .codehilite .pm { color: #89DDFF } /* Punctuation.Marker */
.dark .codehilite .w { color: #EEFFFF } /* Text.Whitespace */
.dark .codehilite .mb { color: #F78C6C } /* Literal.Number.Bin */
.dark .codehilite .mf { color: #F78C6C } /* Literal.Number.Float */
.dark .codehilite .mh { color: #F78C6C } /* Literal.Number.Hex */
.dark .codehilite .mi { color: #F78C6C } /* Literal.Number.Integer */
.dark .codehilite .mo { color: #F78C6C } /* Literal.Number.Oct */
.dark .codehilite .sa { color: #BB80B3 } /* Literal.String.Affix */
.dark .codehilite .sb { color: #C3E88D } /* Literal.String.Backtick */
.dark .codehilite .sc { color: #C3E88D } /* Literal.String.Char */
.dark .codehilite .dl { color: #EEFFFF } /* Literal.String.Delimiter */
.dark .codehilite .sd { color: #79d618; font-style: italic } /* Literal.String.Doc */
.dark .codehilite .s2 { color: #C3E88D } /* Literal.String.Double */
.dark .codehilite .se { color: #EEFFFF } /* Literal.String.Escape */
.dark .codehilite .sh { color: #C3E88D } /* Literal.String.Heredoc */
.dark .codehilite .si { color: #89DDFF } /* Literal.String.Interpol */
.dark .codehilite .sx { color: #C3E88D } /* Literal.String.Other */
.dark .codehilite .sr { color: #89DDFF } /* Literal.String.Regex */
.dark .codehilite .s1 { color: #C3E88D } /* Literal.String.Single */
.dark .codehilite .ss { color: #89DDFF } /* Literal.String.Symbol */
.dark .codehilite .bp { color: #89DDFF } /* Name.Builtin.Pseudo */
.dark .codehilite .fm { color: #82AAFF } /* Name.Function.Magic */
.dark .codehilite .vc { color: #89DDFF } /* Name.Variable.Class */
.dark .codehilite .vg { color: #89DDFF } /* Name.Variable.Global */
.dark .codehilite .vi { color: #89DDFF } /* Name.Variable.Instance */
.dark .codehilite .vm { color: #82AAFF } /* Name.Variable.Magic */
.dark .codehilite .il { color: #F78C6C } /* Literal.Number.Integer.Long */
""" """

查看文件

@@ -3,9 +3,23 @@ import importlib
import traceback import traceback
import inspect import inspect
import re import re
import os
from latex2mathml.converter import convert as tex2mathml from latex2mathml.converter import convert as tex2mathml
from functools import wraps, lru_cache from functools import wraps, lru_cache
############################### 插件输入输出接驳区 #######################################
"""
========================================================================
第一部分
函数插件输入输出接驳区
- ChatBotWithCookies: 带Cookies的Chatbot类,为实现更多强大的功能做基础
- ArgsGeneralWrapper: 装饰器函数,用于重组输入参数,改变输入参数的顺序与结构
- update_ui: 刷新界面用 yield from update_ui(chatbot, history)
- CatchException: 将插件中出的所有问题显示在界面上
- HotReload: 实现插件的热更新
- trimmed_format_exc: 打印traceback,为了安全而隐藏绝对地址
========================================================================
"""
class ChatBotWithCookies(list): class ChatBotWithCookies(list):
def __init__(self, cookie): def __init__(self, cookie):
self._cookies = cookie self._cookies = cookie
@@ -20,33 +34,35 @@ class ChatBotWithCookies(list):
def get_cookies(self): def get_cookies(self):
return self._cookies return self._cookies
def ArgsGeneralWrapper(f): def ArgsGeneralWrapper(f):
""" """
装饰器函数,用于重组输入参数,改变输入参数的顺序与结构。 装饰器函数,用于重组输入参数,改变输入参数的顺序与结构。
""" """
def decorated(cookies, max_length, llm_model, txt, txt2, top_p, temperature, chatbot, history, system_prompt, *args): def decorated(cookies, max_length, llm_model, txt, txt2, top_p, temperature, chatbot, history, system_prompt, plugin_advanced_arg, *args):
txt_passon = txt txt_passon = txt
if txt == "" and txt2 != "": txt_passon = txt2 if txt == "" and txt2 != "": txt_passon = txt2
# 引入一个有cookie的chatbot # 引入一个有cookie的chatbot
cookies.update({ cookies.update({
'top_p':top_p, 'top_p':top_p,
'temperature':temperature, 'temperature':temperature,
}) })
llm_kwargs = { llm_kwargs = {
'api_key': cookies['api_key'], 'api_key': cookies['api_key'],
'llm_model': llm_model, 'llm_model': llm_model,
'top_p':top_p, 'top_p':top_p,
'max_length': max_length, 'max_length': max_length,
'temperature':temperature, 'temperature':temperature,
} }
plugin_kwargs = { plugin_kwargs = {
# 目前还没有 "advanced_arg": plugin_advanced_arg,
} }
chatbot_with_cookie = ChatBotWithCookies(cookies) chatbot_with_cookie = ChatBotWithCookies(cookies)
chatbot_with_cookie.write_list(chatbot) chatbot_with_cookie.write_list(chatbot)
yield from f(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, *args) yield from f(txt_passon, llm_kwargs, plugin_kwargs, chatbot_with_cookie, history, system_prompt, *args)
return decorated return decorated
def update_ui(chatbot, history, msg='正常', **kwargs): # 刷新界面 def update_ui(chatbot, history, msg='正常', **kwargs): # 刷新界面
""" """
刷新用户界面 刷新用户界面
@@ -54,10 +70,18 @@ def update_ui(chatbot, history, msg='正常', **kwargs): # 刷新界面
assert isinstance(chatbot, ChatBotWithCookies), "在传递chatbot的过程中不要将其丢弃。必要时,可用clear将其清空,然后用for+append循环重新赋值。" assert isinstance(chatbot, ChatBotWithCookies), "在传递chatbot的过程中不要将其丢弃。必要时,可用clear将其清空,然后用for+append循环重新赋值。"
yield chatbot.get_cookies(), chatbot, history, msg yield chatbot.get_cookies(), chatbot, history, msg
def trimmed_format_exc():
import os, traceback
str = traceback.format_exc()
current_path = os.getcwd()
replace_path = "."
return str.replace(current_path, replace_path)
def CatchException(f): def CatchException(f):
""" """
装饰器函数,捕捉函数f中的异常并封装到一个生成器中返回,并显示到聊天当中。 装饰器函数,捕捉函数f中的异常并封装到一个生成器中返回,并显示到聊天当中。
""" """
@wraps(f) @wraps(f)
def decorated(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT): def decorated(txt, top_p, temperature, chatbot, history, systemPromptTxt, WEB_PORT):
try: try:
@@ -66,9 +90,10 @@ def CatchException(f):
from check_proxy import check_proxy from check_proxy import check_proxy
from toolbox import get_conf from toolbox import get_conf
proxies, = get_conf('proxies') proxies, = get_conf('proxies')
tb_str = '```\n' + traceback.format_exc() + '```' tb_str = '```\n' + trimmed_format_exc() + '```'
if chatbot is None or len(chatbot) == 0: if len(chatbot) == 0:
chatbot = [["插件调度异常", "异常原因"]] chatbot.clear()
chatbot.append(["插件调度异常", "异常原因"])
chatbot[-1] = (chatbot[-1][0], chatbot[-1] = (chatbot[-1][0],
f"[Local Message] 实验性函数调用出错: \n\n{tb_str} \n\n当前代理可用性: \n\n{check_proxy(proxies)}") f"[Local Message] 实验性函数调用出错: \n\n{tb_str} \n\n当前代理可用性: \n\n{check_proxy(proxies)}")
yield from update_ui(chatbot=chatbot, history=history, msg=f'异常 {e}') # 刷新界面 yield from update_ui(chatbot=chatbot, history=history, msg=f'异常 {e}') # 刷新界面
@@ -93,7 +118,23 @@ def HotReload(f):
return decorated return decorated
####################################### 其他小工具 ##################################### """
========================================================================
第二部分
其他小工具:
- write_results_to_file: 将结果写入markdown文件中
- regular_txt_to_markdown: 将普通文本转换为Markdown格式的文本。
- report_execption: 向chatbot中添加简单的意外错误信息
- text_divide_paragraph: 将文本按照段落分隔符分割开,生成带有段落标签的HTML代码。
- markdown_convertion: 用多种方式组合,将markdown转化为好看的html
- format_io: 接管gradio默认的markdown处理方式
- on_file_uploaded: 处理文件的上传(自动解压)
- on_report_generated: 将生成的报告自动投射到文件上传区
- clip_history: 当历史上下文过长时,自动截断
- get_conf: 获取设置
- select_api_key: 根据当前的模型类别,抽取可用的api-key
========================================================================
"""
def get_reduce_token_percent(text): def get_reduce_token_percent(text):
""" """
@@ -113,7 +154,6 @@ def get_reduce_token_percent(text):
return 0.5, '不详' return 0.5, '不详'
def write_results_to_file(history, file_name=None): def write_results_to_file(history, file_name=None):
""" """
将对话记录history以Markdown格式写入文件中。如果没有指定文件名,则使用当前时间生成文件名。 将对话记录history以Markdown格式写入文件中。如果没有指定文件名,则使用当前时间生成文件名。
@@ -178,13 +218,17 @@ def text_divide_paragraph(text):
text = "</br>".join(lines) text = "</br>".join(lines)
return text return text
@lru_cache(maxsize=128) # 使用 lru缓存 加快转换速度
def markdown_convertion(txt): def markdown_convertion(txt):
""" """
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。 将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
""" """
pre = '<div class="markdown-body">' pre = '<div class="markdown-body">'
suf = '</div>' suf = '</div>'
if txt.startswith(pre) and txt.endswith(suf):
# print('警告,输入了已经经过转化的字符串,二次转化可能出问题')
return txt # 已经被转化过,不需要再次转化
markdown_extension_configs = { markdown_extension_configs = {
'mdx_math': { 'mdx_math': {
'enable_dollar_delimiter': True, 'enable_dollar_delimiter': True,
@@ -219,7 +263,7 @@ def markdown_convertion(txt):
return content return content
else: else:
return tex2mathml_catch_exception(content) return tex2mathml_catch_exception(content)
def markdown_bug_hunt(content): def markdown_bug_hunt(content):
""" """
解决一个mdx_math的bug单$包裹begin命令时多余<script> 解决一个mdx_math的bug单$包裹begin命令时多余<script>
@@ -227,9 +271,15 @@ def markdown_convertion(txt):
content = content.replace('<script type="math/tex">\n<script type="math/tex; mode=display">', '<script type="math/tex; mode=display">') content = content.replace('<script type="math/tex">\n<script type="math/tex; mode=display">', '<script type="math/tex; mode=display">')
content = content.replace('</script>\n</script>', '</script>') content = content.replace('</script>\n</script>', '</script>')
return content return content
if ('$' in txt) and ('```' not in txt): # 有$标识的公式符号,且没有代码段```的标识 def no_code(txt):
if '```' not in txt:
return True
else:
if '```reference' in txt: return True # newbing
else: return False
if ('$' in txt) and no_code(txt): # 有$标识的公式符号,且没有代码段```的标识
# convert everything to html format # convert everything to html format
split = markdown.markdown(text='---') split = markdown.markdown(text='---')
convert_stage_1 = markdown.markdown(text=txt, extensions=['mdx_math', 'fenced_code', 'tables', 'sane_lists'], extension_configs=markdown_extension_configs) convert_stage_1 = markdown.markdown(text=txt, extensions=['mdx_math', 'fenced_code', 'tables', 'sane_lists'], extension_configs=markdown_extension_configs)
@@ -248,7 +298,7 @@ def markdown_convertion(txt):
def close_up_code_segment_during_stream(gpt_reply): def close_up_code_segment_during_stream(gpt_reply):
""" """
在gpt输出代码的中途输出了前面的```,但还没输出完后面的```),补上后面的``` 在gpt输出代码的中途输出了前面的```,但还没输出完后面的```),补上后面的```
Args: Args:
gpt_reply (str): GPT模型返回的回复字符串。 gpt_reply (str): GPT模型返回的回复字符串。
@@ -369,6 +419,9 @@ def find_recent_files(directory):
def on_file_uploaded(files, chatbot, txt, txt2, checkboxes): def on_file_uploaded(files, chatbot, txt, txt2, checkboxes):
"""
当文件被上传时的回调函数
"""
if len(files) == 0: if len(files) == 0:
return chatbot, txt return chatbot, txt
import shutil import shutil
@@ -388,8 +441,7 @@ def on_file_uploaded(files, chatbot, txt, txt2, checkboxes):
shutil.copy(file.name, f'private_upload/{time_tag}/{file_origin_name}') shutil.copy(file.name, f'private_upload/{time_tag}/{file_origin_name}')
err_msg += extract_archive(f'private_upload/{time_tag}/{file_origin_name}', err_msg += extract_archive(f'private_upload/{time_tag}/{file_origin_name}',
dest_dir=f'private_upload/{time_tag}/{file_origin_name}.extract') dest_dir=f'private_upload/{time_tag}/{file_origin_name}.extract')
moved_files = [fp for fp in glob.glob( moved_files = [fp for fp in glob.glob('private_upload/**/*', recursive=True)]
'private_upload/**/*', recursive=True)]
if "底部输入区" in checkboxes: if "底部输入区" in checkboxes:
txt = "" txt = ""
txt2 = f'private_upload/{time_tag}' txt2 = f'private_upload/{time_tag}'
@@ -414,8 +466,9 @@ def on_report_generated(files, chatbot):
return report_files, chatbot return report_files, chatbot
def is_openai_api_key(key): def is_openai_api_key(key):
API_MATCH = re.match(r"sk-[a-zA-Z0-9]{48}$", key) API_MATCH_ORIGINAL = re.match(r"sk-[a-zA-Z0-9]{48}$", key)
return bool(API_MATCH) API_MATCH_AZURE = re.match(r"[a-zA-Z0-9]{32}$", key)
return bool(API_MATCH_ORIGINAL) or bool(API_MATCH_AZURE)
def is_api2d_key(key): def is_api2d_key(key):
if key.startswith('fk') and len(key) == 41: if key.startswith('fk') and len(key) == 41:
@@ -432,6 +485,19 @@ def is_any_api_key(key):
else: else:
return is_openai_api_key(key) or is_api2d_key(key) return is_openai_api_key(key) or is_api2d_key(key)
def what_keys(keys):
avail_key_list = {'OpenAI Key':0, "API2D Key":0}
key_list = keys.split(',')
for k in key_list:
if is_openai_api_key(k):
avail_key_list['OpenAI Key'] += 1
for k in key_list:
if is_api2d_key(k):
avail_key_list['API2D Key'] += 1
return f"检测到: OpenAI Key {avail_key_list['OpenAI Key']} 个,API2D Key {avail_key_list['API2D Key']}"
def select_api_key(keys, llm_model): def select_api_key(keys, llm_model):
import random import random
@@ -447,20 +513,81 @@ def select_api_key(keys, llm_model):
if is_api2d_key(k): avail_key_list.append(k) if is_api2d_key(k): avail_key_list.append(k)
if len(avail_key_list) == 0: if len(avail_key_list) == 0:
raise RuntimeError(f"您提供的api-key不满足要求,不包含任何可用于{llm_model}的api-key。") raise RuntimeError(f"您提供的api-key不满足要求,不包含任何可用于{llm_model}的api-key。您可能选择了错误的模型或请求源。")
api_key = random.choice(avail_key_list) # 随机负载均衡 api_key = random.choice(avail_key_list) # 随机负载均衡
return api_key return api_key
def read_env_variable(arg, default_value):
"""
环境变量可以是 `GPT_ACADEMIC_CONFIG`(优先),也可以直接是`CONFIG`
例如在windows cmd中,既可以写
set USE_PROXY=True
set API_KEY=sk-j7caBpkRoxxxxxxxxxxxxxxxxxxxxxxxxxxxx
set proxies={"http":"http://127.0.0.1:10085", "https":"http://127.0.0.1:10085",}
set AVAIL_LLM_MODELS=["gpt-3.5-turbo", "chatglm"]
set AUTHENTICATION=[("username", "password"), ("username2", "password2")]
也可以写:
set GPT_ACADEMIC_USE_PROXY=True
set GPT_ACADEMIC_API_KEY=sk-j7caBpkRoxxxxxxxxxxxxxxxxxxxxxxxxxxxx
set GPT_ACADEMIC_proxies={"http":"http://127.0.0.1:10085", "https":"http://127.0.0.1:10085",}
set GPT_ACADEMIC_AVAIL_LLM_MODELS=["gpt-3.5-turbo", "chatglm"]
set GPT_ACADEMIC_AUTHENTICATION=[("username", "password"), ("username2", "password2")]
"""
from colorful import print亮红, print亮绿
arg_with_prefix = "GPT_ACADEMIC_" + arg
if arg_with_prefix in os.environ:
env_arg = os.environ[arg_with_prefix]
elif arg in os.environ:
env_arg = os.environ[arg]
else:
raise KeyError
print(f"[ENV_VAR] 尝试加载{arg},默认值:{default_value} --> 修正值:{env_arg}")
try:
if isinstance(default_value, bool):
r = bool(env_arg)
elif isinstance(default_value, int):
r = int(env_arg)
elif isinstance(default_value, float):
r = float(env_arg)
elif isinstance(default_value, str):
r = env_arg.strip()
elif isinstance(default_value, dict):
r = eval(env_arg)
elif isinstance(default_value, list):
r = eval(env_arg)
elif default_value is None:
assert arg == "proxies"
r = eval(env_arg)
else:
print亮红(f"[ENV_VAR] 环境变量{arg}不支持通过环境变量设置! ")
raise KeyError
except:
print亮红(f"[ENV_VAR] 环境变量{arg}加载失败! ")
raise KeyError(f"[ENV_VAR] 环境变量{arg}加载失败! ")
print亮绿(f"[ENV_VAR] 成功读取环境变量{arg}")
return r
@lru_cache(maxsize=128) @lru_cache(maxsize=128)
def read_single_conf_with_lru_cache(arg): def read_single_conf_with_lru_cache(arg):
from colorful import print亮红, print亮绿 from colorful import print亮红, print亮绿, print亮蓝
try: try:
r = getattr(importlib.import_module('config_private'), arg) # 优先级1. 获取环境变量作为配置
default_ref = getattr(importlib.import_module('config'), arg) # 读取默认值作为数据类型转换的参考
r = read_env_variable(arg, default_ref)
except: except:
r = getattr(importlib.import_module('config'), arg) try:
# 优先级2. 获取config_private中的配置
r = getattr(importlib.import_module('config_private'), arg)
except:
# 优先级3. 获取config中的配置
r = getattr(importlib.import_module('config'), arg)
# 在读取API_KEY时,检查一下是不是忘了改config # 在读取API_KEY时,检查一下是不是忘了改config
if arg == 'API_KEY': if arg == 'API_KEY':
print亮蓝(f"[API_KEY] 本项目现已支持OpenAI和API2D的api-key。也支持同时填写多个api-key,如API_KEY=\"openai-key1,openai-key2,api2d-key3\"")
print亮蓝(f"[API_KEY] 您既可以在config.py中修改api-key(s),也可以在问题输入区输入临时的api-key(s),然后回车键提交后即可生效。")
if is_any_api_key(r): if is_any_api_key(r):
print亮绿(f"[API_KEY] 您的 API_KEY 是: {r[:15]}*** API_KEY 导入成功") print亮绿(f"[API_KEY] 您的 API_KEY 是: {r[:15]}*** API_KEY 导入成功")
else: else:
@@ -493,10 +620,10 @@ def clear_line_break(txt):
class DummyWith(): class DummyWith():
""" """
这段代码定义了一个名为DummyWith的空上下文管理器, 这段代码定义了一个名为DummyWith的空上下文管理器,
它的作用是……额……用,即在代码结构不变得情况下取代其他的上下文管理器。 它的作用是……额……就是不起作用,即在代码结构不变得情况下取代其他的上下文管理器。
上下文管理器是一种Python对象,用于与with语句一起使用, 上下文管理器是一种Python对象,用于与with语句一起使用,
以确保一些资源在代码块执行期间得到正确的初始化和清理。 以确保一些资源在代码块执行期间得到正确的初始化和清理。
上下文管理器必须实现两个方法,分别为 __enter__()和 __exit__()。 上下文管理器必须实现两个方法,分别为 __enter__()和 __exit__()。
在上下文执行开始的情况下,__enter__()方法会在代码块被执行前被调用, 在上下文执行开始的情况下,__enter__()方法会在代码块被执行前被调用,
而在上下文执行结束时,__exit__()方法则会被调用。 而在上下文执行结束时,__exit__()方法则会被调用。
""" """
@@ -505,3 +632,86 @@ class DummyWith():
def __exit__(self, exc_type, exc_value, traceback): def __exit__(self, exc_type, exc_value, traceback):
return return
def run_gradio_in_subpath(demo, auth, port, custom_path):
"""
把gradio的运行地址更改到指定的二次路径上
"""
def is_path_legal(path: str)->bool:
'''
check path for sub url
path: path to check
return value: do sub url wrap
'''
if path == "/": return True
if len(path) == 0:
print("ilegal custom path: {}\npath must not be empty\ndeploy on root url".format(path))
return False
if path[0] == '/':
if path[1] != '/':
print("deploy on sub-path {}".format(path))
return True
return False
print("ilegal custom path: {}\npath should begin with \'/\'\ndeploy on root url".format(path))
return False
if not is_path_legal(custom_path): raise RuntimeError('Ilegal custom path')
import uvicorn
import gradio as gr
from fastapi import FastAPI
app = FastAPI()
if custom_path != "/":
@app.get("/")
def read_main():
return {"message": f"Gradio is running at: {custom_path}"}
app = gr.mount_gradio_app(app, demo, path=custom_path)
uvicorn.run(app, host="0.0.0.0", port=port) # , auth=auth
def clip_history(inputs, history, tokenizer, max_token_limit):
"""
reduce the length of history by clipping.
this function search for the longest entries to clip, little by little,
until the number of token of history is reduced under threshold.
通过裁剪来缩短历史记录的长度。
此函数逐渐地搜索最长的条目进行剪辑,
直到历史记录的标记数量降低到阈值以下。
"""
import numpy as np
from request_llm.bridge_all import model_info
def get_token_num(txt):
return len(tokenizer.encode(txt, disallowed_special=()))
input_token_num = get_token_num(inputs)
if input_token_num < max_token_limit * 3 / 4:
# 当输入部分的token占比小于限制的3/4时,裁剪时
# 1. 把input的余量留出来
max_token_limit = max_token_limit - input_token_num
# 2. 把输出用的余量留出来
max_token_limit = max_token_limit - 128
# 3. 如果余量太小了,直接清除历史
if max_token_limit < 128:
history = []
return history
else:
# 当输入部分的token占比 > 限制的3/4时,直接清除历史
history = []
return history
everything = ['']
everything.extend(history)
n_token = get_token_num('\n'.join(everything))
everything_token = [get_token_num(e) for e in everything]
# 截断时的颗粒度
delta = max(everything_token) // 16
while n_token > max_token_limit:
where = np.argmax(everything_token)
encoded = tokenizer.encode(everything[where], disallowed_special=())
clipped_encoded = encoded[:len(encoded)-delta]
everything[where] = tokenizer.decode(clipped_encoded)[:-1] # -1 to remove the may-be illegal char
everything_token[where] = get_token_num(everything[where])
n_token = get_token_num('\n'.join(everything))
history = everything[1:]
return history

查看文件

@@ -1,5 +1,5 @@
{ {
"version": 3.1, "version": 3.33,
"show_feature": true, "show_feature": true,
"new_feature": "添加支持清华ChatGLM和GPT-4 <-> 改进架构,支持与多个LLM模型同时对话 <-> 添加支持API2D国内,可支持gpt4<-> 支持多API-KEY负载均衡并列填写,逗号分割 <-> 添加输入区文本清除按键" "new_feature": "提供docker-compose方案兼容LLAMA盘古RWKV等模型的后端 <-> 新增Live2D WAIFU装饰 <-> 完善对话历史的保存/载入/删除 <-> ChatGLM加线程锁提高并发稳定性 <-> 支持NewBing <-> Markdown翻译功能支持直接输入Readme文件网址 <-> 保存对话功能 <-> 解读任意语言代码+同时询问任意的LLM组合 <-> 添加联网Google回答问题插件 <-> 修复ChatGLM上下文BUG <-> 添加支持清华ChatGLM"
} }