From 03d00dacbafafdd22b3ff1eece25219b6d031223 Mon Sep 17 00:00:00 2001 From: Darrick Date: Fri, 8 Dec 2023 16:33:24 +0100 Subject: [PATCH] [Copilot] Minor fixes and additions for AI module (#416) #### Summary - Add subscriber to `GetCopilotCapabilityStatus` to return if a copilot capability is enabled - Add captions to the Copilot Status enum for translation - Add Copilot Status to dimensions for onmodify - Add additional search term to Copilot & Capabilities page #### Work Item(s) Fixes AB#492257 AB#492176 AB#491285 AB#491283 --- .../src/Copilot/CopilotAICapabilities.Page.al | 2 +- .../Copilot/CopilotCapabilityImpl.Codeunit.al | 25 +++++++++++++++++++ .../App/AI/src/Copilot/CopilotStatus.Enum.al | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/System Application/App/AI/src/Copilot/CopilotAICapabilities.Page.al b/src/System Application/App/AI/src/Copilot/CopilotAICapabilities.Page.al index 76e4a85867..c9ee40267e 100644 --- a/src/System Application/App/AI/src/Copilot/CopilotAICapabilities.Page.al +++ b/src/System Application/App/AI/src/Copilot/CopilotAICapabilities.Page.al @@ -20,7 +20,7 @@ page 7775 "Copilot AI Capabilities" DataCaptionExpression = ''; AboutTitle = 'About Copilot'; AboutText = 'Copilot is the AI-powered assistant that helps people across your organization unlock their creativity and automate tedious tasks.'; - AdditionalSearchTerms = 'OpenAI,AI,Copilot,Co-pilot,Artificial Intelligence,GPT,GTP,Dynamics 365 Copilot,ChatGPT,Copilot settings,Copilot setup,enable Copilot,Copilot admin'; + AdditionalSearchTerms = 'OpenAI,AI,Copilot,Co-pilot,Artificial Intelligence,GPT,GTP,Dynamics 365 Copilot,ChatGPT,Copilot settings,Copilot setup,enable Copilot,Copilot admin,Copilot and'; InsertAllowed = false; DeleteAllowed = false; Extensible = false; diff --git a/src/System Application/App/AI/src/Copilot/CopilotCapabilityImpl.Codeunit.al b/src/System Application/App/AI/src/Copilot/CopilotCapabilityImpl.Codeunit.al index 60a8326c05..921145280b 100644 --- a/src/System Application/App/AI/src/Copilot/CopilotCapabilityImpl.Codeunit.al +++ b/src/System Application/App/AI/src/Copilot/CopilotCapabilityImpl.Codeunit.al @@ -8,6 +8,7 @@ using System.Globalization; using System.Telemetry; using System.Security.User; using System.Azure.Identity; +using System.Environment; using System.Privacy; codeunit 7774 "Copilot Capability Impl" @@ -82,6 +83,7 @@ codeunit 7774 "Copilot Capability Impl" Commit(); AddTelemetryDimensions(CopilotCapability, CallerModuleInfo.Id(), CustomDimensions); + AddStatusTelemetryDimension(CopilotSettings.Status, CustomDimensions); FeatureTelemetry.LogUsage('0000LDW', CopilotCategoryLbl, TelemetryModifiedCopilotCapabilityLbl, CustomDimensions); end; @@ -198,6 +200,19 @@ codeunit 7774 "Copilot Capability Impl" exit(CopilotCategoryLbl); end; + procedure AddStatusTelemetryDimension(CopilotStatus: Enum "Copilot Status"; var CustomDimensions: Dictionary of [Text, Text]) + var + Language: Codeunit Language; + SavedGlobalLanguageId: Integer; + begin + SavedGlobalLanguageId := GlobalLanguage(); + GlobalLanguage(Language.GetDefaultApplicationLanguageId()); + + CustomDimensions.Add('Status', Format(CopilotStatus)); + + GlobalLanguage(SavedGlobalLanguageId); + end; + procedure AddTelemetryDimensions(CopilotCapability: Enum "Copilot Capability"; AppId: Guid; var CustomDimensions: Dictionary of [Text, Text]) var Language: Codeunit Language; @@ -230,4 +245,14 @@ codeunit 7774 "Copilot Capability Impl" TempPrivacyNotice."Integration Service Name" := AzureOpenAiTxt; if not TempPrivacyNotice.Insert() then; end; + + [EventSubscriber(ObjectType::Codeunit, Codeunit::"System Action Triggers", 'GetCopilotCapabilityStatus', '', false, false)] + local procedure GetCopilotCapabilityStatus(Capability: Integer; var IsEnabled: Boolean) + var + AzureOpenAI: Codeunit "Azure OpenAI"; + CopilotCapability: Enum "Copilot Capability"; + begin + CopilotCapability := Enum::"Copilot Capability".FromInteger(Capability); + Isenabled := AzureOpenAI.IsEnabled(CopilotCapability, true); + end; } \ No newline at end of file diff --git a/src/System Application/App/AI/src/Copilot/CopilotStatus.Enum.al b/src/System Application/App/AI/src/Copilot/CopilotStatus.Enum.al index 01f7dee3b1..66cb48a45f 100644 --- a/src/System Application/App/AI/src/Copilot/CopilotStatus.Enum.al +++ b/src/System Application/App/AI/src/Copilot/CopilotStatus.Enum.al @@ -17,6 +17,7 @@ enum 7775 "Copilot Status" /// value(0; Active) { + Caption = 'Active'; } /// @@ -24,5 +25,6 @@ enum 7775 "Copilot Status" /// value(1; Inactive) { + Caption = 'Inactive'; } } \ No newline at end of file