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 @@ -165,6 +165,8 @@ codeunit 7771 "Azure OpenAI"
AzureOpenAIImpl.SetAuthorization(ModelType, Deployment);
end;

#if not CLEAN29
Comment thread
martinsrui-msft marked this conversation as resolved.

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}$

GenerateTextCompletion (all four overloads) on codeunit 7771 "Azure OpenAI" is marked [Obsolete('...', '29.0')] (Pending stage) but the entire block is also wrapped in #if not CLEAN29 ... #endif, with the internal AL0432 warning suppressed. Per the obsoletion staging guidance, Pending should keep the element compilable and callable (with only a deprecation warning); the #if not CLEAN<version> removal mechanic belongs to the later Removed stage. As written, defining CLEAN29 removes these public procedures from compilation immediately, giving consumers no working deprecation window despite the Pending marker implying one.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.32.4

#pragma warning disable AL0432
/// <summary>
/// Generates a text completion given a prompt.
/// </summary>
Expand All @@ -174,6 +176,7 @@ codeunit 7771 "Azure OpenAI"
/// <error>The completion authentication was not configured.</error>
/// <error>The completion generation failed with status code %1.</error>
[NonDebuggable]
[Obsolete('Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.', '29.0')]
procedure GenerateTextCompletion(Prompt: SecretText; var AOAIOperationResponse: Codeunit "AOAI Operation Response"): Text
var
CallerModuleInfo: ModuleInfo;
Expand All @@ -192,6 +195,7 @@ codeunit 7771 "Azure OpenAI"
/// <error>The completion authentication was not configured.</error>
/// <error>The completion generation failed with status code %1.</error>
[NonDebuggable]
[Obsolete('Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.', '29.0')]
procedure GenerateTextCompletion(Prompt: SecretText; AOAICompletionParams: Codeunit "AOAI Text Completion Params"; var AOAIOperationResponse: Codeunit "AOAI Operation Response"): Text
var
CallerModuleInfo: ModuleInfo;
Expand All @@ -210,6 +214,7 @@ codeunit 7771 "Azure OpenAI"
/// <error>The completion authentication was not configured.</error>
/// <error>The completion generation failed with status code %1.</error>
[NonDebuggable]
[Obsolete('Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.', '29.0')]
procedure GenerateTextCompletion(Metaprompt: SecretText; Prompt: SecretText; var AOAIOperationResponse: Codeunit "AOAI Operation Response"): Text
var
CallerModuleInfo: ModuleInfo;
Expand All @@ -229,14 +234,16 @@ codeunit 7771 "Azure OpenAI"
/// <error>The completion authentication was not configured.</error>
/// <error>The completion generation failed with status code %1.</error>
[NonDebuggable]
[Obsolete('Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.', '29.0')]
procedure GenerateTextCompletion(Metaprompt: SecretText; Prompt: SecretText; AOAICompletionParams: Codeunit "AOAI Text Completion Params"; var AOAIOperationResponse: Codeunit "AOAI Operation Response"): Text
var
CallerModuleInfo: ModuleInfo;
begin
NavApp.GetCallerModuleInfo(CallerModuleInfo);
exit(AzureOpenAIImpl.GenerateTextCompletion(Metaprompt, Prompt, AOAICompletionParams, AOAIOperationResponse, CallerModuleInfo));
end;

#pragma warning restore AL0432
#endif

/// <summary>
/// Generates embeddings given an input.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace System.AI;

