From 68c6d545de3963e1f21de28b30fc2f8249ee05e1 Mon Sep 17 00:00:00 2001 From: xunbu Date: Wed, 21 May 2025 22:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E7=A4=BA=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 119 +++++++++++++------------ docutranslate/agents/agent.py | 2 +- docutranslate/agents/markdown_agent.py | 2 +- docutranslate/static/index.html | 16 +++- docutranslate/translater.py | 1 + pyproject.toml | 2 +- 6 files changed, 78 insertions(+), 64 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c1c32a1..f2317e0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,7 +6,11 @@ - + + + + + - { + "keyToString": { + "DefaultHtmlFileTemplate": "HTML File", + "JavaScript 调试.output.html (1).executor": "Run", + "JavaScript 调试.output.html.executor": "Run", + "JavaScript 调试.regex.md_中文.html.executor": "Run", + "JavaScript 调试.regex_中文.html.executor": "Run", + "JavaScript 调试.test.html.executor": "Run", + "JavaScript 调试.test2.html.executor": "Run", + "JavaScript 调试.test2_英文.html.executor": "Run", + "JavaScript 调试.test4-1_中文.html.executor": "Run", + "JavaScript 调试.互联网认证授权机制.html.executor": "Run", + "JavaScript 调试.互联网认证授权机制_英文.html.executor": "Run", + "JavaScript 调试.毕业论文_英文.html.executor": "Run", + "ModuleVcsDetector.initialDetectionPerformed": "true", + "Python 测试.Python 测试 (markdown_mask.py 内).executor": "Run", + "Python 测试.markdown_mask.Test.test_basic_link_masking 的 Python 测试.executor": "Run", + "Python 测试.pytest (test_html.py 内).executor": "Run", + "Python.1test.executor": "Run", + "Python.2test2 (1).executor": "Run", + "Python.PDFtranslater (1).executor": "Run", + "Python.PDFtranslater (2).executor": "Run", + "Python.agent.executor": "Debug", + "Python.agent_utils.executor": "Run", + "Python.app (1).executor": "Run", + "Python.app.executor": "Run", + "Python.app2.executor": "Run", + "Python.app_test (1).executor": "Run", + "Python.convert.executor": "Run", + "Python.converter_docling.executor": "Run", + "Python.converter_mineru.executor": "Run", + "Python.markdown_splitter.executor": "Debug", + "Python.markdown_utils.executor": "Run", + "Python.test.executor": "Run", + "Python.test1.executor": "Run", + "Python.test2.executor": "Run", + "Python.test3.executor": "Run", + "Python.test4.executor": "Run", + "Python.testhtml.executor": "Run", + "Python.translater.executor": "Run", + "Python.切分测试.executor": "Run", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true", + "RunOnceActivity.git.unshallow": "true", + "git-widget-placeholder": "main", + "last_opened_file_path": "C:/Users/jxgm/Desktop/translate/docutranslate", + "list.type.of.created.stylesheet": "CSS", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.tslint": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_package_manager_path": "npm", + "settings.editor.selected.configurable": "preferences.pluginManager", + "vue.rearranger.settings.migration": "true" } -}]]> +} @@ -603,6 +607,7 @@ + @@ -621,7 +626,7 @@ - + diff --git a/docutranslate/agents/agent.py b/docutranslate/agents/agent.py index b4f8d48..8a7da42 100644 --- a/docutranslate/agents/agent.py +++ b/docutranslate/agents/agent.py @@ -84,7 +84,7 @@ class Agent: result = response.json()["choices"][0]["message"]["content"] return result except httpx.HTTPStatusError as e: - print(f"prompt:{prompt}\nsystem_prompt:{system_prompt}") + print(f"AI请求错误,prompt:{prompt}\n") raise Exception(f"AI请求错误 (async): {e.response.status_code} - {e.response.text}") from e except httpx.RequestError as e: raise Exception(f"AI请求连接错误 (async): {e}") from e diff --git a/docutranslate/agents/markdown_agent.py b/docutranslate/agents/markdown_agent.py index 398101d..3898b9e 100644 --- a/docutranslate/agents/markdown_agent.py +++ b/docutranslate/agents/markdown_agent.py @@ -51,7 +51,7 @@ class MDTranslateAgent(Agent): # 要求 翻译要有专业性和高质量 没有任何解释和注释。 -引用的参考文献和其作者不要翻译 +引用的参考文献名和其作者名保持原文不翻译 形如的占位符不要改变 code、latex和HTML只翻译说明文字,其余保持原文 公式必须表示为合法的latex公式,行内公式需被$正确包裹 diff --git a/docutranslate/static/index.html b/docutranslate/static/index.html index 1fb9ed9..665d64f 100644 --- a/docutranslate/static/index.html +++ b/docutranslate/static/index.html @@ -17,6 +17,12 @@ padding: 1rem; } + summary { + border-bottom: 1px dashed #ccc; + padding-bottom: 0.5rem; + } + + .log-area { background-color: #f5f5f5; border: 1px solid #e0e0e0; @@ -42,7 +48,9 @@ } .form-group { - margin-bottom: 1rem; + margin-bottom: 0.5rem; + margin-left: 1rem; + margin-right: 2rem; } .form-grid { @@ -65,7 +73,7 @@ } details { - margin-bottom: 1rem; + margin-bottom: 2rem; } .checkbox-group { @@ -372,8 +380,8 @@
+ target="_blank" + title="获取API-KEY">🔗
diff --git a/docutranslate/translater.py b/docutranslate/translater.py index 6d24e93..2614290 100644 --- a/docutranslate/translater.py +++ b/docutranslate/translater.py @@ -38,6 +38,7 @@ class FileTranslater: self.docling_artifact = docling_artifact if docling_artifact is None: artifact_path = Path("./docling_artifact") + print(f"artifact_path:{artifact_path.resolve()},existed:{artifact_path.is_dir()}") if artifact_path.is_dir(): translater_logger.info("检测到docling_artifact文件夹") self.docling_artifact = artifact_path diff --git a/pyproject.toml b/pyproject.toml index a37a0e3..d0740e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "docutranslate" -version = "0.2.22" +version = "0.2.23" description = "文件翻译工具" readme = "README.md" requires-python = ">=3.10"