Skip to content

Commit

Permalink
Error if not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Magnus Hartvig Grønbech committed Feb 10, 2025
1 parent c85d431 commit af2de12
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ codeunit 7779 "Azure DI Impl."
TelemetryAnalyzeReceiptCompletedLbl: Label 'Analyze receipt completed.', Locked = true;
GenerateRequestFailedErr: Label 'The request did not return a success status code.';
AzureAiDocumentIntelligenceTxt: Label 'Azure AI Document Intelligence', Locked = true;

CapabilityNotEnabledErr: Label 'Copilot capability ''%1'' has not been enabled. Please contact your system administrator.', Comment = '%1 is the name of the Copilot Capability';

procedure SetCopilotCapability(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo; AzureAIServiceName: Text)
begin
Expand All @@ -50,7 +50,9 @@ codeunit 7779 "Azure DI Impl."
CustomDimensions: Dictionary of [Text, Text];
begin
CopilotCapabilityImpl.CheckCapabilitySet();
CopilotCapabilityImpl.IsCapabilityActive(CallerModuleInfo);
if not CopilotCapabilityImpl.IsCapabilityActive(CallerModuleInfo) then
Error(CapabilityNotEnabledErr, CopilotCapabilityImpl.GetCapabilityName());

CopilotCapabilityImpl.CheckCapabilityServiceType(Enum::"Azure AI Service Type"::"Azure Document Intelligence");
CopilotCapabilityImpl.AddTelemetryCustomDimensions(CustomDimensions, CallerModuleInfo);

Expand All @@ -74,7 +76,9 @@ codeunit 7779 "Azure DI Impl."
CustomDimensions: Dictionary of [Text, Text];
begin
CopilotCapabilityImpl.CheckCapabilitySet();
CopilotCapabilityImpl.IsCapabilityActive(CallerModuleInfo);
if not CopilotCapabilityImpl.IsCapabilityActive(CallerModuleInfo) then
Error(CapabilityNotEnabledErr, CopilotCapabilityImpl.GetCapabilityName());

CopilotCapabilityImpl.AddTelemetryCustomDimensions(CustomDimensions, CallerModuleInfo);

if not SendRequest(Base64Data, Enum::"ADI Model Type"::Receipt, CallerModuleInfo, Result) then begin
Expand Down

0 comments on commit af2de12

Please sign in to comment.