Skip to content

Latest commit

 

History

History
66 lines (37 loc) · 1.67 KB

addUserMessage.md

File metadata and controls

66 lines (37 loc) · 1.67 KB

addUserMessage

Add user message to message history

updatedMessages = addUserMessage(messages,content)

Description

updatedMessages = addUserMessage(messages,content) adds a user message to the messageHistory object messages and specifies the content of the message.

Examples

Add User Message to Message History

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?"

Input Arguments

messages — Message history

messageHistory object

Message history, specified as a messageHistory object.

content — Message content

string scalar | character vector

Message content, specified as a string scalar or character vector. The content must be nonempty.

Output Argument

updatedMessages — Updated message history

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

See Also

messageHistory | generate | openAIChat | ollamaChat | azureChat | addSystemMessage | addUserMessageWithImage | addToolMessage | addResponseMessage

Copyright 2024 The MathWorks, Inc.