Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:666ghj BettaFish DocumentLayoutNode run

From Leeroopedia
Knowledge Sources
Domains Report_Generation, LLM_Prompting, domain:Document_Design
Last Updated 2026-10-08 00:00 GMT

Overview

Concrete node that uses an LLM to design the document's global layout including title, subtitle, table of contents, hero section, and theme color tokens from template sections and multi-source reports.

Description

The DocumentLayoutNode takes parsed template sections, normalized engine reports, forum logs, and the user query, then calls an LLM to produce a document design dict containing: title, subtitle, tocPlan, tocTitle, hero (KPI/metrics section), themeTokens (color palette), and layoutNotes. This design guides the visual and structural aspects of the final report.

Usage

Import this node when you need to plan the visual layout of a report. It runs after template slicing in the ReportEngine pipeline.

Code Reference

Source Location

  • Repository: BettaFish
  • File: `ReportEngine/nodes/document_layout_node.py:L21-208`

Signature

class DocumentLayoutNode(BaseNode):
    def __init__(self, llm_client):
        """Args: llm_client - LLMClient"""

    def run(
        self,
        sections: List[TemplateSection],
        template_markdown: str,
        reports: Dict[str, str],
        forum_logs: str,
        query: str,
        template_overview: Dict[str, Any] | None = None,
    ) -> Dict[str, Any]:
        """
        Generate document layout design.

        Returns:
            Dict with title, subtitle, tocPlan, tocTitle, hero,
            themeTokens, layoutNotes
        """

Import

from ReportEngine.nodes import DocumentLayoutNode

I/O Contract

Inputs

Name Type Required Description
sections List[TemplateSection] Yes Parsed template sections
template_markdown str Yes Full template text
reports Dict[str, str] Yes Normalized engine reports
forum_logs str No Forum debate logs
query str Yes User query

Outputs

Name Type Description
title str Report title
subtitle str Report subtitle
tocPlan List Table of contents plan
hero Dict Hero section (KPIs, metrics)
themeTokens Dict Color palette for rendering

Usage Examples

Generate Layout Design

from ReportEngine.nodes import DocumentLayoutNode
from ReportEngine.llms import LLMClient

llm = LLMClient(api_key="sk-...", model_name="deepseek-chat", base_url="...")
node = DocumentLayoutNode(llm)

design = node.run(
    sections=template_sections,
    template_markdown=template_md,
    reports={"query_engine": "...", "media_engine": "...", "insight_engine": "..."},
    forum_logs="",
    query="武汉大学舆情分析"
)
print(f"Title: {design['title']}")
print(f"Theme: {design['themeTokens']}")

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment