bluente_translate_document_workflow
Translate documents while preserving formatting. Upload files, specify languages, and receive translated versions in PDF, DOCX, or XLSX formats.
Instructions
Run end-to-end translation: upload, start, poll until READY, and optionally download.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| from | Yes | ||
| to | Yes | ||
| to_type | No | docx | |
| engine | No | LLM | |
| glossary | No | ||
| custom_glossary | No | ||
| bilingual | No | line | |
| vertical_bilingual | No | ||
| scanned | No | ||
| namespace | No | ||
| metadata | No | ||
| poll_interval_ms | No | ||
| max_poll_attempts | No | ||
| auto_download | No | ||
| status_entry | No | ||
| output_path | No |
Implementation Reference
- The service method `runDocumentWorkflow` implements the core logic for the translation document workflow.
async runDocumentWorkflow({ filePath, from, to, toType, engine, glossary, customGlossary, bilingual, verticalBilingual, scanned, namespace, metadata, pollIntervalMs, maxPollAttempts, autoDownload, statusEntry = "pdf", outputPath }) { const uploadResult = await this.client.uploadFile({ filePath, engine, glossary }); const id = uploadResult?.data?.id; if (!id) { throw new BluenteApiError("Upload completed but no task id was returned.", { uploadResult }); } await this.client.translateFile({ id, action: "start", from, to, engine, glossary, customGlossary, bilingual, verticalBilingual, scanned, namespace, metadata }); let finalStatusPayload = null; for (let i = 0; i < maxPollAttempts; i += 1) { const statusPayload = await this.client.getTranslationStatus({ id, entry: statusEntry }); finalStatusPayload = statusPayload; const status = statusPayload?.data?.status; if (TERMINAL_TRANSLATION_STATUSES.has(status)) { break; } await sleep(pollIntervalMs); } const finalStatus = finalStatusPayload?.data?.status; if (finalStatus !== "READY") { throw new BluenteApiError("Translation job did not reach READY state.", { id, finalStatus, finalStatusPayload }); } const download = autoDownload ? await this.client.downloadFile({ id, toType, outputPath }) : null; return { id, finalStatus, status: finalStatusPayload, download }; } - src/tools/translate-document-workflow.tool.js:6-34 (registration)Tool registration for 'bluente_translate_document_workflow', which calls the workflow service.
export function registerTranslateDocumentWorkflowTool(server, { workflowService }) { server.tool( TOOL_NAME, "Run end-to-end translation: upload, start, poll until READY, and optionally download.", documentWorkflowSchema, async (args) => executeTool(TOOL_NAME, async () => workflowService.runDocumentWorkflow({ filePath: args.file_path, from: args.from, to: args.to, toType: args.to_type, engine: args.engine, glossary: args.glossary, customGlossary: args.custom_glossary, bilingual: args.bilingual, verticalBilingual: args.vertical_bilingual, scanned: args.scanned, namespace: args.namespace, metadata: args.metadata, pollIntervalMs: args.poll_interval_ms, maxPollAttempts: args.max_poll_attempts, autoDownload: args.auto_download, statusEntry: args.status_entry, outputPath: args.output_path }) ) ); }