Skip to contents

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.

Usage

get_last_prompt()

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.

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
} # }