Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ codeunit 6195 "E-Doc. AI Tool Processor"
var
AOAIDeployments: Codeunit "AOAI Deployments";
begin
exit(AOAIDeployments.GetGPT41Latest());
exit(AOAIDeployments.GetGPT53ChatLatest());
end;

procedure GetEDocumentMatchingAssistanceName(): Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ codeunit 6231 "E-Document MLLM Handler" implements IStructureReceivedEDocument,
Base64Data := Base64Convert.ToBase64(InStream);

// Build AOAI call
AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", AOAIDeployments.GetGPT41MiniPreview());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

Cost regression: Mini model replaced by full GPT-5.3

The previous model GetGPT41MiniPreview() was a deliberately chosen smaller/cheaper model for high-volume document processing. Replacing it with the full GetGPT53ChatLatest() model will substantially increase token costs per document processed through the MLLM extraction path, without any evidence the task complexity justifies the upgrade.

Recommendation:

  • If a multimodal-capable GPT-5.3 mini or smaller variant is available (e.g., GetGPT53MiniLatest()), prefer it for the MLLM handler to preserve the cost profile. Reserve the full GPT-5.3 model for the matching and tool-processor codeunits where the reasoning complexity is higher.
Suggested change
AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", AOAIDeployments.GetGPT41MiniPreview());
// Prefer a mini/smaller variant for cost efficiency if available:
AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", AOAIDeployments.GetGPT53MiniLatest());

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟠\ High\ Severity\ —\ Upgrade} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

Vision model replaced with chat-only model

The MLLM handler uses AddFilePart() to attach Base64-encoded PDF documents (via 'data:application/pdf;base64,%1') and then calls GenerateChatCompletion. This requires a vision/multimodal-capable model. GetGPT41MiniPreview() was specifically a multimodal model; if GetGPT53ChatLatest() is a text-only chat model, the file attachment will either be rejected by the API or silently ignored, causing every MLLM extraction to fall back to ADI instead of using the AI extraction path.

Recommendation:

  • Verify that the deployment returned by GetGPT53ChatLatest() supports multimodal / vision inputs (file parts). If it does not, use a GPT-5.3 deployment that explicitly supports vision, or retain a vision-capable model for this handler. Add an integration test that confirms file-part content is correctly processed by the new model.
Suggested change
AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", AOAIDeployments.GetGPT41MiniPreview());
// If GPT-5.3 has a vision variant, use it:
AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", AOAIDeployments.GetGPT53VisionLatest());
// Otherwise keep GPT-4.1 Mini (vision) until a multimodal GPT-5.3 deployment is available:
// AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", AOAIDeployments.GetGPT41MiniPreview());

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", AOAIDeployments.GetGPT53ChatLatest());
AzureOpenAI.SetCopilotCapability(Enum::"Copilot Capability"::"E-Document MLLM Analysis");

AOAIChatCompletionParams.SetTemperature(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ codeunit 6163 "E-Doc. PO Copilot Matching"
Session.LogMessage('0000MOT', AttempToUseCopilotMsg, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::All, 'Category', FeatureName());

// Generate OpenAI Completion
AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", AOAIDeployments.GetGPT41Latest());
AzureOpenAI.SetAuthorization(Enum::"AOAI Model Type"::"Chat Completions", AOAIDeployments.GetGPT53ChatLatest());
AzureOpenAI.SetCopilotCapability(Enum::"Copilot Capability"::"E-Document Matching Assistance");

AOAIChatCompletionParams.SetMaxTokens(MaxTokens());
Expand Down
4 changes: 2 additions & 2 deletions src/Apps/W1/EDocument/App/src/Processing/docs/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The Processing module orchestrates what happens to E-Documents between creation

**Order matching.** For incoming purchase orders, `EDocLineMatching.Codeunit.al` matches imported e-document lines to existing purchase order lines. Automatic matching filters on UOM, unit cost, and discount, then uses `CalculateStringNearness()` above 80% for description matching, plus Item Reference and Text-to-Account Mapping lookups. The Copilot subfolder adds AI-assisted matching via Azure OpenAI when automatic matching leaves unmatched lines.

**AI tools.** `EDocAIToolProcessor.Codeunit.al` is a generic Copilot orchestrator that configures Azure OpenAI (GPT-4.1), registers AI tools as function calls, and processes responses. The `Tools/` subfolder provides implementations for historical matching, G/L account matching, deferral matching, and similar-description lookups.
**AI tools.** `EDocAIToolProcessor.Codeunit.al` is a generic Copilot orchestrator that configures Azure OpenAI (GPT-5.3 chat), registers AI tools as function calls, and processes responses. The `Tools/` subfolder provides implementations for historical matching, G/L account matching, deferral matching, and similar-description lookups.

## Things to know

Expand All @@ -22,7 +22,7 @@ The Processing module orchestrates what happens to E-Documents between creation

- Order matching only applies to incoming purchase orders (`"Document Type" = "Purchase Order"`, `Direction = Incoming`, `Status = "Order Linked"`). The matching page lets users match manually, run automatic matching, or invoke Copilot. Accepted matches persist to the `"E-Doc. Order Match"` table and update `"Qty. to Invoice"` on purchase lines.

- The Copilot PO matching (`EDocPOCopilotMatching.Codeunit.al`) builds a user prompt from imported line and PO line descriptions, sends it to GPT-4.1 with function-calling tools, and grounds the result by verifying cost/quantity thresholds before surfacing proposals.
- The Copilot PO matching (`EDocPOCopilotMatching.Codeunit.al`) builds a user prompt from imported line and PO line descriptions, sends it to GPT-5.3 chat with function-calling tools, and grounds the result by verifying cost/quantity thresholds before surfacing proposals.

- `EDocumentBackgroundJobs` manages three job types: the one-shot "created flow" trigger, the recurring 5-minute `GetResponse` poller, and the recurrent batch send/import jobs with configurable frequency.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ If you are working on the V2.0 import pipeline (Prepare Draft / Finish Draft sta

## Copilot PO matching

When automatic matching (V1 interactive system) leaves unmatched lines, users can invoke Copilot from the matching page. `EDocPOCopilotMatching.MatchWithCopilot()` builds a prompt containing imported line and PO line descriptions, sends it to Azure OpenAI (GPT-4.1 via the `"E-Document Matching Assistance"` Copilot capability), and interprets the response through function-calling tools.
When automatic matching (V1 interactive system) leaves unmatched lines, users can invoke Copilot from the matching page. `EDocPOCopilotMatching.MatchWithCopilot()` builds a prompt containing imported line and PO line descriptions, sends it to Azure OpenAI (GPT-5.3 chat via the `"E-Document Matching Assistance"` Copilot capability), and interprets the response through function-calling tools.

The Copilot result is **grounded** before being shown: the framework verifies that proposed matches respect the cost difference threshold configured in `"Purchases & Payables Setup"."E-Document Matching Difference"`. Proposals that exceed the threshold are discarded. Accepted proposals are surfaced on a proposal page where the user reviews and confirms.

Expand Down
Loading