From 5dfad6b77bf5958741eacca13ca139ac2ca7de29 Mon Sep 17 00:00:00 2001 From: Ruben Talstra Date: Sat, 24 May 2025 20:59:22 +0200 Subject: [PATCH] feat: Enhance document intelligence support with new model configuration and API integration --- api/models/Agent.js | 1 - .../Files/AzureDocumentIntelligence/crud.js | 20 +++++++++++-------- packages/data-provider/src/config.ts | 1 + 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/api/models/Agent.js b/api/models/Agent.js index 050fa9cb88..11fd6dabb2 100644 --- a/api/models/Agent.js +++ b/api/models/Agent.js @@ -278,7 +278,6 @@ const updateAgent = async (searchParameter, updateData, updatingUserId = null) = } } - const versionEntry = { ...versionData, ...directUpdates, diff --git a/api/server/services/Files/AzureDocumentIntelligence/crud.js b/api/server/services/Files/AzureDocumentIntelligence/crud.js index 80931cc4f7..3c5de85dea 100644 --- a/api/server/services/Files/AzureDocumentIntelligence/crud.js +++ b/api/server/services/Files/AzureDocumentIntelligence/crud.js @@ -1,5 +1,5 @@ const axios = require('axios'); -const fs = require('fs'); +const fs = require('fs'); const { logger } = require('~/config'); /** @@ -17,14 +17,18 @@ async function uploadAzureDocumentIntelligence({ filePath, apiKey, endpoint, mod const base64Source = fileBuffer.toString('base64'); try { - const response = await axios.post(`${endpoint}/documentModels/${modelId}/analyze?outputContentFormat=markdown`, { - base64Source, - }, { - headers: { - 'Ocp-Apim-Subscription-Key': apiKey, - 'Content-Type': 'application/json', + const response = await axios.post( + `${endpoint}/documentModels/${modelId}/analyze?outputContentFormat=markdown`, + { + base64Source, }, - }); + { + headers: { + 'Ocp-Apim-Subscription-Key': apiKey, + 'Content-Type': 'application/json', + }, + }, + ); const operationLocation = response.headers['Operation-Location']; // Polling for the result diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts index 24dcbf78a3..b1b8f40c4b 100644 --- a/packages/data-provider/src/config.ts +++ b/packages/data-provider/src/config.ts @@ -628,6 +628,7 @@ export type TWebSearchConfig = z.infer; export const ocrSchema = z.object({ mistralModel: z.string().optional(), + documentIntelligenceModel: z.string().optional(), apiKey: z.string().optional().default('${OCR_API_KEY}'), baseURL: z.string().optional().default('${OCR_BASEURL}'), strategy: z.nativeEnum(OCRStrategy).default(OCRStrategy.MISTRAL_OCR),