summarize_traces() totals a module's traces: the number of calls,
tokens, cost and latency, and the calls per model. Printing the result
gives a short report.
Value
A list of class dsprrr_trace_summary with n_traces,
total_tokens, total_latency_ms and total_cost (in US dollars, NA
when a cost is unknown). For a module with traces, it also has
total_input_tokens, total_output_tokens, total_cached_tokens,
total_duration_s, avg_latency_ms, avg_tokens_per_request,
token_breakdown (input and output totals and their ratio) and
model_usage (a data frame of calls per model).
See also
Other inspection:
accessors,
clear_prompt_history(),
clear_traces(),
export_traces(),
get_last_prompt(),
inspect_history(),
session_cost()
Examples
if (FALSE) { # \dontrun{
qa <- module(signature("question -> answer"))
run(qa, question = "What is 2 + 2?", .llm = ellmer::chat_openai(model = "gpt-6-luna"))
summarize_traces(qa)
} # }