Suchun-sv commited on
Commit
566aee2
1 Parent(s): 35c77ea
README.md CHANGED
@@ -10,7 +10,7 @@ app_file: main.py
10
  pinned: false
11
  ---
12
 
13
- # <img src="docs/logo.png" width="40" > ChatGPT 学术优化
14
 
15
  **如果喜欢这个项目,请给它一个Star;如果你发明了更好用的快捷键或函数插件,欢迎发issue或者pull requests**
16
 
@@ -22,7 +22,7 @@ If you like this project, please give it a Star. If you've come up with more use
22
  >
23
  > 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)当中。
24
  >
25
- > 3.已支持OpenAI和API2D的api-key共存,可在配置文件中填写如`API_KEY="openai-key1,openai-key2,api2d-key3"`。需要临时更换`API_KEY`时,在输入区输入临时的`API_KEY`然后回车键提交后即可生效。
26
 
27
  <div align="center">
28
 
@@ -40,7 +40,6 @@ If you like this project, please give it a Star. If you've come up with more use
40
  Latex全文翻译、润色 | [函数插件] 一键翻译或润色latex论文
41
  批量注释生成 | [函数插件] 一键批量生成函数注释
42
  chat分析报告生成 | [函数插件] 运行后自动生成总结汇报
43
- Markdown中英互译 | [函数插件] 看到上面5种语言的[README](https://github.com/binary-husky/chatgpt_academic/blob/master/docs/README_EN.md)了吗?
44
  [arxiv小助手](https://www.bilibili.com/video/BV1LM4y1279X) | [函数插件] 输入arxiv文章url即可一键翻译摘要+下载PDF
45
  [PDF论文全文翻译功能](https://www.bilibili.com/video/BV1KT411x7Wn) | [函数插件] PDF论文提取题目&摘要+翻译全文(多线程)
46
  [谷歌学术统合小助手](https://www.bilibili.com/video/BV19L411U7ia) | [函数插件] 给定任意谷歌学术搜索页面URL,让gpt帮你选择有趣的文章
@@ -54,7 +53,7 @@ huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/
54
  </div>
55
 
56
 
57
- - 新界面(修改`config.py`中的LAYOUT选项即可实现“左右布局”和“上下布局”的切换)
58
  <div align="center">
59
  <img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
60
  </div>
@@ -102,8 +101,8 @@ cd chatgpt_academic
102
 
103
  在`config.py`中,配置 海外Proxy 和 OpenAI API KEY,说明如下
104
  ```
105
- 1. 如果你在国内,需要设置海外代理才能够顺利使用OpenAI API,设置方法请仔细阅读config.py(1.修改其中的USE_PROXY为True; 2.按照说明修改其中的proxies)。
106
- 2. 配置 OpenAI API KEY。支持任意数量的OpenAI的密钥和API2D的密钥共存/负载均衡,多个KEY用英文逗号分隔即可,例如输入 API_KEY="OpenAI密钥1,API2D密钥2,OpenAI密钥3,OpenAI密钥4"
107
  3. 与代理网络有关的issue(网络超时、代理不起作用)汇总到 https://github.com/binary-husky/chatgpt_academic/issues/1
108
  ```
109
  (P.S. 程序运行时会优先检查是否存在名为`config_private.py`的私密配置文件,并用其中的配置覆盖`config.py`的同名配置。因此,如果您能理解我们的配置读取逻辑,我们强烈建议您在`config.py`旁边创建一个名为`config_private.py`的新配置文件,并把`config.py`中的配置转移(复制)到`config_private.py`中。`config_private.py`不受git管控,可以让您的隐私信息更加安全。)
@@ -111,17 +110,19 @@ cd chatgpt_academic
111
 
112
  3. 安装依赖
113
  ```sh
114
- # (选择I: 如熟悉python)推荐
115
- python -m pip install -r requirements.txt
116
- # 备注:使用官方pip源或者阿里pip源,其他pip源(如一些大学的pip)有可能出问题,临时换源方法:python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
117
-
118
- # (选择II: 如不熟悉python)使用anaconda,步骤也是类似的:
119
- # (II-1)conda create -n gptac_venv python=3.11
120
- # (II-2conda activate gptac_venv
121
- # (II-3)python -m pip install -r requirements.txt
 
 
122
  ```
123
 
124
- 如果需要支持清华ChatGLM后端,需要额外安装更多依赖(不熟悉python、电脑配置不佳者,建议不要尝试):
125
  ```sh
126
  python -m pip install -r request_llm/requirements_chatglm.txt
127
  ```
@@ -134,16 +135,15 @@ python main.py
134
  5. 测试函数插件
135
  ```
136
  - 测试Python项目分析
137
- (选择1)input区域 输入 `./crazy_functions/test_project/python/dqn` , 然后点击 "解析整个Python项目"
138
- (选择2)展开文件上传区,将python文件/包含python文件的压缩包拖拽进去,在出现反馈提示后, 然后点击 "解析整个Python项目"
139
- - 测试自我代码解读(本项目自译解)
140
  点击 "[多线程Demo] 解析此项目本身(源码自译解)"
141
- - 测试函数插件模板函数(要求gpt回答历史上的今天发生了什么),您可以根据此函数为模板,实现更复杂的功能
142
  点击 "[函数插件模板Demo] 历史上的今天"
143
  - 函数插件区下拉菜单中有更多功能可供选择
144
  ```
145
 
146
- ## 安装-方法2:使用Docker (Linux)
147
 
148
  1. 仅ChatGPT(推荐大多数人选择)
149
  ``` sh
@@ -156,23 +156,33 @@ cd chatgpt_academic
156
  docker build -t gpt-academic .
157
  # 运行
158
  docker run --rm -it --net=host gpt-academic
 
 
 
 
 
 
 
 
 
 
159
  ```
160
 
161
- 2. ChatGPT+ChatGLM(需要对docker熟悉 + 读懂Dockerfile + 电脑配置够强)
162
 
163
  ``` sh
164
- # 修改Dockerfile
165
  cd docs && nano Dockerfile+ChatGLM
166
- # 构建 (Dockerfile+ChatGLM在docs路径下,请先cd docs)
167
  docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
168
- # 运行 (1) 直接运行:
169
  docker run --rm -it --net=host --gpus=all gpt-academic
170
- # 运行 (2) 我想运行之前进容器做一些调整:
171
  docker run --rm -it --net=host --gpus=all gpt-academic bash
172
  ```
173
 
174
 
175
- ## 安装-方法3:其他部署方式(需要云服务器知识与经验)
176
 
177
  1. 远程云服务器部署
178
  请访问[部署wiki-1](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
@@ -191,9 +201,7 @@ docker run --rm -it --net=host --gpus=all gpt-academic bash
191
 
192
  ---
193
 
194
- ## 自定义新的便捷按钮 / 自定义函数插件
195
-
196
- 1. 自定义新的便捷按钮(学术快捷键)
197
  任意文本编辑器打开`core_functional.py`,添加条目如下,然后重启程序即可。(如果按钮已经添加成功并可见,那么前缀、后缀都支持热修改,无需重启程序即可生效。)
198
  例如
199
  ```
@@ -209,25 +217,19 @@ docker run --rm -it --net=host --gpus=all gpt-academic bash
209
  <img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
210
  </div>
211
 
212
- 2. 自定义函数插件
213
-
214
- 编写强大的函数插件来执行任何你想得到的和想不到的任务。
215
- 本项目的插件编写、调试难度很低,只要您具备一定的python基础知识,就可以仿照我们提供的模板实现自己的插件功能。
216
- 详情请参考[函数插件指南](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)。
217
-
218
-
219
  ---
220
 
221
 
222
  ## 部分功能展示
223
 
224
- 1. 图片显示:
225
 
226
  <div align="center">
227
  <img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
228
  </div>
229
 
230
- 2. 本项目的代码自译解(如果一个程序能够读懂并剖析自己):
 
231
 
232
  <div align="center">
233
  <img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
@@ -237,7 +239,7 @@ docker run --rm -it --net=host --gpus=all gpt-academic bash
237
  <img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
238
  </div>
239
 
240
- 3. 其他任意Python/Cpp/Java/Go/Rect/...项目剖析:
241
  <div align="center">
242
  <img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
243
  </div>
@@ -246,26 +248,26 @@ docker run --rm -it --net=host --gpus=all gpt-academic bash
246
  <img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
247
  </div>
248
 
249
- 4. Latex论文一键阅读理解与摘要生成
250
  <div align="center">
251
  <img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
252
  </div>
253
 
254
- 5. 自动报告生成
255
  <div align="center">
256
  <img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
257
  <img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
258
  <img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
259
  </div>
260
 
261
- 6. 模块化功能设计
262
  <div align="center">
263
  <img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
264
  <img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
265
  </div>
266
 
267
 
268
- 7. 源代码转译英文
269
 
270
  <div align="center">
271
  <img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
@@ -284,13 +286,11 @@ docker run --rm -it --net=host --gpus=all gpt-academic bash
284
  - version 2.0: 引入模块化函数插件
285
  - version 1.0: 基础功能
286
 
287
- chatgpt_academic开发者QQ群:734063350
288
-
289
  ## 参考与学习
290
 
291
  ```
292
  代码中参考了很多其他优秀项目中的设计,主要包括:
293
- # test
294
  # 借鉴项目1:借鉴了ChuanhuChatGPT中诸多技巧
295
  https://github.com/GaiZhenbiao/ChuanhuChatGPT
296
 
 
10
  pinned: false
11
  ---
12
 
13
+ # ChatGPT 学术优化
14
 
15
  **如果喜欢这个项目,请给它一个Star;如果你发明了更好用的快捷键或函数插件,欢迎发issue或者pull requests**
16
 
 
22
  >
23
  > 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)当中。
24
  >
25
+
26
 
27
  <div align="center">
28
 
 
40
  Latex全文翻译、润色 | [函数插件] 一键翻译或润色latex论文
41
  批量注释生成 | [函数插件] 一键批量生成函数注释
42
  chat分析报告生成 | [函数插件] 运行后自动生成总结汇报
 
43
  [arxiv小助手](https://www.bilibili.com/video/BV1LM4y1279X) | [函数插件] 输入arxiv文章url即可一键翻译摘要+下载PDF
44
  [PDF论文全文翻译功能](https://www.bilibili.com/video/BV1KT411x7Wn) | [函数插件] PDF论文提取题目&摘要+翻译全文(多线程)
45
  [谷歌学术统合小助手](https://www.bilibili.com/video/BV19L411U7ia) | [函数插件] 给定任意谷歌学术搜索页面URL,让gpt帮你选择有趣的文章
 
53
  </div>
54
 
55
 
56
+ - 新界面(修改config.py中的LAYOUT选项即可实现“左右布局”和“上下布局”的切换)
57
  <div align="center">
58
  <img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
59
  </div>
 
101
 
102
  在`config.py`中,配置 海外Proxy 和 OpenAI API KEY,说明如下
103
  ```
104
+ 1. 如果你在国内,需要设置海外代理才能够顺利使用 OpenAI API,设置方法请仔细阅读config.py(1.修改其中的USE_PROXY为True; 2.按照说明修改其中的proxies)。
105
+ 2. 配置 OpenAI API KEY。你需要在 OpenAI 官网上注册并获取 API KEY。一旦你拿到了 API KEY,在 config.py 文件里配置好即可。
106
  3. 与代理网络有关的issue(网络超时、代理不起作用)汇总到 https://github.com/binary-husky/chatgpt_academic/issues/1
107
  ```
108
  (P.S. 程序运行时会优先检查是否存在名为`config_private.py`的私密配置文件,并用其中的配置覆盖`config.py`的同名配置。因此,如果您能理解我们的配置读取逻辑,我们强烈建议您在`config.py`旁边创建一个名为`config_private.py`的新配置文件,并把`config.py`中的配置转移(复制)到`config_private.py`中。`config_private.py`不受git管控,可以让您的隐私信息更加安全。)
 
110
 
111
  3. 安装依赖
112
  ```sh
113
+ # (选择一)推荐
114
+ python -m pip install -r requirements.txt
115
+
116
+ # (选择二)如果您使用anaconda,步骤也是类似的:
117
+ # (选择二.1)conda create -n gptac_venv python=3.11
118
+ # (选择二.2)conda activate gptac_venv
119
+ # (选择二.3python -m pip install -r requirements.txt
120
+
121
+ # 备注:使用官方pip源或者阿里pip源,其他pip源(如一些大学的pip)有可能出问题,临时换源方法:
122
+ # python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
123
  ```
124
 
125
+ 如果需要支持清华ChatGLM,需要额外安装更多依赖(不熟悉python者、电脑配置不佳者,建议不要尝试):
126
  ```sh
127
  python -m pip install -r request_llm/requirements_chatglm.txt
128
  ```
 
135
  5. 测试函数插件
136
  ```
137
  - 测试Python项目分析
138
+ input区域 输入 `./crazy_functions/test_project/python/dqn` , 然后点击 "解析整个Python项目"
139
+ - 测试自我代码解读
 
140
  点击 "[多线程Demo] 解析此项目本身(源码自译解)"
141
+ - 测试实验功能模板函数(要求gpt回答历史上的今天发生了什么),您可以根据此函数为模板,实现更复杂的功能
142
  点击 "[函数插件模板Demo] 历史上的今天"
143
  - 函数插件区下拉菜单中有更多功能可供选择
144
  ```
145
 
146
+ ## 安装-方法2:使用docker (Linux)
147
 
148
  1. 仅ChatGPT(推荐大多数人选择)
149
  ``` sh
 
156
  docker build -t gpt-academic .
157
  # 运行
158
  docker run --rm -it --net=host gpt-academic
159
+
160
+ # 测试函数插件
161
+ ## 测试函数插件模板函数(要求gpt回答历史上的今天发生了什么),您可以根据此函数为模板,实现更复杂的功能
162
+ 点击 "[函数插件模板Demo] 历史上的今天"
163
+ ## 测试给Latex项目写摘要
164
+ input区域 输入 ./crazy_functions/test_project/latex/attention , 然后点击 "读Tex论文写摘要"
165
+ ## 测试Python项目分析
166
+ input区域 输入 ./crazy_functions/test_project/python/dqn , 然后点击 "解析整个Python项目"
167
+
168
+ 函数插件区下拉菜单中有更多功能可供选择
169
  ```
170
 
171
+ 2. ChatGPT+ChatGLM(需要对docker非常熟悉 + 电脑配置足够强)
172
 
173
  ``` sh
174
+ # 修改dockerfile
175
  cd docs && nano Dockerfile+ChatGLM
176
+ # How to build | 如何构建 (Dockerfile+ChatGLM在docs路径下,请先cd docs)
177
  docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
178
+ # How to run | 如何运行 (1) 直接运行:
179
  docker run --rm -it --net=host --gpus=all gpt-academic
180
+ # How to run | 如何运行 (2) 我想运行之前进容器做一些调整:
181
  docker run --rm -it --net=host --gpus=all gpt-academic bash
182
  ```
183
 
184
 
185
+ ## 安装-方法3:其他部署方式
186
 
187
  1. 远程云服务器部署
188
  请访问[部署wiki-1](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
 
201
 
202
  ---
203
 
204
+ ## 自定义新的便捷按钮(学术快捷键自定义)
 
 
205
  任意文本编辑器打开`core_functional.py`,添加条目如下,然后重启程序即可。(如果按钮已经添加成功并可见,那么前缀、后缀都支持热修改,无需重启程序即可生效。)
206
  例如
207
  ```
 
217
  <img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
218
  </div>
219
 
 
 
 
 
 
 
 
220
  ---
221
 
222
 
223
  ## 部分功能展示
224
 
225
+ ### 图片显示:
226
 
227
  <div align="center">
228
  <img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
229
  </div>
230
 
231
+
232
+ ### 如果一个程序能够读懂并剖析自己:
233
 
234
  <div align="center">
235
  <img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
 
239
  <img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
240
  </div>
241
 
242
+ ### 其他任意Python/Cpp项目剖析:
243
  <div align="center">
244
  <img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
245
  </div>
 
248
  <img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
249
  </div>
250
 
251
+ ### Latex论文一键阅读理解与摘要生成
252
  <div align="center">
253
  <img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
254
  </div>
255
 
256
+ ### 自动报告生成
257
  <div align="center">
258
  <img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
259
  <img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
260
  <img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
261
  </div>
262
 
263
+ ### 模块化功能设计
264
  <div align="center">
265
  <img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
266
  <img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
267
  </div>
268
 
269
 
270
+ ### 源代码转译英文
271
 
272
  <div align="center">
273
  <img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
 
286
  - version 2.0: 引入模块化函数插件
287
  - version 1.0: 基础功能
288
 
 
 
289
  ## 参考与学习
290
 
291
  ```
292
  代码中参考了很多其他优秀项目中的设计,主要包括:
293
+
294
  # 借鉴项目1:借鉴了ChuanhuChatGPT中诸多技巧
295
  https://github.com/GaiZhenbiao/ChuanhuChatGPT
296
 
config.py CHANGED
@@ -1,6 +1,6 @@
1
  # [step 1]>> 例如: API_KEY = "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" (此key无效)
2
  import os
3
- API_KEY = os.environ["key"] # 可同时填写多个API-KEY,用英文逗号分割,例如API_KEY = "sk-openaikey1,sk-openaikey2,fkxxxx-api2dkey1,fkxxxx-api2dkey2"
4
 
5
  # [step 2]>> 改为True应用代理,如果直接在海外服务器部署,此处不修改
6
  USE_PROXY = False
@@ -44,9 +44,9 @@ WEB_PORT = -1
44
  # 如果OpenAI不响应(网络卡顿、代理失败、KEY失效),重试的次数限制
45
  MAX_RETRY = 2
46
 
47
- # OpenAI模型选择是(gpt4现在只对申请成功的人开放,体验gpt-4可以试试api2d)
48
- LLM_MODEL = "gpt-3.5-turbo" # 可选 ↓↓↓
49
- AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "api2d-gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "chatglm"]
50
 
51
  # 本地LLM模型如ChatGLM的执行方式 CPU/GPU
52
  LOCAL_MODEL_DEVICE = "cpu" # 可选 "cuda"
 
1
  # [step 1]>> 例如: API_KEY = "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" (此key无效)
2
  import os
3
+ API_KEY = os.environ.get("key") # 可同时填写多个API-KEY,用英文逗号分割,例如API_KEY = "sk-openaikey1,sk-openaikey2,fkxxxx-api2dkey1,fkxxxx-api2dkey2"
4
 
5
  # [step 2]>> 改为True应用代理,如果直接在海外服务器部署,此处不修改
6
  USE_PROXY = False
 
44
  # 如果OpenAI不响应(网络卡顿、代理失败、KEY失效),重试的次数限制
45
  MAX_RETRY = 2
46
 
47
+ # OpenAI模型选择是(gpt4现在只对申请成功的人开放)
48
+ LLM_MODEL = "gpt-3.5-turbo" # 可选 "chatglm"
49
+ AVAIL_LLM_MODELS = ["gpt-3.5-turbo", "gpt-4", "api2d-gpt-4", "api2d-gpt-3.5-turbo"]
50
 
51
  # 本地LLM模型如ChatGLM的执行方式 CPU/GPU
52
  LOCAL_MODEL_DEVICE = "cpu" # 可选 "cuda"
crazy_functional.py CHANGED
@@ -173,23 +173,20 @@ def get_crazy_functions():
173
 
174
  ###################### 第三组插件 ###########################
175
  # [第三组插件]: 尚未充分测试的函数插件,放在这里
176
- from crazy_functions.下载arxiv论文翻译摘要 import 下载arxiv论文并翻译摘要
177
- function_plugins.update({
178
- "一键下载arxiv论文并翻译摘要(先在input输入编号,如1812.10695)": {
179
- "Color": "stop",
180
- "AsButton": False, # 加入下拉菜单中
181
- "Function": HotReload(下载arxiv论文并翻译摘要)
182
- }
183
- })
 
 
 
 
184
 
185
- from crazy_functions.联网的ChatGPT import 连接网络回答问题
186
- function_plugins.update({
187
- "连接网络回答问题(先输入问题,再点击按钮,需要访问谷歌)": {
188
- "Color": "stop",
189
- "AsButton": False, # 加入下拉菜单中
190
- "Function": HotReload(连接网络回答问题)
191
- }
192
- })
193
 
194
  ###################### 第n组插件 ###########################
195
  return function_plugins
 
173
 
174
  ###################### 第三组插件 ###########################
175
  # [第三组插件]: 尚未充分测试的函数插件,放在这里
176
+ try:
177
+ from crazy_functions.下载arxiv论文翻译摘要 import 下载arxiv论文并翻译摘要
178
+ function_plugins.update({
179
+ "一键下载arxiv论文并翻译摘要(先在input输入编号,如1812.10695)": {
180
+ "Color": "stop",
181
+ "AsButton": False, # 加入下拉菜单中
182
+ "Function": HotReload(下载arxiv论文并翻译摘要)
183
+ }
184
+ })
185
+
186
+ except Exception as err:
187
+ print(f'[下载arxiv论文并翻译摘要] 插件导入失败 {str(err)}')
188
 
189
+
 
 
 
 
 
 
 
190
 
191
  ###################### 第n组插件 ###########################
192
  return function_plugins
crazy_functions/crazy_functions_test.py CHANGED
@@ -12,7 +12,7 @@ def validate_path():
12
  sys.path.append(root_dir_assume)
13
 
14
  validate_path() # validate path so you can run from base directory
15
- from colorful import *
16
  from toolbox import get_conf, ChatBotWithCookies
17
  proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, CHATBOT_HEIGHT, LAYOUT, API_KEY = \
18
  get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'CHATBOT_HEIGHT', 'LAYOUT', 'API_KEY')
@@ -79,46 +79,14 @@ def test_下载arxiv论文并翻译摘要():
79
  for cookies, cb, hist, msg in 下载arxiv论文并翻译摘要(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
80
  print(cb)
81
 
82
- def test_联网回答问题():
83
- from crazy_functions.联网的ChatGPT import 连接网络回答问题
84
- # txt = "“我们称之为高效”是什么梗?"
85
- # >> 从第0份、第1份、第2份搜索结果可以看出,“我们称之为高效”是指在游戏社区中,用户们用来形容一些游戏策略或行为非常高效且能够带来好的效果的用语。这个用语最初可能是在群星(Stellaris)这个游戏里面流行起来的,后来也传播到了其他游戏中,比如巨像(Titan)等游戏。其中第1份搜索结果中的一篇文章也指出,“我们称之为高效”这 一用语来源于群星(Stellaris)游戏中的一个情节。
86
- # txt = "为什么说枪毙P社玩家没有一个冤枉的?"
87
- # >> 它们都是关于一个知乎用户所发的帖子,引用了一群游戏玩家对于需要对P社玩家进行枪毙的讨论,这个话题的本质是玩家们对于P 社游戏中的政治与历史元素的不同看法,以及其中不少玩家以极端立场宣扬的想法和言论,因此有人就以枪毙这些玩家来回应此类言论。但是这个话题本身并没有实质内容,只是一个玩笑或者恶搞,并不应该被当做真实的态度或者观点,因此这种说法没有实际意义。
88
- # txt = "谁是应急食品?"
89
- # >> '根据以上搜索结果可以得知,应急食品是“原神”游戏中的角色派蒙的外号。'
90
- # txt = "道路千万条,安全第一条。后面两句是?"
91
- # >> '行车不规范,亲人两行泪。'
92
- # txt = "What is in the canister?"
93
- # >> Rainbow Six Siege 游戏中 Smoke 的 Canister 中装有何种物质相关的官方信息。
94
- # txt = "失败的man是什么?"
95
- # >> 根据第1份搜索结果,可以得知失败的man是指一位在B站购买了蜘蛛侠COS服后穿上后被网友嘲笑的UP主,而“失败的man”是蜘蛛侠英文名“spiderman”的谐音梗,并且网友们还 给这位UP主起了“苍蝇侠”的外号。因此,失败的man是指这位UP主在穿上蜘蛛侠COS服后被网友嘲笑的情况。
96
- # txt = "老六是什么,起源于哪里?"
97
- # >> 老六是网络流行语,最初起源于游戏《CSGO》,指游戏中玩家中独来独往、游离于队伍之外的“自由人”或玩得比较菜或者玩得比较阴险的人 ,后来逐渐演变成指玩得比较阴险的玩家。
98
- # txt = "罗小黑战记因为什么经常被吐槽?"
99
- # >> 3. 更新速度。罗小黑战记的更新时间不定,时而快时而慢,给观众留下了等待的时间过长的印象。
100
- # txt = "沙特、伊朗最近的关系如何?"
101
- # >> 最近在中国的斡旋下,沙特和伊朗于3月10日达成了恢复两国外交关系的协议,这表明两国关系已经重新回到正常化状态。
102
- # txt = "You should have gone for the head. What does that mean?"
103
- # >> The phrase "You should have gone for the head" is a quote from the Marvel movies, Avengers: Infinity War and Avengers: Endgame. It was spoken by the character Thanos in Infinity War and by Thor in Endgame.
104
- txt = "AutoGPT是什么?"
105
- # >> AutoGPT是一个基于GPT-4语言模型的开源应用程序。它可以根据用户需求自主执行任务,包括事件分析、营销方案撰写、代码编程、数学运算等等,并完全不需要用户插手。它可以自己思考,给出实现的步骤和实现细节,甚至可以自问自答执 行任务。最近它在GitHub上爆火,成为了业内最热门的项目之一。
106
- # txt = "钟离带什么圣遗物?"
107
- for cookies, cb, hist, msg in 连接网络回答问题(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
108
- print("当前问答:", cb[-1][-1].replace("\n"," "))
109
- for i, it in enumerate(cb): print亮蓝(it[0]); print亮黄(it[1])
110
-
111
- # test_解析一个Python项目()
112
- # test_Latex英文润色()
113
- # test_Markdown中译英()
114
- # test_批量翻译PDF文档()
115
- # test_谷歌检索小助手()
116
- # test_总结word文档()
117
- # test_下载arxiv论文并翻译摘要()
118
- # test_解析一个Cpp项目()
119
-
120
- test_联网回答问题()
121
-
122
 
123
  input("程序完成,回车退出。")
124
  print("退出。")
 
12
  sys.path.append(root_dir_assume)
13
 
14
  validate_path() # validate path so you can run from base directory
15
+
16
  from toolbox import get_conf, ChatBotWithCookies
17
  proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION, CHATBOT_HEIGHT, LAYOUT, API_KEY = \
18
  get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION', 'CHATBOT_HEIGHT', 'LAYOUT', 'API_KEY')
 
79
  for cookies, cb, hist, msg in 下载arxiv论文并翻译摘要(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
80
  print(cb)
81
 
82
+ test_解析一个Python项目()
83
+ test_Latex英文润色()
84
+ test_Markdown中译英()
85
+ test_批量翻译PDF文档()
86
+ test_谷歌检索小助手()
87
+ test_总结word文档()
88
+ test_下载arxiv论文并翻译摘要()
89
+ test_解析一个Cpp项目()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  input("程序完成,回车退出。")
92
  print("退出。")
crazy_functions/询问多个大语言模型.py CHANGED
@@ -13,11 +13,11 @@ def 同时问询(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt
13
  web_port 当前软件运行的端口号
14
  """
15
  history = [] # 清空历史,以免输入溢出
16
- chatbot.append((txt, "正在同时咨询ChatGPTChatGLM……"))
17
  yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
18
 
19
  # llm_kwargs['llm_model'] = 'chatglm&gpt-3.5-turbo&api2d-gpt-3.5-turbo' # 支持任意数量的llm接口,用&符号分隔
20
- llm_kwargs['llm_model'] = 'chatglm&gpt-3.5-turbo' # 支持任意数量的llm接口,用&符号分隔
21
  gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
22
  inputs=txt, inputs_show_user=txt,
23
  llm_kwargs=llm_kwargs, chatbot=chatbot, history=history,
 
13
  web_port 当前软件运行的端口号
14
  """
15
  history = [] # 清空历史,以免输入溢出
16
+ chatbot.append((txt, "正在同时咨询gpt-3.5gpt-4……"))
17
  yield from update_ui(chatbot=chatbot, history=history) # 刷新界面 # 由于请求gpt需要一段时间,我们先及时地做一次界面更新
18
 
19
  # llm_kwargs['llm_model'] = 'chatglm&gpt-3.5-turbo&api2d-gpt-3.5-turbo' # 支持任意数量的llm接口,用&符号分隔
20
+ llm_kwargs['llm_model'] = 'gpt-3.5-turbo&gpt-4' # 支持任意数量的llm接口,用&符号分隔
21
  gpt_say = yield from request_gpt_model_in_new_thread_with_ui_alive(
22
  inputs=txt, inputs_show_user=txt,
23
  llm_kwargs=llm_kwargs, chatbot=chatbot, history=history,
main.py CHANGED
@@ -53,10 +53,11 @@ def main():
53
  cancel_handles = []
54
  with gr.Blocks(title="ChatGPT 学术优化", theme=set_theme, analytics_enabled=False, css=advanced_css) as demo:
55
  gr.HTML(title_html)
 
56
  cookies = gr.State({'api_key': API_KEY, 'llm_model': LLM_MODEL})
57
  with gr_L1():
58
  with gr_L2(scale=2):
59
- chatbot = gr.Chatbot(label=f"当前模型:{LLM_MODEL}")
60
  chatbot.style(height=CHATBOT_HEIGHT)
61
  history = gr.State([])
62
  with gr_L2(scale=1):
@@ -112,7 +113,7 @@ def main():
112
  with gr.Row():
113
  resetBtn2 = gr.Button("重置", variant="secondary"); resetBtn2.style(size="sm")
114
  stopBtn2 = gr.Button("停止", variant="secondary"); stopBtn2.style(size="sm")
115
- clearBtn2 = gr.Button("清除", variant="secondary", visible=False); clearBtn2.style(size="sm")
116
  # 功能区显示开关与功能区的互动
117
  def fn_area_visibility(a):
118
  ret = {}
@@ -155,9 +156,6 @@ def main():
155
  variant = crazy_fns[k]["Color"] if "Color" in crazy_fns[k] else "secondary"
156
  return {switchy_bt: gr.update(value=k, variant=variant)}
157
  dropdown.select(on_dropdown_changed, [dropdown], [switchy_bt] )
158
- def on_md_dropdown_changed(k):
159
- return {chatbot: gr.update(label="当前模型:"+k)}
160
- md_dropdown.select(on_md_dropdown_changed, [md_dropdown], [chatbot] )
161
  # 随变按钮的回调函数注册
162
  def route(k, *args, **kwargs):
163
  if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
@@ -186,7 +184,7 @@ def main():
186
  threading.Thread(target=warm_up_modules, name="warm-up", daemon=True).start()
187
 
188
  auto_opentab_delay()
189
- demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", server_port=PORT, auth=AUTHENTICATION, favicon_path="docs/logo.png")
190
 
191
  if __name__ == "__main__":
192
- main()
 
53
  cancel_handles = []
54
  with gr.Blocks(title="ChatGPT 学术优化", theme=set_theme, analytics_enabled=False, css=advanced_css) as demo:
55
  gr.HTML(title_html)
56
+ gr.HTML('''<center><a href="https://huggingface.co/spaces/qingxu98/gpt-academic?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space">''')
57
  cookies = gr.State({'api_key': API_KEY, 'llm_model': LLM_MODEL})
58
  with gr_L1():
59
  with gr_L2(scale=2):
60
+ chatbot = gr.Chatbot()
61
  chatbot.style(height=CHATBOT_HEIGHT)
62
  history = gr.State([])
63
  with gr_L2(scale=1):
 
113
  with gr.Row():
114
  resetBtn2 = gr.Button("重置", variant="secondary"); resetBtn2.style(size="sm")
115
  stopBtn2 = gr.Button("停止", variant="secondary"); stopBtn2.style(size="sm")
116
+ clearBtn2 = gr.Button("清除", variant="secondary", visible=False); clearBtn.style(size="sm")
117
  # 功能区显示开关与功能区的互动
118
  def fn_area_visibility(a):
119
  ret = {}
 
156
  variant = crazy_fns[k]["Color"] if "Color" in crazy_fns[k] else "secondary"
157
  return {switchy_bt: gr.update(value=k, variant=variant)}
158
  dropdown.select(on_dropdown_changed, [dropdown], [switchy_bt] )
 
 
 
159
  # 随变按钮的回调函数注册
160
  def route(k, *args, **kwargs):
161
  if k in [r"打开插件列表", r"请先从插件列表中选择"]: return
 
184
  threading.Thread(target=warm_up_modules, name="warm-up", daemon=True).start()
185
 
186
  auto_opentab_delay()
187
+ demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=False, favicon_path="docs/logo.png")
188
 
189
  if __name__ == "__main__":
190
+ main()
request_llm/bridge_chatgpt.py CHANGED
@@ -208,8 +208,6 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
208
  chatbot[-1] = (chatbot[-1][0], "[Local Message] You exceeded your current quota. OpenAI以账户额度不足为由,拒绝服务.")
209
  elif "bad forward key" in error_msg:
210
  chatbot[-1] = (chatbot[-1][0], "[Local Message] Bad forward key. API2D账户额度不足.")
211
- elif "Not enough point" in error_msg:
212
- chatbot[-1] = (chatbot[-1][0], "[Local Message] Not enough point. API2D账户点数不足.")
213
  else:
214
  from toolbox import regular_txt_to_markdown
215
  tb_str = '```\n' + traceback.format_exc() + '```'
 
208
  chatbot[-1] = (chatbot[-1][0], "[Local Message] You exceeded your current quota. OpenAI以账户额度不足为由,拒绝服务.")
209
  elif "bad forward key" in error_msg:
210
  chatbot[-1] = (chatbot[-1][0], "[Local Message] Bad forward key. API2D账户额度不足.")
 
 
211
  else:
212
  from toolbox import regular_txt_to_markdown
213
  tb_str = '```\n' + traceback.format_exc() + '```'
toolbox.py CHANGED
@@ -454,15 +454,13 @@ def select_api_key(keys, llm_model):
454
 
455
  @lru_cache(maxsize=128)
456
  def read_single_conf_with_lru_cache(arg):
457
- from colorful import print亮红, print亮绿, print亮蓝
458
  try:
459
  r = getattr(importlib.import_module('config_private'), arg)
460
  except:
461
  r = getattr(importlib.import_module('config'), arg)
462
  # 在读取API_KEY时,检查一下是不是忘了改config
463
  if arg == 'API_KEY':
464
- print亮蓝(f"[API_KEY] 本项目现已支持OpenAI和API2D的api-key。也支持同时填写多个api-key,如API_KEY=\"openai-key1,openai-key2,api2d-key3\"")
465
- print亮蓝(f"[API_KEY] 您既可以在config.py中修改api-key(s),也可以在问题输入区输入临时的api-key(s),然后回车键提交后即可生效。")
466
  if is_any_api_key(r):
467
  print亮绿(f"[API_KEY] 您的 API_KEY 是: {r[:15]}*** API_KEY 导入成功")
468
  else:
 
454
 
455
  @lru_cache(maxsize=128)
456
  def read_single_conf_with_lru_cache(arg):
457
+ from colorful import print亮红, print亮绿
458
  try:
459
  r = getattr(importlib.import_module('config_private'), arg)
460
  except:
461
  r = getattr(importlib.import_module('config'), arg)
462
  # 在读取API_KEY时,检查一下是不是忘了改config
463
  if arg == 'API_KEY':
 
 
464
  if is_any_api_key(r):
465
  print亮绿(f"[API_KEY] 您的 API_KEY 是: {r[:15]}*** API_KEY 导入成功")
466
  else: