Codeunit "AOAI Chat Messages"
Helper functions for the AOAI Chat Message table.
Properties
Name | Value |
---|---|
Access | Public |
InherentEntitlements | X |
InherentPermissions | X |
Methods
SetPrimarySystemMessage
Sets the system message which is always at the top of the chat messages history provided to the model.
[NonDebuggable]
procedure SetPrimarySystemMessage(Message: SecretText)
Parameters
Name | Type | Description |
---|---|---|
Message | SecretText |
The primary system message. |
AddSystemMessage
Adds a system message to the chat messages history.
[NonDebuggable]
procedure AddSystemMessage(NewMessage: Text)
Parameters
Name | Type | Description |
---|---|---|
NewMessage | Text |
The message to add. |
AddUserMessage
Adds a user message to the chat messages history.
[NonDebuggable]
procedure AddUserMessage(NewMessage: Text)
Parameters
Name | Type | Description |
---|---|---|
NewMessage | Text |
The message to add. |
AddUserMessage
Adds a user message to the chat messages history.
[NonDebuggable]
procedure AddUserMessage(NewMessage: Text, NewName: Text[2048])
Parameters
Name | Type | Description |
---|---|---|
NewMessage | Text |
The message to add. |
NewName | Text[2048] |
The name of the user. |
AddAssistantMessage
Adds a assistant message to the chat messages history.
[NonDebuggable]
procedure AddAssistantMessage(NewMessage: Text)
Parameters
Name | Type | Description |
---|---|---|
NewMessage | Text |
The message to add. |
AddToolMessage
Adds a tool result to the chat messages history.
[NonDebuggable]
procedure AddToolMessage(ToolCallId: Text, FunctionName: Text, FunctionResult: Text)
Parameters
Name | Type | Description |
---|---|---|
ToolCallId | Text |
The id of the tool call. |
FunctionName | Text |
The name of the called function. |
FunctionResult | Text |
The result of the tool call. |
ModifyMessage
Modifies a message in the chat messages history.
[NonDebuggable]
procedure ModifyMessage(Id: Integer, NewMessage: Text, NewRole: Enum "AOAI Chat Roles", NewName: Text[2048])
Parameters
Name | Type | Description |
---|---|---|
Id | Integer |
Id of the message. |
NewMessage | Text |
The new message. |
NewRole | System.AI."AOAI Chat Roles" |
The new role. |
NewName | Text[2048] |
The new name. |
DeleteMessage
Deletes a message from the chat messages history.
[NonDebuggable]
procedure DeleteMessage(Id: Integer)
Parameters
Name | Type | Description |
---|---|---|
Id | Integer |
Id of the message. |
GetHistory
Gets the history of chat messages.
[NonDebuggable]
procedure GetHistory(): List of [Text]
Returns
Type | Description |
---|---|
List of [Text] |
List of chat messages. |
GetHistoryNames
Gets the history names of chat messages.
[NonDebuggable]
procedure GetHistoryNames(): List of [Text[2048]]
Returns
Type | Description |
---|---|
List of [Text[2048]] |
List of names of chat messages. |
GetHistoryRoles
Gets the history roles of chat messages.
[NonDebuggable]
procedure GetHistoryRoles(): List of [Enum "AOAI Chat Roles"]
Returns
Type | Description |
---|---|
List of [Enum System.AI."AOAI Chat Roles"] |
List of roles of chat messages. |
GetLastMessage
Gets the last chat message.
[NonDebuggable]
procedure GetLastMessage(): Text
Returns
Type | Description |
---|---|
Text |
The last chat message. |
GetLastRole
Gets the last chat message role.
[NonDebuggable]
procedure GetLastRole(): Enum "AOAI Chat Roles"
Returns
Type | Description |
---|---|
System.AI."AOAI Chat Roles" |
The last chat message role. |
GetLastName
Gets the last chat message name.
[NonDebuggable]
procedure GetLastName(): Text[2048]
Returns
Type | Description |
---|---|
Text[2048] |
The last chat message name. |
GetLastToolCalls
Gets a copy of the last chat message tool calls array.
[NonDebuggable]
procedure GetLastToolCalls(): JsonArray
Returns
Type | Description |
---|---|
JsonArray |
The last tool calls array. |
SetHistoryLength
Set the length of history that is used by the model.
[NonDebuggable]
procedure SetHistoryLength(NewLength: Integer)
Parameters
Name | Type | Description |
---|---|---|
NewLength | Integer |
The new length. |
GetHistoryTokenCount
Gets the number of tokens used by the primary system messages and all other messages.
[NonDebuggable]
procedure GetHistoryTokenCount(): Integer
Returns
Type | Description |
---|---|
Integer |
AddTool
Obsolete
This element will become obsolete from version 25.0. Use AddTool that takes in an AOAI Function interface.
Appends a Tool to the payload.
[NonDebuggable]
[Obsolete(Use AddTool that takes in an AOAI Function interface.,25.0)]
procedure AddTool(NewTool: JsonObject)
Parameters
Name | Type | Description |
---|---|---|
NewTool | JsonObject |
The Tool to be added to the payload. |
Remarks
See more details here: https://go.microsoft.com/fwlink/?linkid=2254538
ModifyTool
Obsolete
This element will become obsolete from version 25.0. Deprecated with no replacement. Use DeleteFunctionTool and AddTool.
Modifies a Tool in the list of Tool.
[NonDebuggable]
[Obsolete(Deprecated with no replacement. Use DeleteFunctionTool and AddTool.,25.0)]
procedure ModifyTool(Id: Integer, NewTool: JsonObject)
Parameters
Name | Type | Description |
---|---|---|
Id | Integer |
Id of the message. |
NewTool | JsonObject |
The new Tool. |
DeleteTool
Obsolete
This element will become obsolete from version 25.0. Use DeleteFunctionTool that takes in a function name instead.
Deletes a Tool from the list of Tool.
[Obsolete(Use DeleteFunctionTool that takes in a function name instead.,25.0)]
procedure DeleteTool(Id: Integer)
Parameters
Name | Type | Description |
---|---|---|
Id | Integer |
Id of the Tool. |
AddTool
Adds a function to the payload.
procedure AddTool(Function: Interface "AOAI Function")
Parameters
Name | Type | Description |
---|---|---|
Function | System.AI."AOAI Function" |
The function to be added |
DeleteFunctionTool
Deletes a Function from the list of Functions.
procedure DeleteFunctionTool(Name: Text): Boolean
Parameters
Name | Type | Description |
---|---|---|
Name | Text |
Name of the Function. |
Returns
Type | Description |
---|---|
Boolean |
ClearTools
Remove all tools.
procedure ClearTools()
GetFunctionTool
Gets the function associated with the specified name.
procedure GetFunctionTool(Name: Text, var Function: Interface "AOAI Function"): Boolean
Parameters
Name | Type | Description |
---|---|---|
Name | Text |
Name of the function to get. |
Function | System.AI."AOAI Function" |
Name of the function to get. |
Returns
Type | Description |
---|---|
Boolean |
The function codeunit. |
GetFunctionTools
Gets the list of names of Function Tools that have been added.
procedure GetFunctionTools(): List of [Text]
Returns
Type | Description |
---|---|
List of [Text] |
List of function tool names. |
GetTools
Obsolete
This element will become obsolete from version 25.0. Use GetFunctionTool() that takes in a function name and returns the interface.
Gets the list of Tools.
[NonDebuggable]
[Obsolete(Use GetFunctionTool() that takes in a function name and returns the interface.,25.0)]
procedure GetTools(): List of [JsonObject]
Returns
Type | Description |
---|---|
List of [JsonObject] |
List of Tools. |
ToolsExists
Checks if at least one Tools exists in the list.
procedure ToolsExists(): Boolean
Returns
Type | Description |
---|---|
Boolean |
True if Tools exists, false otherwise. |
SetAddToolsToPayload
Sets the Tools to be added to the payload.
procedure SetAddToolsToPayload(AddToolsToPayload: Boolean)
Parameters
Name | Type | Description |
---|---|---|
AddToolsToPayload | Boolean |
True if Tools is to be added to the payload, false otherwise. |
SetToolChoice
Sets the Tool choice, which allow model to determine how Tools should be called.
[NonDebuggable]
procedure SetToolChoice(ToolChoice: Text)
Parameters
Name | Type | Description |
---|---|---|
ToolChoice | Text |
Remarks
See more details here: https://go.microsoft.com/fwlink/?linkid=2254538
SetFunctionAsToolChoice
Sets the function as the tool choice to be called.
[NonDebuggable]
procedure SetFunctionAsToolChoice(FunctionName: Text)
Parameters
Name | Type | Description |
---|---|---|
FunctionName | Text |
The function name parameter. |
Remarks
See more details here: https://go.microsoft.com/fwlink/?linkid=2254538
SetFunctionAsToolChoice
Sets the function as the tool choice to be called.
[NonDebuggable]
procedure SetFunctionAsToolChoice(Function: Interface "AOAI Function")
Parameters
Name | Type | Description |
---|---|---|
Function | System.AI."AOAI Function" |
The function codeunit. |
Remarks
See more details here: https://go.microsoft.com/fwlink/?linkid=2254538
GetToolChoice
Gets the Tool choice parameter.
[NonDebuggable]
procedure GetToolChoice(): Text
Returns
Type | Description |
---|---|
Text |
The Tool choice parameter. |
SetToolInvokePreference
Sets the tool invocation preference, controls how a tool calls response should be handled.
procedure SetToolInvokePreference(AOAIToolInvokePreference: Enum "AOAI Tool Invoke Preference")
Parameters
Name | Type | Description |
---|---|---|
AOAIToolInvokePreference | System.AI."AOAI Tool Invoke Preference" |
Remarks
The default behavior is to execute the tools and append the results to the chat history.
GetToolInvokePreference
Gets the tool invocation preference, controls how a tool calls response should be handled.
procedure GetToolInvokePreference(): Enum "AOAI Tool Invoke Preference"
Returns
Type | Description |
---|---|
System.AI."AOAI Tool Invoke Preference" |