690601:2143 ADR-032-232 #09
This commit is contained in:
@@ -86,6 +86,7 @@ import { AiEnabledGuard } from './guards/ai-enabled.guard';
|
||||
import { InjectRedis } from '@nestjs-modules/ioredis';
|
||||
import Redis from 'ioredis';
|
||||
import { FileStorageService } from '../../common/file-storage/file-storage.service';
|
||||
import { SandboxOcrEngineType } from './services/sandbox-ocr-engine.service';
|
||||
import { AiMigrationCheckpointService } from './ai-migration-checkpoint.service';
|
||||
import {
|
||||
MigrationErrorLogDto,
|
||||
@@ -538,7 +539,7 @@ export class AiController {
|
||||
},
|
||||
engineType: {
|
||||
type: 'string',
|
||||
enum: ['auto', 'tesseract', 'typhoon-ocr-3b'],
|
||||
enum: ['auto', 'tesseract', 'typhoon-ocr-3b', 'typhoon-ocr1.5-3b'],
|
||||
description: 'OCR engine ที่ต้องการใช้ (default: auto)',
|
||||
},
|
||||
},
|
||||
@@ -560,13 +561,17 @@ export class AiController {
|
||||
const attachment = await this.fileStorageService.upload(file, user.user_id);
|
||||
const requestPublicId = uuidv7();
|
||||
// ตรวจสอบและ normalize engineType ให้เป็นค่าที่ valid
|
||||
const validEngineTypes = ['auto', 'tesseract', 'typhoon-ocr-3b'] as const;
|
||||
const resolvedEngineType: 'auto' | 'tesseract' | 'typhoon-ocr-3b' =
|
||||
validEngineTypes.includes(
|
||||
engineType as 'auto' | 'tesseract' | 'typhoon-ocr-3b'
|
||||
)
|
||||
? (engineType as 'auto' | 'tesseract' | 'typhoon-ocr-3b')
|
||||
: 'auto';
|
||||
const validEngineTypes = [
|
||||
'auto',
|
||||
'tesseract',
|
||||
'typhoon-ocr-3b',
|
||||
'typhoon-ocr1.5-3b',
|
||||
] as const;
|
||||
const resolvedEngineType: SandboxOcrEngineType = validEngineTypes.includes(
|
||||
engineType as SandboxOcrEngineType
|
||||
)
|
||||
? (engineType as SandboxOcrEngineType)
|
||||
: 'auto';
|
||||
const jobId = await this.aiQueueService.enqueueSandboxJob(
|
||||
'sandbox-ocr-only',
|
||||
{
|
||||
|
||||
@@ -184,7 +184,7 @@ export class TyphoonOcrProcessor extends WorkerHost {
|
||||
const log = this.auditLogRepo.create({
|
||||
documentPublicId: params.documentPublicId,
|
||||
aiModel: 'typhoon-ocr',
|
||||
modelName: 'scb10x/typhoon-ocr-3b',
|
||||
modelName: 'scb10x/typhoon-ocr1.5-3b',
|
||||
modelType: params.engineType,
|
||||
status: params.status,
|
||||
processingTimeMs: params.processingTimeMs,
|
||||
|
||||
@@ -319,7 +319,7 @@ export class OcrService {
|
||||
new Blob([fileBuffer], { type: 'application/pdf' }),
|
||||
'upload.pdf'
|
||||
);
|
||||
form.append('engine', 'typhoon-ocr-3b');
|
||||
form.append('engine', 'typhoon-ocr1.5-3b');
|
||||
const response = await axios.post<OcrSidecarResponse>(
|
||||
`${this.ocrApiUrl}/ocr-upload`,
|
||||
form,
|
||||
@@ -332,7 +332,7 @@ export class OcrService {
|
||||
await this.writeAuditLog({
|
||||
documentPublicId: input.documentPublicId,
|
||||
aiModel: 'typhoon-ocr',
|
||||
modelName: 'typhoon-ocr-3b',
|
||||
modelName: 'typhoon-ocr1.5-3b',
|
||||
modelType: 'typhoon-ocr',
|
||||
status: AiAuditStatus.SUCCESS,
|
||||
processingTimeMs: durationMs,
|
||||
|
||||
@@ -9,7 +9,11 @@ import axios from 'axios';
|
||||
import * as fs from 'fs';
|
||||
import { OcrService } from './ocr.service';
|
||||
|
||||
export type SandboxOcrEngineType = 'auto' | 'tesseract' | 'typhoon-ocr-3b';
|
||||
export type SandboxOcrEngineType =
|
||||
| 'auto'
|
||||
| 'tesseract'
|
||||
| 'typhoon-ocr-3b'
|
||||
| 'typhoon-ocr1.5-3b';
|
||||
|
||||
interface SandboxOcrSidecarResponse {
|
||||
text?: string;
|
||||
|
||||
Reference in New Issue
Block a user