Skip to content

latent.stats.summary

LLM-based textual summary generation for StatisticalReport.

Lives in latent.stats so any flow can call it without taking on agent or runtime dependencies. The intended consumer pattern is:

from latent.stats.summary import generate_report_summary
report.summary = await generate_report_summary(report, summary_model, label=...)

Returns "" and logs a warning on any failure — summarization is best-effort and never raises.

Functions

generate_report_summary

generate_report_summary(report: StatisticalReport, summary_model: str, label: str | None = None, max_tokens: int = 4096, temperature: float = 0.3) -> str

Return a 3-5 sentence summary of report, or "" on failure.

Args: report: The StatisticalReport to summarize. summary_model: A litellm model identifier (e.g. "gemini/gemini-2.5-pro" or "anthropic/claude-sonnet-4"). label: Optional human-readable label for the report (e.g. flow name). max_tokens: Token budget. Defaults to 4096; thinking models like Gemini 2.5 Pro consume part of this on internal reasoning, so keep it generous. temperature: Sampling temperature.