样式修改,修改提示词

This commit is contained in:
xunbu
2025-05-21 22:55:14 +08:00
parent d03bef6d96
commit 68c6d545de
6 changed files with 78 additions and 64 deletions

119
.idea/workspace.xml generated
View File

@@ -6,7 +6,11 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="6b18b44a-df57-4212-a857-9e291ebe5dd2" name="更改" comment=""> <list default="true" id="6b18b44a-df57-4212-a857-9e291ebe5dd2" name="更改" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lite.spec" beforeDir="false" afterPath="$PROJECT_DIR$/lite.spec" afterDir="false" /> <change beforePath="$PROJECT_DIR$/docutranslate/agents/agent.py" beforeDir="false" afterPath="$PROJECT_DIR$/docutranslate/agents/agent.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/docutranslate/agents/markdown_agent.py" beforeDir="false" afterPath="$PROJECT_DIR$/docutranslate/agents/markdown_agent.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/docutranslate/static/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/docutranslate/static/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/docutranslate/translater.py" beforeDir="false" afterPath="$PROJECT_DIR$/docutranslate/translater.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pyproject.toml" beforeDir="false" afterPath="$PROJECT_DIR$/pyproject.toml" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -36,62 +40,62 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"DefaultHtmlFileTemplate": "HTML File", &quot;DefaultHtmlFileTemplate&quot;: &quot;HTML File&quot;,
"JavaScript 调试.output.html (1).executor": "Run", &quot;JavaScript 调试.output.html (1).executor&quot;: &quot;Run&quot;,
"JavaScript 调试.output.html.executor": "Run", &quot;JavaScript 调试.output.html.executor&quot;: &quot;Run&quot;,
"JavaScript 调试.regex.md_中文.html.executor": "Run", &quot;JavaScript 调试.regex.md_中文.html.executor&quot;: &quot;Run&quot;,
"JavaScript 调试.regex_中文.html.executor": "Run", &quot;JavaScript 调试.regex_中文.html.executor&quot;: &quot;Run&quot;,
"JavaScript 调试.test.html.executor": "Run", &quot;JavaScript 调试.test.html.executor&quot;: &quot;Run&quot;,
"JavaScript 调试.test2.html.executor": "Run", &quot;JavaScript 调试.test2.html.executor&quot;: &quot;Run&quot;,
"JavaScript 调试.test2_英文.html.executor": "Run", &quot;JavaScript 调试.test2_英文.html.executor&quot;: &quot;Run&quot;,
"JavaScript 调试.test4-1_中文.html.executor": "Run", &quot;JavaScript 调试.test4-1_中文.html.executor&quot;: &quot;Run&quot;,
"JavaScript 调试.互联网认证授权机制.html.executor": "Run", &quot;JavaScript 调试.互联网认证授权机制.html.executor&quot;: &quot;Run&quot;,
"JavaScript 调试.互联网认证授权机制_英文.html.executor": "Run", &quot;JavaScript 调试.互联网认证授权机制_英文.html.executor&quot;: &quot;Run&quot;,
"JavaScript 调试.毕业论文_英文.html.executor": "Run", &quot;JavaScript 调试.毕业论文_英文.html.executor&quot;: &quot;Run&quot;,
"ModuleVcsDetector.initialDetectionPerformed": "true", &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
"Python 测试.Python 测试 (markdown_mask.py 内).executor": "Run", &quot;Python 测试.Python 测试 (markdown_mask.py 内).executor&quot;: &quot;Run&quot;,
"Python 测试.markdown_mask.Test.test_basic_link_masking 的 Python 测试.executor": "Run", &quot;Python 测试.markdown_mask.Test.test_basic_link_masking 的 Python 测试.executor&quot;: &quot;Run&quot;,
"Python 测试.pytest (test_html.py 内).executor": "Run", &quot;Python 测试.pytest (test_html.py 内).executor&quot;: &quot;Run&quot;,
"Python.1test.executor": "Run", &quot;Python.1test.executor&quot;: &quot;Run&quot;,
"Python.2test2 (1).executor": "Run", &quot;Python.2test2 (1).executor&quot;: &quot;Run&quot;,
"Python.PDFtranslater (1).executor": "Run", &quot;Python.PDFtranslater (1).executor&quot;: &quot;Run&quot;,
"Python.PDFtranslater (2).executor": "Run", &quot;Python.PDFtranslater (2).executor&quot;: &quot;Run&quot;,
"Python.agent.executor": "Debug", &quot;Python.agent.executor&quot;: &quot;Debug&quot;,
"Python.agent_utils.executor": "Run", &quot;Python.agent_utils.executor&quot;: &quot;Run&quot;,
"Python.app (1).executor": "Run", &quot;Python.app (1).executor&quot;: &quot;Run&quot;,
"Python.app.executor": "Run", &quot;Python.app.executor&quot;: &quot;Run&quot;,
"Python.app2.executor": "Run", &quot;Python.app2.executor&quot;: &quot;Run&quot;,
"Python.app_test (1).executor": "Run", &quot;Python.app_test (1).executor&quot;: &quot;Run&quot;,
"Python.convert.executor": "Run", &quot;Python.convert.executor&quot;: &quot;Run&quot;,
"Python.converter_docling.executor": "Run", &quot;Python.converter_docling.executor&quot;: &quot;Run&quot;,
"Python.converter_mineru.executor": "Run", &quot;Python.converter_mineru.executor&quot;: &quot;Run&quot;,
"Python.markdown_splitter.executor": "Debug", &quot;Python.markdown_splitter.executor&quot;: &quot;Debug&quot;,
"Python.markdown_utils.executor": "Run", &quot;Python.markdown_utils.executor&quot;: &quot;Run&quot;,
"Python.test.executor": "Run", &quot;Python.test.executor&quot;: &quot;Run&quot;,
"Python.test1.executor": "Run", &quot;Python.test1.executor&quot;: &quot;Run&quot;,
"Python.test2.executor": "Run", &quot;Python.test2.executor&quot;: &quot;Run&quot;,
"Python.test3.executor": "Run", &quot;Python.test3.executor&quot;: &quot;Run&quot;,
"Python.test4.executor": "Run", &quot;Python.test4.executor&quot;: &quot;Run&quot;,
"Python.testhtml.executor": "Run", &quot;Python.testhtml.executor&quot;: &quot;Run&quot;,
"Python.translater.executor": "Run", &quot;Python.translater.executor&quot;: &quot;Run&quot;,
"Python.切分测试.executor": "Run", &quot;Python.切分测试.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true", &quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager&quot;: &quot;true&quot;,
"RunOnceActivity.git.unshallow": "true", &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
"git-widget-placeholder": "main", &quot;git-widget-placeholder&quot;: &quot;main&quot;,
"last_opened_file_path": "C:/Users/jxgm/Desktop/translate/docutranslate", &quot;last_opened_file_path&quot;: &quot;C:/Users/jxgm/Desktop/translate/docutranslate&quot;,
"list.type.of.created.stylesheet": "CSS", &quot;list.type.of.created.stylesheet&quot;: &quot;CSS&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"settings.editor.selected.configurable": "preferences.pluginManager", &quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}]]></component> }</component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\jxgm\Desktop\translate\docutranslate" /> <recent name="C:\Users\jxgm\Desktop\translate\docutranslate" />
@@ -603,6 +607,7 @@
<workItem from="1747752718385" duration="81000" /> <workItem from="1747752718385" duration="81000" />
<workItem from="1747754618316" duration="16566000" /> <workItem from="1747754618316" duration="16566000" />
<workItem from="1747828300140" duration="4611000" /> <workItem from="1747828300140" duration="4611000" />
<workItem from="1747836914405" duration="2380000" />
</task> </task>
<servers /> <servers />
</component> </component>
@@ -621,7 +626,7 @@
</option> </option>
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/filetranslate$app_test__1_.coverage" NAME="app_test (1) 覆盖结果" MODIFIED="1747831001962" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/tests" /> <SUITE FILE_PATH="coverage/filetranslate$app_test__1_.coverage" NAME="app_test (1) 覆盖结果" MODIFIED="1747839177989" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/tests" />
<SUITE FILE_PATH="coverage/filetranslate$test.coverage" NAME="test 覆盖结果" MODIFIED="1747472297913" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/tests" /> <SUITE FILE_PATH="coverage/filetranslate$test.coverage" NAME="test 覆盖结果" MODIFIED="1747472297913" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/tests" />
<SUITE FILE_PATH="coverage/filetranslate$convert.coverage" NAME="convert 覆盖结果" MODIFIED="1746963490689" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/docutranslate/utils" /> <SUITE FILE_PATH="coverage/filetranslate$convert.coverage" NAME="convert 覆盖结果" MODIFIED="1746963490689" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/docutranslate/utils" />
<SUITE FILE_PATH="coverage/PDFtranslate$PDFtranslater__1_.coverage" NAME="PDFtranslater (1) 覆盖结果" MODIFIED="1746633258205" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/pdftranslate_packages" /> <SUITE FILE_PATH="coverage/PDFtranslate$PDFtranslater__1_.coverage" NAME="PDFtranslater (1) 覆盖结果" MODIFIED="1746633258205" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/pdftranslate_packages" />

