diff --git a/apps/docs/content/docs/integrations/mistral_parse.mdx b/apps/docs/content/docs/integrations/mistral_parse.mdx index 30aef60dc6c..f6c3542db88 100644 --- a/apps/docs/content/docs/integrations/mistral_parse.mdx +++ b/apps/docs/content/docs/integrations/mistral_parse.mdx @@ -10,12 +10,12 @@ import { ReferenceDetails } from "@/components/ui/reference-details" {/* MANUAL-CONTENT-START:intro */} -Use [Mistral's OCR API](https://mistral.ai/) to extract text and page structure from a PDF uploaded to Sim or supplied by URL. The current parser returns page Markdown, image metadata, the model, and usage information. **Specific Pages** accepts zero-based indices such as `0,1,2`; leave it empty to process all pages. The block offers Markdown, plain-text, and JSON format values, but its current result uses the structured page output documented below. Turn on **Extract Images** to get the images Mistral finds in the document (figures, logos, photos) as files on the `images` output, up to 100 per parse; each page's image entry carries a `file_name` matching its file. **Max Images** and **Min Image Size** (advanced) narrow what is extracted. **Tables** keeps tables inline in the page Markdown by default, or returns them separately as Markdown or HTML in each page's `tables` list. +Use [Mistral's OCR API](https://mistral.ai/) to extract text and page structure from a PDF uploaded to Sim or passed in as a file from a previous block. The current parser returns page Markdown, image metadata, the model, and usage information. **Specific Pages** accepts zero-based indices such as `0,1,2`; leave it empty to process all pages. The block offers Markdown, plain-text, and JSON format values, but its current result uses the structured page output documented below. Turn on **Extract Images** to get the images Mistral finds in the document (figures, logos, photos) as files on the `images` output, up to 100 per parse; each page's image entry carries a `file_name` matching its file. **Max Images** and **Min Image Size** (advanced) narrow what is extracted. **Tables** keeps tables inline in the page Markdown by default, or returns them separately as Markdown or HTML in each page's `tables` list. {/* MANUAL-CONTENT-END */} ## Use the block [#usage-instructions] -Extract text, tables, and images from uploaded PDF documents, or from a URL. Images come back as files an agent can pass on. +Extract text, tables, and images from an uploaded PDF or a file from a previous block. Images come back as files an agent can pass on. ## Actions diff --git a/apps/sim/blocks/blocks/mistral_parse.ts b/apps/sim/blocks/blocks/mistral_parse.ts index 8ce994a3032..e20702d7a64 100644 --- a/apps/sim/blocks/blocks/mistral_parse.ts +++ b/apps/sim/blocks/blocks/mistral_parse.ts @@ -12,6 +12,7 @@ import { normalizeFileInput, parseOptionalNumberInput, } from '@/blocks/utils' +import { MAX_OCR_EXTRACTED_IMAGES } from '@/tools/mistral/types' export const MistralParseBlock: BlockConfig = { type: 'mistral_parse', @@ -310,7 +311,7 @@ export const MistralParseV3Block: BlockConfig = { name: 'Mistral Parser', description: 'Extract text, tables, and images from PDF documents', longDescription: - 'Extract text, tables, and images from uploaded PDF documents, or from a URL. Images come back as files an agent can pass on.', + 'Extract text, tables, and images from an uploaded PDF or a file from a previous block. Images come back as files an agent can pass on.', hideFromToolbar: false, /* v3 renamed the canonical pair's advanced member `filePath` -> `fileReference`, so the inherited sentence would reference a subblock this block lacks. */ @@ -464,6 +465,7 @@ export const MistralParseV3Block: BlockConfig = { parameters.imageLimit = parseOptionalNumberInput(params.imageLimit, 'Max Images', { integer: true, min: 0, + max: MAX_OCR_EXTRACTED_IMAGES, }) parameters.imageMinSize = parseOptionalNumberInput( params.imageMinSize, diff --git a/apps/sim/lib/internal/mistral/images.test.ts b/apps/sim/lib/internal/mistral/images.test.ts index 06f8ddd50fe..e972533d38c 100644 --- a/apps/sim/lib/internal/mistral/images.test.ts +++ b/apps/sim/lib/internal/mistral/images.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest' -import { extractOcrImageFiles, MAX_OCR_EXTRACTED_IMAGES } from '@/lib/internal/mistral/images' +import { extractOcrImageFiles } from '@/lib/internal/mistral/images' +import { MAX_OCR_EXTRACTED_IMAGES } from '@/tools/mistral/types' const JPEG = Buffer.concat([Buffer.from([0xff, 0xd8, 0xff]), Buffer.from('synthetic jpeg body')]) const dataUri = (bytes: Buffer) => `data:image/jpeg;base64,${bytes.toString('base64')}` diff --git a/apps/sim/lib/internal/mistral/images.ts b/apps/sim/lib/internal/mistral/images.ts index 1bf9bc61697..58706e4b47e 100644 --- a/apps/sim/lib/internal/mistral/images.ts +++ b/apps/sim/lib/internal/mistral/images.ts @@ -5,9 +5,7 @@ import type { InternalToolFile } from '@/lib/internal/tool-operations/file-resul import { MAX_BUFFERED_TRANSFER_BYTES } from '@/lib/uploads/shared/types' import { resolveEffectiveMimeType } from '@/lib/uploads/utils/file' import { resolveStoredFileMetadata } from '@/lib/uploads/utils/stored-file-metadata' - -/** Most images one parse stores; Mistral's `image_limit` is clamped to it. */ -export const MAX_OCR_EXTRACTED_IMAGES = 100 +import { MAX_OCR_EXTRACTED_IMAGES } from '@/tools/mistral/types' /** Largest single image kept; a bigger one is a page scan, not a figure. */ const MAX_OCR_IMAGE_BYTES = 20 * 1024 * 1024 diff --git a/apps/sim/lib/internal/mistral/operations.ts b/apps/sim/lib/internal/mistral/operations.ts index 1c41825de8b..d353c5057b5 100644 --- a/apps/sim/lib/internal/mistral/operations.ts +++ b/apps/sim/lib/internal/mistral/operations.ts @@ -7,7 +7,7 @@ import { decodeDataUriWithinLimit } from '@/lib/file-parsers/data-uri' import { isFileParserError } from '@/lib/file-parsers/errors' import { submitMistralOcr } from '@/lib/internal/mistral/client' import { MistralOperationError } from '@/lib/internal/mistral/errors' -import { extractOcrImageFiles, MAX_OCR_EXTRACTED_IMAGES } from '@/lib/internal/mistral/images' +import { extractOcrImageFiles } from '@/lib/internal/mistral/images' import type { MistralParseInput } from '@/lib/internal/mistral/input' import { countMistralPdfPages } from '@/lib/internal/mistral/page-count' import { @@ -31,6 +31,7 @@ import { type ServableFile, } from '@/lib/uploads/utils/file.server' import { assertToolFileAccess } from '@/app/api/files/authorization' +import { MAX_OCR_EXTRACTED_IMAGES } from '@/tools/mistral/types' const logger = createLogger('MistralOperations') const IMAGE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.avif'] as const diff --git a/apps/sim/tools/mistral/types.ts b/apps/sim/tools/mistral/types.ts index 0b565d71841..a30fbb64c95 100644 --- a/apps/sim/tools/mistral/types.ts +++ b/apps/sim/tools/mistral/types.ts @@ -2,6 +2,12 @@ import type { RawFileInput } from '@/lib/uploads/utils/file' import type { UserFile } from '@/executor/types' import type { OutputProperty, ToolResponse } from '@/tools/types' +/** + * Most images one Mistral Parser run extracts. Bounds the block's Max Images field, the + * server's `image_limit` clamp, and the extraction loop. + */ +export const MAX_OCR_EXTRACTED_IMAGES = 100 + /** * Shared output property definitions for Mistral OCR API responses. * Based on Mistral API documentation: https://docs.mistral.ai/api/endpoint/ocr diff --git a/packages/deployment-config/src/integrations.json b/packages/deployment-config/src/integrations.json index 35b687c12d6..d2bf2131280 100644 --- a/packages/deployment-config/src/integrations.json +++ b/packages/deployment-config/src/integrations.json @@ -1,5 +1,5 @@ { - "updatedAt": "2026-11-10", + "updatedAt": "2026-11-11", "integrations": [ { "type": "onepassword", @@ -18362,7 +18362,7 @@ "slug": "mistral-parser", "name": "Mistral Parser", "description": "Extract text, tables, and images from PDF documents", - "longDescription": "Extract text, tables, and images from uploaded PDF documents, or from a URL. Images come back as files an agent can pass on.", + "longDescription": "Extract text, tables, and images from an uploaded PDF or a file from a previous block. Images come back as files an agent can pass on.", "bgColor": "#000000", "iconName": "MistralIcon", "docsUrl": "https://docs.sim.ai/integrations/mistral_parse", @@ -18379,7 +18379,7 @@ "category": "tools", "integrationType": "ai", "tags": ["document-processing", "ocr"], - "updatedAt": "2026-11-10" + "updatedAt": "2026-11-11" }, { "type": "modal",