Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Magnus Hartvig Grønbech committed Feb 11, 2025
1 parent 0787dfd commit db18633
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using System.AI;
/// <summary>
/// Azure Document Intelligence implementation.
/// </summary>
codeunit 7779 "Azure DI Impl."
codeunit 7779 "Azure DI Impl." implements IAIServiceName
{
Access = Internal;
InherentEntitlements = X;
Expand All @@ -29,9 +29,9 @@ codeunit 7779 "Azure DI Impl."
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)
procedure SetCopilotCapability(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo)
begin
CopilotCapabilityImpl.SetCopilotCapability(Capability, CallerModuleInfo, AzureAIServiceName);
CopilotCapabilityImpl.SetCopilotCapability(Capability, CallerModuleInfo, Enum::"Azure AI Service Type"::"Azure Document Intelligence");
end;

procedure RegisterCopilotCapability(CopilotCapability: Enum "Copilot Capability"; CopilotAvailability: Enum "Copilot Availability"; LearnMoreUrl: Text[2048]; CallerModuleInfo: ModuleInfo)
Expand Down Expand Up @@ -134,7 +134,12 @@ codeunit 7779 "Azure DI Impl."
exit(JsonText);
end;

procedure GetAzureAIDocumentIntelligenceCategory(): Code[50]
procedure GetServiceName(): Text[250]
begin
exit(AzureAiDocumentIntelligenceTxt);
end;

procedure GetServiceId(): Code[50];
begin
exit(AzureAiDocumentIntelligenceTxt);
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ codeunit 7780 "Azure Document Intelligence"
CallerModuleInfo: ModuleInfo;
begin
NavApp.GetCallerModuleInfo(CallerModuleInfo);
AzureDIImpl.SetCopilotCapability(CopilotCapability, CallerModuleInfo, AzureDIImpl.GetAzureAIDocumentIntelligenceCategory());
AzureDIImpl.SetCopilotCapability(CopilotCapability, CallerModuleInfo);
end;

}
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ codeunit 7771 "Azure OpenAI"
CallerModuleInfo: ModuleInfo;
begin
NavApp.GetCallerModuleInfo(CallerModuleInfo);
AzureOpenAIImpl.SetCopilotCapability(CopilotCapability, CallerModuleInfo, AzureOpenAIImpl.GetAzureOpenAICategory());
AzureOpenAIImpl.SetCopilotCapability(CopilotCapability, CallerModuleInfo);
end;

#if not CLEAN24
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using System.Environment;
using System.Privacy;
using System.Telemetry;

