Merge branch 'master' into huggingface-beta
Browse files- .gitignore +1 -0
- Dockerfile +6 -0
- README.md +68 -61
- check_proxy.py +8 -1
- crazy_functional.py +12 -11
- crazy_functions/Latex全文润色.py +2 -3
- crazy_functions/Latex全文翻译.py +2 -3
- crazy_functions/crazy_functions_test.py +52 -3
- crazy_functions/crazy_utils.py +6 -5
- crazy_functions/代码重写为全英文_多线程.py +2 -3
- crazy_functions/批量Markdown翻译.py +3 -4
- crazy_functions/批量翻译PDF文档_多线程.py +6 -6
- crazy_functions/理解PDF文档内容.py +2 -2
- docs/Dockerfile+ChatGLM +13 -4
- docs/README_EN.md +142 -145
- docs/README_FR.md +296 -0
- docs/README_JP.md +302 -0
- docs/README_RS.md +291 -0
- docs/logo.png +0 -0
- main.py +6 -5
- request_llm/bridge_all.py +38 -13
- request_llm/bridge_chatglm.py +31 -4
- request_llm/bridge_chatgpt.py +11 -5
- toolbox.py +1 -2
- version +1 -1
.gitignore
CHANGED
@@ -144,3 +144,4 @@ other_llms
|
|
144 |
cradle*
|
145 |
debug*
|
146 |
private*
|
|
|
|
144 |
cradle*
|
145 |
debug*
|
146 |
private*
|
147 |
+
crazy_functions/test_project/pdf_and_word
|
Dockerfile
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
FROM python:3.11
|
2 |
|
3 |
RUN echo '[global]' > /etc/pip.conf && \
|
@@ -11,4 +14,7 @@ RUN pip3 install -r requirements.txt
|
|
11 |
|
12 |
COPY . .
|
13 |
|
|
|
|
|
|
|
14 |
CMD ["python3", "-u", "main.py"]
|
|
|
1 |
+
# 此Dockerfile适用于“无本地模型”的环境构建,如果需要使用chatglm等本地模型,请参考 docs/Dockerfile+ChatGLM
|
2 |
+
# 如何构建: 先修改 `config.py`, 然后 docker build -t gpt-academic .
|
3 |
+
# 如何运行: docker run --rm -it --net=host gpt-academic
|
4 |
FROM python:3.11
|
5 |
|
6 |
RUN echo '[global]' > /etc/pip.conf && \
|
|
|
14 |
|
15 |
COPY . .
|
16 |
|
17 |
+
# 可选步骤,用于预热模块
|
18 |
+
RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()'
|
19 |
+
|
20 |
CMD ["python3", "-u", "main.py"]
|
README.md
CHANGED
@@ -14,7 +14,7 @@ pinned: false
|
|
14 |
|
15 |
**如果喜欢这个项目,请给它一个Star;如果你发明了更好用的快捷键或函数插件,欢迎发issue或者pull requests**
|
16 |
|
17 |
-
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
|
18 |
|
19 |
> **Note**
|
20 |
>
|
@@ -33,7 +33,7 @@ If you like this project, please give it a Star. If you've come up with more use
|
|
33 |
一键代码解释 | 可以正确显示代码、解释代码
|
34 |
[自定义快捷键](https://www.bilibili.com/video/BV14s4y1E7jN) | 支持自定义快捷键
|
35 |
[配置代理服务器](https://www.bilibili.com/video/BV1rc411W7Dr) | 支持配置代理服务器
|
36 |
-
模块化设计 |
|
37 |
[自我程序剖析](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)本项目的源代码
|
38 |
[程序剖析](https://www.bilibili.com/video/BV1cj411A7VW) | [函数插件] 一键可以剖析其他Python/C/C++/Java/Lua/...项目树
|
39 |
读论文 | [函数插件] 一键解读latex论文全文并生成摘要
|
@@ -46,8 +46,7 @@ chat分析报告生成 | [函数插件] 运行后自动生成总结汇报
|
|
46 |
公式/图片/表格显示 | 可以同时显示公式的tex形式和渲染形式,支持公式、代码高亮
|
47 |
多线程函数插件支持 | 支持多线调用chatgpt,一键处理海量文本或程序
|
48 |
启动暗色gradio[主题](https://github.com/binary-husky/chatgpt_academic/issues/173) | 在浏览器url后面添加```/?__dark-theme=true```可以切换dark主题
|
49 |
-
[多LLM模型](https://www.bilibili.com/video/
|
50 |
-
兼容[TGUI](https://github.com/oobabooga/text-generation-webui)接入更多样的语言模型 | 接入opt-1.3b, galactica-1.3b等模型([v3.1分支](https://github.com/binary-husky/chatgpt_academic/tree/v3.0)测试中)
|
51 |
huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/gpt-academic) | 登陆huggingface后复制[此空间](https://huggingface.co/spaces/qingxu98/gpt-academic)
|
52 |
…… | ……
|
53 |
|
@@ -80,22 +79,25 @@ huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/
|
|
80 |
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
|
81 |
</div>
|
82 |
|
83 |
-
- 多种大语言模型混合调用([
|
84 |
<div align="center">
|
85 |
-
<img src="https://user-images.githubusercontent.com/96192199/
|
86 |
</div>
|
87 |
|
|
|
88 |
|
89 |
|
90 |
-
|
|
|
|
|
91 |
|
92 |
-
|
93 |
```sh
|
94 |
git clone https://github.com/binary-husky/chatgpt_academic.git
|
95 |
cd chatgpt_academic
|
96 |
```
|
97 |
|
98 |
-
|
99 |
|
100 |
在`config.py`中,配置 海外Proxy 和 OpenAI API KEY,说明如下
|
101 |
```
|
@@ -106,7 +108,7 @@ cd chatgpt_academic
|
|
106 |
(P.S. 程序运行时会优先检查是否存在名为`config_private.py`的私密配置文件,并用其中的配置覆盖`config.py`的同名配置。因此,如果您能理解我们的配置读取逻辑,我们强烈建议您在`config.py`旁边创建一个名为`config_private.py`的新配置文件,并把`config.py`��的配置转移(复制)到`config_private.py`中。`config_private.py`不受git管控,可以让您的隐私信息更加安全。)
|
107 |
|
108 |
|
109 |
-
|
110 |
```sh
|
111 |
# (选择一)推荐
|
112 |
python -m pip install -r requirements.txt
|
@@ -120,27 +122,30 @@ python -m pip install -r requirements.txt
|
|
120 |
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
121 |
```
|
122 |
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
124 |
```sh
|
125 |
python main.py
|
126 |
```
|
127 |
|
128 |
-
|
129 |
```
|
130 |
-
- 测试C++项目头文件分析
|
131 |
-
input区域 输入 `./crazy_functions/test_project/cpp/libJPG` , 然后点击 "[实验] 解析整个C++项目(input输入项目根路径)"
|
132 |
-
- 测试给Latex项目写摘要
|
133 |
-
input区域 输入 `./crazy_functions/test_project/latex/attention` , 然后点击 "[实验] 读tex论文写摘要(input输入项目根路径)"
|
134 |
- 测试Python项目分析
|
135 |
-
input区域 输入 `./crazy_functions/test_project/python/dqn` , 然后点击 "
|
136 |
- 测试自我代码解读
|
137 |
-
点击 "[
|
138 |
- 测试实验功能模板函数(要求gpt回答历史上的今天发生了什么),您可以根据此函数为模板,实现更复杂的功能
|
139 |
-
点击 "[
|
|
|
140 |
```
|
141 |
|
142 |
-
##
|
143 |
|
|
|
144 |
``` sh
|
145 |
# 下载项目
|
146 |
git clone https://github.com/binary-husky/chatgpt_academic.git
|
@@ -152,67 +157,70 @@ docker build -t gpt-academic .
|
|
152 |
# 运行
|
153 |
docker run --rm -it --net=host gpt-academic
|
154 |
|
155 |
-
#
|
156 |
-
##
|
157 |
-
点击 "[
|
158 |
-
## 测试实验功能模板函数(要求gpt回答历史上的今天发生了什么),您可以根据此函数为模板,实现更复杂的功能
|
159 |
-
点击 "[实验] 实验功能函数模板"
|
160 |
-
##(请注意在docker中运行时,需要额外注意程序的文件访问权限问题)
|
161 |
-
## 测试C++项目头文件分析
|
162 |
-
input区域 输入 ./crazy_functions/test_project/cpp/libJPG , 然后点击 "[实验] 解析整个C++项目(input输入项目根路径)"
|
163 |
## 测试给Latex项目写摘要
|
164 |
-
input区域 输入 ./crazy_functions/test_project/latex/attention , 然后点击 "
|
165 |
## 测试Python项目分析
|
166 |
-
input区域 输入 ./crazy_functions/test_project/python/dqn , 然后点击 "
|
|
|
|
|
|
|
|
|
|
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
```
|
169 |
|
170 |
-
## 其他部署方式
|
171 |
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
## 自定义新的便捷按钮(学术快捷键自定义)
|
179 |
任意文本编辑器打开`core_functional.py`,添加条目如下,然后重启程序即可。(如果按钮已经添加成功并可见,那么前缀、后缀都支持热修改,无需重启程序即可生效。)
|
180 |
例如
|
181 |
```
|
182 |
"超级英译中": {
|
183 |
-
|
184 |
# 前缀,会被加在你的输入之前。例如,用来描述你的要求,例如翻译、解释代码、润色等等
|
185 |
"Prefix": "请翻译把下面一段内容成中文,然后用一个markdown表格逐一解释文中出现的专有名词:\n\n",
|
186 |
|
187 |
# 后缀,会被加在你的输入之后。例如,配合前缀可以把你的输入内容用引号圈起来。
|
188 |
"Suffix": "",
|
189 |
-
|
190 |
},
|
191 |
```
|
192 |
<div align="center">
|
193 |
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
|
194 |
</div>
|
195 |
|
|
|
196 |
|
197 |
-
如果你发明了更好用的快捷键,欢迎发issue或者pull requests!
|
198 |
-
|
199 |
-
## 配置代理
|
200 |
-
### 方法一:常规方法
|
201 |
-
在```config.py```中修改端口与代理软件对应
|
202 |
-
|
203 |
-
<div align="center">
|
204 |
-
<img src="https://user-images.githubusercontent.com/96192199/226571294-37a47cd9-4d40-4c16-97a2-d360845406f7.png" width="500" >
|
205 |
-
<img src="https://user-images.githubusercontent.com/96192199/226838985-e5c95956-69c2-4c23-a4dd-cd7944eeb451.png" width="500" >
|
206 |
-
</div>
|
207 |
-
|
208 |
-
配置完成后,你可以用以下命令测试代理是否工作,如果一切正常,下面的代码将输出你的代理服务器所在地:
|
209 |
-
```
|
210 |
-
python check_proxy.py
|
211 |
-
```
|
212 |
-
### 方法二:纯新手教程
|
213 |
-
[纯新手教程](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)
|
214 |
|
215 |
-
##
|
216 |
|
217 |
### 图片显示:
|
218 |
|
@@ -266,8 +274,9 @@ python check_proxy.py
|
|
266 |
</div>
|
267 |
|
268 |
## Todo 与 版本规划:
|
269 |
-
|
270 |
-
- version 3.
|
|
|
271 |
- version 2.6: 重构了插件结构,提高了交互性,加入更多插件
|
272 |
- version 2.5: 自更新,解决总结大工程源代码时文本过长、token溢出的问题
|
273 |
- version 2.4: (1)新增PDF全文翻译功能; (2)新增输入区切换位置的功能; (3)新增垂直布局选项; (4)多线程函数插件优化。
|
@@ -279,14 +288,12 @@ python check_proxy.py
|
|
279 |
|
280 |
## 参考与学习
|
281 |
|
282 |
-
|
283 |
```
|
284 |
代码中参考了很多其他优秀项目中的设计,主要包括:
|
285 |
|
286 |
-
# 借鉴项目1:借鉴了ChuanhuChatGPT
|
287 |
https://github.com/GaiZhenbiao/ChuanhuChatGPT
|
288 |
|
289 |
-
# 借鉴项目2:
|
290 |
https://github.com/THUDM/ChatGLM-6B
|
291 |
-
|
292 |
```
|
|
|
14 |
|
15 |
**如果喜欢这个项目,请给它一个Star;如果你发明了更好用的快捷键或函数插件,欢迎发issue或者pull requests**
|
16 |
|
17 |
+
If you like this project, please give it a Star. If you've come up with more useful academic shortcuts or functional plugins, feel free to open an issue or pull request. We also have a README in [English|](docs/README_EN.md)[日本語|](docs/README_JP.md)[Русский|](docs/README_RS.md)[Français](docs/README_FR.md) translated by this project itself.
|
18 |
|
19 |
> **Note**
|
20 |
>
|
|
|
33 |
一键代码解释 | 可以正确显示代码、解释代码
|
34 |
[自定义快捷键](https://www.bilibili.com/video/BV14s4y1E7jN) | 支持自定义快捷键
|
35 |
[配置代理服务器](https://www.bilibili.com/video/BV1rc411W7Dr) | 支持配置代理服务器
|
36 |
+
模块化设计 | 支持自定义高阶的函数插件与[函数插件],插件支持[热更新](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)
|
37 |
[自我程序剖析](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)本项目的源代码
|
38 |
[程序剖析](https://www.bilibili.com/video/BV1cj411A7VW) | [函数插件] 一键可以剖析其他Python/C/C++/Java/Lua/...项目树
|
39 |
读论文 | [函数插件] 一键解读latex论文全文并生成摘要
|
|
|
46 |
公式/图片/表格显示 | 可以同时显示公式的tex形式和渲染形式,支持公式、代码高亮
|
47 |
多线程函数插件支持 | 支持多线调用chatgpt,一键处理海量文本或程序
|
48 |
启动暗色gradio[主题](https://github.com/binary-husky/chatgpt_academic/issues/173) | 在浏览器url后面添加```/?__dark-theme=true```可以切换dark主题
|
49 |
+
[多LLM模型](https://www.bilibili.com/video/BV1wT411p7yf)支持,[API2D](https://api2d.com/)接口支持 | 同时被GPT3.5、GPT4和[清华ChatGLM](https://github.com/THUDM/ChatGLM-6B)伺候的感觉一定会很不错吧?
|
|
|
50 |
huggingface免科学上网[在线体验](https://huggingface.co/spaces/qingxu98/gpt-academic) | 登陆huggingface后复制[此空间](https://huggingface.co/spaces/qingxu98/gpt-academic)
|
51 |
…… | ……
|
52 |
|
|
|
79 |
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
|
80 |
</div>
|
81 |
|
82 |
+
- 多种大语言模型混合调用(ChatGLM + OpenAI-GPT3.5 + [API2D](https://api2d.com/)-GPT4)
|
83 |
<div align="center">
|
84 |
+
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
|
85 |
</div>
|
86 |
|
87 |
+
多种大语言模型混合调用[huggingface测试版](https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta)(huggingface版不支持chatglm)
|
88 |
|
89 |
|
90 |
+
---
|
91 |
+
|
92 |
+
## 安装-方法1:直接运行 (Windows, Linux or MacOS)
|
93 |
|
94 |
+
1. 下载项目
|
95 |
```sh
|
96 |
git clone https://github.com/binary-husky/chatgpt_academic.git
|
97 |
cd chatgpt_academic
|
98 |
```
|
99 |
|
100 |
+
2. 配置API_KEY和代理设置
|
101 |
|
102 |
在`config.py`中,配置 海外Proxy 和 OpenAI API KEY,说明如下
|
103 |
```
|
|
|
108 |
(P.S. 程序运行时会优先检查是否存在名为`config_private.py`的私密配置文件,并用其中的配置覆盖`config.py`的同名配置。因此,如果您能理解我们的配置读取逻辑,我们强烈建议您在`config.py`旁边创建一个名为`config_private.py`的新配置文件,并把`config.py`��的配置转移(复制)到`config_private.py`中。`config_private.py`不受git管控,可以让您的隐私信息更加安全。)
|
109 |
|
110 |
|
111 |
+
3. 安装依赖
|
112 |
```sh
|
113 |
# (选择一)推荐
|
114 |
python -m pip install -r requirements.txt
|
|
|
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 |
+
```
|
129 |
+
|
130 |
+
4. 运行
|
131 |
```sh
|
132 |
python main.py
|
133 |
```
|
134 |
|
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
|
150 |
# 下载项目
|
151 |
git clone https://github.com/binary-husky/chatgpt_academic.git
|
|
|
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)
|
189 |
+
|
190 |
+
2. 使用WSL2(Windows Subsystem for Linux 子系统)
|
191 |
+
请访问[部署wiki-2](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
|
192 |
+
|
193 |
|
194 |
+
## 安装-代理配置
|
195 |
+
1. 常规方法
|
196 |
+
[配置代理](https://github.com/binary-husky/chatgpt_academic/issues/1)
|
197 |
+
|
198 |
+
2. 纯新手教程
|
199 |
+
[纯新手教程](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)
|
200 |
+
|
201 |
+
|
202 |
+
---
|
203 |
|
204 |
## 自定义新的便捷按钮(学术快捷键自定义)
|
205 |
任意文本编辑器打开`core_functional.py`,添加条目如下,然后重启程序即可。(如果按钮已经添加成功并可见,那么前缀、后缀都支持热修改,无需重启程序即可生效。)
|
206 |
例如
|
207 |
```
|
208 |
"超级英译中": {
|
|
|
209 |
# 前缀,会被加在你的输入之前。例如,用来描述你的要求,例如翻译、解释代码、润色等等
|
210 |
"Prefix": "请翻译把下面一段内容成中文,然后用一个markdown表格逐一解释文中出现的专有名词:\n\n",
|
211 |
|
212 |
# 后缀,会被加在你的输入之后。例如,配合前缀可以把你的输入内容用引号圈起来。
|
213 |
"Suffix": "",
|
|
|
214 |
},
|
215 |
```
|
216 |
<div align="center">
|
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 |
|
|
|
274 |
</div>
|
275 |
|
276 |
## Todo 与 版本规划:
|
277 |
+
- version 3.2+ (todo): 函数插件支持更多参数接口
|
278 |
+
- version 3.1: 支持同时问询多个gpt模型!支持api2d,支持多个apikey负载均衡
|
279 |
+
- version 3.0: 对chatglm和其他小型llm的支持
|
280 |
- version 2.6: 重构了插件结构,提高了交互性,加入更多插件
|
281 |
- version 2.5: 自更新,解决总结大工程源代码时文本过长、token溢出的问题
|
282 |
- version 2.4: (1)新增PDF全文翻译功能; (2)新增输入区切换位置的功能; (3)新增垂直布局选项; (4)多线程函数插件优化。
|
|
|
288 |
|
289 |
## 参考与学习
|
290 |
|
|
|
291 |
```
|
292 |
代码中参考了很多其他优秀项目中的设计,主要包括:
|
293 |
|
294 |
+
# 借鉴项目1:借鉴了ChuanhuChatGPT中诸多技巧
|
295 |
https://github.com/GaiZhenbiao/ChuanhuChatGPT
|
296 |
|
297 |
+
# 借鉴项目2:清华ChatGLM-6B:
|
298 |
https://github.com/THUDM/ChatGLM-6B
|
|
|
299 |
```
|
check_proxy.py
CHANGED
@@ -103,7 +103,7 @@ def auto_update():
|
|
103 |
import json
|
104 |
proxies, = get_conf('proxies')
|
105 |
response = requests.get(
|
106 |
-
"https://raw.githubusercontent.com/binary-husky/chatgpt_academic/master/version", proxies=proxies, timeout=
|
107 |
remote_json_data = json.loads(response.text)
|
108 |
remote_version = remote_json_data['version']
|
109 |
if remote_json_data["show_feature"]:
|
@@ -133,6 +133,13 @@ def auto_update():
|
|
133 |
except:
|
134 |
print('自动更新程序:已禁用')
|
135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
if __name__ == '__main__':
|
138 |
import os
|
|
|
103 |
import json
|
104 |
proxies, = get_conf('proxies')
|
105 |
response = requests.get(
|
106 |
+
"https://raw.githubusercontent.com/binary-husky/chatgpt_academic/master/version", proxies=proxies, timeout=5)
|
107 |
remote_json_data = json.loads(response.text)
|
108 |
remote_version = remote_json_data['version']
|
109 |
if remote_json_data["show_feature"]:
|
|
|
133 |
except:
|
134 |
print('自动更新程序:已禁用')
|
135 |
|
136 |
+
def warm_up_modules():
|
137 |
+
print('正在执行一些模块的预热...')
|
138 |
+
from request_llm.bridge_all import model_info
|
139 |
+
enc = model_info["gpt-3.5-turbo"]['tokenizer']
|
140 |
+
enc.encode("模块预热", disallowed_special=())
|
141 |
+
enc = model_info["gpt-4"]['tokenizer']
|
142 |
+
enc.encode("模块预热", disallowed_special=())
|
143 |
|
144 |
if __name__ == '__main__':
|
145 |
import os
|
crazy_functional.py
CHANGED
@@ -3,7 +3,6 @@ from toolbox import HotReload # HotReload 的意思是热更新,修改函数
|
|
3 |
|
4 |
def get_crazy_functions():
|
5 |
###################### 第一组插件 ###########################
|
6 |
-
# [第一组插件]: 最早期编写的项目插件和一些demo
|
7 |
from crazy_functions.读文章写摘要 import 读文章写摘要
|
8 |
from crazy_functions.生成函数注释 import 批量生成函数注释
|
9 |
from crazy_functions.解析项目源代码 import 解析项目本身
|
@@ -19,15 +18,17 @@ def get_crazy_functions():
|
|
19 |
from crazy_functions.询问多个大语言模型 import 同时问询
|
20 |
from crazy_functions.解析项目源代码 import 解析一个Lua项目
|
21 |
from crazy_functions.解析项目源代码 import 解析一个CSharp项目
|
|
|
22 |
function_plugins = {
|
23 |
-
|
24 |
-
"Color": "stop", # 按钮颜色
|
25 |
-
"Function": HotReload(同时问询)
|
26 |
-
},
|
27 |
"解析整个Python项目": {
|
28 |
"Color": "stop", # 按钮颜色
|
29 |
"Function": HotReload(解析一个Python项目)
|
30 |
},
|
|
|
|
|
|
|
|
|
31 |
"解析整个C++项目头文件": {
|
32 |
"Color": "stop", # 按钮颜色
|
33 |
"AsButton": False, # 加入下拉菜单中
|
@@ -86,10 +87,9 @@ def get_crazy_functions():
|
|
86 |
|
87 |
}
|
88 |
###################### 第二组插件 ###########################
|
89 |
-
# [第二组插件]:
|
90 |
from crazy_functions.批量总结PDF文档 import 批量总结PDF文档
|
91 |
from crazy_functions.批量总结PDF文档pdfminer import 批量总结PDF文档pdfminer
|
92 |
-
from crazy_functions.总结word文档 import 总结word文档
|
93 |
from crazy_functions.批量翻译PDF文档_多线程 import 批量翻译PDF文档
|
94 |
from crazy_functions.谷歌检索小助手 import 谷歌检索小助手
|
95 |
from crazy_functions.理解PDF文档内容 import 理解PDF文档内容标准文件输入
|
@@ -105,6 +105,10 @@ def get_crazy_functions():
|
|
105 |
"AsButton": True, # 加入下拉菜单中
|
106 |
"Function": HotReload(批量翻译PDF文档)
|
107 |
},
|
|
|
|
|
|
|
|
|
108 |
"[测试功能] 批量总结PDF文档": {
|
109 |
"Color": "stop",
|
110 |
"AsButton": False, # 加入下拉菜单中
|
@@ -121,10 +125,7 @@ def get_crazy_functions():
|
|
121 |
"AsButton": False, # 加入下拉菜单中
|
122 |
"Function": HotReload(谷歌检索小助手)
|
123 |
},
|
124 |
-
|
125 |
-
"Color": "stop",
|
126 |
-
"Function": HotReload(总结word文档)
|
127 |
-
},
|
128 |
"理解PDF文档内容 (模仿ChatPDF)": {
|
129 |
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
|
130 |
"Color": "stop",
|
|
|
3 |
|
4 |
def get_crazy_functions():
|
5 |
###################### 第一组插件 ###########################
|
|
|
6 |
from crazy_functions.读文章写摘要 import 读文章写摘要
|
7 |
from crazy_functions.生成函数注释 import 批量生成函数注释
|
8 |
from crazy_functions.解析项目源代码 import 解析项目本身
|
|
|
18 |
from crazy_functions.询问多个大语言模型 import 同时问询
|
19 |
from crazy_functions.解析项目源代码 import 解析一个Lua项目
|
20 |
from crazy_functions.解析项目源代码 import 解析一个CSharp项目
|
21 |
+
from crazy_functions.总结word文档 import 总结word文档
|
22 |
function_plugins = {
|
23 |
+
|
|
|
|
|
|
|
24 |
"解析整个Python项目": {
|
25 |
"Color": "stop", # 按钮颜色
|
26 |
"Function": HotReload(解析一个Python项目)
|
27 |
},
|
28 |
+
"批量总结Word文档": {
|
29 |
+
"Color": "stop",
|
30 |
+
"Function": HotReload(总结word文档)
|
31 |
+
},
|
32 |
"解析整个C++项目头文件": {
|
33 |
"Color": "stop", # 按钮颜色
|
34 |
"AsButton": False, # 加入下拉菜单中
|
|
|
87 |
|
88 |
}
|
89 |
###################### 第二组插件 ###########################
|
90 |
+
# [第二组插件]: 经过充分测试
|
91 |
from crazy_functions.批量总结PDF文档 import 批量总结PDF文档
|
92 |
from crazy_functions.批量总结PDF文档pdfminer import 批量总结PDF文档pdfminer
|
|
|
93 |
from crazy_functions.批量翻译PDF文档_多线程 import 批量翻译PDF文档
|
94 |
from crazy_functions.谷歌检索小助手 import 谷歌检索小助手
|
95 |
from crazy_functions.理解PDF文档内容 import 理解PDF文档内容标准文件输入
|
|
|
105 |
"AsButton": True, # 加入下拉菜单中
|
106 |
"Function": HotReload(批量翻译PDF文档)
|
107 |
},
|
108 |
+
"询问多个GPT模型": {
|
109 |
+
"Color": "stop", # 按钮颜色
|
110 |
+
"Function": HotReload(同时问询)
|
111 |
+
},
|
112 |
"[测试功能] 批量总结PDF文档": {
|
113 |
"Color": "stop",
|
114 |
"AsButton": False, # 加入下拉菜单中
|
|
|
125 |
"AsButton": False, # 加入下拉菜单中
|
126 |
"Function": HotReload(谷歌检索小助手)
|
127 |
},
|
128 |
+
|
|
|
|
|
|
|
129 |
"理解PDF文档内容 (模仿ChatPDF)": {
|
130 |
# HotReload 的意思是热更新,修改函数插件代码后,不需要重启程序,代码直接生效
|
131 |
"Color": "stop",
|
crazy_functions/Latex全文润色.py
CHANGED
@@ -11,9 +11,8 @@ class PaperFileGroup():
|
|
11 |
self.sp_file_tag = []
|
12 |
|
13 |
# count_token
|
14 |
-
import
|
15 |
-
|
16 |
-
enc = tiktoken.encoding_for_model("gpt-3.5-turbo")
|
17 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
18 |
self.get_token_num = get_token_num
|
19 |
|
|
|
11 |
self.sp_file_tag = []
|
12 |
|
13 |
# count_token
|
14 |
+
from request_llm.bridge_all import model_info
|
15 |
+
enc = model_info["gpt-3.5-turbo"]['tokenizer']
|
|
|
16 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
17 |
self.get_token_num = get_token_num
|
18 |
|
crazy_functions/Latex全文翻译.py
CHANGED
@@ -11,9 +11,8 @@ class PaperFileGroup():
|
|
11 |
self.sp_file_tag = []
|
12 |
|
13 |
# count_token
|
14 |
-
import
|
15 |
-
|
16 |
-
enc = tiktoken.encoding_for_model("gpt-3.5-turbo")
|
17 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
18 |
self.get_token_num = get_token_num
|
19 |
|
|
|
11 |
self.sp_file_tag = []
|
12 |
|
13 |
# count_token
|
14 |
+
from request_llm.bridge_all import model_info
|
15 |
+
enc = model_info["gpt-3.5-turbo"]['tokenizer']
|
|
|
16 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
17 |
self.get_token_num = get_token_num
|
18 |
|
crazy_functions/crazy_functions_test.py
CHANGED
@@ -31,13 +31,62 @@ system_prompt = "Serve me as a writing and programming assistant."
|
|
31 |
web_port = 1024
|
32 |
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
def test_总结word文档():
|
35 |
from crazy_functions.总结word文档 import 总结word文档
|
36 |
-
txt = "
|
37 |
-
for
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
|
|
|
|
|
|
|
|
|
|
40 |
test_总结word文档()
|
|
|
|
|
41 |
|
42 |
input("程序完成,回车退出。")
|
43 |
print("退出。")
|
|
|
31 |
web_port = 1024
|
32 |
|
33 |
|
34 |
+
def test_解析一个Python项目():
|
35 |
+
from crazy_functions.解析项目源代码 import 解析一个Python项目
|
36 |
+
txt = "crazy_functions/test_project/python/dqn"
|
37 |
+
for cookies, cb, hist, msg in 解析一个Python项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
38 |
+
print(cb)
|
39 |
+
|
40 |
+
def test_解析一个Cpp项目():
|
41 |
+
from crazy_functions.解析项目源代码 import 解析一个C项目
|
42 |
+
txt = "crazy_functions/test_project/cpp/cppipc"
|
43 |
+
for cookies, cb, hist, msg in 解析一个C项目(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
44 |
+
print(cb)
|
45 |
+
|
46 |
+
def test_Latex英文润色():
|
47 |
+
from crazy_functions.Latex全文润色 import Latex英文润色
|
48 |
+
txt = "crazy_functions/test_project/latex/attention"
|
49 |
+
for cookies, cb, hist, msg in Latex英文润色(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
50 |
+
print(cb)
|
51 |
+
|
52 |
+
def test_Markdown中译英():
|
53 |
+
from crazy_functions.批量Markdown翻译 import Markdown中译英
|
54 |
+
txt = "README.md"
|
55 |
+
for cookies, cb, hist, msg in Markdown中译英(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
56 |
+
print(cb)
|
57 |
+
|
58 |
+
def test_批量翻译PDF文档():
|
59 |
+
from crazy_functions.批量翻译PDF文档_多线程 import 批量翻译PDF文档
|
60 |
+
txt = "crazy_functions/test_project/pdf_and_word"
|
61 |
+
for cookies, cb, hist, msg in 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
62 |
+
print(cb)
|
63 |
+
|
64 |
+
def test_谷歌检索小助手():
|
65 |
+
from crazy_functions.谷歌检索小助手 import 谷歌检索小助手
|
66 |
+
txt = "https://scholar.google.com/scholar?hl=en&as_sdt=0%2C5&q=auto+reinforcement+learning&btnG="
|
67 |
+
for cookies, cb, hist, msg in 谷歌检索小助手(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
68 |
+
print(cb)
|
69 |
+
|
70 |
def test_总结word文档():
|
71 |
from crazy_functions.总结word文档 import 总结word文档
|
72 |
+
txt = "crazy_functions/test_project/pdf_and_word"
|
73 |
+
for cookies, cb, hist, msg in 总结word文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt, web_port):
|
74 |
+
print(cb)
|
75 |
+
|
76 |
+
def test_下载arxiv论文并翻译摘要():
|
77 |
+
from crazy_functions.下载arxiv论文翻译摘要 import 下载arxiv论文并翻译摘要
|
78 |
+
txt = "1812.10695"
|
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/crazy_utils.py
CHANGED
@@ -2,9 +2,9 @@ import traceback
|
|
2 |
from toolbox import update_ui, get_conf
|
3 |
|
4 |
def input_clipping(inputs, history, max_token_limit):
|
5 |
-
import tiktoken
|
6 |
import numpy as np
|
7 |
-
|
|
|
8 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
9 |
|
10 |
mode = 'input-and-history'
|
@@ -448,6 +448,7 @@ def read_and_clean_pdf_text(fp):
|
|
448 |
pf = 998
|
449 |
for l in t['lines']:
|
450 |
txt_line = "".join([wtf['text'] for wtf in l['spans']])
|
|
|
451 |
pf = primary_ffsize(l)
|
452 |
meta_line.append([txt_line, pf, l['bbox'], l])
|
453 |
for wtf in l['spans']: # for l in t['lines']:
|
@@ -558,8 +559,8 @@ def read_and_clean_pdf_text(fp):
|
|
558 |
meta_txt = meta_txt.replace('\n', '\n\n')
|
559 |
|
560 |
############################## <第 5 步,展示分割效果> ##################################
|
561 |
-
for f in finals:
|
562 |
-
|
563 |
-
|
564 |
|
565 |
return meta_txt, page_one_meta
|
|
|
2 |
from toolbox import update_ui, get_conf
|
3 |
|
4 |
def input_clipping(inputs, history, max_token_limit):
|
|
|
5 |
import numpy as np
|
6 |
+
from request_llm.bridge_all import model_info
|
7 |
+
enc = model_info["gpt-3.5-turbo"]['tokenizer']
|
8 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
9 |
|
10 |
mode = 'input-and-history'
|
|
|
448 |
pf = 998
|
449 |
for l in t['lines']:
|
450 |
txt_line = "".join([wtf['text'] for wtf in l['spans']])
|
451 |
+
if len(txt_line) == 0: continue
|
452 |
pf = primary_ffsize(l)
|
453 |
meta_line.append([txt_line, pf, l['bbox'], l])
|
454 |
for wtf in l['spans']: # for l in t['lines']:
|
|
|
559 |
meta_txt = meta_txt.replace('\n', '\n\n')
|
560 |
|
561 |
############################## <第 5 步,展示分割效果> ##################################
|
562 |
+
# for f in finals:
|
563 |
+
# print亮黄(f)
|
564 |
+
# print亮绿('***************************')
|
565 |
|
566 |
return meta_txt, page_one_meta
|
crazy_functions/代码重写为全英文_多线程.py
CHANGED
@@ -59,9 +59,8 @@ def 全项目切换英文(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys_
|
|
59 |
|
60 |
# 第5步:Token限制下的截断与处理
|
61 |
MAX_TOKEN = 3000
|
62 |
-
import
|
63 |
-
|
64 |
-
enc = tiktoken.encoding_for_model("gpt-3.5-turbo")
|
65 |
def get_token_fn(txt): return len(enc.encode(txt, disallowed_special=()))
|
66 |
|
67 |
|
|
|
59 |
|
60 |
# 第5步:Token限制下的截断与处理
|
61 |
MAX_TOKEN = 3000
|
62 |
+
from request_llm.bridge_all import model_info
|
63 |
+
enc = model_info["gpt-3.5-turbo"]['tokenizer']
|
|
|
64 |
def get_token_fn(txt): return len(enc.encode(txt, disallowed_special=()))
|
65 |
|
66 |
|
crazy_functions/批量Markdown翻译.py
CHANGED
@@ -11,9 +11,8 @@ class PaperFileGroup():
|
|
11 |
self.sp_file_tag = []
|
12 |
|
13 |
# count_token
|
14 |
-
import
|
15 |
-
|
16 |
-
enc = tiktoken.encoding_for_model("gpt-3.5-turbo")
|
17 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
18 |
self.get_token_num = get_token_num
|
19 |
|
@@ -51,7 +50,7 @@ def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
|
|
51 |
pfg.file_contents.append(file_content)
|
52 |
|
53 |
# <-------- 拆分过长的Markdown文件 ---------->
|
54 |
-
pfg.run_file_split(max_token_limit=
|
55 |
n_split = len(pfg.sp_file_contents)
|
56 |
|
57 |
# <-------- 多线程润色开始 ---------->
|
|
|
11 |
self.sp_file_tag = []
|
12 |
|
13 |
# count_token
|
14 |
+
from request_llm.bridge_all import model_info
|
15 |
+
enc = model_info["gpt-3.5-turbo"]['tokenizer']
|
|
|
16 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
17 |
self.get_token_num = get_token_num
|
18 |
|
|
|
50 |
pfg.file_contents.append(file_content)
|
51 |
|
52 |
# <-------- 拆分过长的Markdown文件 ---------->
|
53 |
+
pfg.run_file_split(max_token_limit=1500)
|
54 |
n_split = len(pfg.sp_file_contents)
|
55 |
|
56 |
# <-------- 多线程润色开始 ---------->
|
crazy_functions/批量翻译PDF文档_多线程.py
CHANGED
@@ -13,7 +13,7 @@ def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys_
|
|
13 |
# 基本信息:功能、贡献者
|
14 |
chatbot.append([
|
15 |
"函数插件功能?",
|
16 |
-
"
|
17 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
18 |
|
19 |
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
@@ -59,7 +59,7 @@ def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys_
|
|
59 |
def 解析PDF(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, sys_prompt):
|
60 |
import os
|
61 |
import tiktoken
|
62 |
-
TOKEN_LIMIT_PER_FRAGMENT =
|
63 |
generated_conclusion_files = []
|
64 |
for index, fp in enumerate(file_manifest):
|
65 |
|
@@ -68,8 +68,8 @@ def 解析PDF(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot,
|
|
68 |
|
69 |
# 递归地切割PDF文件
|
70 |
from .crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf
|
71 |
-
from
|
72 |
-
enc =
|
73 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
74 |
paper_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf(
|
75 |
txt=file_content, get_token_fn=get_token_num, limit=TOKEN_LIMIT_PER_FRAGMENT)
|
@@ -91,13 +91,13 @@ def 解析PDF(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot,
|
|
91 |
# 多线,翻译
|
92 |
gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
|
93 |
inputs_array=[
|
94 |
-
f"
|
95 |
inputs_show_user_array=[f"\n---\n 原文: \n\n {frag.replace('#', '')} \n---\n 翻译:\n " for frag in paper_fragments],
|
96 |
llm_kwargs=llm_kwargs,
|
97 |
chatbot=chatbot,
|
98 |
history_array=[[paper_meta] for _ in paper_fragments],
|
99 |
sys_prompt_array=[
|
100 |
-
"
|
101 |
# max_workers=5 # OpenAI所允许的最大并行过载
|
102 |
)
|
103 |
|
|
|
13 |
# 基本信息:功能、贡献者
|
14 |
chatbot.append([
|
15 |
"函数插件功能?",
|
16 |
+
"批量翻译PDF文档。函数插件贡献者: Binary-Husky"])
|
17 |
yield from update_ui(chatbot=chatbot, history=history) # 刷新界面
|
18 |
|
19 |
# 尝试导入依赖,如果缺少依赖,则给出安装建议
|
|
|
59 |
def 解析PDF(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, sys_prompt):
|
60 |
import os
|
61 |
import tiktoken
|
62 |
+
TOKEN_LIMIT_PER_FRAGMENT = 1280
|
63 |
generated_conclusion_files = []
|
64 |
for index, fp in enumerate(file_manifest):
|
65 |
|
|
|
68 |
|
69 |
# 递归地切割PDF文件
|
70 |
from .crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf
|
71 |
+
from request_llm.bridge_all import model_info
|
72 |
+
enc = model_info["gpt-3.5-turbo"]['tokenizer']
|
73 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
74 |
paper_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf(
|
75 |
txt=file_content, get_token_fn=get_token_num, limit=TOKEN_LIMIT_PER_FRAGMENT)
|
|
|
91 |
# 多线,翻译
|
92 |
gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
|
93 |
inputs_array=[
|
94 |
+
f"你需要翻译以下内容:\n{frag}" for frag in paper_fragments],
|
95 |
inputs_show_user_array=[f"\n---\n 原文: \n\n {frag.replace('#', '')} \n---\n 翻译:\n " for frag in paper_fragments],
|
96 |
llm_kwargs=llm_kwargs,
|
97 |
chatbot=chatbot,
|
98 |
history_array=[[paper_meta] for _ in paper_fragments],
|
99 |
sys_prompt_array=[
|
100 |
+
"请你作为一个学术翻译,负责把学术论文准确翻译成中文。注意文章中的每一句话都要翻译。" for _ in paper_fragments],
|
101 |
# max_workers=5 # OpenAI所允许的最大并行过载
|
102 |
)
|
103 |
|
crazy_functions/理解PDF文档内容.py
CHANGED
@@ -17,8 +17,8 @@ def 解析PDF(file_name, llm_kwargs, plugin_kwargs, chatbot, history, system_pro
|
|
17 |
TOKEN_LIMIT_PER_FRAGMENT = 2500
|
18 |
|
19 |
from .crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf
|
20 |
-
from
|
21 |
-
enc =
|
22 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
23 |
paper_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf(
|
24 |
txt=file_content, get_token_fn=get_token_num, limit=TOKEN_LIMIT_PER_FRAGMENT)
|
|
|
17 |
TOKEN_LIMIT_PER_FRAGMENT = 2500
|
18 |
|
19 |
from .crazy_utils import breakdown_txt_to_satisfy_token_limit_for_pdf
|
20 |
+
from request_llm.bridge_all import model_info
|
21 |
+
enc = model_info["gpt-3.5-turbo"]['tokenizer']
|
22 |
def get_token_num(txt): return len(enc.encode(txt, disallowed_special=()))
|
23 |
paper_fragments = breakdown_txt_to_satisfy_token_limit_for_pdf(
|
24 |
txt=file_content, get_token_fn=get_token_num, limit=TOKEN_LIMIT_PER_FRAGMENT)
|
docs/Dockerfile+ChatGLM
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
# How to build | 如何构建: docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
|
2 |
-
# How to run | 如何运行 (1)
|
3 |
-
# How to run | 如何运行 (2) 我想运行之前进容器做一些调整: docker run --rm -it --net=host --gpus=
|
4 |
|
5 |
# 从NVIDIA源,从而支持显卡运损(检查宿主的nvidia-smi中的cuda版本必须>=11.3)
|
6 |
FROM nvidia/cuda:11.3.1-runtime-ubuntu20.04
|
@@ -24,7 +24,7 @@ RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.8
|
|
24 |
|
25 |
# 下载分支
|
26 |
WORKDIR /gpt
|
27 |
-
RUN $useProxyNetwork git clone https://github.com/binary-husky/chatgpt_academic.git
|
28 |
WORKDIR /gpt/chatgpt_academic
|
29 |
RUN $useProxyNetwork python3 -m pip install -r requirements.txt
|
30 |
RUN $useProxyNetwork python3 -m pip install -r request_llm/requirements_chatglm.txt
|
@@ -36,11 +36,20 @@ from transformers import AutoModel, AutoTokenizer \n\
|
|
36 |
chatglm_tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True) \n\
|
37 |
chatglm_model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).float() ' >> warm_up_chatglm.py
|
38 |
RUN python3 -u warm_up_chatglm.py
|
|
|
|
|
|
|
39 |
RUN $useProxyNetwork git pull
|
40 |
|
|
|
|
|
|
|
41 |
# 为chatgpt-academic配置代理和API-KEY (非必要 可选步骤)
|
|
|
|
|
|
|
42 |
RUN echo ' \n\
|
43 |
-
API_KEY = "sk-
|
44 |
USE_PROXY = True \n\
|
45 |
LLM_MODEL = "chatglm" \n\
|
46 |
LOCAL_MODEL_DEVICE = "cuda" \n\
|
|
|
1 |
# How to build | 如何构建: docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
|
2 |
+
# How to run | 如何运行 (1) 直接运行(选择0号GPU): docker run --rm -it --net=host --gpus="0" gpt-academic
|
3 |
+
# How to run | 如何运行 (2) 我想运行之前进容器做一些调整: docker run --rm -it --net=host --gpus="0" gpt-academic bash
|
4 |
|
5 |
# 从NVIDIA源,从而支持显卡运损(检查宿主的nvidia-smi中的cuda版本必须>=11.3)
|
6 |
FROM nvidia/cuda:11.3.1-runtime-ubuntu20.04
|
|
|
24 |
|
25 |
# 下载分支
|
26 |
WORKDIR /gpt
|
27 |
+
RUN $useProxyNetwork git clone https://github.com/binary-husky/chatgpt_academic.git
|
28 |
WORKDIR /gpt/chatgpt_academic
|
29 |
RUN $useProxyNetwork python3 -m pip install -r requirements.txt
|
30 |
RUN $useProxyNetwork python3 -m pip install -r request_llm/requirements_chatglm.txt
|
|
|
36 |
chatglm_tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True) \n\
|
37 |
chatglm_model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).float() ' >> warm_up_chatglm.py
|
38 |
RUN python3 -u warm_up_chatglm.py
|
39 |
+
|
40 |
+
# 禁用缓存,确保更新代码
|
41 |
+
ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache
|
42 |
RUN $useProxyNetwork git pull
|
43 |
|
44 |
+
# 预热Tiktoken模块
|
45 |
+
RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()'
|
46 |
+
|
47 |
# 为chatgpt-academic配置代理和API-KEY (非必要 可选步骤)
|
48 |
+
# 可同时填写多个API-KEY,支持openai的key和api2d的key共存,用英文逗号分割,例如API_KEY = "sk-openaikey1,fkxxxx-api2dkey2,........"
|
49 |
+
# LLM_MODEL 是选择初始的模型
|
50 |
+
# LOCAL_MODEL_DEVICE 是选择chatglm等本地模型运行的设备,可选 cpu 和 cuda
|
51 |
RUN echo ' \n\
|
52 |
+
API_KEY = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,fkxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \n\
|
53 |
USE_PROXY = True \n\
|
54 |
LLM_MODEL = "chatglm" \n\
|
55 |
LOCAL_MODEL_DEVICE = "cuda" \n\
|
docs/README_EN.md
CHANGED
@@ -1,223 +1,227 @@
|
|
1 |
-
# ChatGPT Academic Optimization
|
2 |
> **Note**
|
3 |
>
|
4 |
-
> This English
|
5 |
>
|
6 |
|
|
|
7 |
|
8 |
-
**If you like this project, please give it a
|
9 |
|
10 |
> **Note**
|
11 |
>
|
12 |
-
> 1. Please note that only
|
13 |
>
|
14 |
-
> 2. The
|
15 |
-
>
|
16 |
-
|
17 |
|
18 |
<div align="center">
|
19 |
|
20 |
Function | Description
|
21 |
--- | ---
|
22 |
-
One-
|
23 |
-
One-
|
24 |
-
One-
|
25 |
-
[Custom
|
26 |
-
[Configure
|
27 |
-
Modular
|
28 |
-
[Self-
|
29 |
-
[Program
|
30 |
-
Read
|
31 |
-
Latex
|
32 |
-
Batch
|
33 |
-
Chat
|
34 |
-
[Arxiv
|
35 |
-
[
|
36 |
-
[Google Scholar
|
37 |
-
Formula
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
[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)!
|
44 |
-
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).
|
45 |
-
… | ...
|
46 |
|
47 |
</div>
|
48 |
|
49 |
-
|
50 |
-
- New interface (
|
51 |
<div align="center">
|
52 |
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
|
53 |
</div>
|
54 |
|
55 |
-
|
|
|
56 |
<div align="center">
|
57 |
<img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
|
58 |
</div>
|
59 |
|
60 |
-
-
|
61 |
<div align="center">
|
62 |
<img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
|
63 |
</div>
|
64 |
|
65 |
-
-
|
66 |
<div align="center">
|
67 |
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
|
68 |
</div>
|
69 |
|
70 |
-
-
|
71 |
<div align="center">
|
72 |
-
<img src="https://user-images.githubusercontent.com/96192199/
|
73 |
</div>
|
74 |
|
75 |
-
-
|
76 |
<div align="center">
|
77 |
-
<img src="https://user-images.githubusercontent.com/96192199/
|
78 |
</div>
|
79 |
|
80 |
-
|
|
|
81 |
|
|
|
82 |
|
83 |
-
##
|
84 |
|
85 |
-
|
86 |
```sh
|
87 |
git clone https://github.com/binary-husky/chatgpt_academic.git
|
88 |
cd chatgpt_academic
|
89 |
```
|
90 |
|
91 |
-
|
92 |
|
93 |
-
|
|
|
94 |
```
|
95 |
-
1. If you are in China, you need to set an overseas proxy to use the OpenAI API smoothly. Please read
|
96 |
-
2. Configure OpenAI API KEY. You need to register
|
97 |
-
3. Issues related to proxy
|
98 |
```
|
99 |
-
(
|
|
|
100 |
|
101 |
-
|
102 |
```sh
|
103 |
-
# (Option
|
104 |
python -m pip install -r requirements.txt
|
105 |
|
106 |
-
# (Option
|
107 |
-
# (Option
|
108 |
-
# (Option
|
109 |
-
# (Option
|
110 |
|
111 |
-
# Note: Use
|
112 |
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
113 |
```
|
114 |
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
116 |
```sh
|
117 |
python main.py
|
118 |
```
|
119 |
|
120 |
-
|
121 |
```
|
122 |
-
- Test
|
123 |
-
In the input area, enter `./crazy_functions/test_project/
|
124 |
-
- Test
|
125 |
-
|
126 |
-
- Test
|
127 |
-
|
128 |
-
-
|
129 |
-
Click "[Experiment] Please analyze and deconstruct this project itself"
|
130 |
-
- Test Experimental Function Template (asking GPT what happened in history today), you can implement more complex functions based on this template function
|
131 |
-
Click "[Experiment] Experimental function template"
|
132 |
```
|
133 |
|
134 |
-
## Use Docker (Linux)
|
135 |
|
|
|
136 |
``` sh
|
137 |
-
#
|
138 |
git clone https://github.com/binary-husky/chatgpt_academic.git
|
139 |
cd chatgpt_academic
|
140 |
-
#
|
141 |
-
|
142 |
-
#
|
143 |
docker build -t gpt-academic .
|
144 |
# Run
|
145 |
docker run --rm -it --net=host gpt-academic
|
146 |
|
147 |
-
# Test
|
148 |
-
## Test
|
149 |
-
Click "[
|
150 |
-
## Test
|
151 |
-
|
152 |
-
## (Please note that when running in docker, you need to pay extra attention to file access rights issues of the program.)
|
153 |
-
## Test C++ Project Header Analysis
|
154 |
-
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)"
|
155 |
-
## Test Writing Abstracts for Latex Projects
|
156 |
-
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)"
|
157 |
## Test Python Project Analysis
|
158 |
-
|
|
|
|
|
|
|
159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
```
|
161 |
|
162 |
-
## Other Deployment Methods
|
163 |
-
- Use WSL2 (Windows Subsystem for Linux subsystem)
|
164 |
-
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)
|
165 |
|
166 |
-
-
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
|
|
|
|
|
|
169 |
|
170 |
-
|
171 |
-
|
172 |
|
173 |
-
|
|
|
|
|
|
|
174 |
```
|
175 |
-
"Super English to Chinese
|
|
|
|
|
176 |
|
177 |
-
#
|
178 |
-
"Prefix": "Please translate the following content into Chinese, and then use a markdown table to explain each proprietary term in the text:\n\n",
|
179 |
-
|
180 |
-
# Suffix, which will be added after your input. For example, in conjunction with the prefix, you can bracket your input in quotes.
|
181 |
"Suffix": "",
|
182 |
-
|
183 |
},
|
184 |
```
|
185 |
<div align="center">
|
186 |
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
|
187 |
</div>
|
188 |
|
189 |
-
|
190 |
-
If you invent a more user-friendly academic shortcut key, welcome to post an issue or pull request!
|
191 |
-
|
192 |
-
## Configure Proxy
|
193 |
-
### Method 1: General Method
|
194 |
-
Modify the port and proxy software corresponding in ```config.py```
|
195 |
-
|
196 |
-
<div align="center">
|
197 |
-
<img src="https://user-images.githubusercontent.com/96192199/226571294-37a47cd9-4d40-4c16-97a2-d360845406f7.png" width="500" >
|
198 |
-
<img src="https://user-images.githubusercontent.com/96192199/226838985-e5c95956-69c2-4c23-a4dd-cd7944eeb451.png" width="500" >
|
199 |
-
</div>
|
200 |
|
201 |
|
202 |
-
|
203 |
|
204 |
-
|
205 |
-
python check_proxy.py
|
206 |
-
```
|
207 |
-
|
208 |
-
### Method Two: Pure Beginner Tutorial
|
209 |
-
[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)
|
210 |
|
211 |
-
## Compatibility Testing
|
212 |
|
213 |
-
|
214 |
|
215 |
<div align="center">
|
216 |
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
|
217 |
</div>
|
218 |
|
219 |
-
|
220 |
-
### If the program can read and analyze itself:
|
221 |
|
222 |
<div align="center">
|
223 |
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
|
@@ -227,7 +231,7 @@ python check_proxy.py
|
|
227 |
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
|
228 |
</div>
|
229 |
|
230 |
-
###
|
231 |
<div align="center">
|
232 |
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
|
233 |
</div>
|
@@ -236,59 +240,52 @@ python check_proxy.py
|
|
236 |
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
|
237 |
</div>
|
238 |
|
239 |
-
###
|
240 |
<div align="center">
|
241 |
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
|
242 |
</div>
|
243 |
|
244 |
-
### Automatic
|
245 |
<div align="center">
|
246 |
<img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
|
247 |
<img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
|
248 |
<img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
|
249 |
</div>
|
250 |
|
251 |
-
### Modular
|
252 |
<div align="center">
|
253 |
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
|
254 |
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
|
255 |
</div>
|
256 |
|
257 |
-
|
258 |
-
### Translating source code to English
|
259 |
|
260 |
<div align="center">
|
261 |
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
|
262 |
</div>
|
263 |
|
264 |
-
## Todo and
|
265 |
-
|
266 |
-
- version 3
|
267 |
-
-
|
268 |
-
- version 2.
|
269 |
-
- -
|
270 |
-
-
|
271 |
-
- - Function plugin parameter interface optimization
|
272 |
-
- - Self-updating
|
273 |
-
- 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.
|
274 |
- version 2.3: Enhanced multi-threaded interactivity
|
275 |
-
- version 2.2: Function
|
276 |
-
- version 2.1:
|
277 |
- version 2.0: Introduction of modular function plugins
|
278 |
- version 1.0: Basic functions
|
279 |
|
280 |
-
##
|
281 |
-
|
282 |
|
283 |
```
|
284 |
-
The code
|
285 |
|
286 |
-
# Reference
|
287 |
https://github.com/GaiZhenbiao/ChuanhuChatGPT
|
288 |
|
289 |
-
# Reference
|
290 |
https://github.com/THUDM/ChatGLM-6B
|
291 |
-
|
292 |
```
|
293 |
|
294 |
-
|
|
|
|
|
1 |
> **Note**
|
2 |
>
|
3 |
+
> This English README is automatically generated by the markdown translation plugin in this project, and may not be 100% correct.
|
4 |
>
|
5 |
|
6 |
+
# <img src="logo.png" width="40" > ChatGPT Academic Optimization
|
7 |
|
8 |
+
**If you like this project, please give it a Star. If you've come up with more useful academic shortcuts or functional plugins, feel free to open an issue or pull request. We also have a [README in English](docs/README_EN.md) translated by this project itself.**
|
9 |
|
10 |
> **Note**
|
11 |
>
|
12 |
+
> 1. Please note that only **functions with red color** supports reading files, some functions are located in the **dropdown menu** of plugins. Additionally, we welcome and prioritize any new plugin PRs with **highest priority**!
|
13 |
>
|
14 |
+
> 2. The functionality of each file in this project is detailed in the self-translation report [`self_analysis.md`](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A) of the project. With the iteration of the version, you can also click on the relevant function plugins at any time to call GPT to regenerate the self-analysis report of the project. The FAQ summary is in the [`wiki`](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98) section.
|
15 |
+
>
|
16 |
+
|
17 |
|
18 |
<div align="center">
|
19 |
|
20 |
Function | Description
|
21 |
--- | ---
|
22 |
+
One-Click Polish | Supports one-click polishing and finding grammar errors in academic papers.
|
23 |
+
One-Key Translation Between Chinese and English | One-click translation between Chinese and English.
|
24 |
+
One-Key Code Interpretation | Can correctly display and interpret code.
|
25 |
+
[Custom Shortcut Keys](https://www.bilibili.com/video/BV14s4y1E7jN) | Supports custom shortcut keys.
|
26 |
+
[Configure Proxy Server](https://www.bilibili.com/video/BV1rc411W7Dr) | Supports configuring proxy servers.
|
27 |
+
Modular Design | Supports custom high-order function plugins and [function plugins], and plugins support [hot updates](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97).
|
28 |
+
[Self-programming Analysis](https://www.bilibili.com/video/BV1cj411A7VW) | [Function Plugin] [One-Key Read] (https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A) The source code of this project is analyzed.
|
29 |
+
[Program Analysis](https://www.bilibili.com/video/BV1cj411A7VW) | [Function Plugin] One-click can analyze the project tree of other Python/C/C++/Java/Lua/... projects
|
30 |
+
Read the Paper | [Function Plugin] One-click interpretation of the full text of latex paper and generation of abstracts
|
31 |
+
Latex Full Text Translation, Proofreading | [Function Plugin] One-click translation or proofreading of latex papers.
|
32 |
+
Batch Comment Generation | [Function Plugin] One-click batch generation of function comments
|
33 |
+
Chat Analysis Report Generation | [Function Plugin] After running, an automatic summary report will be generated
|
34 |
+
[Arxiv Assistant](https://www.bilibili.com/video/BV1LM4y1279X) | [Function Plugin] Enter the arxiv article url to translate the abstract and download the PDF with one click
|
35 |
+
[Full-text Translation Function of PDF Paper](https://www.bilibili.com/video/BV1KT411x7Wn) | [Function Plugin] Extract the title & abstract of the PDF paper + translate the full text (multithreading)
|
36 |
+
[Google Scholar Integration Assistant](https://www.bilibili.com/video/BV19L411U7ia) | [Function Plugin] Given any Google Scholar search page URL, let gpt help you choose interesting articles.
|
37 |
+
Formula / Picture / Table Display | Can display both the tex form and the rendering form of formulas at the same time, support formula and code highlighting
|
38 |
+
Multithreaded Function Plugin Support | Supports multi-threaded calling chatgpt, one-click processing of massive text or programs
|
39 |
+
Start Dark Gradio [Theme](https://github.com/binary-husky/chatgpt_academic/issues/173) | Add ```/?__dark-theme=true``` at the end of the browser url to switch to dark theme
|
40 |
+
[Multiple LLM Models](https://www.bilibili.com/video/BV1wT411p7yf) support, [API2D](https://api2d.com/) interface support | It must feel nice to be served by both GPT3.5, GPT4, and [Tsinghua ChatGLM](https://github.com/THUDM/ChatGLM-6B)!
|
41 |
+
Huggingface non-Science Net [Online Experience](https://huggingface.co/spaces/qingxu98/gpt-academic) | After logging in to huggingface, copy [this space](https://huggingface.co/spaces/qingxu98/gpt-academic)
|
42 |
+
... | ...
|
|
|
|
|
|
|
43 |
|
44 |
</div>
|
45 |
|
46 |
+
|
47 |
+
- New interface (switch between "left-right layout" and "up-down layout" by modifying the LAYOUT option in config.py)
|
48 |
<div align="center">
|
49 |
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
|
50 |
</div>
|
51 |
|
52 |
+
|
53 |
+
- All buttons are dynamically generated by reading functional.py and can add custom functionality at will, freeing up clipboard
|
54 |
<div align="center">
|
55 |
<img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
|
56 |
</div>
|
57 |
|
58 |
+
- Proofreading / correcting
|
59 |
<div align="center">
|
60 |
<img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
|
61 |
</div>
|
62 |
|
63 |
+
- If the output contains formulas, it will be displayed in both the tex form and the rendering form at the same time, which is convenient for copying and reading
|
64 |
<div align="center">
|
65 |
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
|
66 |
</div>
|
67 |
|
68 |
+
- Don't want to read the project code? Just take the whole project to chatgpt
|
69 |
<div align="center">
|
70 |
+
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
|
71 |
</div>
|
72 |
|
73 |
+
- Multiple major language model mixing calls (ChatGLM + OpenAI-GPT3.5 + [API2D](https://api2d.com/)-GPT4)
|
74 |
<div align="center">
|
75 |
+
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
|
76 |
</div>
|
77 |
|
78 |
+
Multiple major language model mixing call [huggingface beta version](https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta) (the huggingface version does not support chatglm)
|
79 |
+
|
80 |
|
81 |
+
---
|
82 |
|
83 |
+
## Installation-Method 1: Run directly (Windows, Linux or MacOS)
|
84 |
|
85 |
+
1. Download project
|
86 |
```sh
|
87 |
git clone https://github.com/binary-husky/chatgpt_academic.git
|
88 |
cd chatgpt_academic
|
89 |
```
|
90 |
|
91 |
+
2. Configure API_KEY and proxy settings
|
92 |
|
93 |
+
|
94 |
+
In `config.py`, configure the overseas Proxy and OpenAI API KEY as follows:
|
95 |
```
|
96 |
+
1. If you are in China, you need to set up an overseas proxy to use the OpenAI API smoothly. Please read config.py carefully for setup details (1. Modify USE_PROXY to True; 2. Modify proxies according to the instructions).
|
97 |
+
2. Configure the OpenAI API KEY. You need to register and obtain an API KEY on the OpenAI website. Once you get the API KEY, you can configure it in the config.py file.
|
98 |
+
3. Issues related to proxy networks (network timeouts, proxy failures) are summarized at https://github.com/binary-husky/chatgpt_academic/issues/1
|
99 |
```
|
100 |
+
(P.S. When the program runs, it will first check whether there is a private configuration file named `config_private.py` and use the same-name configuration in `config.py` to overwrite it. Therefore, if you can understand our configuration reading logic, we strongly recommend that you create a new configuration file named `config_private.py` next to `config.py` and transfer (copy) the configuration in `config.py` to` config_private.py`. `config_private.py` is not controlled by git and can make your privacy information more secure.))
|
101 |
+
|
102 |
|
103 |
+
3. Install dependencies
|
104 |
```sh
|
105 |
+
# (Option One) Recommended
|
106 |
python -m pip install -r requirements.txt
|
107 |
|
108 |
+
# (Option Two) If you use anaconda, the steps are similar:
|
109 |
+
# (Option Two.1) conda create -n gptac_venv python=3.11
|
110 |
+
# (Option Two.2) conda activate gptac_venv
|
111 |
+
# (Option Two.3) python -m pip install -r requirements.txt
|
112 |
|
113 |
+
# Note: Use official pip source or Ali pip source. Other pip sources (such as some university pips) may have problems, and temporary replacement methods are as follows:
|
114 |
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
115 |
```
|
116 |
|
117 |
+
If you need to support Tsinghua ChatGLM, you need to install more dependencies (if you are not familiar with python or your computer configuration is not good, we recommend not to try):
|
118 |
+
```sh
|
119 |
+
python -m pip install -r request_llm/requirements_chatglm.txt
|
120 |
+
```
|
121 |
+
|
122 |
+
4. Run
|
123 |
```sh
|
124 |
python main.py
|
125 |
```
|
126 |
|
127 |
+
5. Test function plugins
|
128 |
```
|
129 |
+
- Test Python project analysis
|
130 |
+
In the input area, enter `./crazy_functions/test_project/python/dqn`, and then click "Analyze the entire Python project"
|
131 |
+
- Test self-code interpretation
|
132 |
+
Click "[Multithreading Demo] Interpretation of This Project Itself (Source Code Interpretation)"
|
133 |
+
- Test experimental function template function (requires gpt to answer what happened today in history). You can use this function as a template to implement more complex functions.
|
134 |
+
Click "[Function Plugin Template Demo] Today in History"
|
135 |
+
- There are more functions to choose from in the function plugin area drop-down menu.
|
|
|
|
|
|
|
136 |
```
|
137 |
|
138 |
+
## Installation-Method 2: Use Docker (Linux)
|
139 |
|
140 |
+
1. ChatGPT only (recommended for most people)
|
141 |
``` sh
|
142 |
+
# download project
|
143 |
git clone https://github.com/binary-husky/chatgpt_academic.git
|
144 |
cd chatgpt_academic
|
145 |
+
# configure overseas Proxy and OpenAI API KEY
|
146 |
+
Edit config.py with any text editor
|
147 |
+
# Install
|
148 |
docker build -t gpt-academic .
|
149 |
# Run
|
150 |
docker run --rm -it --net=host gpt-academic
|
151 |
|
152 |
+
# Test function plug-in
|
153 |
+
## Test function plugin template function (requires gpt to answer what happened today in history). You can use this function as a template to implement more complex functions.
|
154 |
+
Click "[Function Plugin Template Demo] Today in History"
|
155 |
+
## Test Abstract Writing for Latex Projects
|
156 |
+
Enter ./crazy_functions/test_project/latex/attention in the input area, and then click "Read Tex Paper and Write Abstract"
|
|
|
|
|
|
|
|
|
|
|
157 |
## Test Python Project Analysis
|
158 |
+
Enter ./crazy_functions/test_project/python/dqn in the input area and click "Analyze the entire Python project."
|
159 |
+
|
160 |
+
More functions are available in the function plugin area drop-down menu.
|
161 |
+
```
|
162 |
|
163 |
+
2. ChatGPT+ChatGLM (requires strong familiarity with docker + strong computer configuration)
|
164 |
+
|
165 |
+
``` sh
|
166 |
+
# Modify dockerfile
|
167 |
+
cd docs && nano Dockerfile+ChatGLM
|
168 |
+
# How to build | 如何构建 (Dockerfile+ChatGLM在docs路径下,请先cd docs)
|
169 |
+
docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
|
170 |
+
# How to run | 如何运行 (1) 直接运行:
|
171 |
+
docker run --rm -it --net=host --gpus=all gpt-academic
|
172 |
+
# How to run | 如何运行 (2) 我想运行之前进容器做一些调整:
|
173 |
+
docker run --rm -it --net=host --gpus=all gpt-academic bash
|
174 |
```
|
175 |
|
|
|
|
|
|
|
176 |
|
177 |
+
## Installation-Method 3: Other Deployment Methods
|
178 |
+
|
179 |
+
1. Remote Cloud Server Deployment
|
180 |
+
Please visit [Deployment Wiki-1] (https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
|
181 |
+
|
182 |
+
2. Use WSL2 (Windows Subsystem for Linux)
|
183 |
+
Please visit [Deployment Wiki-2](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
|
184 |
+
|
185 |
|
186 |
+
## Installation-Proxy Configuration
|
187 |
+
### Method 1: Conventional method
|
188 |
+
[Configure Proxy](https://github.com/binary-husky/chatgpt_academic/issues/1)
|
189 |
|
190 |
+
### Method Two: Step-by-step tutorial for newcomers
|
191 |
+
[Step-by-step tutorial for newcomers](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BB%A3%E7%90%86%E8%BD%AF%E4%BB%B6%E9%97%AE%E9%A2%98%E7%9A%84%E6%96%B0%E6%89%8B%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%EF%BC%88%E6%96%B9%E6%B3%95%E5%8F%AA%E9%80%82%E7%94%A8%E4%BA%8E%E6%96%B0%E6%89%8B%EF%BC%89)
|
192 |
|
193 |
+
---
|
194 |
+
|
195 |
+
## Customizing Convenient Buttons (Customizing Academic Shortcuts)
|
196 |
+
Open `core_functional.py` with any text editor and add an item as follows, then restart the program (if the button has been successfully added and visible, both the prefix and suffix support hot modification without the need to restart the program to take effect). For example:
|
197 |
```
|
198 |
+
"Super English to Chinese translation": {
|
199 |
+
# Prefix, which will be added before your input. For example, to describe your requirements, such as translation, code interpretation, polishing, etc.
|
200 |
+
"Prefix": "Please translate the following content into Chinese and use a markdown table to interpret the proprietary terms in the text one by one:\n\n",
|
201 |
|
202 |
+
# Suffix, which will be added after your input. For example, combined with the prefix, you can put your input content in quotes.
|
|
|
|
|
|
|
203 |
"Suffix": "",
|
|
|
204 |
},
|
205 |
```
|
206 |
<div align="center">
|
207 |
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
|
208 |
</div>
|
209 |
|
210 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
|
212 |
|
213 |
+
## Some Function Displays
|
214 |
|
215 |
+
### Image Display:
|
|
|
|
|
|
|
|
|
|
|
216 |
|
|
|
217 |
|
218 |
+
You are a professional academic paper translator.
|
219 |
|
220 |
<div align="center">
|
221 |
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
|
222 |
</div>
|
223 |
|
224 |
+
### If a program can understand and analyze itself:
|
|
|
225 |
|
226 |
<div align="center">
|
227 |
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
|
|
|
231 |
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
|
232 |
</div>
|
233 |
|
234 |
+
### Analysis of any Python/Cpp project:
|
235 |
<div align="center">
|
236 |
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
|
237 |
</div>
|
|
|
240 |
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
|
241 |
</div>
|
242 |
|
243 |
+
### One-click reading comprehension and summary generation of Latex papers
|
244 |
<div align="center">
|
245 |
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
|
246 |
</div>
|
247 |
|
248 |
+
### Automatic report generation
|
249 |
<div align="center">
|
250 |
<img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
|
251 |
<img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
|
252 |
<img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
|
253 |
</div>
|
254 |
|
255 |
+
### Modular functional design
|
256 |
<div align="center">
|
257 |
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
|
258 |
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
|
259 |
</div>
|
260 |
|
261 |
+
### Source code translation to English
|
|
|
262 |
|
263 |
<div align="center">
|
264 |
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
|
265 |
</div>
|
266 |
|
267 |
+
## Todo and version planning:
|
268 |
+
- version 3.2+ (todo): Function plugin supports more parameter interfaces
|
269 |
+
- version 3.1: Support for inquiring multiple GPT models at the same time! Support for api2d, support for multiple apikeys load balancing
|
270 |
+
- version 3.0: Support for chatglm and other small llms
|
271 |
+
- version 2.6: Refactored the plugin structure, improved interactivity, added more plugins
|
272 |
+
- version 2.5: Self-updating, solves the problem of text being too long and token overflowing when summarizing large project source code
|
273 |
+
- version 2.4: (1) Added PDF full text translation function; (2) Added function to switch input area position; (3) Added vertical layout option; (4) Multi-threaded function plugin optimization.
|
|
|
|
|
|
|
274 |
- version 2.3: Enhanced multi-threaded interactivity
|
275 |
+
- version 2.2: Function plugin supports hot reloading
|
276 |
+
- version 2.1: Foldable layout
|
277 |
- version 2.0: Introduction of modular function plugins
|
278 |
- version 1.0: Basic functions
|
279 |
|
280 |
+
## Reference and learning
|
|
|
281 |
|
282 |
```
|
283 |
+
The code design of this project has referenced many other excellent projects, including:
|
284 |
|
285 |
+
# Reference project 1: Borrowed many tips from ChuanhuChatGPT
|
286 |
https://github.com/GaiZhenbiao/ChuanhuChatGPT
|
287 |
|
288 |
+
# Reference project 2: Tsinghua ChatGLM-6B:
|
289 |
https://github.com/THUDM/ChatGLM-6B
|
|
|
290 |
```
|
291 |
|
|
docs/README_FR.md
ADDED
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
> **Note**
|
2 |
+
>
|
3 |
+
> Ce fichier README est généré automatiquement par le plugin de traduction markdown de ce projet et n'est peut - être pas correct à 100%.
|
4 |
+
>
|
5 |
+
|
6 |
+
# <img src="logo.png" width="40" > ChatGPT Optimisation Académique
|
7 |
+
|
8 |
+
**Si vous aimez ce projet, donnez-lui une étoile; si vous avez inventé des raccourcis académiques plus utiles ou des plugins fonctionnels, n'hésitez pas à ouvrir une demande ou une demande de traction. Nous avons également un fichier README en [anglais|](docs/README_EN.md)[japonais|](docs/README_JP.md)[russe|](docs/README_RS.md)[français](docs/README_FR.md) traduit par ce projet lui-même.**
|
9 |
+
|
10 |
+
> **Note**
|
11 |
+
>
|
12 |
+
> 1. Veuillez noter que seuls les plugins de fonction signalés en **rouge** sont capables de lire les fichiers, certains plugins se trouvent dans le **menu déroulant** de la section plugin. Nous sommes également les bienvenus avec la plus haute priorité pour traiter et accepter tout nouveau PR de plugin!
|
13 |
+
>
|
14 |
+
> 2. Chaque fichier dans ce projet est expliqué en détail dans l'auto-analyse [self_analysis.md](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A). Avec l'itération des versions, vous pouvez également cliquer sur les plugins fonctionnels pertinents pour appeler GPT et générer un rapport d'auto-analyse projet mis à jour. Les questions fréquemment posées sont résumées dans le [wiki](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98).
|
15 |
+
>
|
16 |
+
|
17 |
+
<div align="center">
|
18 |
+
|
19 |
+
Fonctionnalité | Description
|
20 |
+
--- | ---
|
21 |
+
Polissage en un clic | Prend en charge la correction en un clic et la recherche d'erreurs de syntaxe dans les documents de recherche.
|
22 |
+
Traduction Chinois-Anglais en un clic | Une touche pour traduire la partie chinoise en anglais ou celle anglaise en chinois.
|
23 |
+
Explication de code en un clic | Affiche et explique correctement le code.
|
24 |
+
[Raccourcis clavier personnalisables](https://www.bilibili.com/video/BV14s4y1E7jN) | Prend en charge les raccourcis clavier personnalisables.
|
25 |
+
[Configuration du serveur proxy](https://www.bilibili.com/video/BV1rc411W7Dr) | Prend en charge la configuration du serveur proxy.
|
26 |
+
Conception modulaire | Prend en charge la personnalisation des plugins de fonctions et des [plugins] de fonctions hiérarchiques personnalisés, et les plugins prennent en charge [la mise à jour à chaud](https://github.com/binary-husky/chatgpt_academic/wiki/%E5%87%BD%E6%95%B0%E6%8F%92%E4%BB%B6%E6%8C%87%E5%8D%97).
|
27 |
+
[Auto-analyse du programme](https://www.bilibili.com/video/BV1cj411A7VW) | [Plugins] [Lire en un clic](https://github.com/binary-husky/chatgpt_academic/wiki/chatgpt-academic%E9%A1%B9%E7%9B%AE%E8%87%AA%E8%AF%91%E8%A7%A3%E6%8A%A5%E5%91%8A) le code source de ce projet.
|
28 |
+
[Analyse de programme](https://www.bilibili.com/video/BV1cj411A7VW) | [Plugins] En un clic, les projets Python/C/C++/Java/Lua/... peuvent être analysés.
|
29 |
+
Lire le document de recherche | [Plugins] Lisez le résumé de l'article en latex et générer un résumé.
|
30 |
+
Traduction et polissage de l'article complet en LaTeX | [Plugins] Une touche pour traduire ou corriger en LaTeX
|
31 |
+
Génération Commentaire de fonction en vrac | [Plugins] Lisez en un clic les fonctions et générez des commentaires de fonction.
|
32 |
+
Rapport d'analyse automatique des chats générés | [Plugins] Génère un rapport de synthèse après l'exécution.
|
33 |
+
[Assistant arxiv](https://www.bilibili.com/video/BV1LM4y1279X) | [Plugins] Entrez l'url de l'article arxiv pour traduire le résumé + télécharger le PDF en un clic
|
34 |
+
[Traduction complète des articles PDF](https://www.bilibili.com/video/BV1KT411x7Wn) | [Plugins] Extraire le titre et le résumé de l'article PDF + Traduire le texte entier (multithread)
|
35 |
+
[Aide à la recherche Google Academ](https://www.bilibili.com/video/BV19L411U7ia) | [Plugins] Donnez à GPT l'URL de n'importe quelle page de recherche Google Academ pour vous aider à sélectionner des articles intéressants
|
36 |
+
Affichage de formules/images/tableaux | Afficher la forme traduite et rendue d'une formule en même temps, plusieurs formules et surlignage du code prend en charge
|
37 |
+
Prise en charge des plugins multithread | Prise en charge de l'appel multithread de chatgpt, traitement en masse de texte ou de programmes en un clic
|
38 |
+
Activer le thème Gradio sombre [theme](https://github.com/binary-husky/chatgpt_academic/issues/173) au démarrage | Ajoutez ```/?__dark-theme=true``` à l'URL du navigateur pour basculer vers le thème sombre
|
39 |
+
[Prise en charge de plusieurs modèles LLM](https://www.bilibili.com/video/BV1wT411p7yf), [prise en charge de l'interface API2D](https://api2d.com/) | Comment cela serait-il de se faire servir par GPT3.5, GPT4 et la [ChatGLM de Tsinghua](https://github.com/THUDM/ChatGLM-6B) en même temps?
|
40 |
+
Expérience en ligne d'huggingface sans science | Après vous être connecté à huggingface, copiez [cet espace](https://huggingface.co/spaces/qingxu98/gpt-academic)
|
41 |
+
... | ...
|
42 |
+
|
43 |
+
</div>
|
44 |
+
|
45 |
+
|
46 |
+
Vous êtes un traducteur professionnel d'articles universitaires en français.
|
47 |
+
|
48 |
+
Ceci est un fichier Markdown, veuillez le traduire en français sans modifier les commandes Markdown existantes :
|
49 |
+
|
50 |
+
- Nouvelle interface (modifiable en modifiant l'option de mise en page dans config.py pour basculer entre les mises en page gauche-droite et haut-bas)
|
51 |
+
<div align="center">
|
52 |
+
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
|
53 |
+
</div>
|
54 |
+
|
55 |
+
|
56 |
+
- Tous les boutons sont générés dynamiquement en lisant functional.py, les utilisateurs peuvent ajouter librement des fonctions personnalisées pour libérer le presse-papiers.
|
57 |
+
<div align="center">
|
58 |
+
<img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
|
59 |
+
</div>
|
60 |
+
|
61 |
+
- Correction/amélioration
|
62 |
+
<div align="center">
|
63 |
+
<img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
|
64 |
+
</div>
|
65 |
+
|
66 |
+
- Si la sortie contient des formules, elles seront affichées simultanément sous forme de de texte brut et de forme rendue pour faciliter la copie et la lecture.
|
67 |
+
<div align="center">
|
68 |
+
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
|
69 |
+
</div>
|
70 |
+
|
71 |
+
- Pas envie de lire le code du projet ? Faites votre propre démo avec ChatGPT.
|
72 |
+
<div align="center">
|
73 |
+
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
|
74 |
+
</div>
|
75 |
+
|
76 |
+
- Utilisation combinée de plusieurs modèles de langage sophistiqués (ChatGLM + OpenAI-GPT3.5 + [API2D](https://api2d.com/)-GPT4)
|
77 |
+
<div align="center">
|
78 |
+
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
|
79 |
+
</div>
|
80 |
+
|
81 |
+
Utilisation combinée de plusieurs modèles de langage sophistiqués en version de test [huggingface](https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta) (la version huggingface ne prend pas en charge Chatglm).
|
82 |
+
|
83 |
+
|
84 |
+
---
|
85 |
+
|
86 |
+
## Installation - Méthode 1 : Exécution directe (Windows, Linux or MacOS)
|
87 |
+
|
88 |
+
1. Téléchargez le projet
|
89 |
+
```sh
|
90 |
+
git clone https://github.com/binary-husky/chatgpt_academic.git
|
91 |
+
cd chatgpt_academic
|
92 |
+
```
|
93 |
+
|
94 |
+
2. Configuration de l'API_KEY et des paramètres de proxy
|
95 |
+
|
96 |
+
Dans `config.py`, configurez les paramètres de proxy et de clé d'API OpenAI, comme indiqué ci-dessous
|
97 |
+
```
|
98 |
+
1. Si vous êtes en Chine, vous devez configurer un proxy étranger pour utiliser l'API OpenAI en toute transparence. Pour ce faire, veuillez lire attentivement le fichier config.py (1. Modifiez l'option USE_PROXY ; 2. Modifiez les paramètres de proxies comme indiqué dans les instructions).
|
99 |
+
2. Configurez votre clé API OpenAI. Vous devez vous inscrire sur le site web d'OpenAI pour obtenir une clé API. Une fois que vous avez votre clé API, vous pouvez la configurer dans le fichier config.py.
|
100 |
+
3. Tous les problèmes liés aux réseaux de proxy (temps d'attente, non-fonctionnement des proxies) sont résumés dans https://github.com/binary-husky/chatgpt_academic/issues/1.
|
101 |
+
```
|
102 |
+
(Remarque : le programme vérifie d'abord s'il existe un fichier de configuration privé nommé `config_private.py`, et utilise les configurations de celui-ci à la place de celles du fichier `config.py`. Par conséquent, si vous comprenez notre logique de lecture de configuration, nous vous recommandons fortement de créer un nouveau fichier de configuration nommé `config_private.py` à côté de `config.py` et de transférer (copier) les configurations de celui-ci dans `config_private.py`. `config_private.py` n'est pas contrôlé par git et rend vos informations personnelles plus sûres.)
|
103 |
+
|
104 |
+
3. Installation des dépendances
|
105 |
+
```sh
|
106 |
+
# (Option 1) Recommandé
|
107 |
+
python -m pip install -r requirements.txt
|
108 |
+
|
109 |
+
# (Option 2) Si vous utilisez anaconda, les étapes sont similaires :
|
110 |
+
# (Option 2.1) conda create -n gptac_venv python=3.11
|
111 |
+
# (Option 2.2) conda activate gptac_venv
|
112 |
+
# (Option 2.3) python -m pip install -r requirements.txt
|
113 |
+
|
114 |
+
# note : Utilisez la source pip officielle ou la source pip Alibaba. D'autres sources (comme celles des universités) pourraient poser problème. Pour utiliser temporairement une autre source, utilisez :
|
115 |
+
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
116 |
+
```
|
117 |
+
|
118 |
+
Si vous avez besoin de soutenir ChatGLM de Tsinghua, vous devez installer plus de dépendances (si vous n'êtes pas familier avec Python ou que votre ordinateur n'est pas assez performant, nous vous recommandons de ne pas essayer) :
|
119 |
+
```sh
|
120 |
+
python -m pip install -r request_llm/requirements_chatglm.txt
|
121 |
+
```
|
122 |
+
|
123 |
+
4. Exécution
|
124 |
+
```sh
|
125 |
+
python main.py
|
126 |
+
```
|
127 |
+
|
128 |
+
5. Tester les plugins de fonctions
|
129 |
+
```
|
130 |
+
- Test Python Project Analysis
|
131 |
+
Dans la zone de saisie, entrez `./crazy_functions/test_project/python/dqn`, puis cliquez sur "Parse Entire Python Project"
|
132 |
+
- Test d'auto-lecture du code
|
133 |
+
Cliquez sur "[Démo multi-thread] Parser ce projet lui-même (auto-traduction de la source)"
|
134 |
+
- Test du modèle de fonctionnalité expérimentale (exige une réponse de l'IA à ce qui est arrivé aujourd'hui dans l'histoire). Vous pouvez utiliser cette fonctionnalité comme modèle pour des fonctions plus complexes.
|
135 |
+
Cliquez sur "[Démo modèle de plugin de fonction] Histoire du Jour"
|
136 |
+
- Le menu déroulant de la zone de plugin de fonctionnalité contient plus de fonctionnalités à sélectionner.
|
137 |
+
```
|
138 |
+
|
139 |
+
## Installation - Méthode 2 : Utilisation de docker (Linux)
|
140 |
+
|
141 |
+
|
142 |
+
Vous êtes un traducteur professionnel d'articles académiques en français.
|
143 |
+
|
144 |
+
1. ChatGPT seul (recommandé pour la plupart des gens)
|
145 |
+
``` sh
|
146 |
+
# Télécharger le projet
|
147 |
+
git clone https://github.com/binary-husky/chatgpt_academic.git
|
148 |
+
cd chatgpt_academic
|
149 |
+
# Configurer le proxy outre-mer et la clé API OpenAI
|
150 |
+
Modifier le fichier config.py avec n'importe quel éditeur de texte
|
151 |
+
# Installer
|
152 |
+
docker build -t gpt-academic .
|
153 |
+
# Exécuter
|
154 |
+
docker run --rm -it --net=host gpt-academic
|
155 |
+
|
156 |
+
# Tester les modules de fonction
|
157 |
+
## Tester la fonction modèle des modules (requiert la réponse de GPT à "qu'est-ce qui s'est passé dans l'histoire aujourd'hui ?"), vous pouvez utiliser cette fonction en tant que modèle pour implémenter des fonctions plus complexes.
|
158 |
+
Cliquez sur "[Exemple de modèle de module] Histoire d'aujourd'hui"
|
159 |
+
## Tester le résumé écrit pour le projet LaTeX
|
160 |
+
Dans la zone de saisie, tapez ./crazy_functions/test_project/latex/attention, puis cliquez sur "Lire le résumé de l'article de recherche LaTeX"
|
161 |
+
## Tester l'analyse du projet Python
|
162 |
+
Dans la zone de saisie, tapez ./crazy_functions/test_project/python/dqn, puis cliquez sur "Analyser l'ensemble du projet Python"
|
163 |
+
|
164 |
+
D'autres fonctions sont disponibles dans la liste déroulante des modules de fonction.
|
165 |
+
```
|
166 |
+
|
167 |
+
2. ChatGPT+ChatGLM (nécessite une grande connaissance de docker et une configuration informatique suffisamment puissante)
|
168 |
+
``` sh
|
169 |
+
# Modifier le dockerfile
|
170 |
+
cd docs && nano Dockerfile+ChatGLM
|
171 |
+
# Comment construire | 如何构建 (Dockerfile+ChatGLM在docs路径下,请先cd docs)
|
172 |
+
docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
|
173 |
+
# Comment exécuter | 如何运行 (1) Directement exécuter :
|
174 |
+
docker run --rm -it --net=host --gpus=all gpt-academic
|
175 |
+
# Comment exécuter | 如何运行 (2) Je veux effectuer quelques ajustements dans le conteneur avant de lancer :
|
176 |
+
docker run --rm -it --net=host --gpus=all gpt-academic bash
|
177 |
+
```
|
178 |
+
|
179 |
+
## Installation - Méthode 3 : Autres méthodes de déploiement
|
180 |
+
|
181 |
+
1. Déploiement sur un cloud serveur distant
|
182 |
+
Veuillez consulter le [wiki de déploiement-1](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
|
183 |
+
|
184 |
+
2. Utilisation de WSL2 (Windows Subsystem for Linux)
|
185 |
+
Veuillez consulter le [wiki de déploiement-2](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
|
186 |
+
|
187 |
+
|
188 |
+
## Configuration de la procuration de l'installation
|
189 |
+
### Méthode 1 : Méthode conventionnelle
|
190 |
+
[Configuration de la procuration](https://github.com/binary-husky/chatgpt_academic/issues/1)
|
191 |
+
|
192 |
+
### Méthode 2 : Tutoriel pour débutant pur
|
193 |
+
[Tutoriel pour débutant pur](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BB%A3%E7%90%86%E8%BD%AF%E4%BB%B6%E9%97%AE%E9%A2%98%E7%9A%84%E6%96%B0%E6%89%8B%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%EF%BC%88%E6%96%B9%E6%B3%95%E5%8F%AA%E9%80%82%E7%94%A8%E4%BA%8E%E6%96%B0%E6%89%8B%EF%BC%89)
|
194 |
+
|
195 |
+
|
196 |
+
---
|
197 |
+
|
198 |
+
## Personnalisation des nouveaux boutons pratiques (personnalisation des raccourcis académiques)
|
199 |
+
Ouvrez le fichier `core_functional.py` avec n'importe quel éditeur de texte, ajoutez les éléments suivants, puis redémarrez le programme. (Si le bouton a déjà été ajouté avec succès et est visible, le préfixe et le suffixe pris en charge peuvent être modifiés à chaud sans avoir besoin de redémarrer le programme.)
|
200 |
+
Par exemple:
|
201 |
+
```
|
202 |
+
"Traduction Français-Chinois": {
|
203 |
+
# Préfixe, qui sera ajouté avant votre saisie. Par exemple, pour décrire votre demande, telle que la traduction, le débogage de code, l'amélioration, etc.
|
204 |
+
"Prefix": "Veuillez traduire le contenu ci-dessous en chinois, puis expliquer chaque terme propre mentionné dans un tableau Markdown :\n\n",
|
205 |
+
|
206 |
+
# Suffixe, qui sera ajouté après votre saisie. Par exemple, en combinaison avec un préfixe, vous pouvez mettre le contenu de votre saisie entre guillemets.
|
207 |
+
"Suffix": "",
|
208 |
+
},
|
209 |
+
```
|
210 |
+
|
211 |
+
<div align="center">
|
212 |
+
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
|
213 |
+
</div>
|
214 |
+
|
215 |
+
---
|
216 |
+
|
217 |
+
|
218 |
+
## Présentation de certaines fonctionnalités
|
219 |
+
|
220 |
+
### Affichage des images:
|
221 |
+
|
222 |
+
<div align="center">
|
223 |
+
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
|
224 |
+
</div>
|
225 |
+
|
226 |
+
|
227 |
+
### Si un programme peut comprendre et décomposer lui-même :
|
228 |
+
|
229 |
+
<div align="center">
|
230 |
+
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
|
231 |
+
</div>
|
232 |
+
|
233 |
+
<div align="center">
|
234 |
+
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
|
235 |
+
</div>
|
236 |
+
|
237 |
+
|
238 |
+
### Analyse de tout projet Python/Cpp quelconque :
|
239 |
+
<div align="center">
|
240 |
+
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
|
241 |
+
</div>
|
242 |
+
|
243 |
+
<div align="center">
|
244 |
+
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
|
245 |
+
</div>
|
246 |
+
|
247 |
+
### Lecture et résumé générés automatiquement pour les articles en Latex
|
248 |
+
<div align="center">
|
249 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
|
250 |
+
</div>
|
251 |
+
|
252 |
+
### Génération de rapports automatique
|
253 |
+
<div align="center">
|
254 |
+
<img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
|
255 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
|
256 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
|
257 |
+
</div>
|
258 |
+
|
259 |
+
### Conception de fonctionnalités modulaires
|
260 |
+
<div align="center">
|
261 |
+
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
|
262 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
|
263 |
+
</div>
|
264 |
+
|
265 |
+
|
266 |
+
### Traduction de code source en anglais
|
267 |
+
|
268 |
+
<div align="center">
|
269 |
+
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
|
270 |
+
</div>
|
271 |
+
|
272 |
+
## À faire et planification de version :
|
273 |
+
- version 3.2+ (à faire) : Prise en charge de plus de paramètres d'interface de plugin de fonction
|
274 |
+
- version 3.1 : Prise en charge de l'interrogation simultanée de plusieurs modèles GPT ! Prise en charge de l'API2d, prise en charge de la répartition de charge de plusieurs clés API
|
275 |
+
- version 3.0 : Prise en charge de chatglm et d'autres petits llm
|
276 |
+
- version 2.6 : Réorganisation de la structure du plugin, amélioration de l'interactivité, ajout de plus de plugins
|
277 |
+
- version 2.5 : Mise à jour automatique, résolution du problème de dépassement de jeton et de texte trop long lors de la compilation du code source complet
|
278 |
+
- version 2.4 : (1) Ajout de la fonctionnalité de traduction intégrale de PDF ; (2) Ajout d'une fonctionnalité de changement de position de zone de saisie ; (3) Ajout d'une option de disposition verticale ; (4) Optimisation du plugin de fonction multi-thread.
|
279 |
+
- version 2.3 : Amélioration de l'interactivité multi-thread
|
280 |
+
- version 2.2 : Prise en charge du rechargement à chaud du plugin de fonction
|
281 |
+
- version 2.1 : Mise en page pliable
|
282 |
+
- version 2.0 : Introduction du plugin de fonction modulaire
|
283 |
+
- version 1.0 : Fonctionnalité de base
|
284 |
+
|
285 |
+
## Références et apprentissage
|
286 |
+
|
287 |
+
```
|
288 |
+
De nombreux designs d'autres projets exceptionnels ont été utilisés pour référence dans le code, notamment :
|
289 |
+
|
290 |
+
# Projet 1 : De nombreuses astuces ont été empruntées à ChuanhuChatGPT
|
291 |
+
https://github.com/GaiZhenbiao/ChuanhuChatGPT
|
292 |
+
|
293 |
+
# Projet 2 : ChatGLM-6B de Tsinghua :
|
294 |
+
https://github.com/THUDM/ChatGLM-6B
|
295 |
+
```
|
296 |
+
|
docs/README_JP.md
ADDED
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
> **Note**
|
2 |
+
>
|
3 |
+
> このReadmeファイルは、このプロジェクトのmarkdown翻訳プラグインによって自動的に生成されたもので、100%正確ではない可能性があります。
|
4 |
+
>
|
5 |
+
|
6 |
+
# <img src="logo.png" width="40" > ChatGPT 学術最適化
|
7 |
+
|
8 |
+
**このプロジェクトが好きだったら、スターをつけてください。もし、より使いやすい学術用のショートカットキーまたはファンクションプラグインを発明した場合は、issueを発行するかpull requestを作成してください。また、このプロジェクト自体によって翻訳されたREADMEは[英語説明書|](docs/README_EN.md)[日本語説明書|](docs/README_JP.md)[ロシア語説明書|](docs/README_RS.md)[フランス語説明書](docs/README_FR.md)もあります。**
|
9 |
+
|
10 |
+
> **注意事項**
|
11 |
+
>
|
12 |
+
> 1. **赤色**のラベルが付いているファンクションプラグイン(ボタン)のみファイルを読み込めます。一部のプラグインはプラグインエリアのドロップダウンメニューにあります。新しいプラグインのPRを歓迎いたします!
|
13 |
+
>
|
14 |
+
> 2. このプロジェクトの各ファイルの機能は`self_analysis.md`(自己解析レポート)で詳しく説明されています。バージョンが追加されると、関連するファンクションプラグインをクリックして、GPTを呼び出して自己解析レポートを再生成することができます。一般的な質問は`wiki`にまとめられています。(`https://github.com/binary-husky/chatgpt_academic/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98`)
|
15 |
+
|
16 |
+
|
17 |
+
<div align="center">
|
18 |
+
|
19 |
+
機能 | 説明
|
20 |
+
--- | ---
|
21 |
+
ワンクリック整形 | 論文の文法エラーを一括で正確に修正できます。
|
22 |
+
ワンクリック日英翻訳 | 日英翻訳には、ワンクリックで対応できます。
|
23 |
+
ワンクリックコード説明 | コードの正しい表示と説明が可能です。
|
24 |
+
[カスタムショートカットキー](https://www.bilibili.com/video/BV14s4y1E7jN) | カスタムショートカットキーをサポートします。
|
25 |
+
[プロキシサーバーの設定](https://www.bilibili.com/video/BV1rc411W7Dr) | プロキシサーバーの設定をサポートします。
|
26 |
+
モジュラーデザイン | カスタム高階関数プラグインと[関数プラグイン]、プラグイン[ホット更新]のサポートが可能です。詳細は[こちら](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)
|
27 |
+
[自己プログラム解析](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)このプロジェクトのソースコード
|
28 |
+
[プログラム解析機能](https://www.bilibili.com/video/BV1cj411A7VW) | [関数プラグイン] ワンクリックで別のPython/C/C++/Java/Lua/...プロジェクトツリーを解析できます。
|
29 |
+
論文読解 | [関数プラグイン] LaTeX論文の全文をワンクリックで解読し、要約を生成します。
|
30 |
+
LaTeX全文翻訳、整形 | [関数プラグイン] ワンクリックでLaTeX論文を翻訳または整形できます。
|
31 |
+
注釈生成 | [関数プラグイン] ワンクリックで関数の注釈を大量に生成できます。
|
32 |
+
チャット分析レポート生成 | [関数プラグイン] 実行後、まとめレポートを自動生成します。
|
33 |
+
[arxivヘルパー](https://www.bilibili.com/video/BV1LM4y1279X) | [関数プラグイン] 入力したarxivの記事URLで要約をワンクリック翻訳+PDFダウンロードができます。
|
34 |
+
[PDF論文全文翻訳機能](https://www.bilibili.com/video/BV1KT411x7Wn) | [関数プラグイン] PDF論文タイトルと要約を抽出し、全文を翻訳します(マルチスレッド)。
|
35 |
+
[Google Scholar Integratorヘルパー](https://www.bilibili.com/video/BV19L411U7ia) | [関数プラグイン] 任意のGoogle Scholar検索ページURLを指定すると、gptが興味深い記事を選択します。
|
36 |
+
数式/画像/テーブル表示 | 数式のTex形式とレンダリング形式を同時に表示できます。数式、コードのハイライトをサポートしています。
|
37 |
+
マルチスレッド関数プラグインサポート | ChatGPTをマルチスレッドで呼び出すことができ、大量のテキストやプログラムを簡単に処理できます。
|
38 |
+
ダークグラジオ[テーマ](https://github.com/binary-husky/chatgpt_academic/issues/173)の起動 | 「/?__dark-theme=true」というURLをブラウザに追加することで、ダークテーマに切り替えることができます。
|
39 |
+
[多数のLLMモデル](https://www.bilibili.com/video/BV1wT411p7yf)をサポート、[API2D](https://api2d.com/)インターフェースをサポート | GPT3.5、GPT4、[清華ChatGLM](https://github.com/THUDM/ChatGLM-6B)による同時サポートは、と���も素晴らしいですね!
|
40 |
+
huggingface免科学上网[オンライン版](https://huggingface.co/spaces/qingxu98/gpt-academic) | huggingfaceにログイン後、[このスペース](https://huggingface.co/spaces/qingxu98/gpt-academic)をコピーしてください。
|
41 |
+
...... | ......
|
42 |
+
|
43 |
+
|
44 |
+
</div>
|
45 |
+
|
46 |
+
|
47 |
+
- 新しいインターフェース(config.pyのLAYOUTオプションを変更するだけで、「左右レイアウト」と「上下レイアウト」を切り替えることができます)
|
48 |
+
<div align="center">
|
49 |
+
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
|
50 |
+
</div>
|
51 |
+
|
52 |
+
|
53 |
+
- すべてのボタンは、functional.pyを読み込んで動的に生成されます。カスタム機能を自由に追加して、クリップボードを解放します
|
54 |
+
<div align="center">
|
55 |
+
<img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
|
56 |
+
</div>
|
57 |
+
|
58 |
+
- 色を修正/修正
|
59 |
+
<div align="center">
|
60 |
+
<img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
|
61 |
+
</div>
|
62 |
+
|
63 |
+
- 出力に数式が含まれている場合、TeX形式とレンダリング形式の両方が表示され、コピーと読み取りが容易になります
|
64 |
+
<div align="center">
|
65 |
+
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
|
66 |
+
</div>
|
67 |
+
|
68 |
+
- プロジェクトのコードを見るのが面倒?chatgptに整備されたプロジェクトを直接与えましょう
|
69 |
+
<div align="center">
|
70 |
+
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
|
71 |
+
</div>
|
72 |
+
|
73 |
+
- 多数の大規模言語モデルの混合呼び出し(ChatGLM + OpenAI-GPT3.5 + [API2D](https://api2d.com/)-GPT4)
|
74 |
+
<div align="center">
|
75 |
+
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
|
76 |
+
</div>
|
77 |
+
|
78 |
+
多数の大規模言語モデルの混合呼び出し[huggingfaceテスト版](https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta)(huggigface版はchatglmをサポートしていません)
|
79 |
+
|
80 |
+
|
81 |
+
---
|
82 |
+
|
83 |
+
## インストール-方法1:直接運転 (Windows、LinuxまたはMacOS)
|
84 |
+
|
85 |
+
1. プロジェクトをダウンロードします。
|
86 |
+
```sh
|
87 |
+
git clone https://github.com/binary-husky/chatgpt_academic.git
|
88 |
+
cd chatgpt_academic
|
89 |
+
```
|
90 |
+
|
91 |
+
2. API_KEYとプロキシ設定を構成する
|
92 |
+
|
93 |
+
`config.py`で、海外のProxyとOpenAI API KEYを構成して説明します。
|
94 |
+
```
|
95 |
+
1.あなたが中国にいる場合、OpenAI APIをスムーズに使用するには海外プロキシを設定する必要があります。構成の詳細については、config.py(1.その中のUSE_PROXYをTrueに変更し、2.手順に従ってプロキシを変更する)を詳細に読んでください。
|
96 |
+
2. OpenAI API KEYを構成する。OpenAIのウェブサイトでAPI KEYを取得してください。一旦API KEYを手に入れると、config.pyファイルで設定するだけです。
|
97 |
+
3.プロキシネットワークに関連する問題(ネットワークタイムアウト、プロキシが動作しない)をhttps://github.com/binary-husky/chatgpt_academic/issues/1にまとめました。
|
98 |
+
```
|
99 |
+
(P.S. プログラム実行時にconfig.pyの隣にconfig_private.pyという名前のプライバシー設定ファイルを作成し、同じ名前の設定を上書きするconfig_private.pyが存在するかどうかを優先的に確認します。そのため、私たちの構成読み取りロジックを理解できる場合は、config.pyの隣にconfig_private.pyという名前の新しい設定ファイルを作成し、その中のconfig.pyから設定を移動してください。config_private.pyはgitで保守されていないため、プライバシー情報をより安全にすることができます。)
|
100 |
+
|
101 |
+
3. 依存関係をインストールします。
|
102 |
+
```sh
|
103 |
+
# 選択肢があります。
|
104 |
+
python -m pip install -r requirements.txt
|
105 |
+
|
106 |
+
|
107 |
+
# (選択肢2) もしAnacondaを使用する場合、手順は同様です:
|
108 |
+
# (選択肢2.1) conda create -n gptac_venv python=3.11
|
109 |
+
# (選択肢2.2) conda activate gptac_venv
|
110 |
+
# (選択肢2.3) python -m pip install -r requirements.txt
|
111 |
+
|
112 |
+
# 注: 公式のpipソースまたはAlibabaのpipソースを使用してください。 別のpipソース(例:一部の大学のpip)は問題が発生する可能性があります。 一時的なソースの切り替え方法:
|
113 |
+
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
114 |
+
```
|
115 |
+
|
116 |
+
もしあなたが清華ChatGLMをサポートする必要がある場合、さらに多くの依存関係をインストールする必要があります(Pythonに慣れない方やコンピューターの設定が十分でない方は、試みないことをお勧めします):
|
117 |
+
```sh
|
118 |
+
python -m pip install -r request_llm/requirements_chatglm.txt
|
119 |
+
```
|
120 |
+
|
121 |
+
4. 実行
|
122 |
+
```sh
|
123 |
+
python main.py
|
124 |
+
```
|
125 |
+
|
126 |
+
5. 関数プラグインのテスト
|
127 |
+
```
|
128 |
+
- Pythonプロジェクト分析のテスト
|
129 |
+
入力欄に `./crazy_functions/test_project/python/dqn` と入力し、「Pythonプロジェクト全体の解析」をクリックします。
|
130 |
+
- 自己コード解読のテスト
|
131 |
+
「[マルチスレッドデモ] このプロジェクト自体を解析します(ソースを翻訳して解読します)」をクリックします。
|
132 |
+
- 実験的な機能テンプレート関数のテスト(GPTが「今日の歴史」に何が起こったかを回答することが求められます)。この関数をテンプレートとして使用して、より複雑な機能を実装できます。
|
133 |
+
「[関数プラグインテンプレートデモ] 今日の歴史」をクリックします。
|
134 |
+
- 関数プラグインエリアのドロップダウンメニューには他にも選択肢があります。
|
135 |
+
```
|
136 |
+
|
137 |
+
## インストール方法2:Dockerを使用する(Linux)
|
138 |
+
|
139 |
+
1. ChatGPTのみ(大多数の人にお勧めです)
|
140 |
+
``` sh
|
141 |
+
# プロジェクトのダウンロード
|
142 |
+
git clone https://github.com/binary-husky/chatgpt_academic.git
|
143 |
+
cd chatgpt_academic
|
144 |
+
# 海外プロキシとOpenAI API KEYの設定
|
145 |
+
config.pyを任意のテキストエディタで編集する
|
146 |
+
# インストール
|
147 |
+
docker build -t gpt-academic .
|
148 |
+
# 実行
|
149 |
+
docker run --rm -it --net=host gpt-academic
|
150 |
+
|
151 |
+
# 関数プラグインのテスト
|
152 |
+
## 関数プラグインテンプレート関数のテスト(GPTが「今日の歴史」に何が起こったかを回答することが求められます)。この関数をテンプレートとして使用して、より複雑な機能を実装できます。
|
153 |
+
「[関数プラグインテンプレートデモ] 今日の歴史」をクリックします。
|
154 |
+
## Latexプロジェクトの要約を書くテスト
|
155 |
+
入力欄に./crazy_functions/test_project/latex/attentionと入力し、「テックス論文を読んで要約を書く」をクリックします。
|
156 |
+
## Pythonプロジェクト分析のテスト
|
157 |
+
入力欄に./crazy_functions/test_project/python/dqnと入力し、[Pythonプロジェクトの全解析]をクリックします。
|
158 |
+
|
159 |
+
関数プラグインエリアのドロップダウンメニューには他にも選択肢があります。
|
160 |
+
```
|
161 |
+
|
162 |
+
2. ChatGPT + ChatGLM(Dockerに非常に詳しい人+十分なコンピューター設定が必要)
|
163 |
+
|
164 |
+
|
165 |
+
|
166 |
+
```sh
|
167 |
+
# Dockerfileの編集
|
168 |
+
cd docs && nano Dockerfile+ChatGLM
|
169 |
+
# ビルド方法
|
170 |
+
docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
|
171 |
+
# 実行方法 (1) 直接実行:
|
172 |
+
docker run --rm -it --net=host --gpus=all gpt-academic
|
173 |
+
# 実行方法 (2) コンテナに入って調整する:
|
174 |
+
docker run --rm -it --net=host --gpus=all gpt-academic bash
|
175 |
+
```
|
176 |
+
|
177 |
+
## インストール方法3:その他のデプロイ方法
|
178 |
+
|
179 |
+
1. クラウドサーバーデプロイ
|
180 |
+
[デプロイ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)
|
181 |
+
|
182 |
+
2. WSL2を使用 (Windows Subsystem for Linux)
|
183 |
+
[デプロイwiki-2](https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
|
184 |
+
|
185 |
+
|
186 |
+
## インストール-プロキシ設定
|
187 |
+
1. 通常の方法
|
188 |
+
[プロキシを設定する](https://github.com/binary-husky/chatgpt_academic/issues/1)
|
189 |
+
|
190 |
+
2. 初心者向けチュートリアル
|
191 |
+
[初心者向けチュートリアル](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)
|
192 |
+
|
193 |
+
|
194 |
+
---
|
195 |
+
|
196 |
+
## カスタムボタンの追加(学術ショートカットキー)
|
197 |
+
|
198 |
+
`core_functional.py`を任意のテキストエディタで開き、以下のエントリーを追加し、プログラムを再起動してください。(ボタンが追加されて表示される場合、前置詞と後置詞はホット編集がサポートされているため、プログラムを再起動せずに即座に有効になります。)
|
199 |
+
|
200 |
+
例:
|
201 |
+
```
|
202 |
+
"超级英译中": {
|
203 |
+
# 前置詞 - あなたの要求を説明するために使用されます。翻訳、コードの説明、編集など。
|
204 |
+
"Prefix": "以下のコンテンツを中国語に翻訳して、マークダウンテーブルを使用して専門用語を説明してください。\n\n",
|
205 |
+
|
206 |
+
# 後置詞 - プレフィックスと共に使用すると、入力内容を引用符で囲むことができます。
|
207 |
+
"Suffix": "",
|
208 |
+
},
|
209 |
+
```
|
210 |
+
|
211 |
+
<div align="center">
|
212 |
+
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
|
213 |
+
</div>
|
214 |
+
|
215 |
+
|
216 |
+
---
|
217 |
+
|
218 |
+
## いくつかの機能の例
|
219 |
+
|
220 |
+
### 画像表示:
|
221 |
+
|
222 |
+
<div align="center">
|
223 |
+
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
|
224 |
+
</div>
|
225 |
+
|
226 |
+
|
227 |
+
### プログラムが自己解析できる場合:
|
228 |
+
|
229 |
+
<div align="center">
|
230 |
+
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
|
231 |
+
</div>
|
232 |
+
|
233 |
+
<div align="center">
|
234 |
+
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
|
235 |
+
</div>
|
236 |
+
|
237 |
+
### 他のPython/Cppプロジェクトの解析:
|
238 |
+
|
239 |
+
<div align="center">
|
240 |
+
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
|
241 |
+
</div>
|
242 |
+
|
243 |
+
<div align="center">
|
244 |
+
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
|
245 |
+
</div>
|
246 |
+
|
247 |
+
### Latex論文の一括読解と要約生成
|
248 |
+
|
249 |
+
<div align="center">
|
250 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
|
251 |
+
</div>
|
252 |
+
|
253 |
+
### 自動報告生成
|
254 |
+
|
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 |
+
### モジュール化された機能デザイン
|
262 |
+
|
263 |
+
<div align="center">
|
264 |
+
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
|
265 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
|
266 |
+
</div>
|
267 |
+
|
268 |
+
|
269 |
+
### ソースコードの英語翻訳
|
270 |
+
|
271 |
+
<div align="center">
|
272 |
+
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
|
273 |
+
</div>
|
274 |
+
|
275 |
+
## Todo およびバージョン計画:
|
276 |
+
- version 3.2+ (todo): 関数プラグインがより多くのパラメーターインターフェースをサポートするようになります。
|
277 |
+
- version 3.1: 複数のgptモデルを同時にクエリし、api2dをサポートし、複数のapikeyの負荷分散をサポートします。
|
278 |
+
- version 3.0: chatglmおよび他の小型llmのサポート
|
279 |
+
- version 2.6: プラグイン構造を再構成し、相互作用性を高め、より多くのプラグインを追加しました。
|
280 |
+
- version 2.5: 自己更新。総括的な大規模プロジェクトのソースコードをまとめた場合、テキストが長すぎる、トークンがオーバーフローする問題を解決します。
|
281 |
+
- version 2.4: (1)PDF全文翻訳機能を追加。(2)入力エリアの位置を切り替える機能を追加。(3)垂直レイアウトオプションを追加。(4)マルチスレッド関数プラグインの最適化。
|
282 |
+
- version 2.3: 多スレッドの相互作用性を向上させました。
|
283 |
+
- version 2.2: 関数プラグインでホットリロードをサポート
|
284 |
+
- version 2.1: 折りたたみ式レイアウト
|
285 |
+
- version 2.0: モジュール化された関数プラグインを導入
|
286 |
+
- version 1.0: 基本機能
|
287 |
+
|
288 |
+
## 参考および学習
|
289 |
+
|
290 |
+
|
291 |
+
以下は中国語のマークダウンファイルです。日本語に翻訳してください。既存のマークダウンコマンドを変更しないでください:
|
292 |
+
|
293 |
+
```
|
294 |
+
多くの優秀なプロジェクトの設計を参考にしています。主なものは以下の通りです:
|
295 |
+
|
296 |
+
# 参考プロジェクト1:ChuanhuChatGPTから多くのテクニックを借用
|
297 |
+
https://github.com/GaiZhenbiao/ChuanhuChatGPT
|
298 |
+
|
299 |
+
# 参考プロジェクト2:清華ChatGLM-6B:
|
300 |
+
https://github.com/THUDM/ChatGLM-6B
|
301 |
+
```
|
302 |
+
|
docs/README_RS.md
ADDED
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
> **Note**
|
2 |
+
>
|
3 |
+
> Этот файл самовыражения автоматически генерируется модулем перевода markdown в этом проекте и может быть не на 100% правильным.
|
4 |
+
>
|
5 |
+
|
6 |
+
# <img src="logo.png" width="40" > ChatGPT Academic Optimization
|
7 |
+
|
8 |
+
**Если вам понравился этот проект, пожалуйста, поставьте ему звезду. Если вы придумали более полезные академические ярлыки или функциональные плагины, не стесняйтесь создавать запросы на изменение или пул-запросы. Мы также имеем [README на английском языке](docs/README_EN.md), переведенный этим же проектом.
|
9 |
+
|
10 |
+
> **Примечание**
|
11 |
+
>
|
12 |
+
> 1. Пожалуйста, обратите внимание, что только функциonal plugins (buttons) с **красным цветом** могут читать файлы, некоторые из которых находятся в **выпадающем меню** плагинов. Кроме того, мы приветствуем и обрабатываем любые новые плагины с **наивысшим приоритетом**!
|
13 |
+
>
|
14 |
+
> 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) .
|
15 |
+
|
16 |
+
<div align="center">
|
17 |
+
|
18 |
+
Функция | Описание
|
19 |
+
--- | ---
|
20 |
+
Редактирование одним кликом | Поддержка редактирования одним кликом, поиск грамматических ошибок в академических статьях
|
21 |
+
Переключение языков "Английский-Китайский" одним кликом | Одним кликом переключайте языки "Английский-Китайский"
|
22 |
+
Разъяснение программного кода одним кликом | Вы можете правильно отобразить и объяснить программный код.
|
23 |
+
[Настраиваемые сочетания клавиш](https://www.bilibili.com/video/BV14s4y1E7jN) | Поддержка настраиваемых сочетаний клавиш
|
24 |
+
[Настройка сервера-прокси](https://www.bilibili.com/video/BV1rc411W7Dr) | Поддержка настройки сервера-прокси
|
25 |
+
Модульный дизайн | Поддержка настраиваемых функциональных плагинов высших порядков и функциональных плагинов, поддерживающих [горячее обновление](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)
|
26 |
+
[Автоанализ программы](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) кода программы проекта
|
27 |
+
[Анализ программы](https://www.bilibili.com/video/BV1cj411A7VW) | [Функциональный плагин] Один клик для проанализирования дерева других проектов Python/C/C++/Java/Lua/...
|
28 |
+
Чтение статей| [Функциональный плагин] Одним кликом прочитайте весь латех (LaTex) текст статьи и сгенерируйте краткое описание
|
29 |
+
Перевод и редактирование всех статей из LaTex | [Функциональный плагин] Перевод или редактирование LaTex-статьи всего одним нажатием кнопки
|
30 |
+
Генерация комментариев в пакетном режиме | [Функциональный плагин] Одним кликом сгенерируйте комментарии к функциям в пакетном режиме
|
31 |
+
Генерация отчетов пакета CHAT | [Функциональный плагин] Автоматически создавайте сводные отчеты после выполнения
|
32 |
+
[Помощник по arxiv](https://www.bilibili.com/video/BV1LM4y1279X) | [Функциональный плагин] Введите URL статьи arxiv, чтобы легко перевести резюме и загрузить PDF-файл
|
33 |
+
[Перевод полного текста статьи в формате PDF](https://www.bilibili.com/video/BV1KT411x7Wn) | [Функциональный плагин] Извлеките заголовок статьи, резюме и переведите весь текст статьи (многопоточно)
|
34 |
+
[Помощник интеграции Google Scholar](https://www.bilibili.com/video/BV19L411U7ia) | [Функциональный плагин] Дайте GPT выбрать для вас интересные статьи на любой странице поиска Google Scholar.
|
35 |
+
Отображение формул/изображений/таблиц | Одновременно отображается tex-форма и рендер-форма формул, поддержка формул, высокоскоростных кодов
|
36 |
+
Поддержка функциональных плагинов многопоточности | Поддержка многопоточной работы с плагинами, обрабатывайте огромные объемы текста или программы одним кликом
|
37 |
+
Запуск темной темы gradio[подробнее](https://github.com/binary-husky/chatgpt_academic/issues/173) | Добавьте / ?__dark-theme=true в конец URL браузера, чтобы переключиться на темную тему.
|
38 |
+
[Поддержка нескольких моделей LLM](https://www.bilibili.com/video/BV1wT411p7yf), поддержка API2D | Находиться между GPT3.5, GPT4 и [清华ChatGLM](https://github.com/THUDM/ChatGLM-6B) должно быть очень приятно, не так ли?
|
39 |
+
Альтернатива huggingface без использования научной сети [Онлайн-эксперимент](https://huggingface.co/spaces/qingxu98/gpt-academic) | Войдите в систему, скопируйте пространство [этот пространственный URL](https://huggingface.co/spaces/qingxu98/gpt-academic)
|
40 |
+
…… | ……
|
41 |
+
|
42 |
+
|
43 |
+
</div>
|
44 |
+
|
45 |
+
- Новый интерфейс (вы можете изменить настройку LAYOUT в config.py, чтобы переключаться между "горизонтальным расположением" и "вертикальным расположением")
|
46 |
+
<div align="center">
|
47 |
+
<img src="https://user-images.githubusercontent.com/96192199/230361456-61078362-a966-4eb5-b49e-3c62ef18b860.gif" width="700" >
|
48 |
+
</div>
|
49 |
+
|
50 |
+
|
51 |
+
Вы профессиональный переводчик научных статей.
|
52 |
+
|
53 |
+
- Все кнопки генерируются динамически путем чтения functional.py и могут быть легко настроены под пользовательские потребности, освобождая буфер обмена.
|
54 |
+
<div align="center">
|
55 |
+
<img src="https://user-images.githubusercontent.com/96192199/231975334-b4788e91-4887-412f-8b43-2b9c5f41d248.gif" width="700" >
|
56 |
+
</div>
|
57 |
+
|
58 |
+
- Редактирование/корректирование
|
59 |
+
<div align="center">
|
60 |
+
<img src="https://user-images.githubusercontent.com/96192199/231980294-f374bdcb-3309-4560-b424-38ef39f04ebd.gif" width="700" >
|
61 |
+
</div>
|
62 |
+
|
63 |
+
- Если вывод содержит формулы, они отображаются одновременно как в формате tex, так и в рендеринговом формате для удобства копирования и чтения.
|
64 |
+
<div align="center">
|
65 |
+
<img src="https://user-images.githubusercontent.com/96192199/230598842-1d7fcddd-815d-40ee-af60-baf488a199df.png" width="700" >
|
66 |
+
</div>
|
67 |
+
|
68 |
+
- Лень смотреть код проекта? Просто покажите chatgpt.
|
69 |
+
<div align="center">
|
70 |
+
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="700" >
|
71 |
+
</div>
|
72 |
+
|
73 |
+
- Несколько моделей больших языковых моделей смешиваются (ChatGLM + OpenAI-GPT3.5 + [API2D] (https://api2d.com/) -GPT4)
|
74 |
+
<div align="center">
|
75 |
+
<img src="https://user-images.githubusercontent.com/96192199/232537274-deca0563-7aa6-4b5d-94a2-b7c453c47794.png" width="700" >
|
76 |
+
</div>
|
77 |
+
|
78 |
+
Несколько моделей больших языковых моделей смешиваются в [бета-версии huggingface] (https://huggingface.co/spaces/qingxu98/academic-chatgpt-beta) (huggingface-версия не поддерживает chatglm).
|
79 |
+
|
80 |
+
|
81 |
+
---
|
82 |
+
|
83 |
+
## Установка - Метод 1: Запуск (Windows, Linux или MacOS)
|
84 |
+
|
85 |
+
1. Скачайте проект
|
86 |
+
```sh
|
87 |
+
git clone https://github.com/binary-husky/chatgpt_academic.git
|
88 |
+
cd chatgpt_academic
|
89 |
+
```
|
90 |
+
|
91 |
+
2. Настройка API_KEY и настройки прокси
|
92 |
+
|
93 |
+
В файле `config.py` настройте зарубежный прокси и OpenAI API KEY, пояснения ниже
|
94 |
+
```
|
95 |
+
1. Если вы находитесь в Китае, вам нужно настроить зарубежный прокси, чтобы использовать OpenAI API. Пожалуйста, внимательно прочитайте config.py для получения инструкций (1. Измените USE_PROXY на True; 2. Измените прокси в соответствии с инструкциями).
|
96 |
+
2. Настройка API KEY OpenAI. Вам необходимо зарегистрироваться на сайте OpenAI и получить API KEY. После получения API KEY настройте его в файле config.py.
|
97 |
+
3. Вопросы, связанные с сетевыми проблемами (тайм-аут сети, прокси не работает), можно найти здесь: https://github.com/binary-husky/chatgpt_academic/issues/1
|
98 |
+
```
|
99 |
+
(Примечание: при запуске программы будет проверяться наличие конфиденциального файла конфигурации с именем `config_private.py` и использоваться в нем конфигурация параметров, которая перезаписывает параметры с такими же именами в `config.py`. Поэтому, если вы понимаете логику чтения нашей конфигурации, мы настоятельно рекомендуем вам создать новый файл конфигурации с именем `config_private.py` рядом с `config.py` и переместить (скопировать) настройки из `config.py` в `config_private.py`. `config_private.py` не подвергается контролю git, что делает конфиденциальную информацию более безопасной.)
|
100 |
+
|
101 |
+
|
102 |
+
3. Установить зависимости
|
103 |
+
```sh
|
104 |
+
# (Выбор 1) Рекомендуется
|
105 |
+
python -m pip install -r requirements.txt
|
106 |
+
|
107 |
+
# (Выбор 2) Если вы используете anaconda, то шаги будут аналогичны:
|
108 |
+
# (Шаг 2.1) conda create -n gptac_venv python=3.11
|
109 |
+
# (Шаг 2.2) conda activate gptac_venv
|
110 |
+
# (Шаг 2.3) python -m pip install -r requirements.txt
|
111 |
+
|
112 |
+
# Примечание: используйте официальный источник pip или источник pip.aliyun.com. Другие источники pip могут вызывать проблемы. временный метод замены источника:
|
113 |
+
# python -m pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
114 |
+
```
|
115 |
+
|
116 |
+
Если требуется поддержка TUNA ChatGLM, необходимо установить дополнительные зависимости (если вы неудобны с python, необходимо иметь хорошую конфигурацию компьютера):
|
117 |
+
```sh
|
118 |
+
python -m pip install -r request_llm/requirements_chatglm.txt
|
119 |
+
```
|
120 |
+
|
121 |
+
4. Запустите
|
122 |
+
```sh
|
123 |
+
python main.py
|
124 |
+
```
|
125 |
+
|
126 |
+
5. Тестовые функции плагина
|
127 |
+
```
|
128 |
+
- Тестирвоание анализа проекта Python
|
129 |
+
В основной области введите `./crazy_functions/test_project/python/dqn` , а затем нажмите "Анализировать весь проект Python"
|
130 |
+
- Тестирование самостоятельного чтения кода
|
131 |
+
Щелкните " [Демонстрационный режим многопоточности] Проанализируйте сам проект (расшифровка источника кода)"
|
132 |
+
- Тестирование функций шаблонного плагина (вы можете использовать эту функцию как шаблон для более сложных функций, требующих ответа от gpt в связи с тем, что произошло сегодня в истории)
|
133 |
+
Щелкните " [Функции шаблонного плагина] День в истории"
|
134 |
+
- На нижней панели дополнительные функции для выбора
|
135 |
+
```
|
136 |
+
|
137 |
+
## Установка - Метод 2: Использование docker (Linux)
|
138 |
+
|
139 |
+
|
140 |
+
1. Только ChatGPT (рекомендуется для большинства пользователей):
|
141 |
+
``` sh
|
142 |
+
# Скачать проект
|
143 |
+
git clone https://github.com/binary-husky/chatgpt_academic.git
|
144 |
+
cd chatgpt_academic
|
145 |
+
# Настроить прокси за границей и OpenAI API KEY
|
146 |
+
Отредактируйте файл config.py в любом текстовом редакторе.
|
147 |
+
# Установка
|
148 |
+
docker build -t gpt-academic .
|
149 |
+
# Запустить
|
150 |
+
docker run --rm -it --net=host gpt-academic
|
151 |
+
|
152 |
+
# Проверка функциональности плагина
|
153 |
+
## Прове��ка шаблонной функции плагина (требуется, чтобы gpt ответил, что произошло "в истории на этот день"), вы можете использовать эту функцию в качестве шаблона для реализации более сложных функций.
|
154 |
+
Нажмите "[Шаблонный демонстрационный плагин] История на этот день".
|
155 |
+
## Тест абстрактного резюме для проекта на Latex
|
156 |
+
В области ввода введите ./crazy_functions/test_project/latex/attention, а затем нажмите "Чтение реферата о тезисах статьи на LaTeX".
|
157 |
+
## Тестовый анализ проекта на Python
|
158 |
+
Введите в область ввода ./crazy_functions/test_project/python/dqn, затем нажмите "Проанализировать весь проект на Python".
|
159 |
+
|
160 |
+
Выбирайте больше функциональных плагинов в нижнем выпадающем меню.
|
161 |
+
```
|
162 |
+
|
163 |
+
2. ChatGPT + ChatGLM (требуется глубокое знание Docker и достаточно мощное компьютерное оборудование):
|
164 |
+
|
165 |
+
``` sh
|
166 |
+
# Изменение Dockerfile
|
167 |
+
cd docs && nano Dockerfile+ChatGLM
|
168 |
+
# Как построить | Как запустить (Dockerfile+ChatGLM в пути docs, сначала перейдите в папку с помощью cd docs)
|
169 |
+
docker build -t gpt-academic --network=host -f Dockerfile+ChatGLM .
|
170 |
+
# Как запустить | Как запустить (2) я хочу войти в контейнер и сделать какие-то настройки до запуска:
|
171 |
+
docker run --rm -it --net=host --gpus=all gpt-academic bash
|
172 |
+
```
|
173 |
+
|
174 |
+
|
175 |
+
## Установка-Метод 3: Другие способы развертывания
|
176 |
+
|
177 |
+
1. Развертывание на удаленном облачном сервере
|
178 |
+
Пожалуйста, посетите [Deploy Wiki-1] (https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BA%91%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%BF%9C%E7%A8%8B%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97)
|
179 |
+
|
180 |
+
2. Использование WSL2 (Windows Subsystem for Linux)
|
181 |
+
Пожалуйста, посетите [Deploy Wiki-2] (https://github.com/binary-husky/chatgpt_academic/wiki/%E4%BD%BF%E7%94%A8WSL2%EF%BC%88Windows-Subsystem-for-Linux-%E5%AD%90%E7%B3%BB%E7%BB%9F%EF%BC%89%E9%83%A8%E7%BD%B2)
|
182 |
+
|
183 |
+
|
184 |
+
## Установка-Настройки прокси
|
185 |
+
### Метод 1: Обычный способ
|
186 |
+
[Конфигурация прокси] (https://github.com/binary-husky/chatgpt_academic/issues/1)
|
187 |
+
|
188 |
+
### Метод 2: Руководство новичка
|
189 |
+
[Руководство новичка] (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)
|
190 |
+
|
191 |
+
|
192 |
+
---
|
193 |
+
|
194 |
+
## Настройка новой удобной кнопки (настройка быстрой клавиши для научной работы)
|
195 |
+
Откройте `core_functional.py` любым текстовым редактором, добавьте элементы, как показано ниже, затем перезапустите программу. (Если кнопка уже успешно добавлена и видна, то префикс и суффикс поддерживают горячее изменение, чтобы они оказались в действии, не нужно перезапускать программу.)
|
196 |
+
например
|
197 |
+
```
|
198 |
+
"Супер анг-рус": {
|
199 |
+
# Префикс, будет добавлен перед вашим вводом. Например, используется для описания ваших потребностей, таких как перевод, кодинг, редактирование и т. д.
|
200 |
+
"Prefix": "Пожалуйста, переведите этот фрагмент на русский язык, а затем создайте пошаговую таблицу в markdown, чтобы объяснить все специализированные термины, которые встречаются в тексте:\n\n",
|
201 |
+
|
202 |
+
# Суффикс, будет добавлен после вашего ввода. Например, совместно с префиксом можно обрамить ваш ввод в кавычки.
|
203 |
+
"Suffix": "",
|
204 |
+
},
|
205 |
+
```
|
206 |
+
<div align="center">
|
207 |
+
<img src="https://user-images.githubusercontent.com/96192199/226899272-477c2134-ed71-4326-810c-29891fe4a508.png" width="500" >
|
208 |
+
</div>
|
209 |
+
|
210 |
+
---
|
211 |
+
|
212 |
+
|
213 |
+
## Демонстрация некоторых возможностей
|
214 |
+
|
215 |
+
### Отображение изображений:
|
216 |
+
|
217 |
+
<div align="center">
|
218 |
+
<img src="https://user-images.githubusercontent.com/96192199/228737599-bf0a9d9c-1808-4f43-ae15-dfcc7af0f295.png" width="800" >
|
219 |
+
</div>
|
220 |
+
|
221 |
+
|
222 |
+
### Если программа может понимать и разбирать сама себя:
|
223 |
+
|
224 |
+
<div align="center">
|
225 |
+
<img src="https://user-images.githubusercontent.com/96192199/226936850-c77d7183-0749-4c1c-9875-fd4891842d0c.png" width="800" >
|
226 |
+
</div>
|
227 |
+
|
228 |
+
<div align="center">
|
229 |
+
<img src="https://user-images.githubusercontent.com/96192199/226936618-9b487e4b-ab5b-4b6e-84c6-16942102e917.png" width="800" >
|
230 |
+
</div>
|
231 |
+
|
232 |
+
|
233 |
+
### Анализ других проектов на Python/Cpp:
|
234 |
+
<div align="center">
|
235 |
+
<img src="https://user-images.githubusercontent.com/96192199/226935232-6b6a73ce-8900-4aee-93f9-733c7e6fef53.png" width="800" >
|
236 |
+
</div>
|
237 |
+
|
238 |
+
<div align="center">
|
239 |
+
<img src="https://user-images.githubusercontent.com/96192199/226969067-968a27c1-1b9c-486b-8b81-ab2de8d3f88a.png" width="800" >
|
240 |
+
</div>
|
241 |
+
|
242 |
+
### Генерация понимания и абстрактов с помощью Латех статей в один клик
|
243 |
+
<div align="center">
|
244 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504406-86ab97cd-f208-41c3-8e4a-7000e51cf980.png" width="800" >
|
245 |
+
</div>
|
246 |
+
|
247 |
+
### Автоматическое создание отчетов
|
248 |
+
<div align="center">
|
249 |
+
<img src="https://user-images.githubusercontent.com/96192199/227503770-fe29ce2c-53fd-47b0-b0ff-93805f0c2ff4.png" height="300" >
|
250 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504617-7a497bb3-0a2a-4b50-9a8a-95ae60ea7afd.png" height="300" >
|
251 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504005-efeaefe0-b687-49d0-bf95-2d7b7e66c348.png" height="300" >
|
252 |
+
</div>
|
253 |
+
|
254 |
+
### Модульный дизайн функций
|
255 |
+
<div align="center">
|
256 |
+
<img src="https://user-images.githubusercontent.com/96192199/229288270-093643c1-0018-487a-81e6-1d7809b6e90f.png" height="400" >
|
257 |
+
<img src="https://user-images.githubusercontent.com/96192199/227504931-19955f78-45cd-4d1c-adac-e71e50957915.png" height="400" >
|
258 |
+
</div>
|
259 |
+
|
260 |
+
|
261 |
+
### Трансляция исходного кода на английский язык
|
262 |
+
|
263 |
+
<div align="center">
|
264 |
+
<img src="https://user-images.githubusercontent.com/96192199/229720562-fe6c3508-6142-4635-a83d-21eb3669baee.png" height="400" >
|
265 |
+
</div>
|
266 |
+
|
267 |
+
## Todo и планирование версий:
|
268 |
+
- version 3.2+ (todo): функция плагины поддерживают более многочисленные интерфейсы параметров
|
269 |
+
- version 3.1: поддержка одновременного опроса нескольких моделей gpt! Поддержка api2d, поддержка балансировки нагрузки множества apikey.
|
270 |
+
- version 3.0: поддержка chatglm и других маленьких llm
|
271 |
+
- version 2.6: реструктурировал структуру плагинов, повысил интерактивность, добавил больше плагинов
|
272 |
+
- version 2.5: само обновление, решение проблемы слишком длинного текста и переполнения токена при переводе всего проекта исходного кода
|
273 |
+
- version 2.4: (1) добавлена функция перевода всего PDF-документа; (2) добавлена функция изменения положения входной области; (3) добавлена опция вертикального макета; (4) оптимизация функций многопоточности плагина.
|
274 |
+
- version 2.3: улучшение многопоточной интерактивности
|
275 |
+
- version 2.2: функция плагинов поддерживает горячую перезагрузку
|
276 |
+
- version 2.1: блочная раскладка
|
277 |
+
- version 2.0: модульный дизайн функций плагина
|
278 |
+
- version 1.0: основные функции
|
279 |
+
|
280 |
+
## Ссылки на изучение и обучение
|
281 |
+
|
282 |
+
```
|
283 |
+
В коде использовано много хороших дизайнерских решений из других отличных проектов, в том числе:
|
284 |
+
|
285 |
+
# Project1: использование многих приемов из ChuanhuChatGPT
|
286 |
+
https://github.com/GaiZhenbiao/ChuanhuChatGPT
|
287 |
+
|
288 |
+
# Project2: ChatGLM-6B в Тхуде:
|
289 |
+
https://github.com/THUDM/ChatGLM-6B
|
290 |
+
```
|
291 |
+
|
docs/logo.png
ADDED
![]() |
main.py
CHANGED
@@ -40,7 +40,7 @@ def main():
|
|
40 |
set_theme = adjust_theme()
|
41 |
|
42 |
# 代理与自动更新
|
43 |
-
from check_proxy import check_proxy, auto_update
|
44 |
proxy_info = check_proxy(proxies)
|
45 |
|
46 |
gr_L1 = lambda: gr.Row().style()
|
@@ -96,13 +96,13 @@ def main():
|
|
96 |
with gr.Row():
|
97 |
with gr.Accordion("点击展开“文件上传区”。上传本地文件可供红色函数插件调用。", open=False) as area_file_up:
|
98 |
file_upload = gr.Files(label="任何文件, 但推荐上传压缩文件(zip, tar)", file_count="multiple")
|
99 |
-
with gr.Accordion("
|
100 |
system_prompt = gr.Textbox(show_label=True, placeholder=f"System Prompt", label="System prompt", value=initial_prompt)
|
101 |
top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.01,interactive=True, label="Top-p (nucleus sampling)",)
|
102 |
temperature = gr.Slider(minimum=-0, maximum=2.0, value=1.0, step=0.01, interactive=True, label="Temperature",)
|
103 |
-
max_length_sl = gr.Slider(minimum=256, maximum=4096, value=512, step=1, interactive=True, label="MaxLength",)
|
104 |
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区", "底部输入区", "输入清除键"], value=["基础功能区", "函数插件区"], label="显示/隐藏功能区")
|
105 |
-
md_dropdown = gr.Dropdown(AVAIL_LLM_MODELS, value=LLM_MODEL, label="").style(container=False)
|
106 |
|
107 |
gr.Markdown(description)
|
108 |
with gr.Accordion("备选输入区", open=True, visible=False) as area_input_secondary:
|
@@ -181,9 +181,10 @@ def main():
|
|
181 |
webbrowser.open_new_tab(f"http://localhost:{PORT}/?__dark-theme=true")
|
182 |
threading.Thread(target=open, name="open-browser", daemon=True).start()
|
183 |
threading.Thread(target=auto_update, name="self-upgrade", daemon=True).start()
|
|
|
184 |
|
185 |
auto_opentab_delay()
|
186 |
-
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name="0.0.0.0", share=False)
|
187 |
|
188 |
if __name__ == "__main__":
|
189 |
main()
|
|
|
40 |
set_theme = adjust_theme()
|
41 |
|
42 |
# 代理与自动更新
|
43 |
+
from check_proxy import check_proxy, auto_update, warm_up_modules
|
44 |
proxy_info = check_proxy(proxies)
|
45 |
|
46 |
gr_L1 = lambda: gr.Row().style()
|
|
|
96 |
with gr.Row():
|
97 |
with gr.Accordion("点击展开“文件上传区”。上传本地文件可供红色函数插件调用。", open=False) as area_file_up:
|
98 |
file_upload = gr.Files(label="任何文件, 但推荐上传压缩文件(zip, tar)", file_count="multiple")
|
99 |
+
with gr.Accordion("更换模型 & SysPrompt & 交互界面布局", open=(LAYOUT == "TOP-DOWN")):
|
100 |
system_prompt = gr.Textbox(show_label=True, placeholder=f"System Prompt", label="System prompt", value=initial_prompt)
|
101 |
top_p = gr.Slider(minimum=-0, maximum=1.0, value=1.0, step=0.01,interactive=True, label="Top-p (nucleus sampling)",)
|
102 |
temperature = gr.Slider(minimum=-0, maximum=2.0, value=1.0, step=0.01, interactive=True, label="Temperature",)
|
103 |
+
max_length_sl = gr.Slider(minimum=256, maximum=4096, value=512, step=1, interactive=True, label="Local LLM MaxLength",)
|
104 |
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区", "底部输入区", "输入清除键"], value=["基础功能区", "函数插件区"], label="显示/隐藏功能区")
|
105 |
+
md_dropdown = gr.Dropdown(AVAIL_LLM_MODELS, value=LLM_MODEL, label="更换LLM模型/请求源").style(container=False)
|
106 |
|
107 |
gr.Markdown(description)
|
108 |
with gr.Accordion("备选输入区", open=True, visible=False) as area_input_secondary:
|
|
|
181 |
webbrowser.open_new_tab(f"http://localhost:{PORT}/?__dark-theme=true")
|
182 |
threading.Thread(target=open, name="open-browser", daemon=True).start()
|
183 |
threading.Thread(target=auto_update, name="self-upgrade", daemon=True).start()
|
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_all.py
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
2. predict_no_ui_long_connection:在实验过程中发现调用predict_no_ui处理长文档时,和openai的连接容易断掉,这个函数用stream的方式解决这个问题,同样支持多线程
|
10 |
"""
|
11 |
import tiktoken
|
12 |
-
|
13 |
from concurrent.futures import ThreadPoolExecutor
|
14 |
|
15 |
from .bridge_chatgpt import predict_no_ui_long_connection as chatgpt_noui
|
@@ -18,11 +18,36 @@ from .bridge_chatgpt import predict as chatgpt_ui
|
|
18 |
from .bridge_chatglm import predict_no_ui_long_connection as chatglm_noui
|
19 |
from .bridge_chatglm import predict as chatglm_ui
|
20 |
|
21 |
-
from .bridge_tgui import predict_no_ui_long_connection as tgui_noui
|
22 |
-
from .bridge_tgui import predict as tgui_ui
|
23 |
|
24 |
colors = ['#FF00FF', '#00FFFF', '#FF0000', '#990099', '#009999', '#990044']
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
model_info = {
|
27 |
# openai
|
28 |
"gpt-3.5-turbo": {
|
@@ -30,8 +55,8 @@ model_info = {
|
|
30 |
"fn_without_ui": chatgpt_noui,
|
31 |
"endpoint": "https://api.openai.com/v1/chat/completions",
|
32 |
"max_token": 4096,
|
33 |
-
"tokenizer":
|
34 |
-
"token_cnt":
|
35 |
},
|
36 |
|
37 |
"gpt-4": {
|
@@ -39,8 +64,8 @@ model_info = {
|
|
39 |
"fn_without_ui": chatgpt_noui,
|
40 |
"endpoint": "https://api.openai.com/v1/chat/completions",
|
41 |
"max_token": 8192,
|
42 |
-
"tokenizer":
|
43 |
-
"token_cnt":
|
44 |
},
|
45 |
|
46 |
# api_2d
|
@@ -49,8 +74,8 @@ model_info = {
|
|
49 |
"fn_without_ui": chatgpt_noui,
|
50 |
"endpoint": "https://openai.api2d.net/v1/chat/completions",
|
51 |
"max_token": 4096,
|
52 |
-
"tokenizer":
|
53 |
-
"token_cnt":
|
54 |
},
|
55 |
|
56 |
"api2d-gpt-4": {
|
@@ -58,8 +83,8 @@ model_info = {
|
|
58 |
"fn_without_ui": chatgpt_noui,
|
59 |
"endpoint": "https://openai.api2d.net/v1/chat/completions",
|
60 |
"max_token": 8192,
|
61 |
-
"tokenizer":
|
62 |
-
"token_cnt":
|
63 |
},
|
64 |
|
65 |
# chatglm
|
@@ -68,8 +93,8 @@ model_info = {
|
|
68 |
"fn_without_ui": chatglm_noui,
|
69 |
"endpoint": None,
|
70 |
"max_token": 1024,
|
71 |
-
"tokenizer":
|
72 |
-
"token_cnt":
|
73 |
},
|
74 |
|
75 |
}
|
|
|
9 |
2. predict_no_ui_long_connection:在实验过程中发现调用predict_no_ui处理长文档时,和openai的连接容易断掉,这个函数用stream的方式解决这个问题,同样支持多线程
|
10 |
"""
|
11 |
import tiktoken
|
12 |
+
from functools import wraps, lru_cache
|
13 |
from concurrent.futures import ThreadPoolExecutor
|
14 |
|
15 |
from .bridge_chatgpt import predict_no_ui_long_connection as chatgpt_noui
|
|
|
18 |
from .bridge_chatglm import predict_no_ui_long_connection as chatglm_noui
|
19 |
from .bridge_chatglm import predict as chatglm_ui
|
20 |
|
21 |
+
# from .bridge_tgui import predict_no_ui_long_connection as tgui_noui
|
22 |
+
# from .bridge_tgui import predict as tgui_ui
|
23 |
|
24 |
colors = ['#FF00FF', '#00FFFF', '#FF0000', '#990099', '#009999', '#990044']
|
25 |
|
26 |
+
class LazyloadTiktoken(object):
|
27 |
+
def __init__(self, model):
|
28 |
+
self.model = model
|
29 |
+
|
30 |
+
@staticmethod
|
31 |
+
@lru_cache(maxsize=128)
|
32 |
+
def get_encoder(model):
|
33 |
+
print('正在加载tokenizer,如果是第一次运行,可能需要一点时间下载参数')
|
34 |
+
tmp = tiktoken.encoding_for_model(model)
|
35 |
+
print('加载tokenizer完毕')
|
36 |
+
return tmp
|
37 |
+
|
38 |
+
def encode(self, *args, **kwargs):
|
39 |
+
encoder = self.get_encoder(self.model)
|
40 |
+
return encoder.encode(*args, **kwargs)
|
41 |
+
|
42 |
+
def decode(self, *args, **kwargs):
|
43 |
+
encoder = self.get_encoder(self.model)
|
44 |
+
return encoder.decode(*args, **kwargs)
|
45 |
+
|
46 |
+
tokenizer_gpt35 = LazyloadTiktoken("gpt-3.5-turbo")
|
47 |
+
tokenizer_gpt4 = LazyloadTiktoken("gpt-4")
|
48 |
+
get_token_num_gpt35 = lambda txt: len(tokenizer_gpt35.encode(txt, disallowed_special=()))
|
49 |
+
get_token_num_gpt4 = lambda txt: len(tokenizer_gpt4.encode(txt, disallowed_special=()))
|
50 |
+
|
51 |
model_info = {
|
52 |
# openai
|
53 |
"gpt-3.5-turbo": {
|
|
|
55 |
"fn_without_ui": chatgpt_noui,
|
56 |
"endpoint": "https://api.openai.com/v1/chat/completions",
|
57 |
"max_token": 4096,
|
58 |
+
"tokenizer": tokenizer_gpt35,
|
59 |
+
"token_cnt": get_token_num_gpt35,
|
60 |
},
|
61 |
|
62 |
"gpt-4": {
|
|
|
64 |
"fn_without_ui": chatgpt_noui,
|
65 |
"endpoint": "https://api.openai.com/v1/chat/completions",
|
66 |
"max_token": 8192,
|
67 |
+
"tokenizer": tokenizer_gpt4,
|
68 |
+
"token_cnt": get_token_num_gpt4,
|
69 |
},
|
70 |
|
71 |
# api_2d
|
|
|
74 |
"fn_without_ui": chatgpt_noui,
|
75 |
"endpoint": "https://openai.api2d.net/v1/chat/completions",
|
76 |
"max_token": 4096,
|
77 |
+
"tokenizer": tokenizer_gpt35,
|
78 |
+
"token_cnt": get_token_num_gpt35,
|
79 |
},
|
80 |
|
81 |
"api2d-gpt-4": {
|
|
|
83 |
"fn_without_ui": chatgpt_noui,
|
84 |
"endpoint": "https://openai.api2d.net/v1/chat/completions",
|
85 |
"max_token": 8192,
|
86 |
+
"tokenizer": tokenizer_gpt4,
|
87 |
+
"token_cnt": get_token_num_gpt4,
|
88 |
},
|
89 |
|
90 |
# chatglm
|
|
|
93 |
"fn_without_ui": chatglm_noui,
|
94 |
"endpoint": None,
|
95 |
"max_token": 1024,
|
96 |
+
"tokenizer": tokenizer_gpt35,
|
97 |
+
"token_cnt": get_token_num_gpt35,
|
98 |
},
|
99 |
|
100 |
}
|
request_llm/bridge_chatglm.py
CHANGED
@@ -5,6 +5,8 @@ import importlib
|
|
5 |
from toolbox import update_ui, get_conf
|
6 |
from multiprocessing import Process, Pipe
|
7 |
|
|
|
|
|
8 |
#################################################################################
|
9 |
class GetGLMHandle(Process):
|
10 |
def __init__(self):
|
@@ -12,13 +14,26 @@ class GetGLMHandle(Process):
|
|
12 |
self.parent, self.child = Pipe()
|
13 |
self.chatglm_model = None
|
14 |
self.chatglm_tokenizer = None
|
|
|
|
|
|
|
15 |
self.start()
|
16 |
-
print('初始化')
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
def ready(self):
|
19 |
return self.chatglm_model is not None
|
20 |
|
21 |
def run(self):
|
|
|
|
|
22 |
while True:
|
23 |
try:
|
24 |
if self.chatglm_model is None:
|
@@ -33,7 +48,12 @@ class GetGLMHandle(Process):
|
|
33 |
else:
|
34 |
break
|
35 |
except:
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
37 |
while True:
|
38 |
kwargs = self.child.recv()
|
39 |
try:
|
@@ -64,7 +84,11 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history=[], sys_prompt="",
|
|
64 |
global glm_handle
|
65 |
if glm_handle is None:
|
66 |
glm_handle = GetGLMHandle()
|
67 |
-
observe_window[0] = "
|
|
|
|
|
|
|
|
|
68 |
|
69 |
# chatglm 没有 sys_prompt 接口,因此把prompt加入 history
|
70 |
history_feedin = []
|
@@ -93,8 +117,11 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
|
93 |
global glm_handle
|
94 |
if glm_handle is None:
|
95 |
glm_handle = GetGLMHandle()
|
96 |
-
chatbot[-1] = (inputs, "
|
97 |
yield from update_ui(chatbot=chatbot, history=[])
|
|
|
|
|
|
|
98 |
|
99 |
if additional_fn is not None:
|
100 |
import core_functional
|
|
|
5 |
from toolbox import update_ui, get_conf
|
6 |
from multiprocessing import Process, Pipe
|
7 |
|
8 |
+
load_message = "ChatGLM尚未加载,加载需要一段时间。注意,取决于`config.py`的配置,ChatGLM消耗大量的内存(CPU)或显存(GPU),也许会导致低配计算机卡死 ……"
|
9 |
+
|
10 |
#################################################################################
|
11 |
class GetGLMHandle(Process):
|
12 |
def __init__(self):
|
|
|
14 |
self.parent, self.child = Pipe()
|
15 |
self.chatglm_model = None
|
16 |
self.chatglm_tokenizer = None
|
17 |
+
self.info = ""
|
18 |
+
self.success = True
|
19 |
+
self.check_dependency()
|
20 |
self.start()
|
|
|
21 |
|
22 |
+
def check_dependency(self):
|
23 |
+
try:
|
24 |
+
import sentencepiece
|
25 |
+
self.info = "依赖检测通过"
|
26 |
+
self.success = True
|
27 |
+
except:
|
28 |
+
self.info = "缺少ChatGLM的依赖,如果要使用ChatGLM,除了基础的pip依赖以外,您还需要运行`pip install -r request_llm/requirements_chatglm.txt`安装ChatGLM的依赖。"
|
29 |
+
self.success = False
|
30 |
+
|
31 |
def ready(self):
|
32 |
return self.chatglm_model is not None
|
33 |
|
34 |
def run(self):
|
35 |
+
# 第一次运行,加载参数
|
36 |
+
retry = 0
|
37 |
while True:
|
38 |
try:
|
39 |
if self.chatglm_model is None:
|
|
|
48 |
else:
|
49 |
break
|
50 |
except:
|
51 |
+
retry += 1
|
52 |
+
if retry > 3:
|
53 |
+
self.child.send('[Local Message] Call ChatGLM fail 不能正常加载ChatGLM的参数。')
|
54 |
+
raise RuntimeError("不能正常加载ChatGLM的参数!")
|
55 |
+
|
56 |
+
# 进入任务等待状态
|
57 |
while True:
|
58 |
kwargs = self.child.recv()
|
59 |
try:
|
|
|
84 |
global glm_handle
|
85 |
if glm_handle is None:
|
86 |
glm_handle = GetGLMHandle()
|
87 |
+
observe_window[0] = load_message + "\n\n" + glm_handle.info
|
88 |
+
if not glm_handle.success:
|
89 |
+
error = glm_handle.info
|
90 |
+
glm_handle = None
|
91 |
+
raise RuntimeError(error)
|
92 |
|
93 |
# chatglm 没有 sys_prompt 接口,因此把prompt加入 history
|
94 |
history_feedin = []
|
|
|
117 |
global glm_handle
|
118 |
if glm_handle is None:
|
119 |
glm_handle = GetGLMHandle()
|
120 |
+
chatbot[-1] = (inputs, load_message + "\n\n" + glm_handle.info)
|
121 |
yield from update_ui(chatbot=chatbot, history=[])
|
122 |
+
if not glm_handle.success:
|
123 |
+
glm_handle = None
|
124 |
+
return
|
125 |
|
126 |
if additional_fn is not None:
|
127 |
import core_functional
|
request_llm/bridge_chatgpt.py
CHANGED
@@ -85,6 +85,7 @@ def predict_no_ui_long_connection(inputs, llm_kwargs, history=[], sys_prompt="",
|
|
85 |
raise ConnectionAbortedError("OpenAI拒绝了请求:" + error_msg)
|
86 |
else:
|
87 |
raise RuntimeError("OpenAI拒绝了请求:" + error_msg)
|
|
|
88 |
json_data = json.loads(chunk.lstrip('data:'))['choices'][0]
|
89 |
delta = json_data["delta"]
|
90 |
if len(delta) == 0: break
|
@@ -175,15 +176,17 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
|
175 |
|
176 |
if chunk:
|
177 |
try:
|
178 |
-
|
|
|
|
|
179 |
# 判定为数据流的结束,gpt_replying_buffer也写完了
|
180 |
logging.info(f'[response] {gpt_replying_buffer}')
|
181 |
break
|
182 |
# 处理数据流的主体
|
183 |
-
chunkjson = json.loads(
|
184 |
status_text = f"finish_reason: {chunkjson['choices'][0]['finish_reason']}"
|
185 |
# 如果这里抛出异常,一般是文本过长,详情见get_full_error的输出
|
186 |
-
gpt_replying_buffer = gpt_replying_buffer + json.loads(
|
187 |
history[-1] = gpt_replying_buffer
|
188 |
chatbot[-1] = (history[-2], history[-1])
|
189 |
yield from update_ui(chatbot=chatbot, history=history, msg=status_text) # 刷新界面
|
@@ -192,10 +195,13 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
|
192 |
traceback.print_exc()
|
193 |
yield from update_ui(chatbot=chatbot, history=history, msg="Json解析不合常规") # 刷新界面
|
194 |
chunk = get_full_error(chunk, stream_response)
|
195 |
-
|
|
|
196 |
if "reduce the length" in error_msg:
|
197 |
chatbot[-1] = (chatbot[-1][0], "[Local Message] Reduce the length. 本次输入过长,或历史数据过长. 历史缓存数据现已释放,您可以请再次尝试.")
|
198 |
history = [] # 清除历史
|
|
|
|
|
199 |
elif "Incorrect API key" in error_msg:
|
200 |
chatbot[-1] = (chatbot[-1][0], "[Local Message] Incorrect API key. OpenAI以提供了不正确的API_KEY为由,拒绝服务.")
|
201 |
elif "exceeded your current quota" in error_msg:
|
@@ -205,7 +211,7 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
|
|
205 |
else:
|
206 |
from toolbox import regular_txt_to_markdown
|
207 |
tb_str = '```\n' + traceback.format_exc() + '```'
|
208 |
-
chatbot[-1] = (chatbot[-1][0], f"[Local Message] 异常 \n\n{tb_str} \n\n{regular_txt_to_markdown(
|
209 |
yield from update_ui(chatbot=chatbot, history=history, msg="Json异常" + error_msg) # 刷新界面
|
210 |
return
|
211 |
|
|
|
85 |
raise ConnectionAbortedError("OpenAI拒绝了请求:" + error_msg)
|
86 |
else:
|
87 |
raise RuntimeError("OpenAI拒绝了请求:" + error_msg)
|
88 |
+
if ('data: [DONE]' in chunk): break # api2d 正常完成
|
89 |
json_data = json.loads(chunk.lstrip('data:'))['choices'][0]
|
90 |
delta = json_data["delta"]
|
91 |
if len(delta) == 0: break
|
|
|
176 |
|
177 |
if chunk:
|
178 |
try:
|
179 |
+
chunk_decoded = chunk.decode()
|
180 |
+
# 前者API2D的
|
181 |
+
if ('data: [DONE]' in chunk_decoded) or (len(json.loads(chunk_decoded[6:])['choices'][0]["delta"]) == 0):
|
182 |
# 判定为数据流的结束,gpt_replying_buffer也写完了
|
183 |
logging.info(f'[response] {gpt_replying_buffer}')
|
184 |
break
|
185 |
# 处理数据流的主体
|
186 |
+
chunkjson = json.loads(chunk_decoded[6:])
|
187 |
status_text = f"finish_reason: {chunkjson['choices'][0]['finish_reason']}"
|
188 |
# 如果这里抛出异常,一般是文本过长,详情见get_full_error的输出
|
189 |
+
gpt_replying_buffer = gpt_replying_buffer + json.loads(chunk_decoded[6:])['choices'][0]["delta"]["content"]
|
190 |
history[-1] = gpt_replying_buffer
|
191 |
chatbot[-1] = (history[-2], history[-1])
|
192 |
yield from update_ui(chatbot=chatbot, history=history, msg=status_text) # 刷新界面
|
|
|
195 |
traceback.print_exc()
|
196 |
yield from update_ui(chatbot=chatbot, history=history, msg="Json解析不合常规") # 刷新界面
|
197 |
chunk = get_full_error(chunk, stream_response)
|
198 |
+
chunk_decoded = chunk.decode()
|
199 |
+
error_msg = chunk_decoded
|
200 |
if "reduce the length" in error_msg:
|
201 |
chatbot[-1] = (chatbot[-1][0], "[Local Message] Reduce the length. 本次输入过长,或历史数据过长. 历史缓存数据现已释放,您可以请再次尝试.")
|
202 |
history = [] # 清除历史
|
203 |
+
elif "does not exist" in error_msg:
|
204 |
+
chatbot[-1] = (chatbot[-1][0], f"[Local Message] Model {llm_kwargs['llm_model']} does not exist. 模型不存在,或者您没有获得体验资格.")
|
205 |
elif "Incorrect API key" in error_msg:
|
206 |
chatbot[-1] = (chatbot[-1][0], "[Local Message] Incorrect API key. OpenAI以提供了不正确的API_KEY为由,拒绝服务.")
|
207 |
elif "exceeded your current quota" in error_msg:
|
|
|
211 |
else:
|
212 |
from toolbox import regular_txt_to_markdown
|
213 |
tb_str = '```\n' + traceback.format_exc() + '```'
|
214 |
+
chatbot[-1] = (chatbot[-1][0], f"[Local Message] 异常 \n\n{tb_str} \n\n{regular_txt_to_markdown(chunk_decoded[4:])}")
|
215 |
yield from update_ui(chatbot=chatbot, history=history, msg="Json异常" + error_msg) # 刷新界面
|
216 |
return
|
217 |
|
toolbox.py
CHANGED
@@ -25,7 +25,6 @@ def ArgsGeneralWrapper(f):
|
|
25 |
装饰器函数,用于重组输入参数,改变输入参数的顺序与结构。
|
26 |
"""
|
27 |
def decorated(cookies, max_length, llm_model, txt, txt2, top_p, temperature, chatbot, history, system_prompt, *args):
|
28 |
-
from request_llm.bridge_all import model_info
|
29 |
txt_passon = txt
|
30 |
if txt == "" and txt2 != "": txt_passon = txt2
|
31 |
# 引入一个有cookie的chatbot
|
@@ -401,7 +400,7 @@ def on_file_uploaded(files, chatbot, txt, txt2, checkboxes):
|
|
401 |
chatbot.append(['我上传了文件,请查收',
|
402 |
f'[Local Message] 收到以下文件: \n\n{moved_files_str}' +
|
403 |
f'\n\n调用路径参数已自动修正到: \n\n{txt}' +
|
404 |
-
f'\n\n
|
405 |
return chatbot, txt, txt2
|
406 |
|
407 |
|
|
|
25 |
装饰器函数,用于重组输入参数,改变输入参数的顺序与结构。
|
26 |
"""
|
27 |
def decorated(cookies, max_length, llm_model, txt, txt2, top_p, temperature, chatbot, history, system_prompt, *args):
|
|
|
28 |
txt_passon = txt
|
29 |
if txt == "" and txt2 != "": txt_passon = txt2
|
30 |
# 引入一个有cookie的chatbot
|
|
|
400 |
chatbot.append(['我上传了文件,请查收',
|
401 |
f'[Local Message] 收到以下文件: \n\n{moved_files_str}' +
|
402 |
f'\n\n调用路径参数已自动修正到: \n\n{txt}' +
|
403 |
+
f'\n\n现在您点击任意“红颜色”标识的函数插件时,以上文件将被作为输入参数'+err_msg])
|
404 |
return chatbot, txt, txt2
|
405 |
|
406 |
|
version
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
"version": 3.1,
|
3 |
"show_feature": true,
|
4 |
-
"new_feature": "
|
5 |
}
|
|
|
1 |
{
|
2 |
"version": 3.1,
|
3 |
"show_feature": true,
|
4 |
+
"new_feature": "添加支持清华ChatGLM和GPT-4 <-> 改进架构,支持与多个LLM模型同时对话 <-> 添加支持API2D(国内,可支持gpt4)<-> 支持多API-KEY负载均衡(并列填写,逗号分割) <-> 添加输入区文本清除按键"
|
5 |
}
|