修复文档错误示例

This commit is contained in:
xunbu
2025-09-04 16:31:03 +08:00
parent 571727000a
commit ad26a4a372

View File

@@ -228,8 +228,8 @@ app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
# =================================================================== # ===================================================================
class GlossaryAgentConfigPayload(BaseModel): class GlossaryAgentConfigPayload(BaseModel):
baseurl: str = Field(..., description="用于术语表生成的Agent的LLM API基础URL。", examples=["https://api.openai.com/v1"]) base_url: str = Field(..., description="用于术语表生成的Agent的LLM API基础URL。", examples=["https://api.openai.com/v1"])
key: str = Field(..., description="用于术语表生成的Agent的LLM API密钥。", examples=["sk-agent-api-key"]) api_key: str = Field(..., description="用于术语表生成的Agent的LLM API密钥。", examples=["sk-agent-api-key"])
model_id: str = Field(..., description="用于术语表生成的Agent的模型ID。", examples=["gpt-4-turbo"]) model_id: str = Field(..., description="用于术语表生成的Agent的模型ID。", examples=["gpt-4-turbo"])
to_lang: str = Field(..., description="术语表生成的目标语言。", examples=["简体中文", "English"]) to_lang: str = Field(..., description="术语表生成的目标语言。", examples=["简体中文", "English"])
temperature: float = Field(default=0.7, description="用于术语表生成的Agent的温度参数。") temperature: float = Field(default=0.7, description="用于术语表生成的Agent的温度参数。")
@@ -251,7 +251,7 @@ class BaseWorkflowParams(BaseModel):
chunk_size: int = Field(default=default_params["chunk_size"], description="文本分割的块大小(字符)。") chunk_size: int = Field(default=default_params["chunk_size"], description="文本分割的块大小(字符)。")
concurrent: int = Field(default=default_params["concurrent"], description="并发请求数。") concurrent: int = Field(default=default_params["concurrent"], description="并发请求数。")
temperature: float = Field(default=default_params["temperature"], description="LLM温度参数。") temperature: float = Field(default=default_params["temperature"], description="LLM温度参数。")
thinking: ThinkingMode = Field(default=default_params["thinking"], description="是否启用深度思考", thinking: ThinkingMode = Field(default=default_params["thinking"], description="Agent的思考模式。",
examples=["default", "enable", "disable"]) examples=["default", "enable", "disable"])
custom_prompt: Optional[str] = Field(None, description="用户自定义的翻译Prompt。", alias="custom_prompt") custom_prompt: Optional[str] = Field(None, description="用户自定义的翻译Prompt。", alias="custom_prompt")
glossary_dict: Optional[Dict[str, str]] = Field(None, description="术语表字典key为原文value为译文。") glossary_dict: Optional[Dict[str, str]] = Field(None, description="术语表字典key为原文value为译文。")
@@ -321,7 +321,7 @@ class JsonWorkflowParams(BaseWorkflowParams):
json_paths: List[str] = Field( json_paths: List[str] = Field(
..., ...,
description="一个jsonpath-ng表达式列表用于指定需要翻译的JSON字段。", description="一个jsonpath-ng表达式列表用于指定需要翻译的JSON字段。",
examples=[["$..description", "$.items[0].name", "$.*"]] examples=[["$.product.name", "$.product.description", "$.features[*]"]]
) )
@@ -413,143 +413,162 @@ class TranslateServiceRequest(BaseModel):
json_schema_extra = { json_schema_extra = {
"examples": [ "examples": [
{ {
"summary": "Markdown 工作流示例", "file_name": "annual_report_203.pdf",
"value": { "file_content": "JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9...",
"file_name": "annual_report_203.pdf", "payload": {
"file_content": "JVBERi0xLjcKJeLjz9MKMSAwIG9iago8PC9...", "workflow_type": "markdown_based",
"payload": { "skip_translate": False,
"workflow_type": "markdown_based", "base_url": "https://api.openai.com/v1",
"base_url": "https://api.openai.com/v1", "api_key": "sk-your-api-key-here",
"api_key": "sk-your-api-key-here", "model_id": "gpt-4o",
"model_id": "gpt-4o", "to_lang": "中文",
"to_lang": "简体中文", "chunk_size": default_params["chunk_size"],
"convert_engine": "mineru", "concurrent": default_params["concurrent"],
"mineru_token": "your-mineru-token-if-any", "temperature": default_params["temperature"],
"thinking": "default",
"glossary_generate_enable": False,
"convert_engine": "mineru",
"mineru_token": "your-mineru-token-if-any",
"formula_ocr": True,
"model_version": "vlm"
}
},
{
"file_name": "product_info.json",
"file_content": "ewogICAgImlkIjogIjEyMzQ1IiwK...",
"payload": {
"workflow_type": "json",
"skip_translate": False,
"base_url": "https://api.openai.com/v1",
"api_key": "sk-your-api-key-here",
"model_id": "gpt-4o",
"to_lang": "中文",
"chunk_size": default_params["chunk_size"],
"concurrent": default_params["concurrent"],
"temperature": default_params["temperature"],
"thinking": "default",
"glossary_generate_enable": False,
"json_paths": ["$.product.name", "$.product.description", "$.features[*]"],
}
},
{
"file_name": "product_list.xlsx",
"file_content": "UEsDBBQAAAAIA... (base64-encoded xlsx)",
"payload": {
"workflow_type": "xlsx",
"skip_translate": False,
"base_url": "https://api.openai.com/v1",
"api_key": "sk-your-api-key-here",
"model_id": "gpt-4o",
"to_lang": "中文",
"chunk_size": default_params["chunk_size"],
"concurrent": default_params["concurrent"],
"temperature": default_params["temperature"],
"thinking": "default",
"glossary_generate_enable": False,
"insert_mode": "replace",
"separator": "\n",
"translate_regions": ["Sheet1!A1:B10", "C:D"],
"glossary_dict": {
"OpenAI": "开放人工智能",
"LLM": "大语言模型"
} }
} }
}, },
{ {
"summary": "JSON 工作流示例", "file_name": "complex_terms.xlsx",
"value": { "file_content": "UEsDBBQAAAAIA... (base64-encoded xlsx)",
"file_name": "product_info.json", "payload": {
"file_content": "ewogICAgImlkIjogIjEyMzQ1IiwK...", "workflow_type": "xlsx",
"payload": { "base_url": "https://api.openai.com/v1",
"workflow_type": "json", "api_key": "sk-your-main-translator-key",
"model_id": "gpt-4o",
"to_lang": "中文",
"glossary_generate_enable": True,
"glossary_agent_config": {
"base_url": "https://api.openai.com/v1", "base_url": "https://api.openai.com/v1",
"api_key": "sk-your-api-key-here", "api_key": "sk-your-agent-key-for-glossary",
"model_id": "gpt-4o", "model_id": "gpt-4-turbo",
"to_lang": "日本語", "to_lang": "中文",
"json_paths": ["productName", "description.long", "features[*]"], "temperature": 0.7,
"max_concurrent": 30,
"timeout": 2000,
"thinking": "default"
} }
} }
}, },
{ {
"summary": "XLSX 工作流示例", "file_name": "contract.docx",
"value": { "file_content": "UEsDBBQAAAAIA... (base64-encoded docx)",
"file_name": "product_list.xlsx", "payload": {
"file_content": "UEsDBBQAAAAIA... (base64-encoded xlsx)", "workflow_type": "docx",
"payload": { "skip_translate": False,
"workflow_type": "xlsx", "base_url": "https://api.openai.com/v1",
"base_url": "https://api.openai.com/v1", "api_key": "sk-your-api-key-here",
"api_key": "sk-your-api-key-here", "model_id": "gpt-4o",
"model_id": "gpt-4o", "to_lang": "中文",
"to_lang": "简体中文", "insert_mode": "replace",
"insert_mode": "append", "separator": "\n",
"separator": " \n---翻译---\n ", "chunk_size": default_params["chunk_size"],
"chunk_size": 2000, "concurrent": default_params["concurrent"],
"concurrent": 5, "temperature": default_params["temperature"],
"translate_regions": ["Sheet1!A1:B10", "C:D"], "thinking": "default",
"glossary_dict": {
"OpenAI": "开放人工智能",
"LLM": "大语言模型"
}
}
} }
}, },
{ {
"summary": "XLSX 带术语表生成", "file_name": "movie.srt",
"value": { "file_content": "MSAKMDA6MDA6MDEsMjAwIC0tPiAwMDowMD...",
"file_name": "complex_terms.xlsx", "payload": {
"file_content": "UEsDBBQAAAAIA... (base64-encoded xlsx)", "workflow_type": "srt",
"payload": { "skip_translate": False,
"workflow_type": "xlsx", "base_url": "https://api.openai.com/v1",
"base_url": "https://api.openai.com/v1", "api_key": "sk-your-api-key-here",
"api_key": "sk-your-main-translator-key", "model_id": "gpt-4o",
"model_id": "gpt-4o", "to_lang": "中文",
"to_lang": "简体中文", "insert_mode": "replace",
"glossary_generate_enable": True, "separator": "\n",
"glossary_agent_config": { "chunk_size": default_params["chunk_size"],
"baseurl": "https://api.openai.com/v1", "concurrent": default_params["concurrent"],
"key": "sk-your-agent-key-for-glossary", "temperature": default_params["temperature"],
"model_id": "gpt-4-turbo", "thinking": "default",
"to_lang": "简体中文",
"temperature": 0.5
}
}
} }
}, },
{ {
"summary": "DOCX 工作流示例", "file_name": "my_book.epub",
"value": { "file_content": "UEsDBBQAAAAIA... (base64-encoded epub)",
"file_name": "contract.docx", "payload": {
"file_content": "UEsDBBQAAAAIA... (base64-encoded docx)", "workflow_type": "epub",
"payload": { "skip_translate": False,
"workflow_type": "docx", "base_url": "https://api.openai.com/v1",
"base_url": "https://api.openai.com/v1", "api_key": "sk-your-api-key-here",
"api_key": "sk-your-api-key-here", "model_id": "gpt-4o",
"model_id": "gpt-4o", "to_lang": "中文",
"to_lang": "English", "insert_mode": "replace",
"insert_mode": "replace", "separator": "\n",
} "chunk_size": default_params["chunk_size"],
"concurrent": default_params["concurrent"],
"temperature": default_params["temperature"],
"thinking": "default",
} }
}, },
{ {
"summary": "SRT 工作流示例", "file_name": "company_about_us.html",
"value": { "file_content": "PGh0bWw+PGhlYWQ+PHRpdGxlPkFib3V0IFVzPC90aXRsZT48L2hlYWQ+PGJvZHk+PGgxPk91ciBDb21wYW55PC9oMT48cD5XZSBhcmUgYSBsZWFkaW5nIHByb3ZpZGVyIG9mIGlubm92YXRpdmUgc29sdXRpb25zLjwvcD48L2JvZHk+PC9odG1sPg==",
"file_name": "movie.srt", "payload": {
"file_content": "MSAKMDA6MDA6MDEsMjAwIC0tPiAwMDowMD...", "workflow_type": "html",
"payload": { "skip_translate": False,
"workflow_type": "srt", "base_url": "https://api.openai.com/v1",
"base_url": "https://api.openai.com/v1", "api_key": "sk-your-api-key-here",
"api_key": "sk-your-api-key-here", "model_id": "gpt-4o",
"model_id": "gpt-4o", "to_lang": "中文",
"to_lang": "English", "insert_mode": "replace",
"insert_mode": "replace", "separator": " ",
} "chunk_size": default_params["chunk_size"],
} "concurrent": default_params["concurrent"],
}, "temperature": default_params["temperature"],
{ "thinking": "default",
"summary": "EPUB 工作流示例",
"value": {
"file_name": "my_book.epub",
"file_content": "UEsDBBQAAAAIA... (base64-encoded epub)",
"payload": {
"workflow_type": "epub",
"base_url": "https://api.openai.com/v1",
"api_key": "sk-your-api-key-here",
"model_id": "gpt-4o",
"to_lang": "简体中文",
"insert_mode": "replace",
}
}
},
# --- HTML EXAMPLE START ---
{
"summary": "HTML 工作流示例",
"value": {
"file_name": "company_about_us.html",
"file_content": "PGh0bWw+PGhlYWQ+PHRpdGxlPkFib3V0IFVzPC90aXRsZT48L2hlYWQ+PGJvZHk+PGgxPk91ciBDb21wYW55PC9oMT48cD5XZSBhcmUgYSBsZWFkaW5nIHByb3ZpZGVyIG9mIGlubm92YXRpdmUgc29sdXRpb25zLjwvcD48L2JvZHk+PC9odG1sPg==",
"payload": {
"workflow_type": "html",
"base_url": "https://api.openai.com/v1",
"api_key": "sk-your-api-key-here",
"model_id": "gpt-4o",
"to_lang": "简体中文",
"insert_mode": "replace"
}
} }
} }
# --- HTML EXAMPLE END ---
] ]
} }