Compare commits

..

531 Commits

Author SHA1 Message Date
66bdf8b29a Delete 润色.gif 2023-04-14 15:53:01 +08:00
72a034a1ff Delete 公式.gif 2023-04-14 15:52:53 +08:00
faaa3bb1b6 Update README.md 2023-04-14 15:52:01 +08:00
0485d01d67 Update README.md 2023-04-14 15:41:44 +08:00
f48914f56d Update README.md 2023-04-14 15:38:06 +08:00
443f23521c Update README.md 2023-04-14 15:34:45 +08:00
cd6a1fd399 当无法正常切割PDF文档时,强制切割 2023-04-14 13:52:56 +08:00
f10ea20351 延长遇到Rate limit reached时的等待时间 2023-04-14 13:15:42 +08:00
2e044d97c7 更新提示 2023-04-14 13:10:40 +08:00
ea7fd53a97 OpenAI缩减了免费用户的请求速率限制 2023-04-14 13:08:19 +08:00
b2fba01487 把函数插件并行数量限制放到config中 2023-04-14 12:52:47 +08:00
fb3d0948a0 修改注释 2023-04-14 12:30:43 +08:00
c8349e766b 削减默认的最大线程数到5 2023-04-14 12:28:25 +08:00
de8d20bcc2 修改部分注释 2023-04-14 12:23:05 +08:00
512e3f7a32 修改注释 2023-04-14 12:05:22 +08:00
717fae8984 修改提示 2023-04-14 12:02:10 +08:00
2b352de7df 修改提示 2023-04-14 12:01:49 +08:00
bc3f3429a5 源代码文件数量限制 1024 个 2023-04-14 11:57:27 +08:00
7e14229229 Update issue templates 2023-04-14 11:45:25 +08:00
2aab3acfea 2.68 2023-04-14 10:33:53 +08:00
dd648bd446 disallow special token + limit num of file < 512 2023-04-14 09:50:14 +08:00
a2002ebd85 Update README.md 2023-04-13 17:05:01 +08:00
ff50f30669 Update README.md 2023-04-13 17:01:47 +08:00
0ac7734c7d Delete Dockerfile+ChatGLM 2023-04-13 16:36:08 +08:00
23686bfc77 Update README.md 2023-04-13 15:41:47 +08:00
7e541a7229 Update README.md 2023-04-13 15:40:45 +08:00
5c251f03eb Update README.md 2023-04-13 15:29:27 +08:00
0c21b1edd9 Delete objdump.tmp 2023-04-13 15:26:40 +08:00
0c58795a5e Update README.md 2023-04-13 13:49:54 +08:00
a70c08a3c4 更新readme 2023-04-13 13:43:05 +08:00
2712d99d08 添加Markdown全文翻译插件,并用此插件翻译了本项目的README 2023-04-13 13:40:13 +08:00
76ee4c2c55 Merge branch 'master' of https://github.com/binary-husky/chatgpt_academic into master 2023-04-13 12:46:34 +08:00
fc222bf287 Lua工程解析+修正注释 2023-04-13 12:46:31 +08:00
eee5763b15 Update requirements.txt 2023-04-13 12:27:28 +08:00
ff55bbd498 Update README.md 2023-04-13 12:20:54 +08:00
703ff7f814 Update README.md 2023-04-13 12:17:59 +08:00
16f7a52207 Update 高级功能函数模板.py 2023-04-13 12:02:52 +08:00
7cad5fa594 Update README.md 2023-04-13 11:53:52 +08:00
0b1d833804 Merge pull request #436 from DDreame/patch-1
[fix]Update requirements.txt For fix
2023-04-13 11:47:19 +08:00
7d414f67f0 Merge pull request #439 from mrhblfx/patch-2
增加解析Lua项目
2023-04-13 11:45:42 +08:00
3e1cecd9f5 Merge pull request #438 from mrhblfx/patch-1
增加了解析Go项目匹配的文件: `go.mod`, `go.sum`, `go.work`
2023-04-13 11:44:03 +08:00
98724cd395 更新注释 2023-04-13 11:18:44 +08:00
8ac9b454e3 改善chatpdf的功能 2023-04-13 11:08:53 +08:00
5e602cabf5 Update crazy_functional.py 2023-04-12 22:44:07 +08:00
c6610b2aab 新增解析一个Lua项目 2023-04-12 22:39:31 +08:00
7e53cf7c7e 增加了解析Go项目匹配的文件: go.mod, go.sum, go.work 2023-04-12 22:33:34 +08:00
3d6e4ee3a7 [fix]Update requirements.txt For fix
Modify the version of Gradio, which does not support the color button when it is lower than version 3.24. On version 3.25, it fixes the issue https://github.com/gradio-app/gradio/issues/3716 and #371 .

