Skip to content
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

[Copilot] Add Silent to CopilotCapabilityStatus #1991

Merged
merged 9 commits into from
Sep 10, 2024
Merged
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 @@ -43,6 +43,22 @@ codeunit 7771 "Azure OpenAI"
exit(AzureOpenAIImpl.IsEnabled(CopilotCapability, Silent, CallerModuleInfo));
end;

/// <summary>
/// Checks if the Azure OpenAI API is enabled for the environment and if the capability is active on the environment.
/// </summary>
/// <param name="CopilotCapability">The copilot capability to check.</param>
/// <param name="Silent">If true, no error message will be shown if API is not enabled.</param>
/// <param name="AppId">The id of the app, which registered the copilot capability.</param>
/// <returns>True if API and capability is enabled for environment.</returns>
procedure IsEnabled(CopilotCapability: Enum "Copilot Capability"; Silent: Boolean; AppId: Guid): Boolean
var
AppModuleInfo: ModuleInfo;
begin
if not NavApp.GetModuleInfo(AppId, AppModuleInfo) then
exit(false);
exit(AzureOpenAIImpl.IsEnabled(CopilotCapability, Silent, AppModuleInfo));
end;

/// <summary>
/// Checks if the Azure OpenAI API authorization is configured for the environment.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,22 +272,12 @@ codeunit 7774 "Copilot Capability Impl"
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"System Action Triggers", 'GetCopilotCapabilityStatus', '', false, false)]
local procedure GetCopilotCapabilityStatus(Capability: Integer; var IsEnabled: Boolean; AppId: Guid)
local procedure GetCopilotCapabilityStatus(Capability: Integer; var IsEnabled: Boolean; AppId: Guid; Silent: Boolean)
var
AzureOpenAI: Codeunit "Azure OpenAI";
CurrentModuleInfo: ModuleInfo;
CopilotCapability: Enum "Copilot Capability";
Silent: Boolean;
begin
NavApp.GetCallerModuleInfo(CurrentModuleInfo);
if AppId <> CurrentModuleInfo.Id() then
exit;

CopilotCapability := Enum::"Copilot Capability".FromInteger(Capability);

if CopilotCapability = Enum::"Copilot Capability"::Chat then
Silent := true;

IsEnabled := AzureOpenAI.IsEnabled(CopilotCapability, Silent);
IsEnabled := AzureOpenAI.IsEnabled(CopilotCapability, Silent, AppId);
end;
}
Loading