diff --git a/src/System Application/App/AI/src/Azure OpenAI/AOAIDeploymentsImpl.Codeunit.al b/src/System Application/App/AI/src/Azure OpenAI/AOAIDeploymentsImpl.Codeunit.al index 2eb0d3c083..4ea70a1d03 100644 --- a/src/System Application/App/AI/src/Azure OpenAI/AOAIDeploymentsImpl.Codeunit.al +++ b/src/System Application/App/AI/src/Azure OpenAI/AOAIDeploymentsImpl.Codeunit.al @@ -7,6 +7,7 @@ namespace System.AI; #if not CLEAN25 using System.Environment; #endif +using System.Telemetry; codeunit 7769 "AOAI Deployments Impl" { @@ -15,11 +16,15 @@ codeunit 7769 "AOAI Deployments Impl" InherentPermissions = X; var + Telemetry: Codeunit Telemetry; UnableToGetDeploymentNameErr: Label 'Unable to get deployment name, if this is a third party capability you must specify your own deployment name. You may need to contact your partner.'; GPT4oLatestLbl: Label 'gpt-4o-latest', Locked = true; GPT4oPreviewLbl: Label 'gpt-4o-preview', Locked = true; GPT4oMiniLatestLbl: Label 'gpt-4o-mini-latest', Locked = true; GPT4oMiniPreviewLbl: Label 'gpt-4o-mini-preview', Locked = true; + DeploymentDeprecationDates: Dictionary of [Text, Date]; + DeprecationDatesInitialized: Boolean; + DeprecationMessageLbl: Label 'Deployment %1 deprecated from %2. Check out codeunit 7768 AOAI Deployments', Comment = 'Telemetry message where %1 is the name of the deployment and %2 is the date of deprecation'; #if not CLEAN25 GPT4LatestLbl: Label 'gpt-4-latest', Locked = true; GPT4PreviewLbl: Label 'gpt-4-preview', Locked = true; @@ -103,12 +108,43 @@ codeunit 7769 "AOAI Deployments Impl" exit(GetDeploymentName(GPT4oMiniLatestLbl, CallerModuleInfo)); end; + local procedure InitializeDeploymentDeprecationDates() + begin + if DeprecationDatesInitialized then + exit; + + // Add deprecated deployments with their deprecation dates here + DeploymentDeprecationDates.Add(Turbo0301SaasLbl, DMY2Date(1, 11, 2024)); + DeploymentDeprecationDates.Add(GPT40613SaasLbl, DMY2Date(1, 11, 2024)); + DeploymentDeprecationDates.Add(Turbo0613SaasLbl, DMY2Date(1, 11, 2024)); + DeploymentDeprecationDates.Add(GPT35TurboLatestLbl, DMY2Date(1, 11, 2024)); + DeploymentDeprecationDates.Add(GPT35TurboPreviewLbl, DMY2Date(1, 11, 2024)); + DeploymentDeprecationDates.Add(GPT4PreviewLbl, DMY2Date(1, 11, 2024)); + DeploymentDeprecationDates.Add(GPT4LatestLbl, DMY2Date(1, 11, 2024)); + + DeprecationDatesInitialized := true; + end; + local procedure GetDeploymentName(DeploymentName: Text; CallerModuleInfo: ModuleInfo): Text var AzureOpenAiImpl: Codeunit "Azure OpenAI Impl"; CurrentModuleInfo: ModuleInfo; + IsDeprecated: Boolean; + CustomDimensions: Dictionary of [Text, Text]; + DeprecatedDate: Date; begin + InitializeDeploymentDeprecationDates(); + NavApp.GetCurrentModuleInfo(CurrentModuleInfo); + + IsDeprecated := DeploymentDeprecationDates.ContainsKey(DeploymentName); + if IsDeprecated then begin + DeprecatedDate := DeploymentDeprecationDates.Get(DeploymentName); + CustomDimensions.Add('DeploymentName', DeploymentName); + CustomDimensions.Add('DeprecationDate', Format(DeprecatedDate)); + Telemetry.LogMessage('0000AD1', StrSubstNo(DeprecationMessageLbl, DeploymentName, DeprecatedDate), Verbosity::Warning, DataClassification::SystemMetadata, Enum::"AL Telemetry Scope"::All, CustomDimensions); + end; + if (CallerModuleInfo.Publisher <> CurrentModuleInfo.Publisher) and not AzureOpenAiImpl.IsTenantAllowlistedForFirstPartyCopilotCalls() then Error(UnableToGetDeploymentNameErr);