修改一下gradio的版本,低于 3.24版本时不支持 color button,3.25则修复了 issue: #371https://github.com/gradio-app/gradio/issues/3716
2023-04-12 21:32:03 +08:00
613be5509b 启动ChatGPT+ChatGLM 2023-04-12 17:41:33 +08:00
d40fa20ce8 Merge branch 'master' of https://github.com/binary-husky/chatgpt_academic 2023-04-12 16:57:56 +08:00
40bd857c70 UTF8 Ignore read file errors 2023-04-12 16:57:01 +08:00
6e1976d9b8 Update README.md 2023-04-12 12:04:57 +08:00
88a86635c6 Update README.md 2023-04-12 11:21:20 +08:00
acbeebd18d Update README.md 2023-04-12 02:46:04 +08:00
7515863503 Update README.md 2023-04-12 02:41:43 +08:00
a1af5a99e0 Update README.md 2023-04-12 02:27:55 +08:00
84f6ee2fb7 Update README.md 2023-04-12 02:27:10 +08:00
c090df34fa Update README.md 2023-04-12 00:12:42 +08:00
3cb46534b6 Update README.md 2023-04-12 00:08:31 +08:00
c41eb0e997 移除故障代码说明 2023-04-11 21:19:31 +08:00
c43a3e6f59 默认关闭share
注意,由于国内 Gradio 的网络访问较为缓慢,启用 demo.queue().launch(share=True, inbrowser=True) 时所有网络会经过 Gradio 服务器转发,导致打字机体验大幅下降,现在默认启动方式已经改为 share=False,如有需要公网访问的需求,可以重新修改为 share=True 启动。
2023-04-11 21:13:21 +08:00
a8399d2727 Merge pull request #413 from liyishuai/patch-1
Dockerfile: unbuffer stdout
2023-04-11 20:15:10 +08:00
d41d0db810 Update README.md 2023-04-11 20:00:33 +08:00
19d6323801 Merge branch 'master' of https://github.com/binary-husky/chatgpt_academic into master 2023-04-11 19:59:09 +08:00
929c0afc9b 2.67 修复typo 2023-04-11 19:59:06 +08:00
3748979133 2.67 修复typo 2023-04-11 19:58:37 +08:00
6e8c5637aa Update README.md 2023-04-11 19:34:03 +08:00
f336ba060d Merge branch 'master' of https://github.com/binary-husky/chatgpt_academic into master 2023-04-11 19:32:02 +08:00
4fe4626608 修改功能说明 2023-04-11 19:31:57 +08:00
e6fbf13c67 Update README.md 2023-04-11 19:00:20 +08:00
6bc5cbce20 Update README.md 2023-04-11 18:58:16 +08:00
3c9d63c37b UP 2023-04-11 18:50:56 +08:00
93d5fc2f1a 修复 2023-04-11 18:49:22 +08:00
2f2ad59823 2.62 BUG 修复 2023-04-11 18:47:51 +08:00
b841d58a26 renew all 2023-04-11 18:36:38 +08:00
3d66e3eb79 UP 2023-04-11 18:23:59 +08:00
4dad114ce7 紧急bug修复 2023-04-11 18:16:33 +08:00
f8d565c5a1 紧急BUG修复 2023-04-11 18:15:26 +08:00
6bbc10f5b9 紧急bug修复 2023-04-11 18:12:31 +08:00
8bf2956ff7 version 2.6 2023-04-11 17:55:30 +08:00
270889a533 print change 2023-04-11 17:52:40 +08:00
a72b95d2b9 Merge branch 'dev_grand' of https://github.com/binary-husky/chatgpt_academic into dev_grand 2023-04-11 17:42:59 +08:00
7167c84394 修正解析源代码bug 2023-04-11 17:42:56 +08:00
d587189ceb 更正bug 2023-04-11 17:40:50 +08:00
4a4fb661df Dockerfile: two-stage copy 2023-04-11 17:25:30 +08:00
a7083873c0 界面重构 2023-04-11 15:31:46 +08:00
a13ed231d3 Dockerfile: unbuffer stdout 2023-04-11 15:30:40 +08:00
0b960df309 add arxiv dependency 2023-04-11 15:20:04 +08:00
42d366be94 修复chatbotwithcookies的对象传递问题 2023-04-11 15:17:00 +08:00
fc331681b4 移除陈旧函数 2023-04-11 14:45:00 +08:00
e965c36db3 Merge branch 'master' into dev_grand 2023-04-10 12:38:26 +08:00
ad208ff7cf Merge pull request #395 from HougeLangley/master
Added python-docx
2023-04-10 10:05:01 +08:00
1256387488 Added python-docx
解决在使用批量导入 .docx 文件是提示需要 pip install --upgrade python-docx 的问题
2023-04-10 01:06:34 +08:00
88919db63e Merge pull request #388 from WangRongsheng/master
update en2ch prompt
2023-04-10 00:39:54 +08:00
bc8415b905 翻译成地道的中文 2023-04-10 00:36:05 +08:00
21a3519c50 Merge branch 'master' of https://github.com/WangRongsheng/chatgpt_academic into WangRongsheng-master 2023-04-10 00:33:16 +08:00
a3dd982159 Merge pull request #389 from Ljp66/master
Update toolbox.py
2023-04-10 00:31:24 +08:00
f38929b149 +Latex全文中英互译插件 2023-04-10 00:29:53 +08:00
c8a9069ee3 强调中文 2023-04-10 00:21:20 +08:00
53b099e3a6 实验 2023-04-10 00:11:07 +08:00
0d387fa699 UP 2023-04-10 00:05:46 +08:00
acf0349215 更新提示 2023-04-10 00:00:03 +08:00
869de46078 自动更新程序+自动pip包安装 2023-04-09 23:56:24 +08:00
6ce9b724ec 修正prompt 2023-04-09 23:32:32 +08:00
49a6ff6a7c Latex全文润色 2023-04-09 23:28:57 +08:00
3725122de1 增加临时输入api-key的功能 2023-04-09 21:23:21 +08:00
1f6defedfc UP 2023-04-09 20:50:33 +08:00
0666fec86e 增扩框架的参数IO 2023-04-09 20:42:23 +08:00
ea031ab05b st 2023-04-09 19:49:42 +08:00
47445fdc90 declare depriction 2023-04-09 19:02:18 +08:00
e6cf5532a9 提升稳定性 2023-04-09 18:59:43 +08:00
d741f884c5 Delete core_functional.py 2023-04-09 11:55:27 +08:00
58db0b04fa Update toolbox.py
remove duplicate "import importlib"
2023-04-09 11:55:00 +08:00
c5ce25d581 update en2ch prompt 2023-04-09 11:45:34 +08:00
53cfed89d5 update en2ch prompt 2023-04-09 11:38:37 +08:00
3592a0de11 Update version 2023-04-08 22:51:37 +08:00
91d07c329a version 2.5 2023-04-08 22:27:02 +08:00
ab373c5bf7 移动参数位置 2023-04-08 22:16:33 +08:00
f714bfc59f 错别字 2023-04-08 22:15:33 +08:00
09ab60c46d up 2023-04-08 22:14:05 +08:00
6383113e85 加入自动更新协议 2023-04-08 02:48:35 +08:00
d52b4d6dbb 显示版本 2023-04-08 02:39:54 +08:00
2f9ec385c9 自动更新程序 2023-04-08 02:38:02 +08:00
3249b31155 多种接口 2023-04-08 00:51:58 +08:00
9cd15c6f88 新插件移动到插件菜单中 2023-04-08 00:42:54 +08:00
300484f301 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-08 00:41:46 +08:00
476a174320 代码高亮开关 2023-04-08 00:41:39 +08:00
b475a4f32a Merge pull request #366 from Hanzoe/master
new function: 实现单篇PDF论文翻译理解
2023-04-08 00:41:03 +08:00
c07196698e Update README.md 2023-04-08 00:32:22 +08:00
e371b82ea3 更新requirements.txt实现代码高亮必要 2023-04-08 00:23:26 +08:00
3de941ee5e Fix dockerfile 2023-04-08 00:01:11 +08:00
2120c074c1 version 2.45 2023-04-07 23:58:10 +08:00
8dbae2c68a Merge branch 'master' into dev 2023-04-07 23:55:19 +08:00
50dfccc010 新增谷歌学术统合小助手 2023-04-07 23:54:24 +08:00
036bd93115 version 2.43 2023-04-07 22:08:05 +08:00
b7dca67f6e 处理多线程中出现的网络问题 2023-04-07 22:06:08 +08:00
33dcbf5093 Update crazy_functional.py 2023-04-07 21:35:36 +08:00
a5785446c0 Add files via upload 2023-04-07 21:34:55 +08:00
8a83f8315b Merge pull request #1 from binary-husky/master
单篇论文翻译理解
2023-04-07 21:34:11 +08:00
9344c414b6 Merge branch 'dev' of github.com:binary-husky/chatgpt_academic into dev 2023-04-07 21:09:43 +08:00
042d06846b highlight 2023-04-07 21:09:37 +08:00
2a8d6e1d53 highlight 2023-04-07 21:08:34 +08:00
ce1cf491b6 Merge branch 'dev' of github.com:binary-husky/chatgpt_academic into dev 2023-04-07 21:00:32 +08:00
28a4188332 Merge branch 'master' into dev 2023-04-07 20:59:35 +08:00
e2770fe37f 代码、公式高亮 2023-04-07 20:30:30 +08:00
c2dcab0e12 Merge branch 'master' of https://github.com/binary-husky/chatgpt_academic into master 2023-04-07 19:26:20 +08:00
8597dba5f2 修复小BUG 2023-04-07 19:26:17 +08:00
1f09afcb8f Update README.md 2023-04-07 19:09:18 +08:00
533359e19f Update README.md 2023-04-07 19:08:41 +08:00
2e3f6b3126 正确显示列表序号 2023-04-07 18:33:46 +08:00
3d3d259125 Update toolbox.py 2023-04-07 18:27:52 +08:00
fffa536303 Update README.md 2023-04-07 18:21:13 +08:00
2df4742815 修复公式显示错误 2023-04-07 18:14:27 +08:00
9ca7a90590 fix equation 2023-04-07 17:55:24 +08:00
d1a18d293a 更新requirements.txt 2023-04-07 12:45:47 +08:00
769f2fe7d7 Update README.md 2023-04-06 19:24:37 +08:00
991cd29395 Update README.md 2023-04-06 19:15:58 +08:00
9a12adf853 Update README.md 2023-04-06 18:55:16 +08:00
928bef8983 Update README.md 2023-04-06 18:49:49 +08:00
f14aa4818a 改善提示 2023-04-06 18:45:24 +08:00
a4d731b190 替换基础函数 2023-04-06 18:41:04 +08:00
0079733bfd 主要代码规整化 2023-04-06 18:29:49 +08:00
1055fdaab7 小问题修复 2023-04-06 18:26:46 +08:00
0b3f7b8821 format file 2023-04-06 18:15:11 +08:00
e8cf757dc0 修复完成后的文件显示问题 2023-04-06 18:13:16 +08:00
06f8094a0a fix error 2023-04-06 17:23:26 +08:00
d4ed4efa03 Merge branch 'dev_ui' of https://github.com/binary-husky/chatgpt_academic into dev_ui 2023-04-06 17:19:28 +08:00
aa7574dcec change UI 2023-04-06 17:19:25 +08:00
62a946e499 change UI 2023-04-06 17:18:30 +08:00
0b2b0a83d6 change UI 2023-04-06 17:17:31 +08:00
f8b2524aa3 恢复模板函数 2023-04-06 17:15:13 +08:00
079916f56c 修正打印提示 2023-04-06 16:59:52 +08:00
1da77af2a2 update self_analysis 2023-04-06 16:33:01 +08:00
946481b774 2.4版本 2023-04-06 16:13:56 +08:00
d32a52c8e9 End 2023-04-06 03:43:53 +08:00
85d85d850a update 2023-04-06 03:30:02 +08:00
dcaa7a1808 重命名一些函数 2023-04-06 02:02:04 +08:00
785893b64f 修改文件命名 2023-04-05 16:19:35 +08:00
8aa2b48816 Merge remote-tracking branch 'origin/master' into dev_ui 2023-04-05 14:35:46 +08:00
3269f430ff Update README.md 2023-04-05 14:34:43 +08:00
dad6a64194 Update README.md 2023-04-05 14:09:56 +08:00
2126a5ce74 Update README.md 2023-04-05 14:09:35 +08:00
7ee257a854 Update README.md 2023-04-05 14:07:59 +08:00
ddb39453fd 处理没有文件返回的问题 2023-04-05 02:15:47 +08:00
eda3c6d345 BUG FIX 2023-04-05 01:58:34 +08:00
745734b601 改进效率 2023-04-05 00:25:53 +08:00
2bb1f3dd30 Merge branch 'dev_ui' of https://github.com/binary-husky/chatgpt_academic into dev_ui 2023-04-05 00:15:09 +08:00
82952882eb BUG FIX 2023-04-05 00:11:12 +08:00
971b45f332 BUG FIX 2023-04-05 00:10:06 +08:00
04504b1d99 Bug Fix: Hot Reload Wapper For All 2023-04-05 00:09:13 +08:00
85e71f8a71 参数输入bug修复 2023-04-05 00:07:08 +08:00
c96a253568 支持更多界面布局的切换 2023-04-04 23:46:47 +08:00
24780ee628 merge 2023-04-04 22:56:06 +08:00
b87bfeaddb check_new_version 2023-04-04 22:54:08 +08:00
effa1421b4 Update version 2023-04-04 22:34:28 +08:00
3d95e42dc8 Update version 2023-04-04 22:20:39 +08:00
602fbb08da Update version 2023-04-04 22:20:21 +08:00
7f0393b2b0 Update version 2023-04-04 22:17:47 +08:00
79c617e437 规划版本号 2023-04-04 21:38:20 +08:00
e5bd6186d5 Update issue templates 2023-04-04 17:13:40 +08:00
2418c45159 Update README.md 2023-04-04 15:33:53 +08:00
3aa446cf19 修复代码英文重构Bug 2023-04-04 15:23:42 +08:00
23c1b14ca3 默认暗色护眼主题 2023-04-03 20:56:00 +08:00
f1b0e5f0f7 Merge pull request #290 from LiZheGuang/master
fix: 🐛 修复react解析项目不显示在下拉列表的问题
2023-04-03 17:58:28 +08:00
535525e9d5 fix: 🐛 修复react解析项目不显示在下拉列表的问题 2023-04-03 17:44:09 +08:00
c54be726bf Update issue templates 2023-04-03 17:00:51 +08:00
858c40b0a5 update README 2023-04-03 09:32:01 +08:00
ed33bf5a15 Update README.md 2023-04-03 01:49:40 +08:00
1b793e3397 Update README.md 2023-04-03 01:47:49 +08:00
f58f4fbbf8 Update README.md 2023-04-03 01:39:17 +08:00
b1ed86ee7d Update README.md 2023-04-03 01:38:44 +08:00
5570b94ad1 Update README.md 2023-04-03 01:03:00 +08:00
5aab515bac Update README.md 2023-04-03 01:01:57 +08:00
9b45a66137 Update README.md 2023-04-02 22:15:12 +08:00
7658842bdd Update README.md 2023-04-02 22:04:33 +08:00
a96a865265 Update config.py 2023-04-02 22:02:41 +08:00
ad48645db9 Update README.md 2023-04-02 21:51:41 +08:00
80fed7135a Update README.md 2023-04-02 21:44:44 +08:00
5e003070cd Update README.md 2023-04-02 21:41:36 +08:00
a10a23e347 Update README.md 2023-04-02 21:39:28 +08:00
c2062c05cb Update README.md 2023-04-02 21:33:09 +08:00
2dd674b0b3 Update README.md 2023-04-02 21:31:44 +08:00
88e92bfd8c Update README.md 2023-04-02 21:28:59 +08:00
872888d957 Update README.md 2023-04-02 21:27:19 +08:00
dcbfabf657 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-04-02 20:35:16 +08:00
75754718c1 #236 2023-04-02 20:35:09 +08:00
97193065f6 remove verbose print 2023-04-02 20:22:11 +08:00
a999487b8e CHATBOT_HEIGHT - 1 2023-04-02 20:20:37 +08:00
c330fa6be1 return None instead of [] when no file is concluded 2023-04-02 20:18:58 +08:00
5b9de09c11 +异常处理 2023-04-02 20:03:25 +08:00
01265c5934 微调theme 2023-04-02 20:02:47 +08:00
4888656a72 Update README.md 2023-04-02 16:55:18 +08:00
4556559e53 Merge branch 'CSS' of https://github.com/Keldos-Li/chatgpt_academic (#236) 2023-04-02 16:01:35 +08:00
900b752e61 修改按钮提示 2023-04-02 15:48:54 +08:00
174146b5d7 Merge pull request #253 from RongkangXiong/dev
add crazy_functions 解析一个Java项目
2023-04-02 15:40:03 +08:00
3387b5acb0 添加Golang、Java等项目的支持 2023-04-02 15:33:09 +08:00
bf3eb0bfab 加入 arxiv 小助手插件 2023-04-02 15:19:21 +08:00
9540cf9448 add crazy_functions 解析一个Rect项目 2023-04-02 03:07:21 +08:00
55ef4acea9 add crazy_functions 解析一个Java项目 2023-04-02 02:59:03 +08:00
8e0f401bf3 Merge branch 'master' into dev 2023-04-02 01:24:03 +08:00
99e13e5895 update 2023-04-02 01:23:15 +08:00
190b547373 stage llm model interface 2023-04-02 01:18:51 +08:00
eee4cb361c q 2023-04-02 00:51:17 +08:00
2420d62a33 接入TGUI 2023-04-02 00:40:05 +08:00
3af0bbdbe4 成功借助tgui调用更多LLM 2023-04-02 00:22:41 +08:00
bfa6661367 up 2023-04-01 23:46:32 +08:00
d79dfe2fc7 wait new pr 2023-04-01 21:56:55 +08:00
919b15b242 修改文件名 2023-04-01 21:45:58 +08:00
a469d8714d fix: 修正CSS中的注释解决列表显示
- 同时使用.markdown-body缩限了css作用域
2023-04-01 20:34:18 +08:00
15d9d9a307 Update README.md 2023-04-01 20:21:31 +08:00
a8bd564cd1 advanced theme 2023-04-01 19:48:14 +08:00
a51cfbc625 新的arxiv论文插件 2023-04-01 19:43:56 +08:00
d10fec81fa Merge pull request #239 from ylsislove/golang-code-analysis
feat: add function to parse Golang projects
2023-04-01 19:42:06 +08:00
a0841c6e6c Update functional_crazy.py 2023-04-01 19:37:39 +08:00
594f4b24f6 feat: add function to parse Golang projects
This commit adds a new function to parse Golang projects to the collection of crazy functions.
2023-04-01 19:19:36 +08:00
629d022e8a fix bug 2023-04-01 19:07:58 +08:00
c5355a9ca4 README 2023-04-01 18:07:26 +08:00
0218efaae7 Typo in Prompt 2023-04-01 17:29:30 +08:00
1533c4b604 python3.7 compat 2023-04-01 17:11:59 +08:00
b64596de0e feat: 调整表格样式 2023-04-01 16:58:51 +08:00
9752af934e feat: 使用CSS完善表格、列表、代码块、对话气泡显示样式
移植了 川虎ChatGPT 的CSS——但是川虎ChatGPT的CSS也是我写的~
2023-04-01 16:51:38 +08:00
70d9300972 README up 2023-04-01 16:36:57 +08:00
47ea28693a update README 2023-04-01 16:35:45 +08:00
172eb4a977 Merge branch 'dev' 2023-04-01 16:31:57 +08:00
666a7448a0 Update README.md 2023-04-01 04:25:03 +08:00
9ce3497183 Update README.md 2023-04-01 04:19:02 +08:00
2c963cc368 交互优化 2023-04-01 04:11:31 +08:00
b0dfef48e9 将css样式移动到theme文件,减少main.py的代码行数 2023-04-01 03:39:43 +08:00
c85923b17b Merge pull request #209 from jr-shen/dev-1
(1)修改语法检查的prompt,确保输出格式统一。

之前使用时经常发现输出没有把修改的部分加粗,或者在表格中把整段文字输出了,影响阅读。因此在之前的prompt基础上增加了一个example,确保输出格式统一。

(2)表格内增加了边框线,使行/列之间的分隔更清楚。

