From baaacc5a7bbf9d61cbcbb19def7bd4a21679067f Mon Sep 17 00:00:00 2001
From: binary-husky <96192199+binary-husky@users.noreply.github.com>
Date: Sat, 9 Sep 2023 19:11:21 +0800
Subject: [PATCH 01/29] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index ef463bd1..04b2f630 100644
--- a/README.md
+++ b/README.md
@@ -255,7 +255,7 @@ Tip:不指定文件直接点击 `载入对话历史存档` 可以查看历史h
3. 虚空终端(从自然语言输入中,理解用户意图+自动调用其他插件)
-- 步骤一:输入 “ 请调用插件翻译PDF论文,地址为https://storage.googleapis.com/deepmind-media/alphago/AlphaGoNaturePaper.pdf ”
+- 步骤一:输入 “ 请调用插件翻译PDF论文,地址为https://openreview.net/pdf?id=rJl0r3R9KX ”
- 步骤二:点击“虚空终端”
From 7c307d89647257f05823ff8e89f564e74a53ad79 Mon Sep 17 00:00:00 2001
From: binary-husky
Date: Sat, 9 Sep 2023 19:33:05 +0800
Subject: [PATCH 02/29] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=BA=90=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=E8=A7=A3=E6=9E=90=E6=A8=A1=E5=9D=97=E4=B8=8E=E8=99=9A?=
=?UTF-8?q?=E7=A9=BA=E7=BB=88=E7=AB=AF=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/解析项目源代码.py | 10 ++++++----
docs/GithubAction+AllCapacity | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/crazy_functions/解析项目源代码.py b/crazy_functions/解析项目源代码.py
index 30ae4440..926b629d 100644
--- a/crazy_functions/解析项目源代码.py
+++ b/crazy_functions/解析项目源代码.py
@@ -1,5 +1,5 @@
-from toolbox import update_ui
-from toolbox import CatchException, report_execption, write_results_to_file
+from toolbox import update_ui, promote_file_to_downloadzone
+from toolbox import CatchException, report_execption, write_history_to_file
from .crazy_utils import input_clipping
def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, system_prompt):
@@ -43,7 +43,8 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
# 全部文件解析完成,结果写入文件,准备对工程源代码进行汇总分析
report_part_1 = copy.deepcopy(gpt_response_collection)
history_to_return = report_part_1
- res = write_results_to_file(report_part_1)
+ res = write_history_to_file(report_part_1)
+ promote_file_to_downloadzone(res, chatbot=chatbot)
chatbot.append(("完成?", "逐个文件分析已完成。" + res + "\n\n正在开始汇总。"))
yield from update_ui(chatbot=chatbot, history=history_to_return) # 刷新界面
@@ -97,7 +98,8 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
############################## ##################################
history_to_return.extend(report_part_2)
- res = write_results_to_file(history_to_return)
+ res = write_history_to_file(history_to_return)
+ promote_file_to_downloadzone(res, chatbot=chatbot)
chatbot.append(("完成了吗?", res))
yield from update_ui(chatbot=chatbot, history=history_to_return) # 刷新界面
diff --git a/docs/GithubAction+AllCapacity b/docs/GithubAction+AllCapacity
index f6f05daa..82ddd087 100644
--- a/docs/GithubAction+AllCapacity
+++ b/docs/GithubAction+AllCapacity
@@ -1,7 +1,7 @@
# docker build -t gpt-academic-all-capacity -f docs/GithubAction+AllCapacity --network=host --build-arg http_proxy=http://localhost:10881 --build-arg https_proxy=http://localhost:10881 .
# 从NVIDIA源,从而支持显卡(检查宿主的nvidia-smi中的cuda版本必须>=11.3)
-FROM fuqingxu/11.3.1-runtime-ubuntu20.04-with-texlive:latest
+FROM fuqingxu/11.3.1-runtime-ubuntu20.04-with-texlive-cache:latest
# use python3 as the system default python
WORKDIR /gpt
From 2a5171507571e104f443bce05310301ebb931d81 Mon Sep 17 00:00:00 2001
From: binary-husky
Date: Sat, 9 Sep 2023 20:15:46 +0800
Subject: [PATCH 03/29] =?UTF-8?q?=E4=BF=AE=E5=A4=8DDockerfile?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/解析项目源代码.py | 5 +++--
docs/GithubAction+AllCapacity | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/crazy_functions/解析项目源代码.py b/crazy_functions/解析项目源代码.py
index 926b629d..debcb51b 100644
--- a/crazy_functions/解析项目源代码.py
+++ b/crazy_functions/解析项目源代码.py
@@ -1,4 +1,4 @@
-from toolbox import update_ui, promote_file_to_downloadzone
+from toolbox import update_ui, promote_file_to_downloadzone, disable_auto_promotion
from toolbox import CatchException, report_execption, write_history_to_file
from .crazy_utils import input_clipping
@@ -6,7 +6,8 @@ def 解析源代码新(file_manifest, project_folder, llm_kwargs, plugin_kwargs,
import os, copy
from .crazy_utils import request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
- msg = '正常'
+ disable_auto_promotion(chatbot=chatbot)
+
summary_batch_isolation = True
inputs_array = []
inputs_show_user_array = []
diff --git a/docs/GithubAction+AllCapacity b/docs/GithubAction+AllCapacity
index 82ddd087..f6f05daa 100644
--- a/docs/GithubAction+AllCapacity
+++ b/docs/GithubAction+AllCapacity
@@ -1,7 +1,7 @@
# docker build -t gpt-academic-all-capacity -f docs/GithubAction+AllCapacity --network=host --build-arg http_proxy=http://localhost:10881 --build-arg https_proxy=http://localhost:10881 .
# 从NVIDIA源,从而支持显卡(检查宿主的nvidia-smi中的cuda版本必须>=11.3)
-FROM fuqingxu/11.3.1-runtime-ubuntu20.04-with-texlive-cache:latest
+FROM fuqingxu/11.3.1-runtime-ubuntu20.04-with-texlive:latest
# use python3 as the system default python
WORKDIR /gpt
From ad9807dd14eff0632ea4e2e07c377c07b81c364d Mon Sep 17 00:00:00 2001
From: binary-husky
Date: Sat, 9 Sep 2023 20:32:44 +0800
Subject: [PATCH 04/29] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=99=9A=E7=A9=BA?=
=?UTF-8?q?=E7=BB=88=E7=AB=AF=E7=9A=84=E6=8F=90=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/虚空终端.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/crazy_functions/虚空终端.py b/crazy_functions/虚空终端.py
index 2e1b5236..e01b274d 100644
--- a/crazy_functions/虚空终端.py
+++ b/crazy_functions/虚空终端.py
@@ -25,11 +25,12 @@ explain_msg = """
1. 请用**自然语言**描述您需要做什么。例如:
- 「请调用插件,为我翻译PDF论文,论文我刚刚放到上传区了」
- - 「请调用插件翻译PDF论文,地址为https://aaa/bbb/ccc.pdf」
+ - 「请调用插件翻译PDF论文,地址为https://openreview.net/pdf?id=rJl0r3R9KX」
- 「把Arxiv论文翻译成中文PDF,arxiv论文的ID是1812.10695,记得用插件!」
- 「生成一张图片,图中鲜花怒放,绿草如茵,用插件实现」
- 「用插件翻译README,Github网址是https://github.com/facebookresearch/co-tracker」
- 「我不喜欢当前的界面颜色,修改配置,把主题THEME更换为THEME="High-Contrast"」
+ - 「请调用插件,解析python源代码项目,代码我刚刚打包拖到上传区了」
- 「请问Transformer网络的结构是怎样的?」
2. 您可以打开插件下拉菜单以了解本项目的各种能力。
From c45fa88684ece949ee5bd19f0245d51a84eaaf71 Mon Sep 17 00:00:00 2001
From: qingxu fu <505030475@qq.com>
Date: Sat, 9 Sep 2023 21:57:24 +0800
Subject: [PATCH 05/29] update translation matrix
---
docs/translate_english.json | 46 ++++++++++++++++++++++++++++++++++++-
docs/translate_std.json | 4 +++-
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/docs/translate_english.json b/docs/translate_english.json
index 667956c8..a29c3664 100644
--- a/docs/translate_english.json
+++ b/docs/translate_english.json
@@ -2448,5 +2448,49 @@
"插件说明": "Plugin description",
"├── CODE_HIGHLIGHT 代码高亮": "├── CODE_HIGHLIGHT Code highlighting",
"记得用插件": "Remember to use the plugin",
- "谨慎操作": "Handle with caution"
+ "谨慎操作": "Handle with caution",
+ "请检查PDF是否损坏": "#",
+ "执行成功了": "#",
+ "请在输入框内填写需求": "#",
+ "结果": "#",
+ "开始干正事": "#",
+ "次代码生成尝试": "#",
+ "代码生成结束": "#",
+ "Nougat解析论文失败": "#",
+ "受到google限制": "#",
+ "收尾": "#",
+ "结果是一个有效文件": "#",
+ "然后再次点击该插件": "#",
+ "用插件实现」": "#",
+ "文件路径": "#",
+ "仅供测试": "#",
+ "将csv文件转excel表格": "#",
+ "开始执行": "#",
+ "测试": "#",
+ "睡一会防止触发google反爬虫": "#",
+ "某段话的整个句子": "#",
+ "使用tex格式公式 测试2 给出柯西不等式": "#",
+ "找不到本地项目或无法处理": "#",
+ "交换图像的蓝色通道和红色通道": "#",
+ "第三步": "#",
+ "返回给定的url解析出的arxiv_id": "#",
+ "裁剪图像": "#",
+ "已经被记忆": "#",
+ "无法从bing获取信息!": "#",
+ "可能触发了google反爬虫机制": "#",
+ "检索文章的历史版本的题目": "#",
+ "请配置讯飞星火大模型的XFYUN_APPID": "#",
+ "执行失败了": "#",
+ "需要花费较长时间下载NOUGAT参数": "#",
+ "请检查": "#",
+ "写入": "#",
+ "下个句子中已经说完的部分": "#",
+ "精准翻译PDF文档": "#",
+ "解析python源代码项目": "#",
+ "首先在arxiv上搜索": "#",
+ "错误追踪": "#",
+ "结果是一个字符串": "#",
+ "由 test_on_sentence_end": "#",
+ "获取文章摘要": "#",
+ "受到bing限制": "#"
}
\ No newline at end of file
diff --git a/docs/translate_std.json b/docs/translate_std.json
index 63b6baa4..84690c2e 100644
--- a/docs/translate_std.json
+++ b/docs/translate_std.json
@@ -88,5 +88,7 @@
"辅助功能": "Accessibility",
"虚空终端": "VoidTerminal",
"解析PDF_基于GROBID": "ParsePDF_BasedOnGROBID",
- "虚空终端主路由": "VoidTerminalMainRoute"
+ "虚空终端主路由": "VoidTerminalMainRoute",
+ "批量翻译PDF文档_NOUGAT": "BatchTranslatePDFDocuments_NOUGAT",
+ "解析PDF_基于NOUGAT": "ParsePDF_NOUGAT"
}
\ No newline at end of file
From 28d777a96bfb92f86267797c5e2e6bc6ba0b7ae7 Mon Sep 17 00:00:00 2001
From: binary-husky
Date: Sun, 10 Sep 2023 16:52:35 +0800
Subject: [PATCH 06/29] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8A=A5=E9=94=99?=
=?UTF-8?q?=E6=B6=88=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/crazy_utils.py | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/crazy_functions/crazy_utils.py b/crazy_functions/crazy_utils.py
index 5a314b37..15671725 100644
--- a/crazy_functions/crazy_utils.py
+++ b/crazy_functions/crazy_utils.py
@@ -469,14 +469,16 @@ def read_and_clean_pdf_text(fp):
'- ', '') for t in text_areas['blocks'] if 'lines' in t]
############################## <第 2 步,获取正文主字体> ##################################
- fsize_statiscs = {}
- for span in meta_span:
- if span[1] not in fsize_statiscs: fsize_statiscs[span[1]] = 0
- fsize_statiscs[span[1]] += span[2]
- main_fsize = max(fsize_statiscs, key=fsize_statiscs.get)
- if REMOVE_FOOT_NOTE:
- give_up_fize_threshold = main_fsize * REMOVE_FOOT_FFSIZE_PERCENT
-
+ try:
+ fsize_statiscs = {}
+ for span in meta_span:
+ if span[1] not in fsize_statiscs: fsize_statiscs[span[1]] = 0
+ fsize_statiscs[span[1]] += span[2]
+ main_fsize = max(fsize_statiscs, key=fsize_statiscs.get)
+ if REMOVE_FOOT_NOTE:
+ give_up_fize_threshold = main_fsize * REMOVE_FOOT_FFSIZE_PERCENT
+ except:
+ raise RuntimeError(f'抱歉, 我们暂时无法解析此PDF文档: {fp}。')
############################## <第 3 步,切分和重新整合> ##################################
mega_sec = []
sec = []
From 34784333dc29f9c8e8261d1a607c90ac1c3e7ed9 Mon Sep 17 00:00:00 2001
From: binary-husky
Date: Sun, 10 Sep 2023 17:22:35 +0800
Subject: [PATCH 07/29] =?UTF-8?q?=E8=9E=8D=E5=90=88PDF=E5=B7=A6=E5=8F=B3?=
=?UTF-8?q?=E6=AF=94=E4=BE=8B=E8=B0=83=E6=95=B4=E5=88=B095%?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
crazy_functions/latex_fns/latex_toolbox.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crazy_functions/latex_fns/latex_toolbox.py b/crazy_functions/latex_fns/latex_toolbox.py
index 5adc7ea8..e39ac2db 100644
--- a/crazy_functions/latex_fns/latex_toolbox.py
+++ b/crazy_functions/latex_fns/latex_toolbox.py
@@ -423,7 +423,7 @@ def compile_latex_with_timeout(command, cwd, timeout=60):
def merge_pdfs(pdf1_path, pdf2_path, output_path):
import PyPDF2
- Percent = 0.8
+ Percent = 0.95
# Open the first PDF file
with open(pdf1_path, 'rb') as pdf1_file:
pdf1_reader = PyPDF2.PdfFileReader(pdf1_file)
From eb150987f0062e51bf003d3816ea6f8eb9c1cab3 Mon Sep 17 00:00:00 2001
From: qingxu fu <505030475@qq.com>
Date: Mon, 11 Sep 2023 14:49:30 +0800
Subject: [PATCH 08/29] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=B8=80=E4=B8=AAone-a?=
=?UTF-8?q?pi=E6=B2=A1=E6=9C=89done=E6=95=B0=E6=8D=AE=E5=8C=85=E7=9A=84?=
=?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9Bug=E6=83=85=E5=BD=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
request_llm/bridge_chatgpt.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/request_llm/bridge_chatgpt.py b/request_llm/bridge_chatgpt.py
index 929a7546..19d10022 100644
--- a/request_llm/bridge_chatgpt.py
+++ b/request_llm/bridge_chatgpt.py
@@ -179,8 +179,13 @@ def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_promp
# 非OpenAI官方接口的出现这样的报错,OpenAI和API2D不会走这里
chunk_decoded = chunk.decode()
error_msg = chunk_decoded
+ # 首先排除一个one-api没有done数据包的第三方Bug情形
+ if len(gpt_replying_buffer.strip()) > 0 and len(error_msg) == 0:
+ yield from update_ui(chatbot=chatbot, history=history, msg="检测到有缺陷的非OpenAI官方接口,建议选择更稳定的接口。")
+ break
+ # 其他情况,直接返回报错
chatbot, history = handle_error(inputs, llm_kwargs, chatbot, history, chunk_decoded, error_msg)
- yield from update_ui(chatbot=chatbot, history=history, msg="非Openai官方接口返回了错误:" + chunk.decode()) # 刷新界面
+ yield from update_ui(chatbot=chatbot, history=history, msg="非OpenAI官方接口返回了错误:" + chunk.decode()) # 刷新界面
return
chunk_decoded = chunk.decode()
From d495b73456eb504d4cf995ee910ce387d28e4600 Mon Sep 17 00:00:00 2001
From: qingxu fu <505030475@qq.com>
Date: Mon, 11 Sep 2023 22:55:32 +0800
Subject: [PATCH 09/29] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9B=B4=E5=A4=9AUI?=
=?UTF-8?q?=E7=9A=AE=E8=82=A4=E5=A4=96=E8=A7=82=EF=BC=8C=E5=8A=A0=E5=85=A5?=
=?UTF-8?q?=E6=9A=97=E8=89=B2=E4=BA=AE=E8=89=B2=E5=88=87=E6=8D=A2=E9=94=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config.py | 3 ++-
main.py | 9 +++++++++
themes/gradios.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
themes/theme.py | 3 +++
version | 4 ++--
5 files changed, 62 insertions(+), 3 deletions(-)
create mode 100644 themes/gradios.py
diff --git a/config.py b/config.py
index 1e91e39c..2d57f09b 100644
--- a/config.py
+++ b/config.py
@@ -43,7 +43,8 @@ API_URL_REDIRECT = {}
DEFAULT_WORKER_NUM = 3
-# 色彩主题,可选 ["Default", "Chuanhu-Small-and-Beautiful", "High-Contrast"]
+# 色彩主题, 可选 ["Default", "Chuanhu-Small-and-Beautiful", "High-Contrast"]
+# 更多主题, 请查阅Gradio主题商店: https://huggingface.co/spaces/gradio/theme-gallery 可选 ["Gstaff/Xkcd", "NoCrypt/Miku", ...]
THEME = "Default"
diff --git a/main.py b/main.py
index d4752535..628d30b9 100644
--- a/main.py
+++ b/main.py
@@ -123,6 +123,15 @@ def main():
max_length_sl = gr.Slider(minimum=256, maximum=8192, value=4096, step=1, interactive=True, label="Local LLM MaxLength",)
checkboxes = gr.CheckboxGroup(["基础功能区", "函数插件区", "底部输入区", "输入清除键", "插件参数区"], value=["基础功能区", "函数插件区"], label="显示/隐藏功能区")
md_dropdown = gr.Dropdown(AVAIL_LLM_MODELS, value=LLM_MODEL, label="更换LLM模型/请求源").style(container=False)
+ dark_mode_btn = gr.Button("Toggle Dark Mode ☀", variant="secondary").style(size="sm")
+ dark_mode_btn.click(None, None, None, _js="""() => {
+ if (document.querySelectorAll('.dark').length) {
+ document.querySelectorAll('.dark').forEach(el => el.classList.remove('dark'));
+ } else {
+ document.querySelector('body').classList.add('dark');
+ }
+ }""",
+ )
gr.Markdown(description)
with gr.Accordion("备选输入区", open=True, visible=False, elem_id="input-panel2") as area_input_secondary:
with gr.Row():
diff --git a/themes/gradios.py b/themes/gradios.py
new file mode 100644
index 00000000..8b661a56
--- /dev/null
+++ b/themes/gradios.py
@@ -0,0 +1,46 @@
+import gradio as gr
+import logging
+from toolbox import get_conf, ProxyNetworkActivate
+CODE_HIGHLIGHT, ADD_WAIFU, LAYOUT = get_conf('CODE_HIGHLIGHT', 'ADD_WAIFU', 'LAYOUT')
+
+def adjust_theme():
+
+ try:
+ set_theme = gr.themes.ThemeClass()
+ with ProxyNetworkActivate():
+ logging.info('正在下载Gradio主题,请稍等。')
+ THEME, = get_conf('THEME')
+ if THEME.startswith('Huggingface-'): THEME = THEME.lstrip('Huggingface-')
+ if THEME.startswith('huggingface-'): THEME = THEME.lstrip('huggingface-')
+ set_theme = set_theme.from_hub(THEME.lower())
+
+ if LAYOUT=="TOP-DOWN":
+ js = ""
+ else:
+ with open('themes/common.js', 'r', encoding='utf8') as f:
+ js = f""
+
+ # 添加一个萌萌的看板娘
+ if ADD_WAIFU:
+ js += """
+
+
+
+ """
+ gradio_original_template_fn = gr.routes.templates.TemplateResponse
+ def gradio_new_template_fn(*args, **kwargs):
+ res = gradio_original_template_fn(*args, **kwargs)
+ res.body = res.body.replace(b'