using System;
#if not CLEAN29
using System.Azure.KeyVault;
#endif
using System.Environment;
using System.Privacy;
using System.Telemetry;
Expand All @@ -27,24 +29,32 @@ codeunit 7772 "Azure OpenAI Impl" implements "AI Service Name"
Telemetry: Codeunit Telemetry;
InvalidModelTypeErr: Label 'Selected model type is not supported.';
GenerateRequestFailedErr: Label 'The request did not return a success status code.';
#if not CLEAN29
CompletionsFailedWithCodeErr: Label 'Text completions failed to be generated';
#endif
EmbeddingsFailedWithCodeErr: Label 'Embeddings failed to be generated.';
ChatCompletionsFailedWithCodeErr: Label 'Chat completions failed to be generated.';
AuthenticationNotConfiguredErr: Label 'The authentication was not configured.';
CapabilityBackgroundErr: Label 'Microsoft Copilot Capabilities are not allowed in the background.';
CapabilityODataErr: Label 'Microsoft Copilot Capabilities are not allowed in API and OData Web Services sessions.';
MessagesMustContainJsonWordWhenResponseFormatIsJsonErr: Label 'The messages must contain the word ''json'' in some form, to use ''response format'' of type ''json_object''.';
#if not CLEAN29
EmptyMetapromptErr: Label 'The metaprompt has not been set, please provide a metaprompt.';
MetapromptLoadingErr: Label 'Metaprompt not found.';
#endif
FunctionCallingFunctionNotFoundErr: Label 'Function call not found, %1.', Comment = '%1 is the name of the function';
#if not CLEAN29
TelemetryGenerateTextCompletionLbl: Label 'Text completion generated.', Locked = true;
#endif
TelemetryGenerateEmbeddingLbl: Label 'Embedding generated.', Locked = true;
TelemetryGenerateChatCompletionLbl: Label 'Chat Completion generated.', Locked = true;
TelemetryChatCompletionToolCallLbl: Label 'Tools called by chat completion.', Locked = true;
TelemetryChatCompletionToolUsedLbl: Label 'Tools added to chat completion.', Locked = true;
TelemetryProhibitedCharactersTxt: Label 'Prohibited characters removed from the prompt.', Locked = true;
TelemetryTokenCountLbl: Label 'Metaprompt token count: %1, Prompt token count: %2, Total token count: %3', Comment = '%1 is the number of tokens in the metaprompt, %2 is the number of tokens in the prompt, %3 is the total number of tokens', Locked = true;
#if not CLEAN29
TelemetryMetapromptRetrievalErr: Label 'Unable to retrieve metaprompt from Azure Key Vault.', Locked = true;
#endif
TelemetryFunctionCallingFailedErr: Label 'Function calling failed for function: %1', Comment = '%1 is the name of the function', Locked = true;
AzureOpenAiTxt: Label 'Azure OpenAI', Locked = true;
BillingTypeAuthorizationErr: Label 'Usage of AI resources not authorized with chosen billing type, Capability: %1, Billing Type: %2. Please contact your system administrator.', Comment = '%1 is the capability name, %2 is the billing type';
Expand Down Expand Up @@ -155,6 +165,8 @@ codeunit 7772 "Azure OpenAI Impl" implements "AI Service Name"
end;
end;

#if not CLEAN29
#pragma warning disable AL0432
[NonDebuggable]
procedure GenerateTextCompletion(Prompt: SecretText; var AOAIOperationResponse: Codeunit "AOAI Operation Response"; CallerModuleInfo: ModuleInfo): Text
var
Expand Down Expand Up @@ -211,6 +223,8 @@ codeunit 7772 "Azure OpenAI Impl" implements "AI Service Name"
FeatureTelemetry.LogUsage('0000KVL', GetAzureOpenAICategory(), TelemetryGenerateTextCompletionLbl, Enum::"AL Telemetry Scope"::All, CustomDimensions);
Result := AOAIOperationResponse.GetResult();
end;
#pragma warning restore AL0432
#endif

[NonDebuggable]
procedure GenerateEmbeddings(Input: SecretText; var AOAIOperationResponse: Codeunit "AOAI Operation Response"; CallerModuleInfo: ModuleInfo): List of [Decimal]
Expand Down Expand Up @@ -563,6 +577,7 @@ codeunit 7772 "Azure OpenAI Impl" implements "AI Service Name"
exit(Result);
end;

#if not CLEAN29
[NonDebuggable]
internal procedure GetTextMetaprompt() Metaprompt: SecretText;
var
Expand Down Expand Up @@ -596,6 +611,7 @@ codeunit 7772 "Azure OpenAI Impl" implements "AI Service Name"
Error(EmptyMetapromptErr);
end;
end;
#endif

procedure GetTokenCount(Input: SecretText; Encoding: Text) TokenCount: Integer
var
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if not CLEAN29
Comment thread
martinsrui-msft marked this conversation as resolved.

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}$

Codeunit 7765 "AOAI Text Completion Params" sets ObsoleteState = Pending (with ObsoleteReason/ObsoleteTag = '29.0') but the entire public codeunit body is also wrapped in #if not CLEAN29 ... #endif. The same pattern is repeated on internal codeunit 7766 "AOAI TextCompletionParams Impl". Per the obsoletion staging guidance, a Pending element must remain present and compilable; using #if not CLEAN<version> to remove the whole object body belongs to the Removed stage, staged in a later release. Combining both in the same PR erases these codeunits entirely once CLEAN29 is defined, with no working Pending window.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.32.4

// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Expand All @@ -13,6 +14,9 @@ codeunit 7765 "AOAI Text Completion Params"
Access = Public;
InherentEntitlements = X;
InherentPermissions = X;
ObsoleteState = Pending;
ObsoleteReason = 'Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.';
ObsoleteTag = '29.0';

var
AOAITextCompletionParamsImpl: Codeunit "AOAI TextCompletionParams Impl";
Expand Down Expand Up @@ -140,4 +144,5 @@ codeunit 7765 "AOAI Text Completion Params"
begin
AOAITextCompletionParamsImpl.AddCompletionsParametersToPayload(Payload);
end;
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if not CLEAN29
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Expand All @@ -9,6 +10,9 @@ codeunit 7766 "AOAI TextCompletionParams Impl"
Access = Internal;
InherentEntitlements = X;
InherentPermissions = X;
ObsoleteState = Pending;
ObsoleteReason = 'Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.';
ObsoleteTag = '29.0';

var
Initialized: Boolean;
Expand Down Expand Up @@ -152,4 +156,5 @@ codeunit 7766 "AOAI TextCompletionParams Impl"
SetPresencePenalty(0);
SetFrequencyPenalty(0);
end;
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ namespace Partner.Test.AI;

using System.AI;
using System.Privacy;
#if not CLEAN29
using System.TestLibraries.AI;
#endif
using System.TestLibraries.Utilities;

codeunit 139021 "Azure OpenAI Test Partner"
Expand All @@ -25,6 +27,8 @@ codeunit 139021 "Azure OpenAI Test Partner"
LearMoreUrlLbl: Label 'http://LearnMore.com', Locked = true;
BillingTypeAuthorizationErr: Label 'Usage of AI resources not authorized with chosen billing type, Capability: %1, Billing Type: %2. Please contact your system administrator.', Comment = '%1 is the capability name, %2 is the billing type';

#if not CLEAN29
#pragma warning disable AL0432
[Test]
[Scope('OnPrem')]
procedure GenerateTextCompletionsBillingTypeAuthorizationErr()
Expand Down Expand Up @@ -73,6 +77,8 @@ codeunit 139021 "Azure OpenAI Test Partner"
ErrorMessage := StrSubstNo(BillingTypeAuthorizationErr, Enum::"Copilot Capability"::"Text Partner Capability", Enum::"Copilot Billing Type"::"Custom Billed");
LibraryAssert.ExpectedError(ErrorMessage);
end;
#pragma warning restore AL0432
#endif

[Test]
[Scope('OnPrem')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ codeunit 132684 "Azure OpenAI Test"
AzureOpenAiTxt: Label 'Azure OpenAI', Locked = true;
EndpointTxt: Label 'https://resourcename.openai.azure.com/', Locked = true;
DeploymentTxt: Label 'deploymentid', Locked = true;
#if not CLEAN29
BillingTypeAuthorizationErr: Label 'Usage of AI resources not authorized with chosen billing type, Capability: %1, Billing Type: %2. Please contact your system administrator.', Comment = '%1 is the capability name, %2 is the billing type';
#endif

[Test]
[HandlerFunctions('HandleCopilotNotAvailable')]
Expand Down Expand Up @@ -172,6 +174,8 @@ codeunit 132684 "Azure OpenAI Test"
LibraryAssert.ExpectedError('Copilot capability ''Text Capability'' has not been enabled. Please contact your system administrator.');
end;

#if not CLEAN29
#pragma warning disable AL0432
[Test]
procedure GenerateTextCompletionsCopilotCapabilityNotSet()
var
Expand Down Expand Up @@ -324,6 +328,8 @@ codeunit 132684 "Azure OpenAI Test"
ErrorMessage := StrSubstNo(BillingTypeAuthorizationErr, Enum::"Copilot Capability"::"Text Capability", Enum::"Copilot Billing Type"::"Custom Billed");
LibraryAssert.ExpectedError(ErrorMessage);
end;
#pragma warning restore AL0432
#endif

[Test]
procedure GenerateEmbeddingCopilotCapabilityNotSet()
Expand Down
Loading