| 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).
UserTurn, AssistantTurn, and SystemTurn are specialized subclasses
of Turn for different types of conversation turns. AssistantTurn includes
additional metadata about the API response.
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 = NULL, contents = list(), tokens = NULL)
UserTurn(contents = list())
SystemTurn(contents = list())
AssistantTurn(
contents = list(),
json = list(),
tokens = c(NA_real_, NA_real_, NA_real_),
cost = NA_real_,
duration = NA_real_,
finish_reason = NA_character_
)
AssistantPartialTurn(
contents = list(),
json = list(),
tokens = c(NA_real_, NA_real_, NA_real_),
cost = NA_real_,
duration = NA_real_,
finish_reason = NA_character_,
reason = "interrupted"
)
An S7 Turn object
An S7 AssistantTurn object
An S7 AssistantPartialTurn object
UserTurn(list(ContentText("Hello, world!")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.