使用时发现没有边框的表格在里面文字较多时难以区分。因此增加表格内边框线。
2023-04-01 03:37:02 +08:00
5e8eb6253c 优化Token溢出时的处理 2023-04-01 03:36:05 +08:00
833d136fb9 隐藏、显示功能区 2023-04-01 00:21:27 +08:00
753f9d50ff 更清朗些的UI 2023-03-31 23:54:25 +08:00
9ad21838fe 更清朗的UI 2023-03-31 23:51:17 +08:00
7b8de7884f add markdown table border line to make text boundary more clear 2023-03-31 23:40:21 +08:00
b5b0f6a3ce make grammar correction prompt more clear 2023-03-31 23:38:49 +08:00
44a605e766 对word和pdf进行简易的支持 2023-03-31 23:18:45 +08:00
939dfa6ac9 Merge branch 'master' into dev 2023-03-31 23:08:30 +08:00
8c3a8a2e3b Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-03-31 22:49:45 +08:00
d58802af01 修复bug 2023-03-31 22:49:39 +08:00
9593b0d09d 优化自译解功能 2023-03-31 22:36:46 +08:00
f7d50cd9fa Update README.md 2023-03-31 21:48:45 +08:00
14a7d00037 移动函数到调用模组 2023-03-31 21:46:47 +08:00
94e75d2718 Merge pull request #204 from Eralien/dev-clean_pdf
feat: clean pdf fitz text
2023-03-31 21:42:18 +08:00
6fc2423ae3 add contributor 2023-03-31 21:41:17 +08:00
da8cb77314 Merge pull request #147 from JasonGuo1/master
feat(toolbox.py,总结word文档.py): 支持rar格式与7z格式解压;word读取
2023-03-31 21:39:05 +08:00
a87ce5bb77 JasonGuo1 2023-03-31 21:37:46 +08:00
a098d08750 Merge branch 'master' of https://github.com/JasonGuo1/chatgpt_academic into JasonGuo1-master 2023-03-31 21:31:31 +08:00
ab879ca4b7 feat: clean pdf fitz text 2023-03-31 21:26:55 +08:00
dde672c63d Merge pull request #117 from XMB-7/better_prompt
feat: better prompt
2023-03-31 21:19:25 +08:00
030bfb4568 Merge branch 'better_prompt' of https://github.com/XMB-7/chatgpt_academic into XMB-7-better_prompt 2023-03-31 21:18:28 +08:00
149ef28071 Merge pull request #174 from Euclid-Jie/Euclid_Test
feature(read pdf paper then write summary)
2023-03-31 21:06:02 +08:00
16caf34800 整合 2023-03-31 21:05:18 +08:00
666dde9f74 Merge branch 'dev' into Euclid-Jie-Euclid_Test 2023-03-31 21:03:43 +08:00
167be41621 pdfminer整合到一个文件中 2023-03-31 21:03:12 +08:00
a71edeea95 Merge branch 'Euclid_Test' of https://github.com/Euclid-Jie/chatgpt_academic into Euclid-Jie-Euclid_Test 2023-03-31 20:26:59 +08:00
87c09368da 修改文本 2023-03-31 20:12:27 +08:00
72f23cbbef fix import error 2023-03-31 20:05:31 +08:00
a3952be1cb Merge branch 'dev' of github.com:binary-husky/chatgpt_academic into dev 2023-03-31 20:04:11 +08:00
fa7464ae44 config新增说明 2023-03-31 20:02:12 +08:00
e5cc1eacd7 Merge pull request #194 from fulyaec/enhance-chataca
修改AUTHENTICATION的判断,使得AUTHENTICATION为None/[]/""时都可以正确判断
2023-03-31 19:49:40 +08:00
60506eff9f revert toolbox 2023-03-31 19:46:01 +08:00
b655feedde Merge branch 'enhance-chataca' of https://github.com/fulyaec/chatgpt_academic into fulyaec-enhance-chataca 2023-03-31 19:45:23 +08:00
e04d57cddd Merge pull request #198 from oneLuckyman/feature-match-API_KEY
一个小改进:更精准的 API_KEY 确认机制
2023-03-31 19:28:21 +08:00
739cec9ab9 Merge remote-tracking branch 'origin/hot-reload-test' 2023-03-31 19:21:15 +08:00
0b03c797bc 使用 re 模块的 match 函数可以更精准的匹配和确认 API_KEY 是否正确 2023-03-31 17:38:39 +08:00
cec44805a5 refactor and enhance 2023-03-31 16:24:40 +08:00
a88a42799f Update main.py 2023-03-31 13:33:03 +08:00
36890a14bf Update README.md 2023-03-31 13:29:37 +08:00
dca98d404b Update README.md 2023-03-31 13:11:10 +08:00
db8c8afd74 fix(the ".PDF" file can not be recognized): 2023-03-31 10:26:40 +08:00
125fa7c378 fix(fix "gbk" encode error in 批量总结PDF文档 line14):
由于不可编码字符,导致报错,添加软解码,处理原始文本。
2023-03-31 10:03:10 +08:00
285fa4690c feature(read pdf paper then write summary):
add a func called readPdf in toolbox, which can read pdf paper to str. then use bs4.BeautifulSoup to clean content.
2023-03-31 00:54:01 +08:00
380bfe6984 Merge pull request #171 from RoderickChan/add-deploy-instruction
在README中添加远程部署的指导
2023-03-31 00:00:35 +08:00
badf4090c5 Update README.md 2023-03-30 23:59:01 +08:00
a3d179c2fa Update README.md 2023-03-30 23:34:17 +08:00
9564a5e113 在README中添加远程部署的指导方案 2023-03-30 23:31:44 +08:00
ac4fce05cf feat(总结word文档):增加读取docx、doc格式的功能 2023-03-30 23:23:41 +08:00
fda48fd37d 添加Wiki链接 2023-03-30 23:09:45 +08:00
44e77dc741 feat(toolbox):调整了空格的问题 2023-03-30 20:28:15 +08:00
5d03dd37d2 Merge pull request #151 from SadPencil/patch-1
Fix a typo
2023-03-30 19:14:48 +08:00
ba0c17ba53 自译解报告 2023-03-30 18:21:17 +08:00
cd421d8074 Merge branch 'hot-reload-test' of https://github.com/binary-husky/chatgpt_academic into hot-reload-test 2023-03-30 18:05:03 +08:00
363e45508b 新增热更新功能 2023-03-30 18:04:20 +08:00
b073477905 新增热更新功能 2023-03-30 18:01:06 +08:00
743d18cd98 Fix a typo 2023-03-30 15:55:46 +08:00
80e0c4e388 feat(toolbox): 支持rar格式与7z格式解压,修改了下注释 2023-03-30 15:48:55 +08:00
6d8c8cd3f0 feat(toolbox): 支持rar格式与7z格式解压,修改了下注释 2023-03-30 15:48:00 +08:00
d57d529aa1 feat(toolbox): 支持rar格式与7z格式解压,修改了下注释 2023-03-30 15:47:18 +08:00
e470ee1f7f feat(toolbox): 支持rar格式与7z格式解压,修改了下注释 2023-03-30 15:45:58 +08:00
a360cd7e74 feat(支持rar格式与7z格式解压) 2023-03-30 15:24:01 +08:00
16ce033d86 Update README.md 2023-03-30 14:48:46 +08:00
81b0118730 Update README.md 2023-03-30 14:48:20 +08:00
35847e4ec4 Update README.md 2023-03-30 14:47:19 +08:00
1f7f71c6b9 Update README.md 2023-03-30 14:08:24 +08:00
06a04f14d8 Update README.md 2023-03-30 13:24:30 +08:00
c21bdaae52 Merge pull request #124 from Freddd13/master
feat: 添加wsl2使用windows proxy的方法
2023-03-30 12:56:13 +08:00
44155bcc24 查找语法错误之前先清除换行符 2023-03-30 12:52:28 +08:00
4d02ea9863 语法错误查找prompt更新 2023-03-30 12:16:18 +08:00
82742f3ea5 up 2023-03-30 11:51:55 +08:00
6dd83fb1b4 标准化代码格式 2023-03-30 11:50:11 +08:00
2bf30d8a1e 修改配置的读取方式 2023-03-30 11:05:38 +08:00
0b1f351cba update: 修改readme 2023-03-30 02:00:15 +08:00
0975b60c72 Merge remote-tracking branch 'upstream/master' 2023-03-30 01:58:39 +08:00
e3d763acff feat: 支持wsl2使用windows proxy 2023-03-30 01:47:39 +08:00
51c612920d Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-03-30 00:15:37 +08:00
bfdc2dee9a change UI layout 2023-03-30 00:15:31 +08:00
3c5122b529 Update README.md 2023-03-30 00:09:58 +08:00
97cd98d5a2 better prompt 2023-03-30 00:06:02 +08:00
bd4bf71c4b Update README.md 2023-03-29 23:53:33 +08:00
9598029620 Update README.md 2023-03-29 23:50:20 +08:00
d6e4fc27ad Update README.md 2023-03-29 23:48:58 +08:00
e4b3523947 Update README.md 2023-03-29 23:44:37 +08:00
ad75886941 Update README.md 2023-03-29 23:44:01 +08:00
83fef07f58 Merge pull request #108 from sjiang95/condainstall
readme: update
2023-03-29 23:22:44 +08:00
3134e13d87 Merge branch 'dev' 2023-03-29 23:15:29 +08:00
48cc477e48 Merge pull request #102 from ValeriaWong/master
feat(读文章写摘要):支持pdf文件批量阅读及总结 #101
2023-03-29 23:14:12 +08:00
77e34565e6 change UI layout 2023-03-29 23:04:37 +08:00
dc4fe3f8c2 change ui layout 2023-03-29 23:00:16 +08:00
4698ec6b98 Merge https://github.com/ValeriaWong/chatgpt_academic into ValeriaWong-master 2023-03-29 21:49:56 +08:00
a6c4b8d764 add pip package check 2023-03-29 21:47:56 +08:00
92d4400d19 Merge branch 'master' of https://github.com/ValeriaWong/chatgpt_academic 2023-03-29 21:44:59 +08:00
11c641748f readme: update
Re-format a part of the markdown content
and add conda instruction for installation.

