Add user message to message history
updatedMessages = addUserMessage(messages,content)
updatedMessages = addUserMessage(messages,content)
adds a user message to the messageHistory
object messages
and specifies the content of the message.
Initialize the message history.
messages = messageHistory;
Add a user message to the message history.
messages = addUserMessage(messages,"Where is Natick located?");
messages.Messages{1}
ans = struct with fields:
role: "user"
content: "Where is Natick located?"
messageHistory
object
Message history, specified as a messageHistory
object.
string scalar | character vector
Message content, specified as a string scalar or character vector. The content must be nonempty.
messageHistory
object
Updated message history, specified as a messageHistory
object. The updated message history includes a new structure array with these fields:
- role —
"user"
- content — Set by the
content
input argument
messageHistory
| generate
| openAIChat
| ollamaChat
| azureChat
| addSystemMessage
| addUserMessageWithImage
| addToolMessage
| addResponseMessage
Copyright 2024 The MathWorks, Inc.