dragon_conversations: Multi-turn conversations as training data

View source: R/conversations.R

dragon_conversationsR Documentation

Multi-turn conversations as training data

Description

dragon_map() builds one user turn and one assistant turn per row. When the examples are whole conversations, chat transcripts for instance, use this instead. Each conversation is a list of messages with role and content; it must contain at least one user turn and end with an assistant turn, which is the turn the model learns to produce. Earlier turns are context.

Usage

dragon_conversations(x, name = NULL)

Arguments

x

A list of conversations (each a list of messages), a path to a JSONL file with one ⁠{"messages": [...]}⁠ object per line, or a data frame with a messages list column.

name

Display name. Defaults to the file name.

Value

A dragon_dataset mapped as conversations, usable wherever a prompt and response dataset is: dragon_train(), dragon_bundle(), dragon_step_train().

Examples

convs <- list(
  list(
    list(role = "system", content = "You are a support agent."),
    list(role = "user", content = "My thermostat drops off Wi-Fi."),
    list(role = "assistant", content = "Which router do you use?"),
    list(role = "user", content = "An Eero."),
    list(role = "assistant",
         content = "Eero often band-steers 2.4 GHz devices. Make a 2.4 GHz-only network.")
  )
)
ds <- dragon_conversations(convs)
dragon_preview(ds)

dragonfarm documentation built on Oct. 12, 2026, 5:07 p.m.