Signed-off-by: Shengjiang Quan <qsj287068067@126.com>
2023-03-29 22:36:15 +09:00
6867c5eed4 Merge branch 'master' of https://github.com/ValeriaWong/chatgpt_academic 2023-03-29 21:05:25 +08:00
5c6d272950 Merge branch 'binary-husky:master' into master 2023-03-29 20:57:07 +08:00
0f28564fea feat(读文章写摘要):支持pdf文件批量阅读及总结 #101 2023-03-29 20:55:13 +08:00
403dd2fa59 Update main.py 2023-03-29 20:47:34 +08:00
3ac330dff1 bug quick fix 2023-03-29 20:41:07 +08:00
cbcdd39239 Merge pull request #82 from Okabe-Rintarou-0/master
支持暂停按钮 #53
2023-03-29 20:38:06 +08:00
e79b0c0835 提交后不清空输入栏,添加停止键 2023-03-29 20:36:58 +08:00
730cd1e0e3 Merge branch 'master' of https://github.com/Okabe-Rintarou-0/chatgpt_academic into Okabe-Rintarou-0-master 2023-03-29 20:26:13 +08:00
c78254cd86 Merge branch 'master' of https://github.com/Okabe-Rintarou-0/chatgpt_academic into Okabe-Rintarou-0-master 2023-03-29 20:07:38 +08:00
23776b90b9 handle ip location lookup error 2023-03-29 19:37:39 +08:00
8849095776 Merge pull request #87 from Okabe-Rintarou-0/fix-markdown-display
正确显示多行输入的 markdown #84
2023-03-29 19:32:19 +08:00
8f60e962de Merge pull request #96 from eltociear/patch-1
fix typo in predict.py
2023-03-29 18:47:51 +08:00
b100680f72 新增代理配置说明 2023-03-29 18:07:33 +08:00
5d22785e5a fix typo in predict.py
refleshing -> refreshing
2023-03-29 18:57:37 +09:00
3f635bc4aa feat(读文章写摘要):支持pdf文件批量阅读及总结 2023-03-29 17:57:17 +08:00
17abd29d50 error message change 2023-03-29 16:50:37 +08:00
4699395425 dev 2023-03-29 16:47:15 +08:00
33adfc35df fix: markdown display bug #84 2023-03-29 15:29:40 +08:00
4b21ebdba6 feat: support stop generate button (#53) 2023-03-29 14:53:53 +08:00
17d9a060d8 fix directory return bug 2023-03-29 14:28:57 +08:00
7d5aaa5aee update comments 2023-03-29 14:16:59 +08:00
67215bcec5 修复变量名 2023-03-29 13:58:30 +08:00
e381dce78c Merge remote-tracking branch 'origin/test-3-29' 2023-03-29 13:44:57 +08:00
4d70bc0288 config comments 2023-03-29 13:43:07 +08:00
c90391a902 Update README.md 2023-03-29 13:38:43 +08:00
4e06c350bf Merge pull request #57 from GaiZhenbiao/master
Adding a bunch of nice-to-have features
2023-03-29 13:37:58 +08:00
3981555466 Merge branch 'test-3-29' of github.com:binary-husky/chatgpt_academic into test-3-29 2023-03-29 12:29:52 +08:00
403d66c3c2 优化Unsplash API的使用 2023-03-29 12:28:45 +08:00
6ed2b259db 优化Unsplash API的使用 2023-03-29 12:27:47 +08:00
2bedba2e17 历史上的今天,带图片 2023-03-29 12:21:47 +08:00
ebf365841e 更新一个更有意思的模板函数 2023-03-29 11:36:55 +08:00
e76d8cfbc2 [实验] 历史上的今天(高级函数demo) 2023-03-29 11:34:03 +08:00
71d2f01685 bug fix 2023-03-29 01:42:11 +08:00
6f1e9b63c2 change description 2023-03-29 01:39:15 +08:00
d0e3ca7671 更好的多线程交互性 2023-03-29 01:32:28 +08:00
61b4ea6d1b introduce project self-translation 2023-03-29 01:11:53 +08:00
1805f081d3 增加“重置”按钮,提交之后自动清空输入框 2023-03-28 23:33:19 +08:00
17c6524b8d temprature的取值范围为[0, 2] 2023-03-28 23:20:54 +08:00
c7e1b86b52 增加并行处理与权限控制 2023-03-28 23:17:12 +08:00
51bde973a1 simplify codes 2023-03-28 23:09:25 +08:00
954bc36d76 Improve the way to open webbrowser 2023-03-28 22:47:30 +08:00
c06c60b977 界面色彩自定义 2023-03-28 22:35:55 +08:00
b9f1a89812 explain color and theme 2023-03-28 22:31:43 +08:00
67d1d88ebd Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-03-28 22:25:27 +08:00
9ac1068f56 remove .vscode from git 2023-03-28 22:24:59 +08:00
9a1d4a0d72 update todo 2023-03-28 22:10:22 +08:00
043a9ea068 fix unicode bug 2023-03-28 20:31:44 +08:00
256e61b64d Merge pull request #46 from mambaHu/master
Markdown analysis report garbled issue
2023-03-28 20:04:01 +08:00
b9f2792983 improving garbled words issue with utf8 2023-03-28 19:34:18 +08:00
28cd1dbf98 Delete jpeg-compressor.tps 2023-03-28 17:21:14 +08:00
e1ee65eb66 Delete JpegLibrary.tps 2023-03-28 17:21:06 +08:00
d19127b5a9 Delete UElibJPG.Build.cs 2023-03-28 17:20:54 +08:00
2cb1effd45 theme 2023-03-28 12:59:31 +08:00
7b48bdf880 o 2023-03-28 12:53:05 +08:00
8f7d9ad2d7 Update README.md 2023-03-28 01:36:15 +08:00
6ef2280281 Update README.md 2023-03-28 01:13:55 +08:00
d26fa46b27 http post error show 2023-03-27 18:25:07 +08:00
da19fa1992 bug fix 2023-03-27 15:16:50 +08:00
ab05cf6a01 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-03-27 15:14:12 +08:00
d08edf7801 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-03-27 15:14:05 +08:00
fab0c5dd63 Update README.md 2023-03-27 15:09:02 +08:00
cefd025700 Update README.md 2023-03-27 15:01:49 +08:00
e0aa6389cf Update README.md 2023-03-27 15:01:07 +08:00
e2618a0d3e Update README.md 2023-03-27 14:57:12 +08:00
39dde3b803 Update README.md 2023-03-27 14:56:32 +08:00
ec41c1e9f3 Update README.md 2023-03-27 14:56:20 +08:00
098eff8c68 Update README.md 2023-03-27 14:56:03 +08:00
127588c624 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-03-27 14:53:46 +08:00
e341596d4b up 2023-03-27 14:51:05 +08:00
84dd6084cf Update README.md 2023-03-27 14:47:52 +08:00
5ab4ba2db2 Update README.md 2023-03-27 14:45:32 +08:00
d9686ef25e Update README.md 2023-03-27 13:47:08 +08:00
01e42acfe4 Update README.md 2023-03-27 13:45:08 +08:00
9de97da5e3 UI change 2023-03-27 13:24:29 +08:00
81741bc3f6 file IO 2023-03-27 13:01:22 +08:00
9c5cf2b1f7 localFileToRemote 2023-03-27 11:29:11 +08:00
6bc7f95633 Merge branch 'test-3-26' 2023-03-26 20:21:39 +08:00
29c1c898ba Merge pull request #10 from ifyz/patch-1
Update main.py
2023-03-26 20:21:14 +08:00
79914bb6aa fix dockerfile 2023-03-26 20:18:55 +08:00
56bf460c97 Update main.py 2023-03-26 20:11:44 +08:00
c22b4c39a2 UI 2023-03-26 20:10:14 +08:00
6d55c4fbe1 调整样式 2023-03-26 20:04:59 +08:00
f76ec644bf up 2023-03-26 19:32:04 +08:00
66dfd11efe Merge branch 'ifyz-patch-1' into test-3-26 2023-03-26 19:14:49 +08:00
d4a3566b21 Merge branch 'patch-1' of https://github.com/ifyz/chatgpt_academic into ifyz-patch-1 2023-03-26 19:14:27 +08:00
f04d9755bf add comments 2023-03-26 19:13:58 +08:00
bb8b0567ac Update main.py
使用全局变量,禁用Gradio 的分析功能。解决国内用户因调用GoogleAnalytics导致的加载缓慢。
使用本地字体,修改Gradio默认从Googleapis调用字体。从而解决用户由于国内网络环境打开首页缓慢的问题。
2023-03-26 17:11:58 +08:00
dc58745f4c Update main.py
使用本地字体,修改Gradio默认从Googleapis调用字体。从而解决用户由于国内网络环境打开首页缓慢的问题。
2023-03-26 15:48:16 +08:00
6505fea0b7 Merge branch 'master' of https://github.com/binary-husky/chatgpt_academic into master 2023-03-24 21:03:33 +08:00
652a153b3c Update README.md 2023-03-24 21:03:09 +08:00
877283ec05 Update README.md 2023-03-24 21:02:02 +08:00
5772fae7c5 trim button text 2023-03-24 20:56:34 +08:00
d6ced8bfac Update predict.py 2023-03-24 19:54:52 +08:00
f138b13024 Update .gitattributes 2023-03-24 19:51:52 +08:00
c31f63cf6c Update .gitattributes 2023-03-24 19:50:54 +08:00
922fdc3c50 Create .gitattributes 2023-03-24 19:49:58 +08:00
6e593fd678 测试实验性功能 使用说明 2023-03-24 19:47:37 +08:00
57996bf005 update readme 2023-03-24 19:42:21 +08:00
7cb01f2379 Update README.md 2023-03-24 19:38:33 +08:00
1def3cecfa source 2023-03-24 19:37:47 +08:00
8f739cfcdd remote additional file 2023-03-24 19:35:13 +08:00
54cd677d27 move images 2023-03-24 19:34:21 +08:00
7f3b7221fd Update README.md 2023-03-24 19:20:43 +08:00
667cefe391 push 2023-03-24 19:10:34 +08:00
e32ae33965 Update README.md 2023-03-24 19:04:55 +08:00
1f9c90f0e0 Update README.md 2023-03-24 19:03:03 +08:00
b017a3d167 fix count down error 2023-03-24 18:53:43 +08:00
8b4b30a846 beta 2023-03-24 18:47:45 +08:00
d29f72ce10 bug fix 2023-03-24 18:08:48 +08:00
7186d9b17e 模块化封装 2023-03-24 18:04:59 +08:00
86924fffa5 up 2023-03-24 16:34:48 +08:00
fedc748e17 用gpt给自己生成注释 2023-03-24 16:25:40 +08:00
273e8f38d9 muban 2023-03-24 16:22:26 +08:00
7187f079c8 易读性+ 2023-03-24 16:17:01 +08:00
77408f795e 批量生成函数注释 2023-03-24 16:14:25 +08:00
32f36a609e 生成文本报告 2023-03-24 15:42:09 +08:00
93c13aa97a better traceback 2023-03-24 15:25:14 +08:00
f238a34bb0 增加读latex文章的功能,添加测试样例 2023-03-24 14:56:57 +08:00
644c287a24 Merge remote-tracking branch 'origin/master' into test-3-24 2023-03-24 13:29:37 +08:00
abd9077cd2 设置及时响应 2023-03-24 13:28:12 +08:00
fa22df9cb6 update 2023-03-24 13:12:25 +08:00
3f559ec4cb Update functional_crazy.py 2023-03-24 13:11:41 +08:00
c9abcef3e5 Update functional_crazy.py 2023-03-24 13:06:42 +08:00
36b3c70b25 Update functional_crazy.py 2023-03-24 13:06:34 +08:00
1ac203195f Update functional_crazy.py 2023-03-24 13:02:47 +08:00
1c937edcb1 Merge branch 'master' of github.com:binary-husky/chatgpt_academic into master 2023-03-24 11:43:24 +08:00
248e18e2ba auto retry 2023-03-24 11:42:39 +08:00
86cd069ca7 Update README.md 2023-03-24 00:43:33 +08:00
2e67b516d9 Update README.md 2023-03-23 22:15:31 +08:00
7c20e79c01 Update predict.py 2023-03-23 22:13:09 +08:00
4a2c3eec10 Update README.md 2023-03-23 17:03:08 +08:00
09ae862403 Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-03-23 00:35:01 +08:00
ac2c8cab1f 正确地显示requests错误 2023-03-23 00:34:55 +08:00
1f0c4b1454 Update README.md 2023-03-23 00:20:39 +08:00
b1a6cfb799 Update README.md 2023-03-23 00:15:44 +08:00
b3a67b84b9 Update README.md 2023-03-22 22:52:15 +08:00
513d62570f Merge branch 'master' of github.com:binary-husky/chatgpt_academic 2023-03-22 22:42:56 +08:00
5a9aa65f49 bug fix 2023-03-22 22:42:50 +08:00
e39c511444 程序自解析功能 2023-03-22 22:37:14 +08:00
6781279019 Update README.md 2023-03-22 22:34:15 +08:00
3f6ddf85e9 Update README.md 2023-03-22 20:47:28 +08:00
1a301e0133 Update README.md 2023-03-22 20:06:09 +08:00
32824f3736 Update README.md 2023-03-22 20:02:03 +08:00
604ba40bdb Update README.md 2023-03-22 19:58:10 +08:00
889b719b09 私密配置
# config_private.py放自己的秘密如API和代理网址
# 读取时首先看是否存在私密的config_private配置文件(不受git管控),如果有,则覆盖原config文件
2023-03-22 19:49:45 +08:00
a5c122b309 借鉴github.com/GaiZhenbiao/ChuanhuChatGPT项目 2023-03-22 19:47:49 +08:00
e5b7613fc5 from github.com/polarwinkel/mdtex2html 2023-03-22 19:46:08 +08:00
1c4e853484 Update README.md 2023-03-22 19:39:02 +08:00
adbcc22a64 Update README.md 2023-03-22 19:36:39 +08:00
d4434219cd Update README.md 2023-03-22 19:35:34 +08:00
3ea231ee5d Update README.md 2023-03-22 19:33:26 +08:00
2881e080f7 修复gradio不吃代理的问题 2023-03-22 19:22:42 +08:00
a287230baa add private conf 2023-03-22 17:54:15 +08:00
37f4544e0f upload 2023-03-22 17:48:25 +08:00
2a6b17ed5e 代理位置 2023-03-22 17:45:10 +08:00
98f37e9ea7 upload 2023-03-22 17:35:23 +08:00
85ff193e53 logging 2023-03-22 17:32:48 +08:00
54914358c7 fix logging encoding 2023-03-22 17:30:30 +08:00
1fa9a79c3d add proxy debug funtion 2023-03-22 17:25:37 +08:00
dfa76157c8 Update README.md 2023-03-22 16:09:37 +08:00
0382ae2c72 Update predict.py 2023-03-21 21:24:38 +08:00
8ce9266733 Update README.md 2023-03-21 17:53:40 +08:00
7103ffcdf3 Update README.md 2023-03-21 17:53:04 +08:00
3a2511ec1a Update README.md 2023-03-21 15:49:52 +08:00
787b5be7af ok 2023-03-21 13:53:24 +08:00
2f94951996 Update README.md 2023-03-21 13:45:08 +08:00
5066fc8757 add deploy method for windows 2023-03-21 13:35:53 +08:00
4afc7b3dda Update README.md 2023-03-20 18:56:09 +08:00
1faffeca49 Update README.md 2023-03-20 18:55:06 +08:00
5092e710c5 readme 2023-03-20 18:39:48 +08:00
20 changed files with 619 additions and 189 deletions

View File

@ -7,11 +7,17 @@ assignees: ''
--- ---
**Describe the bug 简述** - **(1) Describe the bug 简述**
**Screen Shot 截图**
**Terminal Traceback 终端traceback如果有** - **(2) Screen Shot 截图**
- **(3) Terminal Traceback 终端traceback如有**
- **(4) Material to Help Reproduce Bugs 帮助我们复现的测试材料样本(如有)**
Before submitting an issue 提交issue之前 Before submitting an issue 提交issue之前

View File

@ -1,50 +0,0 @@
# How to build | 如何构建: docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
# How to run | 如何运行 (1) 直接运行: docker run --rm -it --net=host --gpus=all gpt-academic
# How to run | 如何运行 (2) 我想运行之前进容器做一些调整: docker run --rm -it --net=host --gpus=all gpt-academic bash
# 从NVIDIA源从而支持显卡运损检查宿主的nvidia-smi中的cuda版本必须>=11.3
FROM nvidia/cuda:11.3.1-runtime-ubuntu20.04
ARG useProxyNetwork=''
RUN apt-get update
RUN apt-get install -y curl proxychains curl
RUN apt-get install -y git python python3 python-dev python3-dev --fix-missing
# 配置代理网络构建Docker镜像时使用
# # comment out below if you do not need proxy network | 如果不需要翻墙 - 从此行向下删除
RUN $useProxyNetwork curl cip.cc
RUN sed -i '$ d' /etc/proxychains.conf
RUN sed -i '$ d' /etc/proxychains.conf
RUN echo "socks5 127.0.0.1 10880" >> /etc/proxychains.conf
ARG useProxyNetwork=proxychains
# # comment out above if you do not need proxy network | 如果不需要翻墙 - 从此行向上删除
# use python3 as the system default python
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.8
# 下载分支
WORKDIR /gpt
RUN $useProxyNetwork git clone https://github.com/binary-husky/chatgpt_academic.git -b v3.0
WORKDIR /gpt/chatgpt_academic
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 torch --extra-index-url https://download.pytorch.org/whl/cu113
# 预热CHATGLM参数非必要 可选步骤)
RUN echo ' \n\
from transformers import AutoModel, AutoTokenizer \n\
chatglm_tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True) \n\
chatglm_model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).float() ' >> warm_up_chatglm.py
RUN python3 -u warm_up_chatglm.py
RUN $useProxyNetwork git pull
# 为chatgpt-academic配置代理和API-KEY (非必要 可选步骤)
RUN echo ' \n\
API_KEY = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \n\
USE_PROXY = True \n\
LLM_MODEL = "chatglm" \n\
LOCAL_MODEL_DEVICE = "cuda" \n\
proxies = { "http": "socks5h://localhost:10880", "https": "socks5h://localhost:10880", } ' >> config_private.py
# 启动
CMD ["python3", "-u", "main.py"]

View File

@ -1,8 +1,8 @@
# ChatGPT 学术优化 # ChatGPT 学术优化
**如果喜欢这个项目请给它一个Star如果你发明了更好用的快捷键或函数插件欢迎发issue或者pull requestsdev分支** **如果喜欢这个项目请给它一个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 to `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](img/README_EN.md) translated by this project itself.
> **Note** > **Note**
> >
@ -10,8 +10,6 @@ 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.如果您不太习惯部分中文命名的函数、注释或者界面您可以随时点击相关函数插件调用ChatGPT一键生成纯英文的项目源代码。
>
<div align="center"> <div align="center">
@ -25,48 +23,39 @@ If you like this project, please give it a Star. If you've come up with more use
[配置代理服务器](https://www.bilibili.com/video/BV1rc411W7Dr) | 支持配置代理服务器 [配置代理服务器](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://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/Golang/Lua/Rect项目树 [程序剖析](https://www.bilibili.com/video/BV1cj411A7VW) | [函数插件] 一键可以剖析其他Python/C/C++/Java/Lua/...项目树
读论文 | [函数插件] 一键解读latex论文全文并生成摘要 读论文 | [函数插件] 一键解读latex论文全文并生成摘要
Latex全文翻译、润色 | [函数插件] 一键翻译或润色latex论文 Latex全文翻译、润色 | [函数插件] 一键翻译或润色latex论文
批量注释生成 | [函数插件] 一键批量生成函数注释 批量注释生成 | [函数插件] 一键批量生成函数注释
chat分析报告生成 | [函数插件] 运行后自动生成总结汇报 chat分析报告生成 | [函数插件] 运行后自动生成总结汇报
[arxiv小助手](https://www.bilibili.com/video/BV1LM4y1279X) | [函数插件] 输入arxiv文章url即可一键翻译摘要+下载PDF [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) (Version>=2.45) | [函数插件] 给定任意谷歌学术搜索页面URL让gpt帮你选择有趣的文章 [谷歌学术统合小助手](https://www.bilibili.com/video/BV19L411U7ia) | [函数插件] 给定任意谷歌学术搜索页面URL让gpt帮你选择有趣的文章
公式显示 | 可以同时显示公式的tex形式和渲染形式 公式/图片/表格显示 | 可以同时显示公式的tex形式和渲染形式,支持公式、代码高亮
图片显示 | 可以在markdown中显示图片
多线程函数插件支持 | 支持多线调用chatgpt一键处理海量文本或程序 多线程函数插件支持 | 支持多线调用chatgpt一键处理海量文本或程序
支持GPT输出的markdown表格 | 可以输出支持GPT的markdown表格
启动暗色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主题
huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/gpt-academic) | 登陆huggingface后复制[此空间](https://huggingface.co/spaces/qingxu98/gpt-academic) [多LLM模型](https://www.bilibili.com/video/BV1EM411K7VH/)支持([v3.0分支](https://github.com/binary-husky/chatgpt_academic/tree/v3.0) | 同时被ChatGPT和[清华ChatGLM](https://github.com/THUDM/ChatGLM-6B)伺候的感觉一定会很不错吧?
[多LLM模型](https://www.bilibili.com/video/BV1EM411K7VH/)混合支持([v3.0分支](https://github.com/binary-husky/chatgpt_academic/tree/v3.0)测试中) | 同时被ChatGPT和[清华ChatGLM](https://github.com/THUDM/ChatGLM-6B)伺候的感觉一定会很不错吧?
兼容[TGUI](https://github.com/oobabooga/text-generation-webui)接入更多样的语言模型 | 接入opt-1.3b, galactica-1.3b等模型([v3.0分支](https://github.com/binary-husky/chatgpt_academic/tree/v3.0)测试中) 兼容[TGUI](https://github.com/oobabooga/text-generation-webui)接入更多样的语言模型 | 接入opt-1.3b, galactica-1.3b等模型([v3.0分支](https://github.com/binary-husky/chatgpt_academic/tree/v3.0)测试中)
huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/gpt-academic) | 登陆huggingface后复制[此空间](https://huggingface.co/spaces/qingxu98/gpt-academic)
…… | …… …… | ……
</div> </div>
<!-- - 新界面master主分支, 右dev开发前沿 -->
- 新界面修改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>
- 所有按钮都通过读取functional.py动态生成可随意加自定义功能解放粘贴板 - 所有按钮都通过读取functional.py动态生成可随意加自定义功能解放粘贴板
<div align="center"> <div align="center">
<img src="img/公式.gif" width="700" > <img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
</div> </div>
- 润色/纠错 - 润色/纠错
<div align="center"> <div align="center">
<img src="img/润色.gif" width="700" > <img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
</div>
- 支持GPT输出的markdown表格
<div align="center">
<img src="img/demo2.jpg" width="500" >
</div> </div>
- 如果输出包含公式会同时以tex形式和渲染形式显示方便复制和阅读 - 如果输出包含公式会同时以tex形式和渲染形式显示方便复制和阅读
@ -74,15 +63,12 @@ huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/
<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>
- 懒得看项目代码整个工程直接给chatgpt炫嘴里 - 懒得看项目代码整个工程直接给chatgpt炫嘴里
<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>
- 多种大语言模型混合调用([v3.0分支](https://github.com/binary-husky/chatgpt_academic/tree/v3.0)测试中) - 多种大语言模型混合调用([v3.0分支](https://github.com/binary-husky/chatgpt_academic/tree/v3.0)测试中)
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/96192199/231222778-34776885-a7f0-4f2c-b5f4-7cc2ef3ecb58.png" width="700" > <img src="https://user-images.githubusercontent.com/96192199/231222778-34776885-a7f0-4f2c-b5f4-7cc2ef3ecb58.png" width="700" >
</div> </div>
@ -170,13 +156,13 @@ input区域 输入 ./crazy_functions/test_project/python/dqn 然后点击 "[
``` ```
## 其他部署方式 ## 其他部署方式
- 远程云服务器部署
请访问[部署wiki-2](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)
- 使用WSL2Windows Subsystem for Linux 子系统) - 使用WSL2Windows Subsystem for Linux 子系统)
请访问[部署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) 请访问[部署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远程部署
请访问[部署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)
## 自定义新的便捷按钮(学术快捷键自定义) ## 自定义新的便捷按钮(学术快捷键自定义)
打开functional.py添加条目如下然后重启程序即可。如果按钮已经添加成功并可见那么前缀、后缀都支持热修改无需重启程序即可生效。 打开functional.py添加条目如下然后重启程序即可。如果按钮已经添加成功并可见那么前缀、后缀都支持热修改无需重启程序即可生效。
例如 例如
@ -269,13 +255,9 @@ python check_proxy.py
## Todo 与 版本规划: ## Todo 与 版本规划:
- version 3 (Todo): - version 3.0 (Todo): 优化对chatglm和其他小型llm的支持
- - 支持gpt4和其他更多llm - version 2.6: 重构了插件结构,提高了交互性,加入更多插件
- version 2.4+ (Todo): - version 2.5: 自更新解决总结大工程源代码时文本过长、token溢出的问题
- - 总结大工程源代码时文本过长、token溢出的问题
- - 实现项目打包部署
- - 函数插件参数接口优化
- - 自更新
- version 2.4: (1)新增PDF全文翻译功能; (2)新增输入区切换位置的功能; (3)新增垂直布局选项; (4)多线程函数插件优化。 - version 2.4: (1)新增PDF全文翻译功能; (2)新增输入区切换位置的功能; (3)新增垂直布局选项; (4)多线程函数插件优化。
- version 2.3: 增强多线程交互性 - version 2.3: 增强多线程交互性
- version 2.2: 函数插件支持热重载 - version 2.2: 函数插件支持热重载

View File

@ -19,6 +19,11 @@ if USE_PROXY:
else: else:
proxies = None proxies = None
# 多线程函数插件中默认允许多少路线程同时访问OpenAI。
# Free trial users的限制是每分钟3次Pay-as-you-go users的限制是每分钟3500次。提高限制请查询
# https://platform.openai.com/docs/guides/rate-limits/overview
DEFAULT_WORKER_NUM = 3
# [step 3]>> 以下配置可以优化体验,但大部分场合下并不需要修改 # [step 3]>> 以下配置可以优化体验,但大部分场合下并不需要修改
# 对话窗的高度 # 对话窗的高度

View File

@ -16,7 +16,7 @@ def get_crazy_functions():
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英文润色
from crazy_functions.解析项目源代码 import 解析一个Lua项目
function_plugins = { function_plugins = {
"解析整个Python项目": { "解析整个Python项目": {
@ -47,6 +47,11 @@ def get_crazy_functions():
"AsButton": False, # 加入下拉菜单中 "AsButton": False, # 加入下拉菜单中
"Function": HotReload(解析一个Rect项目) "Function": HotReload(解析一个Rect项目)
}, },
"解析整个Lua项目": {
"Color": "stop", # 按钮颜色
"AsButton": False, # 加入下拉菜单中
"Function": HotReload(解析一个Lua项目)
},
"读Tex论文写摘要": { "读Tex论文写摘要": {
"Color": "stop", # 按钮颜色 "Color": "stop", # 按钮颜色
"Function": HotReload(读文章写摘要) "Function": HotReload(读文章写摘要)
@ -80,6 +85,8 @@ 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.Latex全文翻译 import Latex英译中 from crazy_functions.Latex全文翻译 import Latex英译中
from crazy_functions.批量Markdown翻译 import Markdown中译英
from crazy_functions.批量Markdown翻译 import Markdown英译中
function_plugins.update({ function_plugins.update({
"批量翻译PDF文档多线程": { "批量翻译PDF文档多线程": {
@ -137,7 +144,18 @@ def get_crazy_functions():
"AsButton": False, # 加入下拉菜单中 "AsButton": False, # 加入下拉菜单中
"Function": HotReload(Latex英译中) "Function": HotReload(Latex英译中)
}, },
"[测试功能] 批量Markdown中译英输入路径或上传压缩包": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"Color": "stop",
"AsButton": False, # 加入下拉菜单中
"Function": HotReload(Markdown中译英)
},
"[测试功能] 批量Markdown英译中输入路径或上传压缩包": {
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
"Color": "stop",
"AsButton": False, # 加入下拉菜单中
"Function": HotReload(Markdown英译中)
},
}) })
@ -156,14 +174,7 @@ def get_crazy_functions():
except Exception as err: except Exception as err:
print(f'[下载arxiv论文并翻译摘要] 插件导入失败 {str(err)}') print(f'[下载arxiv论文并翻译摘要] 插件导入失败 {str(err)}')
from crazy_functions.解析项目源代码 import 解析一个Lua项目
function_plugins.update({
"解析整个Lua项目": {
"Color": "stop", # 按钮颜色
"AsButton": False, # 加入下拉菜单中
"Function": HotReload(解析一个Lua项目)
},
})
###################### 第n组插件 ########################### ###################### 第n组插件 ###########################
return function_plugins return function_plugins

View File

@ -14,7 +14,7 @@ class PaperFileGroup():
import tiktoken import tiktoken
from toolbox import get_conf from toolbox import get_conf
enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL')) enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL'))
def get_token_num(txt): return len(enc.encode(txt)) def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
self.get_token_num = get_token_num self.get_token_num = get_token_num
def run_file_split(self, max_token_limit=1900): def run_file_split(self, max_token_limit=1900):
@ -92,7 +92,7 @@ def 多文件润色(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
chatbot=chatbot, chatbot=chatbot,
history_array=[[""] for _ in range(n_split)], history_array=[[""] for _ in range(n_split)],
sys_prompt_array=sys_prompt_array, sys_prompt_array=sys_prompt_array,
max_workers=10, # OpenAI所允许的最大并行过载 # max_workers=5, # 并行任务数量限制最多同时执行5个其他的排队等待
scroller_max_len = 80 scroller_max_len = 80
) )

View File

@ -14,7 +14,7 @@ class PaperFileGroup():
import tiktoken import tiktoken
from toolbox import get_conf from toolbox import get_conf
enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL')) enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL'))
def get_token_num(txt): return len(enc.encode(txt)) def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
self.get_token_num = get_token_num self.get_token_num = get_token_num
def run_file_split(self, max_token_limit=1900): def run_file_split(self, max_token_limit=1900):
@ -80,7 +80,7 @@ def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
elif language == 'zh->en': elif language == 'zh->en':
inputs_array = [f"Below is a section from a Chinese academic paper, translate it into English, do not modify any latex command such as \section, \cite and equations:" + inputs_array = [f"Below is a section from a Chinese academic paper, translate it into English, do not modify any latex command such as \section, \cite and equations:" +
f"\n\n{frag}" for frag in pfg.sp_file_contents] f"\n\n{frag}" for frag in pfg.sp_file_contents]
inputs_show_user_array = [f"润色 {f}" for f in pfg.sp_file_tag] inputs_show_user_array = [f"翻译 {f}" for f in pfg.sp_file_tag]
sys_prompt_array = ["You are a professional academic paper translator." for _ in range(n_split)] sys_prompt_array = ["You are a professional academic paper translator." for _ in range(n_split)]
gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency( gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
@ -90,7 +90,7 @@ def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
chatbot=chatbot, chatbot=chatbot,
history_array=[[""] for _ in range(n_split)], history_array=[[""] for _ in range(n_split)],
sys_prompt_array=sys_prompt_array, sys_prompt_array=sys_prompt_array,
max_workers=10, # OpenAI所允许的最大并行过载 # max_workers=5, # OpenAI所允许的最大并行过载
scroller_max_len = 80 scroller_max_len = 80
) )

View File

@ -1,12 +1,11 @@
import traceback import traceback
from toolbox import update_ui from toolbox import update_ui, get_conf
def input_clipping(inputs, history, max_token_limit): def input_clipping(inputs, history, max_token_limit):
import tiktoken import tiktoken
import numpy as np import numpy as np
from toolbox import get_conf
enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL')) enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL'))
def get_token_num(txt): return len(enc.encode(txt)) def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
mode = 'input-and-history' mode = 'input-and-history'
# 当 输入部分的token占比 小于 全文的一半时,只裁剪历史 # 当 输入部分的token占比 小于 全文的一半时,只裁剪历史
@ -23,7 +22,7 @@ def input_clipping(inputs, history, max_token_limit):
while n_token > max_token_limit: while n_token > max_token_limit:
where = np.argmax(everything_token) where = np.argmax(everything_token)
encoded = enc.encode(everything[where]) encoded = enc.encode(everything[where], disallowed_special=())
clipped_encoded = encoded[:len(encoded)-delta] clipped_encoded = encoded[:len(encoded)-delta]
everything[where] = enc.decode(clipped_encoded)[:-1] # -1 to remove the may-be illegal char everything[where] = enc.decode(clipped_encoded)[:-1] # -1 to remove the may-be illegal char
everything_token[where] = get_token_num(everything[where]) everything_token[where] = get_token_num(everything[where])
@ -65,7 +64,6 @@ def request_gpt_model_in_new_thread_with_ui_alive(
from request_llm.bridge_chatgpt import predict_no_ui_long_connection from request_llm.bridge_chatgpt import predict_no_ui_long_connection
# 用户反馈 # 用户反馈
chatbot.append([inputs_show_user, ""]) chatbot.append([inputs_show_user, ""])
msg = '正常'
yield from update_ui(chatbot=chatbot, history=[]) # 刷新界面 yield from update_ui(chatbot=chatbot, history=[]) # 刷新界面
executor = ThreadPoolExecutor(max_workers=16) executor = ThreadPoolExecutor(max_workers=16)
mutable = ["", time.time()] mutable = ["", time.time()]
@ -73,6 +71,9 @@ def request_gpt_model_in_new_thread_with_ui_alive(
retry_op = retry_times_at_unknown_error retry_op = retry_times_at_unknown_error
exceeded_cnt = 0 exceeded_cnt = 0
while True: while True:
# watchdog error
if len(mutable) >= 2 and (time.time()-mutable[1]) > 5:
raise RuntimeError("检测到程序终止。")
try: try:
# 【第一种情况】:顺利完成 # 【第一种情况】:顺利完成
result = predict_no_ui_long_connection( result = predict_no_ui_long_connection(
@ -99,16 +100,20 @@ def request_gpt_model_in_new_thread_with_ui_alive(
except: except:
# 【第三种情况】:其他错误:重试几次 # 【第三种情况】:其他错误:重试几次
tb_str = '```\n' + traceback.format_exc() + '```' tb_str = '```\n' + traceback.format_exc() + '```'
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:
retry_op -= 1 retry_op -= 1
mutable[0] += f"[Local Message] 重试中 {retry_times_at_unknown_error-retry_op}/{retry_times_at_unknown_error}\n\n" mutable[0] += f"[Local Message] 重试中,请稍等 {retry_times_at_unknown_error-retry_op}/{retry_times_at_unknown_error}\n\n"
if "Rate limit reached" in tb_str:
time.sleep(30)
time.sleep(5) time.sleep(5)
continue # 返回重试 continue # 返回重试
else: else:
time.sleep(5) time.sleep(5)
return mutable[0] # 放弃 return mutable[0] # 放弃
# 提交任务
future = executor.submit(_req_gpt, inputs, history, sys_prompt) future = executor.submit(_req_gpt, inputs, history, sys_prompt)
while True: while True:
# yield一次以刷新前端页面 # yield一次以刷新前端页面
@ -129,7 +134,7 @@ def request_gpt_model_in_new_thread_with_ui_alive(
def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency( def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
inputs_array, inputs_show_user_array, llm_kwargs, inputs_array, inputs_show_user_array, llm_kwargs,
chatbot, history_array, sys_prompt_array, chatbot, history_array, sys_prompt_array,
refresh_interval=0.2, max_workers=10, scroller_max_len=30, refresh_interval=0.2, max_workers=-1, scroller_max_len=30,
handle_token_exceed=True, show_user_at_complete=False, handle_token_exceed=True, show_user_at_complete=False,
retry_times_at_unknown_error=2, retry_times_at_unknown_error=2,
): ):
@ -150,7 +155,7 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
history_array (list): List of chat history (历史对话输入,双层列表,第一层列表是子任务分解,第二层列表是对话历史) history_array (list): List of chat history (历史对话输入,双层列表,第一层列表是子任务分解,第二层列表是对话历史)
sys_prompt_array (list): List of system prompts 系统输入列表用于输入给GPT的前提提示比如你是翻译官怎样怎样 sys_prompt_array (list): List of system prompts 系统输入列表用于输入给GPT的前提提示比如你是翻译官怎样怎样
refresh_interval (float, optional): Refresh interval for UI (default: 0.2) 刷新时间间隔频率建议低于1不可高于3仅仅服务于视觉效果 refresh_interval (float, optional): Refresh interval for UI (default: 0.2) 刷新时间间隔频率建议低于1不可高于3仅仅服务于视觉效果
max_workers (int, optional): Maximum number of threads (default: 10) 最大线程数如果子任务非常多需要用此选项防止高频地请求openai导致错误 max_workers (int, optional): Maximum number of threads (default: see config.py) 最大线程数如果子任务非常多需要用此选项防止高频地请求openai导致错误
scroller_max_len (int, optional): Maximum length for scroller (default: 30)(数据流的显示最后收到的多少个字符,仅仅服务于视觉效果) scroller_max_len (int, optional): Maximum length for scroller (default: 30)(数据流的显示最后收到的多少个字符,仅仅服务于视觉效果)
handle_token_exceed (bool, optional): (是否在输入过长时,自动缩减文本) handle_token_exceed (bool, optional): (是否在输入过长时,自动缩减文本)
handle_token_exceed是否自动处理token溢出的情况如果选择自动处理则会在溢出时暴力截断默认开启 handle_token_exceed是否自动处理token溢出的情况如果选择自动处理则会在溢出时暴力截断默认开启
@ -165,21 +170,28 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
from request_llm.bridge_chatgpt import predict_no_ui_long_connection from request_llm.bridge_chatgpt import predict_no_ui_long_connection
assert len(inputs_array) == len(history_array) assert len(inputs_array) == len(history_array)
assert len(inputs_array) == len(sys_prompt_array) assert len(inputs_array) == len(sys_prompt_array)
if max_workers == -1: # 读取配置文件
try: max_workers, = get_conf('DEFAULT_WORKER_NUM')
except: max_workers = 8
if max_workers <= 0 or max_workers >= 20: max_workers = 8
executor = ThreadPoolExecutor(max_workers=max_workers) executor = ThreadPoolExecutor(max_workers=max_workers)
n_frag = len(inputs_array) n_frag = len(inputs_array)
# 用户反馈 # 用户反馈
chatbot.append(["请开始多线程操作。", ""]) chatbot.append(["请开始多线程操作。", ""])
msg = '正常'
yield from update_ui(chatbot=chatbot, history=[]) # 刷新界面 yield from update_ui(chatbot=chatbot, history=[]) # 刷新界面
# 异步原子 # 跨线程传递
mutable = [["", time.time(), "等待中"] for _ in range(n_frag)] mutable = [["", time.time(), "等待中"] for _ in range(n_frag)]
# 子线程任务
def _req_gpt(index, inputs, history, sys_prompt): def _req_gpt(index, inputs, history, sys_prompt):
gpt_say = "" gpt_say = ""
retry_op = retry_times_at_unknown_error retry_op = retry_times_at_unknown_error
exceeded_cnt = 0 exceeded_cnt = 0
mutable[index][2] = "执行中" mutable[index][2] = "执行中"
while True: while True:
# watchdog error
if len(mutable[index]) >= 2 and (time.time()-mutable[index][1]) > 5:
raise RuntimeError("检测到程序终止。")
try: try:
# 【第一种情况】:顺利完成 # 【第一种情况】:顺利完成
# time.sleep(10); raise RuntimeError("测试") # time.sleep(10); raise RuntimeError("测试")
@ -212,13 +224,21 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
except: except:
# 【第三种情况】:其他错误 # 【第三种情况】:其他错误
tb_str = '```\n' + traceback.format_exc() + '```' tb_str = '```\n' + traceback.format_exc() + '```'
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]
if retry_op > 0: if retry_op > 0:
retry_op -= 1 retry_op -= 1
wait = random.randint(5, 20) wait = random.randint(5, 20)
for i in range(wait):# 也许等待十几秒后,情况会好转 if "Rate limit reached" in tb_str:
mutable[index][2] = f"等待重试 {wait-i}"; time.sleep(1) wait = wait * 3
fail_info = "OpenAI请求速率限制 "
else:
fail_info = ""
# 也许等待十几秒后,情况会好转
for i in range(wait):
mutable[index][2] = f"{fail_info}等待重试 {wait-i}"; time.sleep(1)
# 开始重试
mutable[index][2] = f"重试中 {retry_times_at_unknown_error-retry_op}/{retry_times_at_unknown_error}" mutable[index][2] = f"重试中 {retry_times_at_unknown_error-retry_op}/{retry_times_at_unknown_error}"
continue # 返回重试 continue # 返回重试
else: else:
@ -241,7 +261,6 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
break break
# 更好的UI视觉效果 # 更好的UI视觉效果
observe_win = [] observe_win = []
# print([mutable[thread_index][2] for thread_index, _ in enumerate(worker_done)])
# 每个线程都要“喂狗”(看门狗) # 每个线程都要“喂狗”(看门狗)
for thread_index, _ in enumerate(worker_done): for thread_index, _ in enumerate(worker_done):
mutable[thread_index][1] = time.time() mutable[thread_index][1] = time.time()
@ -251,49 +270,30 @@ def request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
replace('\n', '').replace('```', '...').replace( replace('\n', '').replace('```', '...').replace(
' ', '.').replace('<br/>', '.....').replace('$', '.')+"`... ]" ' ', '.').replace('<br/>', '.....').replace('$', '.')+"`... ]"
observe_win.append(print_something_really_funny) observe_win.append(print_something_really_funny)
# 在前端打印些好玩的东西
stat_str = ''.join([f'`{mutable[thread_index][2]}`: {obs}\n\n' stat_str = ''.join([f'`{mutable[thread_index][2]}`: {obs}\n\n'
if not done else f'`{mutable[thread_index][2]}`\n\n' if not done else f'`{mutable[thread_index][2]}`\n\n'
for thread_index, done, obs in zip(range(len(worker_done)), worker_done, observe_win)]) for thread_index, done, obs in zip(range(len(worker_done)), worker_done, observe_win)])
# 在前端打印些好玩的东西
chatbot[-1] = [chatbot[-1][0], f'多线程操作已经开始,完成情况: \n\n{stat_str}' + ''.join(['.']*(cnt % 10+1))] chatbot[-1] = [chatbot[-1][0], f'多线程操作已经开始,完成情况: \n\n{stat_str}' + ''.join(['.']*(cnt % 10+1))]
msg = "正常"
yield from update_ui(chatbot=chatbot, history=[]) # 刷新界面 yield from update_ui(chatbot=chatbot, history=[]) # 刷新界面
# 异步任务结束 # 异步任务结束
gpt_response_collection = [] gpt_response_collection = []
for inputs_show_user, f in zip(inputs_show_user_array, futures): for inputs_show_user, f in zip(inputs_show_user_array, futures):
gpt_res = f.result() gpt_res = f.result()
gpt_response_collection.extend([inputs_show_user, gpt_res]) gpt_response_collection.extend([inputs_show_user, gpt_res])
# 是否在结束时,在界面上显示结果
if show_user_at_complete: if show_user_at_complete:
for inputs_show_user, f in zip(inputs_show_user_array, futures): for inputs_show_user, f in zip(inputs_show_user_array, futures):
gpt_res = f.result() gpt_res = f.result()
chatbot.append([inputs_show_user, gpt_res]) chatbot.append([inputs_show_user, gpt_res])
yield from update_ui(chatbot=chatbot, history=[]) # 刷新界面 yield from update_ui(chatbot=chatbot, history=[]) # 刷新界面
time.sleep(1) time.sleep(0.3)
return gpt_response_collection return gpt_response_collection
def WithRetry(f):
"""
装饰器函数,用于自动重试。
"""
def decorated(retry, res_when_fail, *args, **kwargs):
assert retry >= 0
while True:
try:
res = yield from f(*args, **kwargs)
return res
except:
retry -= 1
if retry<0:
print("达到最大重试次数")
break
else:
print("重试中……")
continue
return res_when_fail
return decorated
def breakdown_txt_to_satisfy_token_limit(txt, get_token_fn, limit): def breakdown_txt_to_satisfy_token_limit(txt, get_token_fn, limit):
def cut(txt_tocut, must_break_at_empty_line): # 递归 def cut(txt_tocut, must_break_at_empty_line): # 递归
if get_token_fn(txt_tocut) <= limit: if get_token_fn(txt_tocut) <= limit:
@ -312,7 +312,6 @@ def breakdown_txt_to_satisfy_token_limit(txt, get_token_fn, limit):
if get_token_fn(prev) < limit: if get_token_fn(prev) < limit:
break break
if cnt == 0: if cnt == 0:
print('what the fuck ?')
raise RuntimeError("存在一行极长的文本!") raise RuntimeError("存在一行极长的文本!")
# print(len(post)) # print(len(post))
# 列表递归接龙 # 列表递归接龙
@ -325,8 +324,18 @@ def breakdown_txt_to_satisfy_token_limit(txt, get_token_fn, limit):
return cut(txt, must_break_at_empty_line=False) return cut(txt, must_break_at_empty_line=False)
def force_breakdown(txt, limit, get_token_fn):
"""
当无法用标点、空行分割时,我们用最暴力的方法切割
"""
for i in reversed(range(len(txt))):
if get_token_fn(txt[:i]) < limit:
return txt[:i], txt[i:]
return "Tiktoken未知错误", "Tiktoken未知错误"
def breakdown_txt_to_satisfy_token_limit_for_pdf(txt, get_token_fn, limit): def breakdown_txt_to_satisfy_token_limit_for_pdf(txt, get_token_fn, limit):
def cut(txt_tocut, must_break_at_empty_line): # 递归 # 递归
def cut(txt_tocut, must_break_at_empty_line, break_anyway=False):
if get_token_fn(txt_tocut) <= limit: if get_token_fn(txt_tocut) <= limit:
return [txt_tocut] return [txt_tocut]
else: else:
@ -338,28 +347,40 @@ def breakdown_txt_to_satisfy_token_limit_for_pdf(txt, get_token_fn, limit):
if must_break_at_empty_line: if must_break_at_empty_line:
if lines[cnt] != "": if lines[cnt] != "":
continue continue
print(cnt)
prev = "\n".join(lines[:cnt]) prev = "\n".join(lines[:cnt])
post = "\n".join(lines[cnt:]) post = "\n".join(lines[cnt:])
if get_token_fn(prev) < limit: if get_token_fn(prev) < limit:
break break
if cnt == 0: if cnt == 0:
# print('what the fuck ? 存在一行极长的文本!') if break_anyway:
raise RuntimeError("存在一行极长的文本!") prev, post = force_breakdown(txt_tocut, limit, get_token_fn)
else:
raise RuntimeError(f"存在一行极长的文本!{txt_tocut}")
# print(len(post)) # print(len(post))
# 列表递归接龙 # 列表递归接龙
result = [prev] result = [prev]
result.extend(cut(post, must_break_at_empty_line)) result.extend(cut(post, must_break_at_empty_line, break_anyway=break_anyway))
return result return result
try: try:
# 第1次尝试将双空行\n\n作为切分点
return cut(txt, must_break_at_empty_line=True) return cut(txt, must_break_at_empty_line=True)
except RuntimeError: except RuntimeError:
try: try:
# 第2次尝试将单空行\n作为切分点
return cut(txt, must_break_at_empty_line=False) return cut(txt, must_break_at_empty_line=False)
except RuntimeError: except RuntimeError:
# 这个中文的句号是故意的,作为一个标识而存在 try:
res = cut(txt.replace('.', '\n'), must_break_at_empty_line=False) # 第3次尝试将英文句号.)作为切分点
res = cut(txt.replace('.', '\n'), must_break_at_empty_line=False) # 这个中文的句号是故意的,作为一个标识而存在
return [r.replace('\n', '.') for r in res] return [r.replace('\n', '.') for r in res]
except RuntimeError as e:
try:
# 第4次尝试将中文句号作为切分点
res = cut(txt.replace('', '。。\n'), must_break_at_empty_line=False)
return [r.replace('。。\n', '') for r in res]
except RuntimeError as e:
# 第5次尝试没办法了随便切一下敷衍吧
return cut(txt, must_break_at_empty_line=False, break_anyway=True)
@ -387,12 +408,15 @@ def read_and_clean_pdf_text(fp):
import re import re
import numpy as np import numpy as np
from colorful import print亮黄, print亮绿 from colorful import print亮黄, print亮绿
fc = 0 fc = 0 # Index 0 文本
fs = 1 fs = 1 # Index 1 字体
fb = 2 fb = 2 # Index 2 框框
REMOVE_FOOT_NOTE = True REMOVE_FOOT_NOTE = True # 是否丢弃掉 不是正文的内容 (比正文字体小,如参考文献、脚注、图注等)
REMOVE_FOOT_FFSIZE_PERCENT = 0.95 REMOVE_FOOT_FFSIZE_PERCENT = 0.95 # 小于正文的判定为不是正文有些文章的正文部分字体大小不是100%统一的,有肉眼不可见的小变化)
def primary_ffsize(l): def primary_ffsize(l):
"""
提取文本块主字体
"""
fsize_statiscs = {} fsize_statiscs = {}
for wtf in l['spans']: for wtf in l['spans']:
if wtf['size'] not in fsize_statiscs: fsize_statiscs[wtf['size']] = 0 if wtf['size'] not in fsize_statiscs: fsize_statiscs[wtf['size']] = 0
@ -400,14 +424,18 @@ def read_and_clean_pdf_text(fp):
return max(fsize_statiscs, key=fsize_statiscs.get) return max(fsize_statiscs, key=fsize_statiscs.get)
def ffsize_same(a,b): def ffsize_same(a,b):
"""
提取字体大小是否近似相等
"""
return abs((a-b)/max(a,b)) < 0.02 return abs((a-b)/max(a,b)) < 0.02
# file_content = ""
with fitz.open(fp) as doc: with fitz.open(fp) as doc:
meta_txt = [] meta_txt = []
meta_font = [] meta_font = []
meta_line = [] meta_line = []
meta_span = [] meta_span = []
############################## <第 1 步,搜集初始信息> ##################################
for index, page in enumerate(doc): for index, page in enumerate(doc):
# file_content += page.get_text() # file_content += page.get_text()
text_areas = page.get_text("dict") # 获取页面上的文本信息 text_areas = page.get_text("dict") # 获取页面上的文本信息
@ -429,7 +457,8 @@ def read_and_clean_pdf_text(fp):
if index == 0: if index == 0:
page_one_meta = [" ".join(["".join([wtf['text'] for wtf in l['spans']]) for l in t['lines']]).replace( page_one_meta = [" ".join(["".join([wtf['text'] for wtf in l['spans']]) for l in t['lines']]).replace(
'- ', '') for t in text_areas['blocks'] if 'lines' in t] '- ', '') for t in text_areas['blocks'] if 'lines' in t]
# 获取正文主字体
############################## <第 2 步,获取正文主字体> ##################################
fsize_statiscs = {} fsize_statiscs = {}
for span in meta_span: for span in meta_span:
if span[1] not in fsize_statiscs: fsize_statiscs[span[1]] = 0 if span[1] not in fsize_statiscs: fsize_statiscs[span[1]] = 0
@ -438,7 +467,7 @@ def read_and_clean_pdf_text(fp):
if REMOVE_FOOT_NOTE: if REMOVE_FOOT_NOTE:
give_up_fize_threshold = main_fsize * REMOVE_FOOT_FFSIZE_PERCENT give_up_fize_threshold = main_fsize * REMOVE_FOOT_FFSIZE_PERCENT
# 切分和重新整合 ############################## <第 3 步,切分和重新整合> ##################################
mega_sec = [] mega_sec = []
sec = [] sec = []
for index, line in enumerate(meta_line): for index, line in enumerate(meta_line):
@ -480,6 +509,7 @@ def read_and_clean_pdf_text(fp):
finals.append(final) finals.append(final)
meta_txt = finals meta_txt = finals
############################## <第 4 步,乱七八糟的后处理> ##################################
def 把字符太少的块清除为回车(meta_txt): def 把字符太少的块清除为回车(meta_txt):
for index, block_txt in enumerate(meta_txt): for index, block_txt in enumerate(meta_txt):
if len(block_txt) < 100: if len(block_txt) < 100:
@ -523,6 +553,7 @@ def read_and_clean_pdf_text(fp):
# 换行 -> 双换行 # 换行 -> 双换行
meta_txt = meta_txt.replace('\n', '\n\n') meta_txt = meta_txt.replace('\n', '\n\n')
############################## <第 5 步,展示分割效果> ##################################
for f in finals: for f in finals:
print亮黄(f) print亮黄(f)
print亮绿('***************************') print亮绿('***************************')

View File

@ -62,7 +62,7 @@ def 全项目切换英文(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys_
import tiktoken import tiktoken
from toolbox import get_conf from toolbox import get_conf
enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL')) enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL'))
def get_token_fn(txt): return len(enc.encode(txt)) def get_token_fn(txt): return len(enc.encode(txt, disallowed_special=()))
# 第6步任务函数 # 第6步任务函数

View File

@ -0,0 +1,162 @@
from toolbox import update_ui
from toolbox import CatchException, report_execption, write_results_to_file
fast_debug = False
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
import tiktoken
from toolbox import get_conf
enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL'))
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}.md")
print('Segmentation: done')
def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, language='en'):
import time, os, re
from .crazy_utils import request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency
# <-------- 读取Markdown文件删除其中的所有注释 ---------->
pfg = PaperFileGroup()
for index, fp in enumerate(file_manifest):
with open(fp, 'r', encoding='utf-8', errors='replace') as f:
file_content = f.read()
# 记录删除注释后的文本
pfg.file_paths.append(fp)
pfg.file_contents.append(file_content)
# <-------- 拆分过长的Markdown文件 ---------->
pfg.run_file_split(max_token_limit=2048)
n_split = len(pfg.sp_file_contents)
# <-------- 多线程润色开始 ---------->
if language == 'en->zh':
inputs_array = ["This is a Markdown file, translate it into Chinese, do not modify any existing Markdown commands:" +
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 academic paper translator." for _ in range(n_split)]
elif language == 'zh->en':
inputs_array = [f"This is a Markdown file, translate it into English, do not modify any existing Markdown commands:" +
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 academic paper translator." for _ in range(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
)
# <-------- 整理结果,退出 ---------->
create_report_file_name = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + f"-chatgpt.polish.md"
res = write_results_to_file(gpt_response_collection, file_name=create_report_file_name)
history = gpt_response_collection
chatbot.append((f"{fp}完成了吗?", res))
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
@CatchException
def Markdown英译中(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
# 基本信息:功能、贡献者
chatbot.append([
"函数插件功能?",
"对整个Markdown项目进行翻译。函数插件贡献者: Binary-Husky"])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
# 尝试导入依赖,如果缺少依赖,则给出安装建议
try:
import tiktoken
except:
report_execption(chatbot, history,
a=f"解析项目: {txt}",
b=f"导入软件依赖失败。使用该模块需要额外依赖,安装方法```pip install --upgrade tiktoken```。")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
history = [] # 清空历史,以免输入溢出
import glob, 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
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.md', recursive=True)]
if len(file_manifest) == 0:
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
yield from 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, language='en->zh')
@CatchException
def Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
# 基本信息:功能、贡献者
chatbot.append([
"函数插件功能?",
"对整个Markdown项目进行翻译。函数插件贡献者: Binary-Husky"])
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
# 尝试导入依赖,如果缺少依赖,则给出安装建议
try:
import tiktoken
except:
report_execption(chatbot, history,
a=f"解析项目: {txt}",
b=f"导入软件依赖失败。使用该模块需要额外依赖,安装方法```pip install --upgrade tiktoken```。")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
history = [] # 清空历史,以免输入溢出
import glob, 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('.md'):
file_manifest = [txt]
else:
file_manifest = [f for f in glob.glob(f'{project_folder}/**/*.md', recursive=True)]
if len(file_manifest) == 0:
report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"找不到任何.md文件: {txt}")
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
return
yield from 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, language='zh->en')

View File

@ -70,7 +70,7 @@ def 解析PDF(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot,
from .crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf from .crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf
from toolbox import get_conf from toolbox import get_conf
enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL')) enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL'))
def get_token_num(txt): return len(enc.encode(txt)) def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
paper_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf( paper_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf(
txt=file_content, get_token_fn=get_token_num, limit=TOKEN_LIMIT_PER_FRAGMENT) txt=file_content, get_token_fn=get_token_num, limit=TOKEN_LIMIT_PER_FRAGMENT)
page_one_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf( page_one_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf(
@ -98,7 +98,7 @@ def 解析PDF(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot,
history_array=[[paper_meta] for _ in paper_fragments], history_array=[[paper_meta] for _ in paper_fragments],
sys_prompt_array=[ sys_prompt_array=[
"请你作为一个学术翻译,负责把学术论文的片段准确翻译成中文。" for _ in paper_fragments], "请你作为一个学术翻译,负责把学术论文的片段准确翻译成中文。" for _ in paper_fragments],
max_workers=16 # OpenAI所允许的最大并行过载 # max_workers=5 # OpenAI所允许的最大并行过载
) )
# 整理报告的格式 # 整理报告的格式

View File

@ -8,17 +8,18 @@ fast_debug = False
def 解析PDF(file_name, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt): def 解析PDF(file_name, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt):
import tiktoken import tiktoken
print('begin analysis on:', file_name) print('begin analysis on:', file_name)
file_content, page_one = read_and_clean_pdf_text(file_name)
############################## <第零步从摘要中提取高价值信息放到history中> ################################## ############################## <第 0 步切割PDF> ##################################
# 递归地切割PDF文件每一块尽量是完整的一个section比如introductionexperiment等必要时再进行切割 # 递归地切割PDF文件每一块尽量是完整的一个section比如introductionexperiment等必要时再进行切割
# 的长度必须小于 2500 个 Token # 的长度必须小于 2500 个 Token
file_content, page_one = read_and_clean_pdf_text(file_name) # 尝试按照章节切割PDF
TOKEN_LIMIT_PER_FRAGMENT = 2500 TOKEN_LIMIT_PER_FRAGMENT = 2500
from .crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf from .crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf
from toolbox import get_conf from toolbox import get_conf
enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL')) enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL'))
def get_token_num(txt): return len(enc.encode(txt)) def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
paper_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf( paper_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf(
txt=file_content, get_token_fn=get_token_num, limit=TOKEN_LIMIT_PER_FRAGMENT) txt=file_content, get_token_fn=get_token_num, limit=TOKEN_LIMIT_PER_FRAGMENT)
page_one_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf( page_one_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf(
@ -26,11 +27,11 @@ def 解析PDF(file_name, llm_kwargs, plugin_kwargs, chatbot, history, system_pro
# 为了更好的效果我们剥离Introduction之后的部分如果有 # 为了更好的效果我们剥离Introduction之后的部分如果有
paper_meta = page_one_fragments[0].split('introduction')[0].split('Introduction')[0].split('INTRODUCTION')[0] paper_meta = page_one_fragments[0].split('introduction')[0].split('Introduction')[0].split('INTRODUCTION')[0]
############################## <第从摘要中提取高价值信息放到history中> ################################## ############################## <第 1 从摘要中提取高价值信息放到history中> ##################################
final_results = [] final_results = []
final_results.append(paper_meta) final_results.append(paper_meta)
############################## <第步,迭代地历遍整个文章,提取精炼信息> ################################## ############################## <第 2 步,迭代地历遍整个文章,提取精炼信息> ##################################
i_say_show_user = f'首先你在英文语境下通读整篇论文。'; gpt_say = "[Local Message] 收到。" # 用户提示 i_say_show_user = f'首先你在英文语境下通读整篇论文。'; gpt_say = "[Local Message] 收到。" # 用户提示
chatbot.append([i_say_show_user, gpt_say]); yield from update_ui(chatbot=chatbot, history=[]) # 更新UI chatbot.append([i_say_show_user, gpt_say]); yield from update_ui(chatbot=chatbot, history=[]) # 更新UI
@ -51,14 +52,14 @@ def 解析PDF(file_name, llm_kwargs, plugin_kwargs, chatbot, history, system_pro
iteration_results.append(gpt_say) iteration_results.append(gpt_say)
last_iteration_result = gpt_say last_iteration_result = gpt_say
############################## <第整理history> ################################## ############################## <第 3 整理history> ##################################
final_results.extend(iteration_results) final_results.extend(iteration_results)
final_results.append(f'接下来,你是一名专业的学术教授,利用以上信息,使用中文回答我的问题。') final_results.append(f'接下来,你是一名专业的学术教授,利用以上信息,使用中文回答我的问题。')
# 接下来两句话只显示在界面上,不起实际作用 # 接下来两句话只显示在界面上,不起实际作用
i_say_show_user = f'接下来,你是一名专业的学术教授,利用以上信息,使用中文回答我的问题。'; gpt_say = "[Local Message] 收到。" i_say_show_user = f'接下来,你是一名专业的学术教授,利用以上信息,使用中文回答我的问题。'; gpt_say = "[Local Message] 收到。"
chatbot.append([i_say_show_user, gpt_say]) chatbot.append([i_say_show_user, gpt_say])
############################## <第设置一个token上限防止回答时Token溢出> ################################## ############################## <第 4 设置一个token上限防止回答时Token溢出> ##################################
from .crazy_utils import input_clipping from .crazy_utils import input_clipping
_, final_results = input_clipping("", final_results, max_token_limit=3200) _, final_results = input_clipping("", final_results, max_token_limit=3200)
yield from update_ui(chatbot=chatbot, history=final_results) # 注意这里的历史记录被替代了 yield from update_ui(chatbot=chatbot, history=final_results) # 注意这里的历史记录被替代了

View File

@ -12,8 +12,10 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
sys_prompt_array = [] sys_prompt_array = []
report_part_1 = [] report_part_1 = []
assert len(file_manifest) <= 1024, "源文件太多超过1024个, 请缩减输入文件的数量。或者您也可以选择删除此行警告并修改代码拆分file_manifest列表从而实现分批次处理。"
############################## <第一步,逐个文件分析,多线程> ################################## ############################## <第一步,逐个文件分析,多线程> ##################################
for index, fp in enumerate(file_manifest): for index, fp in enumerate(file_manifest):
# 读取文件
with open(fp, 'r', encoding='utf-8', errors='replace') as f: with open(fp, 'r', encoding='utf-8', errors='replace') as f:
file_content = f.read() file_content = f.read()
prefix = "接下来请你逐文件分析下面的工程" if index==0 else "" prefix = "接下来请你逐文件分析下面的工程" if index==0 else ""
@ -25,6 +27,7 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
history_array.append([]) history_array.append([])
sys_prompt_array.append("你是一个程序架构分析师,正在分析一个源代码项目。你的回答必须简单明了。") sys_prompt_array.append("你是一个程序架构分析师,正在分析一个源代码项目。你的回答必须简单明了。")
# 文件读取完成对每一个源代码文件生成一个请求线程发送到chatgpt进行分析
gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency( gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
inputs_array = inputs_array, inputs_array = inputs_array,
inputs_show_user_array = inputs_show_user_array, inputs_show_user_array = inputs_show_user_array,
@ -35,28 +38,13 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
show_user_at_complete = True show_user_at_complete = True
) )
# 全部文件解析完成,结果写入文件,准备对工程源代码进行汇总分析
report_part_1 = copy.deepcopy(gpt_response_collection) report_part_1 = copy.deepcopy(gpt_response_collection)
history_to_return = report_part_1 history_to_return = report_part_1
res = write_results_to_file(report_part_1) res = write_results_to_file(report_part_1)
chatbot.append(("完成?", "逐个文件分析已完成。" + res + "\n\n正在开始汇总。")) chatbot.append(("完成?", "逐个文件分析已完成。" + res + "\n\n正在开始汇总。"))
yield from update_ui(chatbot=chatbot, history=history_to_return) # 刷新界面 yield from update_ui(chatbot=chatbot, history=history_to_return) # 刷新界面
############################## <存储中间数据进行调试> ##################################
# def objdump(obj):
# import pickle
# with open('objdump.tmp', 'wb+') as f:
# pickle.dump(obj, f)
# return
# def objload():
# import pickle, os
# if not os.path.exists('objdump.tmp'):
# return
# with open('objdump.tmp', 'rb') as f:
# return pickle.load(f)
# objdump([report_part_1, gpt_response_collection, history_to_return, file_manifest, project_folder, fp, llm_kwargs, chatbot])
############################## <第二步,综合,单线程,分组+迭代处理> ################################## ############################## <第二步,综合,单线程,分组+迭代处理> ##################################
batchsize = 16 # 10个文件为一组 batchsize = 16 # 10个文件为一组
report_part_2 = [] report_part_2 = []

294
img/README_EN.md Normal file
View File

@ -0,0 +1,294 @@
# ChatGPT Academic Optimization
> **Note**
>
> This English readme is automatically generated by the markdown translation plugin in this project, and may not be 100% correct.
>
**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).**
> **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**!
>
> 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).
>
> 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">
Function | Description
--- | ---
One-click refinement | Supports one-click refinement, one-click searching for grammatical errors in papers.
One-click translation between Chinese and English | One-click translation between Chinese and English.
One-click code interpretation | Can correctly display and interpret the code.
[Custom shortcuts](https://www.bilibili.com/video/BV14s4y1E7jN) | Supports custom shortcuts.
[Configure proxy server](https://www.bilibili.com/video/BV1rc411W7Dr) | Supports configuring proxy server.
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).
[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.
[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.
Read papers | [Function Plug-in] One-click reads the full text of a latex paper and generates an abstract.
Latex full-text translation/refinement | [Function Plug-in] One-click translates or refines a latex paper.
Batch annotation generation | [Function Plug-in] One-click generates function annotations in batches.
Chat analysis report generation | [Function Plug-in] Automatically generate summary reports after running.
[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.
[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).
[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.
Formula display | Can simultaneously display the tex form and rendering form of formulas.
Image display | Can display images in Markdown.
Multithreaded function plug-in support | Supports multi-threaded calling of chatgpt, one-click processing of massive texts or programs.
Support for markdown tables output by GPT | Can output markdown tables that support GPT.
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 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>
<!-- - 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").
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
</div>
- All buttons are dynamically generated by reading `functional.py`, and custom functions can be added freely, freeing up the clipboard.
<div align="center">
<img src="公式.gif" width="700" >
</div>
- Refinement/Correction
<div align="center">
<img src="润色.gif" width="700" >
</div>
- Supports markdown tables output by GPT.
<div align="center">
<img src="demo2.jpg" width="500" >
</div>
- If the output contains formulas, both the tex form and the rendering form are displayed simultaneously for easy copying and reading.
<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">
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
</div>
- Multiple large language models mixed calling. ([v3.0 branch](https://github.com/binary-husky/chatgpt_academic/tree/v3.0) in testing)
## Running Directly (Windows, Linux or MacOS)
### 1. Download the Project
```sh
git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic
```
### 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
```sh
# (Option 1) Recommended
python -m pip install -r requirements.txt
# (Option 2) If you use anaconda, the steps are also similar:
# (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: Use the official pip source or the Ali pip source. Other pip sources (such as some university pips) may have problems. Temporary substitution method:
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
```
### 4. Run
```sh
python main.py
```
### 5. Test Experimental Features
```
- 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
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)"
- Test Self-code Interpretation
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)
``` sh
# Download Project
git clone https://github.com/binary-husky/chatgpt_academic.git
cd chatgpt_academic
# Configure Overseas Proxy and OpenAI API KEY
Configure config.py with any text editor
# Installation
docker build -t gpt-academic .
# Run
docker run --rm -it --net=host gpt-academic
# Test Experimental Features
## Test Self-code Interpretation
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"
## (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
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)"
```
## Other Deployment Methods
- 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
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)
## Customizing New Convenient Buttons (Academic Shortcut Key Customization)
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.)
For example,
```
"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",
# Suffix, which will be added after your input. For example, in conjunction with the prefix, you can bracket your input in quotes.
"Suffix": "",
},
```
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
</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:
```
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:
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
</div>
### If the program can read and analyze itself:
<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>
### Any other Python/Cpp project analysis:
<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 paper reading comprehension and abstract generation with one click
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
</div>
### Automatic Report Generation
<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>
### Modular Function Design
<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>
### Translating source code to English
<div align="center">
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
</div>
## Todo and Version Planning:
- version 3 (Todo):
- - Support for gpt4 and other llm
- version 2.4+ (Todo):
- - Summary of long text and token overflow problems in large project source code
- - Implementation of project packaging and deployment
- - 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.2: Function plug-in supports hot reloading
- version 2.1: Collapsible layout
- version 2.0: Introduction of modular function plugins
- version 1.0: Basic functions
## References and Learning
```
The code refers to the design of many other excellent projects, mainly including:
# Reference Project 1: Referenced the method of reading OpenAI json, recording historical inquiry records, and using gradio queue in ChuanhuChatGPT
https://github.com/GaiZhenbiao/ChuanhuChatGPT
# Reference Project 2:
https://github.com/THUDM/ChatGLM-6B
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 MiB

