Codeunit 7783 AOAI User Message in 28
- App
- System Application
- Namespace
- System.AI
Versions171819202122232425262728latest
Source2829
Source in 28
src/System Application/App/AI/src/Azure OpenAI/Chat Completion/AOAIUserMessage.Codeunit.al86 lines, Copyright (c) Microsoft Corporation. MIT
// ------------------------------------------------------------------------------------------------
// 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 a user message with structured content parts for multimodal inputs.
/// Use AddTextPart and AddFilePart to build the message content, then pass this codeunit to AOAIChatMessages.AddUserMessage.
/// </summary>
codeunit 7783 "AOAI User Message"
{
Access = Public;
InherentEntitlements = X;
InherentPermissions = X;
var
AOAIUserMessageImpl: Codeunit "AOAI User Message Impl";
/// <summary>
/// Adds a text content part to the user message.
/// </summary>
/// <param name="TextContent">The text content to add.</param>
[Scope('OnPrem')]
#pragma warning disable AS0022
procedure AddTextPart(TextContent: Text)
#pragma warning restore AS0022
var
CallerModuleInfo: ModuleInfo;
begin
NavApp.GetCallerModuleInfo(CallerModuleInfo);
AOAIUserMessageImpl.AddTextPart(TextContent, CallerModuleInfo);
end;
/// <summary>
/// Adds a file content part to the user message.
/// </summary>
/// <param name="FileData">The file data to add (e.g. base64-encoded content).</param>
[Scope('OnPrem')]
#pragma warning disable AS0022
procedure AddFilePart(FileData: Text)
#pragma warning restore AS0022
var
CallerModuleInfo: ModuleInfo;
begin
NavApp.GetCallerModuleInfo(CallerModuleInfo);
AOAIUserMessageImpl.AddFilePart(FileData, CallerModuleInfo);
end;
/// <summary>
/// Gets the assembled content parts as a JsonArray.
/// </summary>
/// <returns>The content parts JsonArray.</returns>
[NonDebuggable]
internal procedure GetContentParts(): JsonArray
begin
exit(AOAIUserMessageImpl.GetContentParts());
end;
/// <summary>
/// Get if the User Message has been set.
/// </summary>
internal procedure IsSet(): Boolean
begin
exit(AOAIUserMessageImpl.HasFilePart() or AOAIUserMessageImpl.HasTextPart());
end;
/// <summary>
/// Get if the user message contains file part.
/// This is used to determine if the message is compatible with the deployment model, as some models do not support file content.
/// </summary>
internal procedure HasFilePart(): Boolean
begin
exit(AOAIUserMessageImpl.HasFilePart());
end;
/// <summary>
/// Get if the user message contains text part.
/// </summary>
internal procedure HasTextPart(): Boolean
begin
exit(not AOAIUserMessageImpl.HasFilePart());
end;
}
Procedures, 6
| Name | Parameters | Returns | Access | Obsolete |
|---|---|---|---|---|
| AddTextPart | (Text) | public | - | |
| AddFilePart | (Text) | public | - | |
| GetContentParts | () | JsonArray | internal | - |
| IsSet | () | Boolean | internal | - |
| HasFilePart | () | Boolean | internal | - |
| HasTextPart | () | Boolean | internal | - |