insert_message {ollamar} | R Documentation |
Insert message into a list at a specified position
Description
Inserts a message at a specified position in a list of messages. The role and content are converted to a list and inserted into the input list at the given position.
Usage
insert_message(content, role = "user", x = NULL, position = -1, ...)
Arguments
content |
The content of the message. |
role |
The role of the message. Can be "user", "system", "assistant". Default is "user". |
x |
A list of messages. Default is NULL. |
position |
The position at which to insert the new message. Default is -1 (end of list). |
... |
Additional arguments such as images. |
Value
A list of messages with the new message inserted at the specified position.
Examples
messages <- list(
list(role = "system", content = "Be friendly"),
list(role = "user", content = "How are you?")
)
insert_message("INSERT MESSAGE AT THE END", "user", messages)
insert_message("INSERT MESSAGE AT THE BEGINNING", "user", messages, 2)
[Package ollamar version 1.2.1 Index]