Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

fix(mistral-ocr): inline tables instead of as separate references (#1362)

Corentin Thomasset8adb16de44f0
diff --git a/.changeset/mighty-weeks-fry.md b/.changeset/mighty-weeks-fry.md
new file mode 100644
index 00000000..cac21f20
--- /dev/null
+++ b/.changeset/mighty-weeks-fry.md
@@ -0,0 +1,5 @@
+---
+'@papra/app': patch
+---
+
+Fix mistral ocr replacing tables with external references, no more `[tbl-0.md](tbl-0.md)` in extracted content, the tables are now properly extracted and included in the content.
diff --git a/apps/papra-server/src/modules/documents/content-extraction/content-extraction-strategies/mistral-ocr/mistral-ocr.content-extraction-strategy.usecases.ts b/apps/papra-server/src/modules/documents/content-extraction/content-extraction-strategies/mistral-ocr/mistral-ocr.content-extraction-strategy.usecases.ts
index f0a66afa..306db0db 100644
--- a/apps/papra-server/src/modules/documents/content-extraction/content-extraction-strategies/mistral-ocr/mistral-ocr.content-extraction-strategy.usecases.ts
+++ b/apps/papra-server/src/modules/documents/content-extraction/content-extraction-strategies/mistral-ocr/mistral-ocr.content-extraction-strategy.usecases.ts
@@ -39,7 +39,12 @@ export async function extractTextWithMistralOcr({
model: modelName,
include_image_base64: false,
include_blocks: false,
- table_format: 'markdown',
+ // From the doc https://docs.mistral.ai/studio-api/document-processing/basic_ocr :
+ // Table formatting can be toggled between null , markdown and html via the table_format parameter.
+ // - null : Tables are returned inline as markdown within the extracted page.
+ // - markdown : Tables are returned as markdown tables separately.
+ // - html : Tables are returned as html tables separately.
+ table_format: null, // We want tables to be returned inline as markdown within the extracted page.
document: await buildDocumentInfo({ file }),
}),
});