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 FirstSummaryNode run

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

Overview

Concrete node that generates a paragraph summary from search results using an LLM, optionally incorporating forum host guidance, shared across all three search engine pipelines.

Description

The FirstSummaryNode is a StateMutationNode that takes a paragraph's title, content, search query, and search results, then calls an LLM to produce a coherent summary. It optionally reads the latest HOST speech from the forum log and incorporates moderator guidance into the summary generation. The output is stored as `paragraph_latest_state` in the pipeline state. This node runs as the first summarization step in each paragraph's research loop.

Usage

Import this node when you need to synthesize search results into a paragraph summary. It runs after the first search results are obtained and before the ReflectionNode identifies gaps.

Code Reference

Source Location

  • Repository: BettaFish
  • Files:
    • `InsightEngine/nodes/summary_node.py:L34-197`
    • `MediaEngine/nodes/summary_node.py:L34-197`
    • `QueryEngine/nodes/summary_node.py:L34-197`

Signature

class FirstSummaryNode(StateMutationNode):
    def __init__(self, llm_client):
        """
        Args:
            llm_client: LLMClient - OpenAI-compatible LLM client
        """

    def run(self, input_data: Any, **kwargs) -> str:
        """
        Call LLM to generate paragraph summary from search results.

        Args:
            input_data: dict with 'title', 'content', 'search_query',
                        'search_results' keys (and optional 'host_speech')

        Returns:
            str: Paragraph summary text (stored as paragraph_latest_state)
        """

    def mutate_state(self, input_data, state, paragraph_index, **kwargs) -> State:
        """
        Generate summary and update state.paragraphs[paragraph_index].research.latest_summary
        """

Import

from InsightEngine.nodes import FirstSummaryNode  # or MediaEngine/QueryEngine

I/O Contract

Inputs

Name Type Required Description
title str Yes Paragraph title from report structure
content str Yes Paragraph content description
search_query str Yes The search query that produced the results
search_results List Yes Search results from the search tool
host_speech str No Latest HOST moderator speech from forum (auto-read)

Outputs

Name Type Description
summary str Paragraph summary text (paragraph_latest_state)

Usage Examples

Generate First Summary

from InsightEngine.nodes import FirstSummaryNode
from InsightEngine.llms import LLMClient

llm = LLMClient(api_key="sk-...", model_name="moonshot-v1-8k", base_url="https://api.moonshot.cn/v1")
node = FirstSummaryNode(llm)

input_data = {
    "title": "技术发展现状",
    "content": "分析AI技术在教育领域的最新进展",
    "search_query": "AI教育技术 2024 最新进展",
    "search_results": [...]  # DBResponse.results list
}

summary = node.run(input_data)
print(summary[:200])  # First 200 chars of the summary

Related Pages

Implements Principle

Requires Environment

Page Connections

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