get_last_prompt() returns the most recent model call in the prompt
history: the prompt that was sent, the response, and the model, tokens,
cost and duration. Printing it shows a "Prompt Inspection" block with
Prompt, Response and Metadata sections (long prompts and responses are cut
at 500 characters). Use it to see exactly what a module sent.
Value
A list of class dsprrr_prompt_inspection with prompt (the full
prompt, including the instructions), response, model, tokens_in,
tokens_out, cost (in US dollars, when known), duration_s,
timestamp, source (the module class that made the call),
program_artifact_id and trace_context. If no call has been recorded,
NULL, invisibly, with a message.
See also
Other inspection:
accessors,
clear_prompt_history(),
clear_traces(),
export_traces(),
inspect_history(),
session_cost(),
summarize_traces()
Examples
if (FALSE) { # \dontrun{
qa <- module(signature("question -> answer"))
run(qa, question = "What is 2 + 2?", .llm = ellmer::chat_openai(model = "gpt-6-luna"))
get_last_prompt()
get_last_prompt()$prompt
} # }