Turn | R Documentation |
Every conversation with a chatbot consists of pairs of user and assistant
turns, corresponding to an HTTP request and response. These turns are
represented by the Turn
object, which contains a list of Contents representing
the individual messages within the turn. These might be text, images, tool
requests (assistant only), or tool responses (user only).
Note that a call to $chat()
and related functions may result in multiple
user-assistant turn cycles. For example, if you have registered tools,
ellmer will automatically handle the tool calling loop, which may result in
any number of additional cycles. Learn more about tool calling in
vignette("tool-calling")
.
Turn(role, contents = list(), json = list(), tokens = c(0, 0))
role |
Either "user", "assistant", or "system". |
contents |
A list of Content objects. |
json |
The serialized JSON corresponding to the underlying data of the turns. Currently only provided for assistant. This is useful if there's information returned by the provider that ellmer doesn't otherwise expose. |
tokens |
A numeric vector of length 2 representing the number of input and output tokens (respectively) used in this turn. Currently only recorded for assistant turns. |
An S7 Turn
object
Turn(role = "user", contents = list(ContentText("Hello, world!")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.