|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIO. - OpenRouter AI > AIO.SetMessages |
MiniRobotLanguage (MRL)
AIO.SetMessages|$$JSON
Set Custom Messages Array for Chat Context
Purpose
Sets a custom messages array for chat context, allowing full control over the conversation history sent to the AI. This enables multi-turn conversations with system messages, user messages, and assistant responses in a structured format.
Syntax
AIO.SetMessages|$$JSON
Parameters
$$JSON - A JSON string containing an array of message objects. Each object must have a role (system, user, or assistant) and content field.
Return Value
None. The messages array is stored internally and used for the next AIO.Chat call.
Example
' Build a conversation with system context
$$Messages = {
"role": "system",
"content": "You are a helpful coding assistant."
},{
"role": "user",
"content": "How do I declare a variable in Python?"
},{
"role": "assistant",
"content": "Use the syntax: variable_name = value"
},{
"role": "user",
"content": "Can you show me an example?"
}
' Set the messages array
AIO.SetMessages|$$Messages
' Send the conversation to the AI
AIO.Chat||$$Response
Notes
- Messages must be valid JSON format
- Valid roles are: "system", "user", and "assistant"
- The conversation history affects the AI's responses and token usage
- Use AIO.Chat with empty prompt to continue from the set messages
- Cleared when AIO.Init is called
Related Commands
AIO.Chat - Send chat request
AIO.Init - Initialize AIO system
AIO.SetParTools - Enable/disable parallel tool calling