From fba57fd9b5232cb83790c1f47c4f7edb8b63ea91 Mon Sep 17 00:00:00 2001 From: xunbu Date: Thu, 8 May 2025 20:33:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=A8=A1=E5=9E=8B=E5=9B=9E?= =?UTF-8?q?=E7=AD=94=E5=BC=80=E5=A4=B4=E5=88=86=E9=9A=94=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 60 +++++++++++++++--------------- docutranslate/utils/agent_utils.py | 6 +-- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 43bf8dc..3dc4da5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,9 +6,7 @@ - - @@ -309,7 +307,8 @@ - + + @@ -318,15 +317,16 @@ - - + + + + - \ No newline at end of file diff --git a/docutranslate/utils/agent_utils.py b/docutranslate/utils/agent_utils.py index d86d19d..8edeed0 100644 --- a/docutranslate/utils/agent_utils.py +++ b/docutranslate/utils/agent_utils.py @@ -24,7 +24,7 @@ class Agent: data = { "model": self.model_id, "messages": [ - {"role": "system", "content": "所有回复必须严格以<>开头,包括简短回答。示例:\n<>这是示例回答\n"+system_prompt}, + {"role": "system", "content": "回复必须严格以BEGIN>>开头,包括简短回答。\n示例:BEGIN>>这是示例回答\n"+system_prompt}, {"role": "user", "content": prompt} ], "temperature": temperature, @@ -54,10 +54,10 @@ class Agent: ) response.raise_for_status() result=response.json()["choices"][0]["message"]["content"] - pattern=r"<>(.*)" + pattern=r"BEGIN>>(.*)" match= re.search(pattern,result, re.DOTALL) if match is None: - print("检测开头<失败") + print("检测开头`BEGIN>>`失败") else: result=match.group(1) return result