View source: R/response_record.R
| llm_response_record | R Documentation |
Turns a single llmr_response (or a caught error) into a one-row tibble with
the columns the LLMR family treats as the response contract:
response_text, response_id, provider, model, model_version,
finish_reason, sent_tokens, rec_tokens, total_tokens,
reasoning_tokens, cached_tokens, success, error_message,
duration_s, created_at, and request_hash. It is the canonical flattening
path: reuse it rather than reaching into a response's fields, so a sealed
archive or an audit reconstructs the same columns everywhere.
llm_response_record(
x,
request = NULL,
config = NULL,
error = NULL,
started_at = NULL,
ended_at = NULL
)
x |
An llmr_response. If |
request |
The messages or prompt that produced |
config |
The |
error |
Optional caught condition to record instead of (or alongside) a missing response; when supplied, the row is a failure carrying its message. |
started_at, ended_at |
Optional |
A failure is a record, not a gap. Pass a caught condition (or any non-response
object) as error, or as x, and the row carries success = FALSE with the
message in error_message; the call is never silently dropped.
A one-row tibble with the response-contract columns.
llm_request_hash(), llmr_response, llm_usage()
r <- structure(
list(text = "Hello!", provider = "openai", model = "demo",
model_version = NA_character_, finish_reason = "stop",
usage = list(sent = 12L, rec = 5L, total = 17L,
reasoning = NA_integer_, cached = NA_integer_),
response_id = "resp_123", duration_s = 0.012),
class = "llmr_response")
llm_response_record(r)
# a caught error is a row too:
llm_response_record(simpleError("boom"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.