From 4d243c16e64bd9fdc423386a7ba18f29f661c329 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 4 Jun 2026 11:07:29 +0700 Subject: [PATCH] 690604:1107 ADR-034-134 #06 --- backend/src/modules/ai/ai-queue.service.ts | 6 ++++++ backend/src/modules/ai/processors/ai-batch.processor.ts | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/src/modules/ai/ai-queue.service.ts b/backend/src/modules/ai/ai-queue.service.ts index 4e32206e..f132247c 100644 --- a/backend/src/modules/ai/ai-queue.service.ts +++ b/backend/src/modules/ai/ai-queue.service.ts @@ -116,6 +116,11 @@ export class AiQueueService { filePublicId?: string; pdfPath?: string; engineType?: string; + typhoonOptions?: { + temperature?: number; + topP?: number; + repeatPenalty?: number; + }; extraPayload?: Record; } ): Promise { @@ -131,6 +136,7 @@ export class AiQueueService { filePublicId: payload.filePublicId, pdfPath: payload.pdfPath, engineType: payload.engineType, + typhoonOptions: payload.typhoonOptions, ...payload.extraPayload, }, idempotencyKey: payload.idempotencyKey, diff --git a/backend/src/modules/ai/processors/ai-batch.processor.ts b/backend/src/modules/ai/processors/ai-batch.processor.ts index c7fe5338..cecf5a47 100644 --- a/backend/src/modules/ai/processors/ai-batch.processor.ts +++ b/backend/src/modules/ai/processors/ai-batch.processor.ts @@ -452,6 +452,9 @@ export class AiBatchProcessor extends WorkerHost { const { idempotencyKey, payload } = data; const pdfPath = payload.pdfPath as string; const engineType = (payload.engineType as SandboxOcrEngineType) || 'auto'; + const typhoonOptions = payload.typhoonOptions as + | { temperature?: number; topP?: number; repeatPenalty?: number } + | undefined; if (!pdfPath) { throw new Error('pdfPath is required for sandbox-ocr-only job'); @@ -469,7 +472,8 @@ export class AiBatchProcessor extends WorkerHost { try { const ocrResult = await this.sandboxOcrEngineService.detectAndExtract( pdfPath, - engineType + engineType, + typhoonOptions ); // Cache OCR text สำหรับ Step 2