优化提示词

This commit is contained in:
xunbu
2025-11-10 14:53:02 +08:00
parent 38b8135204
commit 59d1edc258
2 changed files with 23 additions and 7 deletions

View File

@@ -429,7 +429,7 @@ class Agent:
)
total = len(prompts)
self.logger.info(
f"base-url:{self.baseurl},model-id:{self.model_id},concurrent:{max_concurrent},temperature:{self.temperature},system_proxy:{self.system_proxy_enable}"
f"base-url:{self.baseurl},model-id:{self.model_id},concurrent:{max_concurrent},temperature:{self.temperature},system_proxy:{self.system_proxy_enable},json_output:{json_format}"
)
self.logger.info(f"预计发送{total}个请求,并发请求数:{max_concurrent}")
self.total_error_counter.max_errors_count = (
@@ -676,7 +676,7 @@ class Agent:
error_result_handler: ErrorResultHandlerType = None,
) -> list[Any]:
self.logger.info(
f"base-url:{self.baseurl},model-id:{self.model_id},concurrent:{self.max_concurrent},temperature:{self.temperature},system_proxy:{self.system_proxy_enable}"
f"base-url:{self.baseurl},model-id:{self.model_id},concurrent:{self.max_concurrent},temperature:{self.temperature},system_proxy:{self.system_proxy_enable},json_output:{json_format}"
)
self.logger.info(
f"预计发送{len(prompts)}个请求,并发请求数:{self.max_concurrent}"

View File

@@ -39,8 +39,8 @@ Input:
```json
{{
3:source,
4:source,
"3":source,
"4":source,
}}
```
@@ -48,11 +48,27 @@ Output(target language: {to_lang}):
```json
{{
3:translation,
4:translation,
"3":translation,
"4":translation,
}}
```
For statements that must be combined during translation, employ merging at the minimal structural level. The total number of keys must remain unchanged after merging, and any empty values should be retained.
Below is an example of how merging should be done when necessary:
input:
```json
{{
"3":"汤姆说:“杰克你",
"4":"好”。"
}}
```
output:
```json
{{
"3":"Tom says:\"Hello Jack.\"",
"4":""
}}
```
</example>
Please return the translated JSON directly without including any additional information and preserve special tags or untranslatable elements (such as code, brand names, technical terms) as they are.
"""
@@ -149,7 +165,7 @@ class SegmentsTranslateAgent(Agent):
# 抛出自定义异常,将部分结果和错误信息一起传递出去
raise PartialAgentResultError("键不匹配,触发重试", partial_result=final_chunk,append_prompt=f"\nThe following keys must be included:{','.join(sorted(list(missing_keys)))}")
raise PartialAgentResultError("键不匹配,触发重试", partial_result=final_chunk,append_prompt=f"\nBe careful not to omit any keys from the input; do not combine sentences when translating.\n")
# 如果键完全匹配(理想情况),正常返回
for key, value in repaired_result.items():