-
Notifications
You must be signed in to change notification settings - Fork 257
AOAI Policy configuration #5091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dchourasia30
wants to merge
7
commits into
main
Choose a base branch
from
private/dchourasia/aoaipolicyconfiguration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cb65cb0
aoai policy config
dchourasia12 f2c2fc8
some pr comment resolutions
dchourasia12 d97afff
use boolean for xpia detection
dchourasia12 68b3f8d
mark internal
dchourasia12 11752d8
add doc comments
dchourasia12 01654ba
object id updates
dchourasia12 ab80759
Merge branch 'main' of https://github.com/microsoft/BCApps into priva…
dchourasia12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,7 @@ | |
"idRanges": [ | ||
{ | ||
"from": 7757, | ||
"to": 7786 | ||
"to": 7788 | ||
} | ||
], | ||
"target": "OnPrem", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIPolicy.Enum.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// ------------------------------------------------------------------------------------------------ | ||
// 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; | ||
|
||
enum 7787 "AOAI Policy" | ||
{ | ||
Extensible = false; | ||
Access = Internal; | ||
|
||
/// <summary> | ||
/// Low harms severity with XPIA detection enabled | ||
/// </summary> | ||
value(1; "ConservativeWithXPIA") | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Low harms severity with XPIA detection disabled | ||
/// </summary> | ||
value(2; "Conservative") | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Medium harms severity with XPIA detection enabled | ||
/// </summary> | ||
value(3; "MediumWithXPIA") | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Medium harms severity with XPIA detection disabled | ||
/// </summary> | ||
value(4; "Default") | ||
{ | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ystem Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIPolicyHarmsSeverity.Enum.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace System.AI; | ||
|
||
enum 7788 "AOAI Policy Harms Severity" | ||
{ | ||
Extensible = false; | ||
|
||
/// <summary> | ||
/// Applies the strictest policy controls. | ||
/// </summary> | ||
value(1; Low) | ||
dchourasia30 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Applies moderately strict policy controls. | ||
/// </summary> | ||
value(2; Medium) | ||
{ | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIPolicyParams.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// ------------------------------------------------------------------------------------------------ | ||
// 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> | ||
/// Represents the AOAI Policy management for combining Harms Severity and XPIA Detection settings. | ||
/// </summary> | ||
codeunit 7787 "AOAI Policy Params" | ||
{ | ||
InherentEntitlements = X; | ||
InherentPermissions = X; | ||
|
||
var | ||
AOAIPolicyParamsImpl: Codeunit "AOAI Policy Params Impl"; | ||
|
||
/// <summary> | ||
/// Gets the current AOAI Policy Harms Severity setting. | ||
/// </summary> | ||
/// <returns>The current AOAI Policy Harms Severity.</returns> | ||
procedure GetHarmsSeverity(): Enum "AOAI Policy Harms Severity" | ||
begin | ||
exit(AOAIPolicyParamsImpl.GetHarmsSeverity()); | ||
end; | ||
|
||
/// <summary> | ||
/// Gets the current AOAI Policy XPIA Detection setting. | ||
/// </summary> | ||
/// <returns>Gets the status of AOAI Policy XPIA Detection.</returns> | ||
procedure GetXPIADetection(): Boolean | ||
begin | ||
exit(AOAIPolicyParamsImpl.GetXPIADetection()); | ||
end; | ||
|
||
/// <summary> | ||
/// Sets the AOAI Policy Harms Severity. | ||
/// </summary> | ||
/// <param name="HarmsSeverity">The AOAI Policy Harms Severity to set.</param> | ||
procedure SetHarmsSeverity(HarmsSeverity: Enum "AOAI Policy Harms Severity") | ||
begin | ||
AOAIPolicyParamsImpl.SetHarmsSeverity(HarmsSeverity); | ||
end; | ||
|
||
/// <summary> | ||
/// Sets the AOAI Policy XPIA Detection. | ||
/// </summary> | ||
dchourasia30 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// <param name="IsEnabled">Enable/Disable AOAI Policy XPIA Detection</param> | ||
/// <remarks>When XPIA detection is enabled, use <see cref="AOAI Chat Messages.EnforceXPIADetection"/> to mark messages for XPIA detection.</remarks> | ||
procedure SetXPIADetection(IsEnabled: Boolean) | ||
begin | ||
AOAIPolicyParamsImpl.SetXPIADetection(IsEnabled); | ||
end; | ||
|
||
/// <summary> | ||
/// Gets the AOAI policy enum based on the provided policy parameters. | ||
/// </summary> | ||
/// <returns>The corresponding AOAI policy enum value.</returns> | ||
internal procedure GetAOAIPolicy(): Enum "AOAI Policy" | ||
begin | ||
exit(AOAIPolicyParamsImpl.GetAOAIPolicy()); | ||
end; | ||
} |
80 changes: 80 additions & 0 deletions
80
...stem Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIPolicyParamsImpl.Codeunit.al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// ------------------------------------------------------------------------------------------------ | ||
// 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; | ||
|
||
codeunit 7788 "AOAI Policy Params Impl" | ||
{ | ||
Access = Internal; | ||
InherentEntitlements = X; | ||
InherentPermissions = X; | ||
|
||
var | ||
HarmsSeverity: Enum "AOAI Policy Harms Severity"; | ||
IsXPIADetectionEnabled: Boolean; | ||
Initialized: Boolean; | ||
|
||
procedure GetHarmsSeverity(): Enum "AOAI Policy Harms Severity" | ||
begin | ||
if not Initialized then | ||
InitializeDefaults(); | ||
|
||
exit(HarmsSeverity); | ||
end; | ||
|
||
procedure GetXPIADetection(): Boolean | ||
begin | ||
if not Initialized then | ||
InitializeDefaults(); | ||
|
||
exit(IsXPIADetectionEnabled); | ||
end; | ||
|
||
procedure SetHarmsSeverity(NewHarmsSeverity: Enum "AOAI Policy Harms Severity") | ||
begin | ||
if not Initialized then | ||
InitializeDefaults(); | ||
|
||
HarmsSeverity := NewHarmsSeverity; | ||
end; | ||
|
||
procedure SetXPIADetection(IsEnabled: Boolean) | ||
begin | ||
if not Initialized then | ||
InitializeDefaults(); | ||
|
||
IsXPIADetectionEnabled := IsEnabled; | ||
end; | ||
|
||
internal procedure GetAOAIPolicy(): Enum "AOAI Policy" | ||
var | ||
AOAIPolicyHarmsSeverity: Enum "AOAI Policy Harms Severity"; | ||
AOAIPolicyXPIADetection: Boolean; | ||
CombinationKey: Text; | ||
begin | ||
AOAIPolicyHarmsSeverity := GetHarmsSeverity(); | ||
AOAIPolicyXPIADetection := GetXPIADetection(); | ||
|
||
// Create readable combination key | ||
CombinationKey := 'Harms' + Format(AOAIPolicyHarmsSeverity) + '|XPIA' + (AOAIPolicyXPIADetection = true ? 'Enabled' : 'Disabled'); | ||
|
||
case CombinationKey of | ||
'HarmsLow|XPIAEnabled': | ||
exit("AOAI Policy"::"ConservativeWithXPIA"); | ||
'HarmsLow|XPIADisabled': | ||
exit("AOAI Policy"::"Conservative"); | ||
'HarmsMedium|XPIAEnabled': | ||
exit("AOAI Policy"::"MediumWithXPIA"); | ||
'HarmsMedium|XPIADisabled': | ||
exit("AOAI Policy"::"Default"); | ||
end; | ||
end; | ||
|
||
local procedure InitializeDefaults() | ||
begin | ||
Initialized := true; | ||
HarmsSeverity := "AOAI Policy Harms Severity"::Low; | ||
IsXPIADetectionEnabled := true; | ||
end; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.