diff --git a/src/System Application/App/AI/src/Azure OpenAI/AzureOpenAIImpl.Codeunit.al b/src/System Application/App/AI/src/Azure OpenAI/AzureOpenAIImpl.Codeunit.al
index 5ff77fd125..71731dc20f 100644
--- a/src/System Application/App/AI/src/Azure OpenAI/AzureOpenAIImpl.Codeunit.al
+++ b/src/System Application/App/AI/src/Azure OpenAI/AzureOpenAIImpl.Codeunit.al
@@ -263,6 +263,7 @@ codeunit 7772 "Azure OpenAI Impl" implements "AI Service Name"
GenerateChatCompletion(ChatMessages, AOAIChatCompletionParams, AOAIOperationResponse, CallerModuleInfo);
end;
+ [NonDebuggable]
procedure GenerateChatCompletion(var ChatMessages: Codeunit "AOAI Chat Messages"; AOAIChatCompletionParams: Codeunit "AOAI Chat Completion Params"; var AOAIOperationResponse: Codeunit "AOAI Operation Response"; CallerModuleInfo: ModuleInfo)
var
AOAIPolicyParams: Codeunit "AOAI Policy Params";
diff --git a/src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIUserMessage.Codeunit.al b/src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIUserMessage.Codeunit.al
index 7f9db0594f..05addf2cf6 100644
--- a/src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIUserMessage.Codeunit.al
+++ b/src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIUserMessage.Codeunit.al
@@ -21,18 +21,30 @@ codeunit 7783 "AOAI User Message"
/// Adds a text content part to the user message.
///
/// The text content to add.
+ [Scope('OnPrem')]
+#pragma warning disable AS0022
procedure AddTextPart(TextContent: Text)
+#pragma warning restore AS0022
+ var
+ CallerModuleInfo: ModuleInfo;
begin
- AOAIUserMessageImpl.AddTextPart(TextContent);
+ NavApp.GetCallerModuleInfo(CallerModuleInfo);
+ AOAIUserMessageImpl.AddTextPart(TextContent, CallerModuleInfo);
end;
///
/// Adds a file content part to the user message.
///
/// The file data to add (e.g. base64-encoded content).
+ [Scope('OnPrem')]
+#pragma warning disable AS0022
procedure AddFilePart(FileData: Text)
+#pragma warning restore AS0022
+ var
+ CallerModuleInfo: ModuleInfo;
begin
- AOAIUserMessageImpl.AddFilePart(FileData);
+ NavApp.GetCallerModuleInfo(CallerModuleInfo);
+ AOAIUserMessageImpl.AddFilePart(FileData, CallerModuleInfo);
end;
///
diff --git a/src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIUserMessageImpl.Codeunit.al b/src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIUserMessageImpl.Codeunit.al
index 8fdae0b9c9..92cd084937 100644
--- a/src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIUserMessageImpl.Codeunit.al
+++ b/src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIUserMessageImpl.Codeunit.al
@@ -11,15 +11,19 @@ codeunit 7784 "AOAI User Message Impl"
InherentPermissions = X;
var
+ CopilotCapabilityImpl: Codeunit "Copilot Capability Impl";
[NonDebuggable]
ContentParts: JsonArray;
HasFileContent, HasTextContent : Boolean;
+ NotMicrosoftPublisherErr: Label 'This functionality is only available to Microsoft published apps.';
[NonDebuggable]
- procedure AddTextPart(TextContent: Text)
+ procedure AddTextPart(TextContent: Text; CallerModuleInfo: ModuleInfo)
var
TextPartObject: JsonObject;
begin
+ if not CopilotCapabilityImpl.IsPublisherMicrosoft(CallerModuleInfo) then
+ Error(NotMicrosoftPublisherErr);
TextPartObject.Add('type', 'text');
TextPartObject.Add('text', TextContent);
ContentParts.Add(TextPartObject);
@@ -27,11 +31,13 @@ codeunit 7784 "AOAI User Message Impl"
end;
[NonDebuggable]
- procedure AddFilePart(FileData: Text)
+ procedure AddFilePart(FileData: Text; CallerModuleInfo: ModuleInfo)
var
FilePartObject: JsonObject;
FileDataObject: JsonObject;
begin
+ if not CopilotCapabilityImpl.IsPublisherMicrosoft(CallerModuleInfo) then
+ Error(NotMicrosoftPublisherErr);
FileDataObject.Add('file_data', FileData);
FilePartObject.Add('type', 'file');
FilePartObject.Add('file', FileDataObject);