From d56bc280e945b47114d6fcfa955491d57ea30216 Mon Sep 17 00:00:00 2001 From: binary-husky Date: Wed, 20 Sep 2023 22:04:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A6=81=E7=94=A8=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crazy_functions/Latex输出PDF结果.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crazy_functions/Latex输出PDF结果.py b/crazy_functions/Latex输出PDF结果.py index 56ca1c6..7ec5a4b 100644 --- a/crazy_functions/Latex输出PDF结果.py +++ b/crazy_functions/Latex输出PDF结果.py @@ -79,7 +79,7 @@ def move_project(project_folder, arxiv_id=None): shutil.copytree(src=project_folder, dst=new_workfolder) return new_workfolder -def arxiv_download(chatbot, history, txt): +def arxiv_download(chatbot, history, txt, allow_cache=True): def check_cached_translation_pdf(arxiv_id): translation_dir = pj(ARXIV_CACHE_DIR, arxiv_id, 'translation') if not os.path.exists(translation_dir): @@ -116,7 +116,7 @@ def arxiv_download(chatbot, history, txt): arxiv_id = url_.split('/abs/')[-1] if 'v' in arxiv_id: arxiv_id = arxiv_id[:10] cached_translation_pdf = check_cached_translation_pdf(arxiv_id) - if cached_translation_pdf: return cached_translation_pdf, arxiv_id + if cached_translation_pdf and allow_cache: return cached_translation_pdf, arxiv_id url_tar = url_.replace('/abs/', '/e-print/') translation_dir = pj(ARXIV_CACHE_DIR, arxiv_id, 'e-print') @@ -228,6 +228,9 @@ def Latex翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot, # <-------------- more requirements -------------> if ("advanced_arg" in plugin_kwargs) and (plugin_kwargs["advanced_arg"] == ""): plugin_kwargs.pop("advanced_arg") more_req = plugin_kwargs.get("advanced_arg", "") + no_cache = more_req.startswith("--no-cache") + if no_cache: more_req.lstrip("--no-cache") + allow_cache = not no_cache _switch_prompt_ = partial(switch_prompt, more_requirement=more_req) # <-------------- check deps -------------> @@ -244,7 +247,7 @@ def Latex翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot, # <-------------- clear history and read input -------------> history = [] - txt, arxiv_id = yield from arxiv_download(chatbot, history, txt) + txt, arxiv_id = yield from arxiv_download(chatbot, history, txt, allow_cache) if txt.endswith('.pdf'): report_execption(chatbot, history, a = f"解析项目: {txt}", b = f"发现已经存在翻译好的PDF文档") yield from update_ui(chatbot=chatbot, history=history) # 刷新界面