diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index e524bf9..b3057d7 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -620,7 +620,10 @@ export default class LineConnection { stationId: this.config.stationId, lineId: this.config.id, }) - const detectLog = await this.detectLogWithAI(this.outputALLScenario) + let detectLog = await this.detectLogWithAI(this.outputALLScenario) + if (typeof detectLog === 'string' && detectLog?.includes('[')) { + detectLog = [...detectLog.matchAll(/"((?:\\.|[^"\\])*)"/g)].map(m => m[1]) + } const result = mapToLineFormat({ lineNumber: this.config.lineNumber, inventory: this.config.inventory, diff --git a/BACKEND/app/ultils/helper.ts b/BACKEND/app/ultils/helper.ts index f3b414d..6428e06 100644 --- a/BACKEND/app/ultils/helper.ts +++ b/BACKEND/app/ultils/helper.ts @@ -29,7 +29,7 @@ type InputData = { lineNumber: number inventory: any latestScenario?: { - detectAI?: DetectAI + detectAI?: string | string[] } data?: any[] } @@ -223,9 +223,10 @@ export function mapToLineFormat(input: InputData) { // // Mode (DPEL / DPELP) // const dataPlatform = input.data?.find((el) => el.command?.trim() === 'show platform') // const mode = dataPlatform && !dataPlatform.output?.includes('Incomplete') ? 'DPELP' : 'DPEL' - + const detectAI: string | string[] | undefined = input.latestScenario?.detectAI // Issues - const issues = Array.isArray(input.latestScenario?.detectAI) ? input.latestScenario?.detectAI : [] + const issues = Array.isArray(detectAI) ? detectAI : typeof detectAI === 'string' && detectAI?.includes('[') ? [...detectAI.matchAll(/"((?:\\.|[^"\\])*)"/g)] + .map(m => m[1]) : [] // Issues const summary = '' diff --git a/BACKEND/tsconfig.json b/BACKEND/tsconfig.json index 86b69e8..e3d4eed 100644 --- a/BACKEND/tsconfig.json +++ b/BACKEND/tsconfig.json @@ -2,6 +2,6 @@ "extends": "@adonisjs/tsconfig/tsconfig.app.json", "compilerOptions": { "rootDir": "./", - "outDir": "./build" - } -} + "outDir": "./build", + }, +} \ No newline at end of file