View File

@@ -84,7 +84,7 @@ class Agent:
result = response.json()["choices"][0]["message"]["content"] result = response.json()["choices"][0]["message"]["content"]
return result return result
except httpx.HTTPStatusError as e: 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 raise Exception(f"AI请求错误 (async): {e.response.status_code} - {e.response.text}") from e
except httpx.RequestError as e: except httpx.RequestError as e:
raise Exception(f"AI请求连接错误 (async): {e}") from e raise Exception(f"AI请求连接错误 (async): {e}") from e

View File

@@ -51,7 +51,7 @@ class MDTranslateAgent(Agent):
# 要求 # 要求
翻译要有专业性和高质量 翻译要有专业性和高质量
没有任何解释和注释。 没有任何解释和注释。
引用的参考文献和其作者不翻译 引用的参考文献和其作者名保持原文不翻译
形如<ph-abc123>的占位符不要改变 形如<ph-abc123>的占位符不要改变
code、latex和HTML只翻译说明文字其余保持原文 code、latex和HTML只翻译说明文字其余保持原文
公式必须表示为合法的latex公式,行内公式需被$正确包裹 公式必须表示为合法的latex公式,行内公式需被$正确包裹

View File

@@ -17,6 +17,12 @@
padding: 1rem; padding: 1rem;
} }
summary {
border-bottom: 1px dashed #ccc;
padding-bottom: 0.5rem;
}
.log-area { .log-area {
background-color: #f5f5f5; background-color: #f5f5f5;
border: 1px solid #e0e0e0; border: 1px solid #e0e0e0;
@@ -42,7 +48,9 @@
} }
.form-group { .form-group {
margin-bottom: 1rem; margin-bottom: 0.5rem;
margin-left: 1rem;
margin-right: 2rem;
} }
.form-grid { .form-grid {
@@ -65,7 +73,7 @@
} }
details { details {
margin-bottom: 1rem; margin-bottom: 2rem;
} }
.checkbox-group { .checkbox-group {
@@ -372,8 +380,8 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="apikey">API 密钥<a id="api_href" class="no-style" href="/" <label for="apikey">API 密钥<a id="api_href" class="no-style" href="/"
target="_blank" target="_blank"
title="获取API-KEY">🔗</a></label> title="获取API-KEY">🔗</a></label>
<input type="password" id="apikey" name="apikey" placeholder="平台对应的API Key" required> <input type="password" id="apikey" name="apikey" placeholder="平台对应的API Key" required>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@@ -38,6 +38,7 @@ class FileTranslater:
self.docling_artifact = docling_artifact self.docling_artifact = docling_artifact
if docling_artifact is None: if docling_artifact is None:
artifact_path = Path("./docling_artifact") artifact_path = Path("./docling_artifact")
print(f"artifact_path:{artifact_path.resolve()}existed{artifact_path.is_dir()}")
if artifact_path.is_dir(): if artifact_path.is_dir():
translater_logger.info("检测到docling_artifact文件夹") translater_logger.info("检测到docling_artifact文件夹")
self.docling_artifact = artifact_path self.docling_artifact = artifact_path

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "docutranslate" name = "docutranslate"
version = "0.2.22" version = "0.2.23"
description = "文件翻译工具" description = "文件翻译工具"
readme = "README.md" readme = "README.md"
requires-python = ">=3.10" requires-python = ">=3.10"