knitr::opts_chunk$set(
collapse = TRUE, comment = "#>",
eval = identical(tolower(Sys.getenv("LLMR_RUN_VIGNETTES", "false")), "true")
)A stateful conversation is useful when a later question depends on
earlier instructions or replies. chat_session() retains
that context across turns and provides access to the resulting
conversation history.
The examples use two DeepSeek models and two Groq-hosted models. To
run them, set DEEPSEEK_API_KEY, GROQ_API_KEY,
and LLMR_RUN_VIGNETTES=true in the R environment.
Chat sessions remember context automatically:
schema <- list(
type = "object",
properties = list(
answer = list(type = "string"),
confidence = list(type = "number")
),
required = list("answer", "confidence"),
additionalProperties = FALSE
)
chat_ds$send_structured(
"Return an answer and a confidence score (0-1) about: Why is the sky blue?",
schema
)