Skip to content

E-Document: Add MLLM extraction with ADI fallback#6893

Open
Groenbech96 wants to merge 13 commits intomainfrom
features/mllm
Open

E-Document: Add MLLM extraction with ADI fallback#6893
Groenbech96 wants to merge 13 commits intomainfrom
features/mllm

Conversation

@Groenbech96
Copy link
Contributor

@Groenbech96 Groenbech96 commented Feb 27, 2026

Summary

  • Add MLLM (Multimodal LLM) extraction as a new structured data handler for e-document PDF processing, with automatic fallback to ADI (Azure Document Intelligence) when MLLM fails
  • Introduce experiment gate in EDocPDFFileFormat with OnOverrideStructureDataImpl integration event for cross-app override
  • Add dedicated "E-Document MLLM Analysis" Copilot Capability enum value
  • Prefill accounting_customer_party from Company Information to help the LLM distinguish buyer from vendor
  • Add system prompt instructions for customer vs vendor identification

AB#618414

Magnus Hartvig Grønbech and others added 6 commits February 20, 2026 15:27
Add a new extraction method using Azure OpenAI GPT-4.1 Mini Preview
to extract structured invoice data from PDF documents. The MLLM handler
sends the PDF via AddFilePart with a JSON schema prompt and maps the
response to E-Document Purchase Header/Line records.

New objects:
- Table/Page 6142: E-Doc. MLLM Extraction Schema (per-service JSON schema)
- Codeunit 6202: E-Document MLLM Handler (IStructureReceivedEDocument)
- Codeunit 6203: E-Doc. MLLM Schema Helper (default schema + JSON mapping)
- System prompt resource for extraction rules

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Renumber codeunits to available IDs: E-Document MLLM Handler (6202→6231),
E-Doc. MLLM Schema Helper (6203→6232), E-Doc. Purchase Draft Writer
(6204→6234). Update app.json idRanges accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ompany prefill

- Add EDocPDFFileFormat experiment gate with OnOverrideStructureDataImpl integration event
- Implement EDocumentMLLMHandler with LLM-first extraction and ADI fallback
- Add dedicated "E-Document MLLM Analysis" copilot capability enum value
- Prefill accounting_customer_party from Company Information in schema helper
- Add system prompt instructions for customer vs vendor identification
- Refactor handler into CallMLLM and ValidateAndUnwrapResponse for readability

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Groenbech96 Groenbech96 requested review from a team as code owners February 27, 2026 08:50
@github-actions github-actions bot added the AL: Apps (W1) Add-on apps for W1 label Feb 27, 2026
… fallback

- Fix missing exit(Result) in EDocPDFFileFormat.PreferredStructureDataImplementation
- Add EDocMLLMSchemaHelperTests (135647): header/line mapping, edge cases
- Add EDocPDFFileFormatTests (135648): experiment allocation, event override
- Add MLLM E2E and fallback tests to EDocumentStructuredTests (139891)
- Combine CAPI/PEPPOL/MLLM validations into single EDocStructuredValidations
- Move test JSON fixtures to .resources/mllm/ loaded via NavApp.GetResourceAsText

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 8, 2026

⚠️ Stale Status Check Deleted

The Pull Request Build workflow run for this PR was older than 72 hours and has been deleted.

📋 Why was it deleted?

Status checks that are too old may no longer reflect the current state of the target branch. To ensure this PR is validated against the latest code and passes up-to-date checks, a fresh build is required.


🔄 How to trigger a new status check:

  1. 📤 Push a new commit to the PR branch, or
  2. 🔁 Close and reopen the PR

This will automatically trigger a new Pull Request Build workflow run.

Magnus Hartvig Grønbech and others added 2 commits March 9, 2026 13:15
Validate vendor name and address instead of the always-true invoice_line
count check, and fix casing/ordering of using statements in test codeunit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Groenbech96 Groenbech96 self-assigned this Mar 9, 2026
Magnus Hartvig Grønbech and others added 3 commits March 10, 2026 09:48
Consolidate codeunits 135647 and 135648 into one test codeunit. Comment
out assert in PreferredImpl_TreatmentAllocation_ReturnsMLLM pending ECS
enablement (Bug #624677).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These codeunits already declare InherentEntitlements = X and
InherentPermissions = X on the object itself.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added this to the Version 29.0 milestone Mar 10, 2026
@Groenbech96
Copy link
Contributor Author

Code review

Found 1 issue:

  1. Duration type mismatch: DurationMs is declared as Integer (line 43), but CurrentDateTime() - StartTime returns a Duration (64-bit) in AL. Assigning a Duration to an Integer (32-bit) risks overflow for long-running API calls. While typical MLLM calls complete quickly, using the Duration data type instead of Integer would be more correct and avoids any truncation risk.

StartTime := CurrentDateTime();
AzureOpenAI.GenerateChatCompletion(AOAIChatMessages, AOAIChatCompletionParams, AOAIOperationResponse);
DurationMs := CurrentDateTime() - StartTime;

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant