% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/statcan_chat.R
\name{statcan_chat_continue}
\alias{statcan_chat_continue}
\title{Continue a \code{statcan_chat()} conversation}
\usage{
statcan_chat_continue(result, message, api_key = NULL)
}
\arguments{
\item{result}{A \code{statcan_chat_result} returned by \code{\link[=statcan_chat]{statcan_chat()}} (or by a
previous \code{statcan_chat_continue()} call).}

\item{message}{One non-empty character string: your follow-up to the model.}

\item{api_key}{API key, re-resolved exactly as in \code{\link[=statcan_chat]{statcan_chat()}}. Defaults
to \code{Sys.getenv("STATCANR_LLM_API_KEY")}, then the provider's native
variable. Not read from \code{options()}.}
}
\value{
An updated \code{statcan_chat_result} with the same \code{candidates}, a new
\code{explanation} and \code{clarifying_question}, and an extended conversation.
}
\description{
Sends a follow-up \code{message} -- typically an answer to the
\code{clarifying_question} from a previous turn -- and returns an updated
result. The follow-up stays scoped to the \strong{same candidate tables} that
\code{\link[=statcan_chat]{statcan_chat()}} already found: it never re-runs \code{\link[=statcan_find]{statcan_find()}} and the
model still never proposes a table number of its own. To search the
catalogue again, start a new conversation with \code{\link[=statcan_chat]{statcan_chat()}}.
}
\details{
The returned object is itself continuable, so you can chain several
follow-ups. The API key is re-resolved on each call (from the \code{api_key}
argument, the \code{STATCANR_LLM_API_KEY} environment variable, or the
provider's native variable) because, for safety, it is never stored in the
result object.
}
\examples{
\dontrun{
Sys.setenv(ANTHROPIC_API_KEY = "sk-ant-...")
chat <- statcan_chat(
  "R&D spending in Quebec",
  provider = "anthropic", model = "claude-opus-4-8"
)
chat$clarifying_question

# Answer it and keep the same shortlist of candidates. Reassigning the same
# variable keeps the latest turn; you never need r1/r2/r3-style names.
chat <- statcan_chat_continue(chat, "annual data, since 2015")
chat$explanation

# Chain another follow-up the same way:
chat <- statcan_chat_continue(chat, "just the total, not by industry")
}
}