Binary file not shown.

View File

@ -1,4 +1,4 @@
# 如何使用其他大语言模型(dev分支测试中) # 如何使用其他大语言模型(v3.0分支测试中)
## 1. 先运行text-generation ## 1. 先运行text-generation
``` sh ``` sh

View File

@ -96,7 +96,7 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history=[], sys_prompt="",
# 看门狗,如果超过期限没有喂狗,则终止 # 看门狗,如果超过期限没有喂狗,则终止
if len(observe_window) >= 2: if len(observe_window) >= 2:
if (time.time()-observe_window[1]) > watch_dog_patience: if (time.time()-observe_window[1]) > watch_dog_patience:
raise RuntimeError("程序终止") raise RuntimeError("用户取消了程序。")
else: raise RuntimeError("意外Json结构"+delta) else: raise RuntimeError("意外Json结构"+delta)
if json_data['finish_reason'] == 'length': if json_data['finish_reason'] == 'length':
raise ConnectionAbortedError("正常结束但显示Token不足导致输出不完整请削减单次输入的文本量。") raise ConnectionAbortedError("正常结束但显示Token不足导致输出不完整请削减单次输入的文本量。")

View File

@ -1,5 +1,5 @@
{ {
"version": 2.68, "version": 2.68,
"show_feature": true, "show_feature": true,
"new_feature": "改善理解pdfchatpdf功能 <-> 如果一键更新失败可前往github手动更新" "new_feature": "改善理解pdfchatpdf功能 <-> 修复读取罕见字符的BUG <-> 如果一键更新失败可前往github手动更新"
} }