diff --git a/src/System Application/App/AI/src/Azure AI Document Intelligence/AzureDIImpl.Codeunit.al b/src/System Application/App/AI/src/Azure AI Document Intelligence/AzureDIImpl.Codeunit.al
index ca133865c3..05044363de 100644
--- a/src/System Application/App/AI/src/Azure AI Document Intelligence/AzureDIImpl.Codeunit.al
+++ b/src/System Application/App/AI/src/Azure AI Document Intelligence/AzureDIImpl.Codeunit.al
@@ -4,7 +4,6 @@
// ------------------------------------------------------------------------------------------------
namespace System.AI.DocumentIntelligence;
-using System.Privacy;
using System.Telemetry;
using System;
using System.AI;
@@ -35,6 +34,11 @@ codeunit 7779 "Azure DI Impl."
CopilotCapabilityImpl.SetCopilotCapability(Capability, CallerModuleInfo, AzureAIServiceName);
end;
+ procedure RegisterCopilotCapability(CopilotCapability: Enum "Copilot Capability"; CopilotAvailability: Enum "Copilot Availability"; LearnMoreUrl: Text[2048]; CallerModuleInfo: ModuleInfo)
+ begin
+ CopilotCapabilityImpl.RegisterCapability(CopilotCapability, CopilotAvailability, Enum::"Azure AI Service Type"::"Azure Document Intelligence", LearnMoreUrl, CallerModuleInfo);
+ end;
+
///
/// Analyze a single invoice.
///
@@ -46,7 +50,8 @@ codeunit 7779 "Azure DI Impl."
CustomDimensions: Dictionary of [Text, Text];
begin
CopilotCapabilityImpl.CheckCapabilitySet();
- CopilotCapabilityImpl.CheckEnabled(CallerModuleInfo, Enum::"Azure AI Service Type"::"Azure Document Intelligence");
+ CopilotCapabilityImpl.IsCapabilityActive(CallerModuleInfo);
+ CopilotCapabilityImpl.CheckCapabilityServiceType(Enum::"Azure AI Service Type"::"Azure Document Intelligence");
CopilotCapabilityImpl.AddTelemetryCustomDimensions(CustomDimensions, CallerModuleInfo);
if not SendRequest(Base64Data, Enum::"ADI Model Type"::Invoice, CallerModuleInfo, Result) then begin
@@ -69,7 +74,7 @@ codeunit 7779 "Azure DI Impl."
CustomDimensions: Dictionary of [Text, Text];
begin
CopilotCapabilityImpl.CheckCapabilitySet();
- CopilotCapabilityImpl.CheckEnabled(CallerModuleInfo, Enum::"Azure AI Service Type"::"Azure Document Intelligence");
+ CopilotCapabilityImpl.IsCapabilityActive(CallerModuleInfo);
CopilotCapabilityImpl.AddTelemetryCustomDimensions(CustomDimensions, CallerModuleInfo);
if not SendRequest(Base64Data, Enum::"ADI Model Type"::Receipt, CallerModuleInfo, Result) then begin
@@ -131,15 +136,4 @@ codeunit 7779 "Azure DI Impl."
exit(AzureAiDocumentIntelligenceTxt);
end;
- [EventSubscriber(ObjectType::Codeunit, Codeunit::"Privacy Notice", OnRegisterPrivacyNotices, '', false, false)]
- local procedure CreatePrivacyNoticeRegistrations(var TempPrivacyNotice: Record "Privacy Notice" temporary)
- begin
- TempPrivacyNotice.Init();
- TempPrivacyNotice.ID := GetAzureAIDocumentIntelligenceCategory();
- TempPrivacyNotice."Integration Service Name" := AzureAiDocumentIntelligenceTxt;
- if not TempPrivacyNotice.Insert() then;
- end;
-
-
-
}
\ No newline at end of file
diff --git a/src/System Application/App/AI/src/Azure AI Document Intelligence/AzureDocumentIntelligence.Codeunit.al b/src/System Application/App/AI/src/Azure AI Document Intelligence/AzureDocumentIntelligence.Codeunit.al
index 9de24eb663..ee22d16686 100644
--- a/src/System Application/App/AI/src/Azure AI Document Intelligence/AzureDocumentIntelligence.Codeunit.al
+++ b/src/System Application/App/AI/src/Azure AI Document Intelligence/AzureDocumentIntelligence.Codeunit.al
@@ -18,7 +18,6 @@ codeunit 7780 "Azure Document Intelligence"
var
AzureDIImpl: Codeunit "Azure DI Impl.";
-
///
/// Analyze the invoice.
///
@@ -47,6 +46,19 @@ codeunit 7780 "Azure Document Intelligence"
exit(AzureDIImpl.AnalyzeReceipt(Base64Data, CallerModuleInfo));
end;
+ ///
+ /// Register a capability for Azure Document Intelligence.
+ ///
+ /// The capability.
+ /// The availability.
+ /// The learn more url.
+ procedure RegisterCopilotCapability(CopilotCapability: Enum "Copilot Capability"; CopilotAvailability: Enum "Copilot Availability"; LearnMoreUrl: Text[2048])
+ var
+ CallerModuleInfo: ModuleInfo;
+ begin
+ NavApp.GetCallerModuleInfo(CallerModuleInfo);
+ AzureDIImpl.RegisterCopilotCapability(CopilotCapability, CopilotAvailability, LearnMoreUrl, CallerModuleInfo);
+ end;
///
/// Sets the copilot capability that the API is running for.
diff --git a/src/System Application/App/AI/src/Azure OpenAI/AzureOpenAIImpl.Codeunit.al b/src/System Application/App/AI/src/Azure OpenAI/AzureOpenAIImpl.Codeunit.al
index 9186430edb..354c6fb1a3 100644
--- a/src/System Application/App/AI/src/Azure OpenAI/AzureOpenAIImpl.Codeunit.al
+++ b/src/System Application/App/AI/src/Azure OpenAI/AzureOpenAIImpl.Codeunit.al
@@ -53,12 +53,12 @@ codeunit 7772 "Azure OpenAI Impl"
procedure IsEnabled(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo): Boolean
begin
- CopilotCapabilityImpl.IsCapabilityEnabled(Capability, CallerModuleInfo, Enum::"Azure AI Service Type"::"Azure OpenAI");
+ CopilotCapabilityImpl.IsCapabilityEnabled(Capability, CallerModuleInfo);
end;
procedure IsEnabled(Capability: Enum "Copilot Capability"; Silent: Boolean; CallerModuleInfo: ModuleInfo): Boolean
begin
- CopilotCapabilityImpl.IsCapabilityEnabled(Capability, Silent, CallerModuleInfo, Enum::"Azure AI Service Type"::"Azure OpenAI");
+ CopilotCapabilityImpl.IsCapabilityEnabled(Capability, Silent, CallerModuleInfo);
end;
procedure SetCopilotCapability(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo; AzureAIServiceName: Text)
@@ -163,7 +163,7 @@ codeunit 7772 "Azure OpenAI Impl"
GuiCheck(TextCompletionsAOAIAuthorization);
CopilotCapabilityImpl.CheckCapabilitySet();
- CopilotCapabilityImpl.CheckEnabled(CallerModuleInfo, Enum::"Azure AI Service Type"::"Azure OpenAI");
+ CopilotCapabilityImpl.CheckEnabled(CallerModuleInfo);
CheckAuthorizationEnabled(TextCompletionsAOAIAuthorization, CallerModuleInfo);
CopilotCapabilityImpl.AddTelemetryCustomDimensions(CustomDimensions, CallerModuleInfo);
@@ -197,7 +197,7 @@ codeunit 7772 "Azure OpenAI Impl"
GuiCheck(EmbeddingsAOAIAuthorization);
CopilotCapabilityImpl.CheckCapabilitySet();
- CopilotCapabilityImpl.CheckEnabled(CallerModuleInfo, Enum::"Azure AI Service Type"::"Azure OpenAI");
+ CopilotCapabilityImpl.CheckEnabled(CallerModuleInfo);
CheckAuthorizationEnabled(EmbeddingsAOAIAuthorization, CallerModuleInfo);
Payload.Add('input', Input.Unwrap());
@@ -251,7 +251,7 @@ codeunit 7772 "Azure OpenAI Impl"
GuiCheck(ChatCompletionsAOAIAuthorization);
CopilotCapabilityImpl.CheckCapabilitySet();
- CopilotCapabilityImpl.CheckEnabled(CallerModuleInfo, Enum::"Azure AI Service Type"::"Azure OpenAI");
+ CopilotCapabilityImpl.CheckEnabled(CallerModuleInfo);
CheckAuthorizationEnabled(ChatCompletionsAOAIAuthorization, CallerModuleInfo);
CopilotCapabilityImpl.AddTelemetryCustomDimensions(CustomDimensions, CallerModuleInfo);
diff --git a/src/System Application/App/AI/src/Copilot/CopilotAICapabilities.Page.al b/src/System Application/App/AI/src/Copilot/CopilotAICapabilities.Page.al
index 6784b465fe..97a9f23e25 100644
--- a/src/System Application/App/AI/src/Copilot/CopilotAICapabilities.Page.al
+++ b/src/System Application/App/AI/src/Copilot/CopilotAICapabilities.Page.al
@@ -291,6 +291,7 @@ page 7775 "Copilot AI Capabilities"
CopilotSettings: Record "Copilot Settings";
begin
CopilotSettings.SetRange(Availability, Enum::"Copilot Availability"::"Early Preview");
+ CopilotSettings.SetRange("Service Type", Enum::"Azure AI Service Type"::"Azure OpenAI");
exit(not CopilotSettings.IsEmpty());
end;
diff --git a/src/System Application/App/AI/src/Copilot/CopilotCapEarlyPreview.Page.al b/src/System Application/App/AI/src/Copilot/CopilotCapEarlyPreview.Page.al
index f322325fb9..f044a41d1f 100644
--- a/src/System Application/App/AI/src/Copilot/CopilotCapEarlyPreview.Page.al
+++ b/src/System Application/App/AI/src/Copilot/CopilotCapEarlyPreview.Page.al
@@ -16,7 +16,7 @@ page 7770 "Copilot Cap. Early Preview"
Editable = false;
Extensible = false;
SourceTable = "Copilot Settings";
- SourceTableView = where(Availability = const("Early Preview"));
+ SourceTableView = where(Availability = const("Early Preview"), "Service Type" = const("Azure AI Service Type"::"Azure OpenAI"));
Permissions = tabledata "Copilot Settings" = rm;
InherentEntitlements = X;
InherentPermissions = X;
diff --git a/src/System Application/App/AI/src/Copilot/CopilotCapabilitiesGA.Page.al b/src/System Application/App/AI/src/Copilot/CopilotCapabilitiesGA.Page.al
index b76b8e4350..241e75d182 100644
--- a/src/System Application/App/AI/src/Copilot/CopilotCapabilitiesGA.Page.al
+++ b/src/System Application/App/AI/src/Copilot/CopilotCapabilitiesGA.Page.al
@@ -16,7 +16,7 @@ page 7774 "Copilot Capabilities GA"
Editable = false;
Extensible = false;
SourceTable = "Copilot Settings";
- SourceTableView = where(Availability = const("Generally Available"));
+ SourceTableView = where(Availability = const("Generally Available"), "Service Type" = const("Azure AI Service Type"::"Azure OpenAI"));
Permissions = tabledata "Copilot Settings" = rm;
InherentEntitlements = X;
InherentPermissions = X;
diff --git a/src/System Application/App/AI/src/Copilot/CopilotCapabilitiesPreview.Page.al b/src/System Application/App/AI/src/Copilot/CopilotCapabilitiesPreview.Page.al
index 38e90454e1..5c528a18a6 100644
--- a/src/System Application/App/AI/src/Copilot/CopilotCapabilitiesPreview.Page.al
+++ b/src/System Application/App/AI/src/Copilot/CopilotCapabilitiesPreview.Page.al
@@ -16,7 +16,7 @@ page 7773 "Copilot Capabilities Preview"
Editable = false;
Extensible = false;
SourceTable = "Copilot Settings";
- SourceTableView = where(Availability = const(Preview));
+ SourceTableView = where(Availability = const(Preview), "Service Type" = const("Azure AI Service Type"::"Azure OpenAI"));
Permissions = tabledata "Copilot Settings" = rm;
InherentEntitlements = X;
InherentPermissions = X;
diff --git a/src/System Application/App/AI/src/Copilot/CopilotCapabilityImpl.Codeunit.al b/src/System Application/App/AI/src/Copilot/CopilotCapabilityImpl.Codeunit.al
index 31e50dc8bf..0ca9e1f526 100644
--- a/src/System Application/App/AI/src/Copilot/CopilotCapabilityImpl.Codeunit.al
+++ b/src/System Application/App/AI/src/Copilot/CopilotCapabilityImpl.Codeunit.al
@@ -11,7 +11,6 @@ using System.Environment;
using System.Environment.Configuration;
using System.Globalization;
using System.Privacy;
-using System.AI.DocumentIntelligence;
using System.Security.User;
using System.Telemetry;
@@ -58,6 +57,11 @@ codeunit 7774 "Copilot Capability Impl"
end;
procedure RegisterCapability(CopilotCapability: Enum "Copilot Capability"; CopilotAvailability: Enum "Copilot Availability"; LearnMoreUrl: Text[2048]; CallerModuleInfo: ModuleInfo)
+ begin
+ RegisterCapability(CopilotCapability, CopilotAvailability, Enum::"Azure AI Service Type"::"Azure OpenAI", LearnMoreUrl, CallerModuleInfo);
+ end;
+
+ procedure RegisterCapability(CopilotCapability: Enum "Copilot Capability"; CopilotAvailability: Enum "Copilot Availability"; AzureAIServiceType: Enum "Azure AI Service Type"; LearnMoreUrl: Text[2048]; CallerModuleInfo: ModuleInfo)
var
CustomDimensions: Dictionary of [Text, Text];
begin
@@ -71,6 +75,7 @@ codeunit 7774 "Copilot Capability Impl"
CopilotSettings.Publisher := CopyStr(CallerModuleInfo.Publisher, 1, MaxStrLen(CopilotSettings.Publisher));
CopilotSettings.Availability := CopilotAvailability;
CopilotSettings."Learn More Url" := LearnMoreUrl;
+ CopilotSettings."Service Type" := AzureAIServiceType;
if CopilotSettings.Availability = Enum::"Copilot Availability"::"Early Preview" then
CopilotSettings.Status := Enum::"Copilot Status"::Inactive
else
@@ -165,6 +170,11 @@ codeunit 7774 "Copilot Capability Impl"
exit(not CopilotSettings.IsEmpty());
end;
+ procedure IsCapabilityActive(CallerModuleInfo: ModuleInfo): Boolean
+ begin
+ exit(IsCapabilityActive(CopilotSettings.Capability, CallerModuleInfo.Id()));
+ end;
+
procedure IsCapabilityActive(CopilotCapability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo): Boolean
begin
exit(IsCapabilityActive(CopilotCapability, CallerModuleInfo.Id()));
@@ -217,22 +227,28 @@ codeunit 7774 "Copilot Capability Impl"
Error(CopilotCapabilityNotSetErr);
end;
- procedure CheckEnabled(CallerModuleInfo: ModuleInfo; ServiceType: Enum "Azure AI Service Type")
+ procedure CheckCapabilityServiceType(ServiceType: Enum "Azure AI Service Type")
+ begin
+ if CopilotSettings."Service Type" <> ServiceType then
+ Error(CopilotCapabilityNotSetErr);
+ end;
+
+ procedure CheckEnabled(CallerModuleInfo: ModuleInfo)
begin
- if not IsCapabilityEnabled(CopilotSettings.Capability, true, CallerModuleInfo, ServiceType) then
+ if not IsCapabilityEnabled(CopilotSettings.Capability, true, CallerModuleInfo) then
Error(CopilotNotEnabledErr);
end;
- procedure IsCapabilityEnabled(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo; ServiceType: Enum "Azure AI Service Type"): Boolean
+ procedure IsCapabilityEnabled(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo): Boolean
begin
- exit(IsCapabilityEnabled(Capability, false, CallerModuleInfo, ServiceType));
+ exit(IsCapabilityEnabled(Capability, false, CallerModuleInfo));
end;
- procedure IsCapabilityEnabled(Capability: Enum "Copilot Capability"; Silent: Boolean; CallerModuleInfo: ModuleInfo; ServiceType: Enum "Azure AI Service Type"): Boolean
+ procedure IsCapabilityEnabled(Capability: Enum "Copilot Capability"; Silent: Boolean; CallerModuleInfo: ModuleInfo): Boolean
var
CopilotNotAvailable: Page "Copilot Not Available";
begin
- if not IsTenantAllowed(ServiceType) then begin
+ if not IsTenantAllowedToUseAOAI() then begin
if not Silent then
Error(CopilotDisabledForTenantErr); // Copilot capabilities cannot be run on this environment.
@@ -248,15 +264,14 @@ codeunit 7774 "Copilot Capability Impl"
exit(false);
end;
- exit(CheckPrivacyNoticeState(Silent, Capability, ServiceType));
+ exit(CheckPrivacyNoticeState(Silent, Capability));
end;
[NonDebuggable]
- local procedure IsTenantAllowed(ServiceType: Enum "Azure AI Service Type"): Boolean
+ local procedure IsTenantAllowedToUseAOAI(): Boolean
var
EnvironmentInformation: Codeunit "Environment Information";
AzureOpenAIImpl: Codeunit "Azure OpenAI Impl";
- AzureDIImpl: Codeunit "Azure DI Impl.";
AzureKeyVault: Codeunit "Azure Key Vault";
AzureAdTenant: Codeunit "Azure AD Tenant";
ModuleInfo: ModuleInfo;
@@ -269,13 +284,7 @@ codeunit 7774 "Copilot Capability Impl"
if ModuleInfo.Publisher <> 'Microsoft' then
exit(true);
- case ServiceType of
- Enum::"Azure AI Service Type"::"Azure OpenAI":
- TelemtryTok := AzureOpenAIImpl.GetAzureOpenAICategory();
- Enum::"Azure AI Service Type"::"Azure Document Intelligence":
- TelemtryTok := AzureDIImpl.GetAzureAIDocumentIntelligenceCategory()
- end;
-
+ TelemtryTok := AzureOpenAIImpl.GetAzureOpenAICategory();
if (not AzureKeyVault.GetAzureKeyVaultSecret(EnabledKeyTok, BlockList)) or (BlockList.Trim() = '') then begin
FeatureTelemetry.LogError('0000KYC', TelemtryTok, TelemetryIsEnabledLbl, TelemetryUnableToCheckEnvironmentKVTxt);
exit(false);
@@ -289,21 +298,14 @@ codeunit 7774 "Copilot Capability Impl"
exit(true);
end;
- local procedure CheckPrivacyNoticeState(Silent: Boolean; Capability: Enum "Copilot Capability"; ServiceType: Enum "Azure AI Service Type"): Boolean
+ local procedure CheckPrivacyNoticeState(Silent: Boolean; Capability: Enum "Copilot Capability"): Boolean
var
PrivacyNotice: Codeunit "Privacy Notice";
AzureOpenAIImpl: Codeunit "Azure OpenAI Impl";
- AzureDIImpl: Codeunit "Azure DI Impl.";
CopilotNotAvailable: Page "Copilot Not Available";
PrivacyNoticeApprovalState: Enum "Privacy Notice Approval State";
begin
- case ServiceType of
- Enum::"Azure AI Service Type"::"Azure OpenAI":
- PrivacyNoticeApprovalState := PrivacyNotice.GetPrivacyNoticeApprovalState(AzureOpenAIImpl.GetAzureOpenAICategory(), false);
- Enum::"Azure AI Service Type"::"Azure Document Intelligence":
- PrivacyNoticeApprovalState := PrivacyNotice.GetPrivacyNoticeApprovalState(AzureDIImpl.GetAzureAIDocumentIntelligenceCategory(), false);
- end;
-
+ PrivacyNoticeApprovalState := PrivacyNotice.GetPrivacyNoticeApprovalState(AzureOpenAIImpl.GetAzureOpenAICategory(), false);
case PrivacyNoticeApprovalState of
Enum::"Privacy Notice Approval State"::Agreed:
exit(true);
diff --git a/src/System Application/App/AI/src/Copilot/CopilotSettings.Table.al b/src/System Application/App/AI/src/Copilot/CopilotSettings.Table.al
index 9ee6c06bfb..e86861ff8f 100644
--- a/src/System Application/App/AI/src/Copilot/CopilotSettings.Table.al
+++ b/src/System Application/App/AI/src/Copilot/CopilotSettings.Table.al
@@ -44,6 +44,10 @@ table 7775 "Copilot Settings"
{
DataClassification = SystemMetadata;
}
+ field(7; "Service Type"; Enum "Azure AI Service Type")
+ {
+ DataClassification = SystemMetadata;
+ }
}
keys