codeunit 7772 "Azure OpenAI Impl"
codeunit 7772 "Azure OpenAI Impl" implements IAIServiceName
{
Access = Internal;
InherentEntitlements = X;
Expand Down Expand Up @@ -61,9 +61,9 @@ codeunit 7772 "Azure OpenAI Impl"
CopilotCapabilityImpl.IsCapabilityEnabled(Capability, Silent, CallerModuleInfo);
end;

procedure SetCopilotCapability(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo; AzureAIServiceName: Text)
procedure SetCopilotCapability(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo)
begin
CopilotCapabilityImpl.SetCopilotCapability(Capability, CallerModuleInfo, AzureAIServiceName);
CopilotCapabilityImpl.SetCopilotCapability(Capability, CallerModuleInfo, Enum::"Azure AI Service Type"::"Azure OpenAI");
end;

procedure IsAuthorizationConfigured(ModelType: Enum "AOAI Model Type"; CallerModule: ModuleInfo): Boolean
Expand Down Expand Up @@ -616,12 +616,22 @@ codeunit 7772 "Azure OpenAI Impl"
exit(AzureOpenAiTxt);
end;

procedure GetServiceName(): Text[250];
begin
exit(AzureOpenAiTxt);
end;

procedure GetServiceId(): Code[50];
begin
exit(AzureOpenAiTxt);
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Privacy Notice", 'OnRegisterPrivacyNotices', '', false, false)]
local procedure CreatePrivacyNoticeRegistrations(var TempPrivacyNotice: Record "Privacy Notice" temporary)
begin
TempPrivacyNotice.Init();
TempPrivacyNotice.ID := GetAzureOpenAICategory();
TempPrivacyNotice."Integration Service Name" := AzureOpenAiTxt;
TempPrivacyNotice."Integration Service Name" := GetServiceName();
if not TempPrivacyNotice.Insert() then;
end;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace System.AI;
/// <summary>
/// The supported service types for Azure AI.
/// </summary>
enum 7778 "Azure AI Service Type"
enum 7778 "Azure AI Service Type" implements IAIServiceName
{
Access = Public;
Extensible = false;
Expand All @@ -18,6 +18,7 @@ enum 7778 "Azure AI Service Type"
value(0; "Azure OpenAI")
{
Caption = 'Azure OpenAI';
Implementation = IAIServiceName = "Azure OpenAI Impl";
}

/// <summary>
Expand All @@ -26,5 +27,6 @@ enum 7778 "Azure AI Service Type"
value(1; "Azure Document Intelligence")
{
Caption = 'Azure Document Intelligence';
Implementation = IAIServiceName = "Azure OpenAI Impl";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ codeunit 7774 "Copilot Capability Impl"
Telemetry.LogMessage('0000LDV', TelemetryRegisteredNewCopilotCapabilityLbl, Verbosity::Normal, DataClassification::OrganizationIdentifiableInformation, Enum::"AL Telemetry Scope"::All, CustomDimensions);
end;

procedure SetCopilotCapability(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo; AzureAIServiceName: Text)
procedure SetCopilotCapability(Capability: Enum "Copilot Capability"; CallerModuleInfo: ModuleInfo; AIServiceType: Enum "Azure AI Service Type")
var
CopilotTelemetry: Codeunit "Copilot Telemetry";
Language: Codeunit Language;
IAIServicename: Interface IAIServiceName;
SavedGlobalLanguageId: Integer;
CustomDimensions: Dictionary of [Text, Text];
ErrorMessage: Text;
Expand All @@ -96,7 +97,8 @@ codeunit 7774 "Copilot Capability Impl"
CustomDimensions.Add('AppId', Format(CallerModuleInfo.Id()));
GlobalLanguage(SavedGlobalLanguageId);

FeatureTelemetry.LogError('0000LFN', AzureAIServiceName, TelemetrySetCapabilityLbl, TelemetryCopilotCapabilityNotRegisteredLbl, '', Enum::"AL Telemetry Scope"::All, CustomDimensions);
IAIServicename := AIServiceType;
FeatureTelemetry.LogError('0000LFN', IAIServicename.GetServiceName(), TelemetrySetCapabilityLbl, TelemetryCopilotCapabilityNotRegisteredLbl, '', Enum::"AL Telemetry Scope"::All, CustomDimensions);
ErrorMessage := StrSubstNo(CapabilityNotRegisteredErr, Capability);
Error(ErrorMessage);
end;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace System.AI;

/// <summary>
/// Interface for providing naming information for a given AI service.
/// </summary>
interface IAIServiceName
{

/// <summary>
/// Get the name of the service.
/// </summary>
/// <returns>The name of the service.</returns>
procedure GetServiceName(): Text[250];

/// <summary>
/// Get the id of the service. Will often be the service name in Code form.
/// </summary>
/// <returns>The id of the service.</returns>
procedure GetServiceId(): Code[50];

}
2 changes: 1 addition & 1 deletion src/System Application/Test/AI/src/AzureDITest.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ codeunit 132685 "Azure DI Test"
asserterror AzureDI.AnalyzeInvoice('Test');

// [THEN] AnalyzeInvoice returns an error
LibraryAssert.ExpectedError('Copilot is not enabled. Please contact your system administrator.');
LibraryAssert.ExpectedError('Copilot capability ''Text Capability'' has not been enabled. Please contact your system administrator.');
end;

local procedure RegisterCapability(Capability: Enum "Copilot Capability")
Expand Down

0 comments on commit db18633

Please sign in to comment.