Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

686 B
Raw Blame
"""Formatting utilities for survey summaries."""

from .llm.schema import SurveySummaryResponse


def format_as_markdown(summary: SurveySummaryResponse) -> str:
    """Convert structured summary to markdown format for display."""
    lines = [summary.overview, ""]

    if summary.themes:
        lines.append("**Key Themes:**")
        for theme in summary.themes:
            # frequency is already a percentage string like ">50%", "25-50%", etc.
            lines.append(f"- **{theme.theme}** ({theme.frequency}): {theme.description}")
        lines.append("")

    if summary.key_insight:
        lines.append(f"**Key Insight:** {summary.key_insight}")

    return "\n".join(lines)