From 25e06de1b6e76166309f05198b005b58275ed32c Mon Sep 17 00:00:00 2001 From: Menghuan1918 Date: Wed, 26 Jun 2024 14:31:31 +0800 Subject: [PATCH 1/2] Docker build bug fix (#1870) --- docs/GithubAction+AllCapacity | 5 +++-- docs/GithubAction+AllCapacityBeta | 5 +++-- docs/GithubAction+ChatGLM+Moss | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/GithubAction+AllCapacity b/docs/GithubAction+AllCapacity index 0ebc1d3c..b9b421cf 100644 --- a/docs/GithubAction+AllCapacity +++ b/docs/GithubAction+AllCapacity @@ -3,6 +3,9 @@ # 从NVIDIA源,从而支持显卡(检查宿主的nvidia-smi中的cuda版本必须>=11.3) FROM fuqingxu/11.3.1-runtime-ubuntu20.04-with-texlive:latest +# edge-tts需要的依赖,某些pip包所需的依赖 +RUN apt update && apt install ffmpeg build-essential -y + # use python3 as the system default python WORKDIR /gpt RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.8 @@ -28,8 +31,6 @@ RUN python3 -m pip install -r request_llms/requirements_chatglm.txt RUN python3 -m pip install -r request_llms/requirements_newbing.txt RUN python3 -m pip install nougat-ocr -# edge-tts需要的依赖 -RUN apt update && apt install ffmpeg -y # 预热Tiktoken模块 RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()' diff --git a/docs/GithubAction+AllCapacityBeta b/docs/GithubAction+AllCapacityBeta index 263d5e9e..e942926c 100644 --- a/docs/GithubAction+AllCapacityBeta +++ b/docs/GithubAction+AllCapacityBeta @@ -5,6 +5,9 @@ # 从NVIDIA源,从而支持显卡(检查宿主的nvidia-smi中的cuda版本必须>=11.3) FROM fuqingxu/11.3.1-runtime-ubuntu20.04-with-texlive:latest +# edge-tts需要的依赖,某些pip包所需的依赖 +RUN apt update && apt install ffmpeg build-essential -y + # use python3 as the system default python WORKDIR /gpt RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.8 @@ -36,8 +39,6 @@ RUN python3 -m pip install -r request_llms/requirements_chatglm.txt RUN python3 -m pip install -r request_llms/requirements_newbing.txt RUN python3 -m pip install nougat-ocr -# edge-tts需要的依赖 -RUN apt update && apt install ffmpeg -y # 预热Tiktoken模块 RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()' diff --git a/docs/GithubAction+ChatGLM+Moss b/docs/GithubAction+ChatGLM+Moss index 7ccdb269..7ebb1685 100644 --- a/docs/GithubAction+ChatGLM+Moss +++ b/docs/GithubAction+ChatGLM+Moss @@ -5,6 +5,8 @@ RUN apt-get update RUN apt-get install -y curl proxychains curl gcc RUN apt-get install -y git python python3 python-dev python3-dev --fix-missing +# edge-tts需要的依赖,某些pip包所需的依赖 +RUN apt update && apt install ffmpeg build-essential -y # use python3 as the system default python RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.8 @@ -21,8 +23,6 @@ RUN python3 -m pip install -r request_llms/requirements_qwen.txt RUN python3 -m pip install -r request_llms/requirements_chatglm.txt RUN python3 -m pip install -r request_llms/requirements_newbing.txt -# edge-tts需要的依赖 -RUN apt update && apt install ffmpeg -y # 预热Tiktoken模块 RUN python3 -c 'from check_proxy import warm_up_modules; warm_up_modules()' From d8b9686eeb653eb7c8ceaa9dbd9db58f7f7e7137 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Thu, 27 Jun 2024 06:49:10 +0000 Subject: [PATCH 2/2] fix latex auto correct --- crazy_functions/latex_fns/latex_pickle_io.py | 8 +++++-- tests/test_latex_auto_correct.py | 22 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/test_latex_auto_correct.py diff --git a/crazy_functions/latex_fns/latex_pickle_io.py b/crazy_functions/latex_fns/latex_pickle_io.py index 451d735b..7b93ea87 100644 --- a/crazy_functions/latex_fns/latex_pickle_io.py +++ b/crazy_functions/latex_fns/latex_pickle_io.py @@ -4,12 +4,14 @@ import pickle class SafeUnpickler(pickle.Unpickler): def get_safe_classes(self): - from .latex_actions import LatexPaperFileGroup, LatexPaperSplit + from crazy_functions.latex_fns.latex_actions import LatexPaperFileGroup, LatexPaperSplit + from crazy_functions.latex_fns.latex_toolbox import LinkedListNode # 定义允许的安全类 safe_classes = { # 在这里添加其他安全的类 'LatexPaperFileGroup': LatexPaperFileGroup, - 'LatexPaperSplit' : LatexPaperSplit, + 'LatexPaperSplit': LatexPaperSplit, + 'LinkedListNode': LinkedListNode, } return safe_classes @@ -20,6 +22,8 @@ class SafeUnpickler(pickle.Unpickler): for class_name in self.safe_classes.keys(): if (class_name in f'{module}.{name}'): match_class_name = class_name + if module == 'numpy' or module.startswith('numpy.'): + return super().find_class(module, name) if match_class_name is not None: return self.safe_classes[match_class_name] # 如果尝试加载未授权的类,则抛出异常 diff --git a/tests/test_latex_auto_correct.py b/tests/test_latex_auto_correct.py new file mode 100644 index 00000000..c51e7414 --- /dev/null +++ b/tests/test_latex_auto_correct.py @@ -0,0 +1,22 @@ +""" +对项目中的各个插件进行测试。运行方法:直接运行 python tests/test_plugins.py +""" + + +import os, sys, importlib + + +def validate_path(): + dir_name = os.path.dirname(__file__) + root_dir_assume = os.path.abspath(dir_name + "/..") + os.chdir(root_dir_assume) + sys.path.append(root_dir_assume) + + +validate_path() # 返回项目根路径 + +if __name__ == "__main__": + plugin_test = importlib.import_module('test_utils').plugin_test + + + plugin_test(plugin='crazy_functions.Latex_Function->Latex翻译中文并重新编译PDF', main_input="2203.01927")