Class LlmOptimisationCsvRenderer

java.lang.Object
org.mockserver.llm.analysis.LlmOptimisationCsvRenderer

public class LlmOptimisationCsvRenderer extends Object
Renders an LlmOptimisationReport to CSV — a third export format alongside the JSON bundle and the Markdown brief. The CSV is intended for spreadsheets and data pipelines: it is stable, deterministic, and properly escaped (a field containing a comma, double-quote, carriage return, or newline is wrapped in double quotes with embedded quotes doubled, per RFC 4180).

The output has two sections separated by a blank line:

  1. Per-call rows — one row per captured call (the headline per-call numbers: provider/model, token breakdown, cost, latency, tool calls, finish reason).
  2. Totals/summary — a single section,metric,value table carrying the aggregate LlmOptimisationReport.Totals and the headline LlmOptimisationReport.Verdict figures.
An empty report renders the per-call header row (no data rows) followed by the totals section with zeros, so the output is always a valid, header-bearing CSV.

Pure — no behaviour, no network, no LLM. The column set is documented in docs/code/llm-mocking.md; it is additive to (not a substitute for) the JSON bundle, so it is not a frozen wire contract.

  • Constructor Details

    • LlmOptimisationCsvRenderer

      public LlmOptimisationCsvRenderer()
  • Method Details

    • render

      public String render(LlmOptimisationReport report)
      Render the report to CSV. A null report renders an empty header-only CSV (so callers never have to null-check the result).