diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9857ef7..49bbe05 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,7 +5,10 @@ + + + - { - "keyToString": { - "DefaultHtmlFileTemplate": "HTML File", - "JavaScript 调试.output.html (1).executor": "Run", - "JavaScript 调试.output.html.executor": "Run", - "JavaScript 调试.regex_中文.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.PDFtranslater (1).executor": "Run", - "Python.PDFtranslater (2).executor": "Run", - "Python.agent.executor": "Debug", - "Python.agent_utils.executor": "Run", - "Python.convert.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.translater.executor": "Run", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.git.unshallow": "true", - "git-widget-placeholder": "main", - "last_opened_file_path": "C:/Users/jxgm/Desktop/FileTranslate/tests/resource", - "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.general", - "vue.rearranger.settings.migration": "true" + +}]]> + @@ -85,7 +90,7 @@ - + @@ -359,7 +384,8 @@ - + + @@ -370,12 +396,13 @@ - + - + + diff --git a/docutranslate/Agents/markdown_agent.py b/docutranslate/Agents/markdown_agent.py index 8983451..3babe24 100644 --- a/docutranslate/Agents/markdown_agent.py +++ b/docutranslate/Agents/markdown_agent.py @@ -14,20 +14,19 @@ class MDRefineAgent(Agent): 对于缺失、中断的句子,应该查看缺失的语句是否可能被错误的放在了其他位置,并通过句子拼接修复不合理之处。 去掉异常字词,修复错误格式。 # 要求 -尽量忠实于原文。 +If refine is unnecessary, return the original text. +NO explanations. NO notes. 不要修改标题的级别(如一级标题不要修改为二级标题) 形如的占位符不要改变。 code、latex和HTML保持结构。 # 输出 修正后的markdown纯文本(不是markdown代码块) # 示例 -## 调整顺序 +## 修正文本流 输入: 什么名字 -# 示例标题 你叫 输出: -# 示例标题 你叫什么名字 ## 去掉异常字词(保持占位符和latex符号) 输入: @@ -42,13 +41,13 @@ class MDTranslateAgent(Agent): super().__init__(**kwargs) self.system_prompt=f""" # 角色 -你是一个翻译markdown文本的专家。 +You are a professional, authentic machine translation engine. # 工作 翻译输入的markdown文本 目标语言{to_lang} # 要求 -尽量忠实于原文。 -必要的专有名词不要翻译。 +If translation is unnecessary (e.g. proper nouns, codes, etc.), return the original text. +NO explanations. NO notes. 不要修改标题的级别(如一级标题不要修改为二级标题) 形如的占位符不要改变。 code、latex和HTML只翻译说明文字,其余保持原文 diff --git a/pyproject.toml b/pyproject.toml index 63f11b7..8a6ab68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "docutranslate" -version = "0.1.5" +version = "0.1.6" description = "文件翻译工具" readme = "README.md" requires-python = ">=3.10" @@ -9,5 +9,5 @@ dependencies = [ "httpx", "markdown2", "mdformat>=0.7.22", - "transformers>=4.50.1" + "transformers>=4.50.1", ] diff --git a/uv.lock b/uv.lock index 76d9e72..1ef5f62 100644 --- a/uv.lock +++ b/uv.lock @@ -420,7 +420,7 @@ wheels = [ [[package]] name = "docutranslate" -version = "0.1.2" +version = "0.1.5" source = { virtual = "." } dependencies = [ { name = "docling", version = "2.15.1", source = { registry = "https://pypi.org/simple" }, marker = "platform_machine == 'x86_64' and sys_platform == 'darwin'" },