From a9df39eb0878f424d34e3a337ff599cc2b89d540 Mon Sep 17 00:00:00 2001 From: xunbu Date: Mon, 12 May 2025 20:20:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=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 | 12 ++++++------ docutranslate/agents/agent.py | 8 ++++---- docutranslate/agents/markdown_agent.py | 27 +++++++++++++++++--------- pyproject.toml | 2 +- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8dc477a..1765c84 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,11 +5,10 @@ - - + + - - + diff --git a/docutranslate/agents/agent.py b/docutranslate/agents/agent.py index 46dbeba..31f4b6d 100644 --- a/docutranslate/agents/agent.py +++ b/docutranslate/agents/agent.py @@ -22,10 +22,10 @@ TIMEOUT = 500 class Agent: - def __init__(self, baseurl="", key="", model_id="", system_prompt="", temperature=0.7, max_concurrent=6,timeout:int=TIMEOUT): - self.baseurl = baseurl - self.key = key - self.model_id = model_id + def __init__(self, baseurl:str="", key:str="xx", model_id:str="", system_prompt:str="", temperature=0.7, max_concurrent=6,timeout:int=TIMEOUT): + self.baseurl = baseurl.strip() + self.key = key.strip() + self.model_id = model_id.strip() self.system_prompt = system_prompt self.temperature = temperature self.client_async = httpx.AsyncClient() diff --git a/docutranslate/agents/markdown_agent.py b/docutranslate/agents/markdown_agent.py index 3babe24..97c0dce 100644 --- a/docutranslate/agents/markdown_agent.py +++ b/docutranslate/agents/markdown_agent.py @@ -8,17 +8,18 @@ class MDRefineAgent(Agent): super().__init__(**kwargs) self.system_prompt=r""" # 角色 -你是一个修正markdown文本的专家。 +你是一个修正markdown文本的专家 # 工作 -找到markdown片段的不合理之处。 -对于缺失、中断的句子,应该查看缺失的语句是否可能被错误的放在了其他位置,并通过句子拼接修复不合理之处。 -去掉异常字词,修复错误格式。 +找到markdown片段的不合理之处 +对于缺失、中断的句子,应该查看缺失的语句是否可能被错误的放在了其他位置,并通过句子拼接修复不合理之处 +去掉异常字词,修复错误格式 # 要求 If refine is unnecessary, return the original text. NO explanations. NO notes. 不要修改标题的级别(如一级标题不要修改为二级标题) -形如的占位符不要改变。 -code、latex和HTML保持结构。 +形如的占位符不要改变 +code、latex和HTML保持结构 +对于修复后的latex文本,用$包裹以构建合法表达式 # 输出 修正后的markdown纯文本(不是markdown代码块) # 示例 @@ -30,9 +31,9 @@ code、latex和HTML保持结构。 你叫什么名字 ## 去掉异常字词(保持占位符和latex符号) 输入: -一道\题@#目:\(x_1+1=2\) +一道\题@#目:c_0+1=2,\(c 0\)等于几 输出: -一道题目::\(x_1+1=2\) +一道题目::$c_0+1=2$,\(c_0\)等于几 \no_think""" @@ -49,7 +50,8 @@ You are a professional, authentic machine translation engine. If translation is unnecessary (e.g. proper nouns, codes, etc.), return the original text. NO explanations. NO notes. 不要修改标题的级别(如一级标题不要修改为二级标题) -形如的占位符不要改变。 +文献名保持原文 +形如的占位符不要改变 code、latex和HTML只翻译说明文字,其余保持原文 # 输出 翻译后的markdown纯文本(不是markdown代码块) @@ -59,4 +61,11 @@ code、latex和HTML只翻译说明文字,其余保持原文 hello, what's your name? 输出: 你好,你叫什么名字? +## 文献名不翻译 +输入: +[2] M. Castro, B. Liskov, et al. Practical byzantine fault tolerance. In OSDI, +volume 99, pages 173–186, 1999. +输出: +[2] M. Castro, B. Liskov, et al. Practical byzantine fault tolerance. In OSDI, +volume 99, pages 173–186, 1999. \\no_think""" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 22f403d..89d3124 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "docutranslate" -version = "0.2.0" +version = "0.2.2" description = "文件翻译工具" readme = "README.md" requires-python = ">=3.10"