Skip to contents

Prepends a message (add to beginning of a list) to a list of messages. The role and content will be converted to a list and prepended to the input list.

Usage

prepend_message(content, role = "user", x = NULL, ...)

Arguments

content

The content of the message.

role

The role of the message. Can be "user", "system", "assistant".

x

A list of messages. Default is NULL.

...

Additional arguments such as images.

Value

A list of messages with the new message prepended.

Examples

prepend_message("user", "Hello")
#> [[1]]
#> [[1]]$role
#> [1] "Hello"
#> 
#> [[1]]$content
#> [1] "user"
#> 
#> 
prepend_message("system", "Always respond nicely")
#> [[1]]
#> [[1]]$role
#> [1] "Always respond nicely"
#> 
#> [[1]]$content
#> [1] "system"
#> 
#>