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 ForumHost generate host speech

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

Overview

Concrete LLM-powered forum moderator that reads agent speeches and generates guidance covering event timeline, viewpoint integration, trend prediction, and discussion direction.

Description

The ForumHost class uses an OpenAI-compatible LLM (default: Qwen3-235B via SiliconFlow) to act as an intelligent forum moderator. Given a list of recent agent speeches (INSIGHT, MEDIA, QUERY), it generates a moderator speech that:

  • Summarizes the event timeline from agent findings
  • Integrates different viewpoints across agents
  • Predicts sentiment trends
  • Suggests discussion directions for agents to explore

The generated speech is capped at 1000 characters and is written to `forum.log` by the LogMonitor, where agents can read it before their next summarization step.

Usage

Import this class when you need an LLM moderator for multi-agent debate. It is called by `LogMonitor._trigger_host_speech()` when the agent speech buffer reaches the threshold.

Code Reference

Source Location

  • Repository: BettaFish
  • File: `ForumEngine/llm_host.py:L27-262`

Signature

class ForumHost:
    def __init__(
        self,
        api_key: str = None,
        base_url: Optional[str] = None,
        model_name: Optional[str] = None
    ):
        """
        Args:
            api_key: Forum host LLM API key (defaults to settings.FORUM_HOST_API_KEY)
            base_url: API base URL (defaults to SiliconFlow endpoint)
            model_name: Model name (defaults to settings.FORUM_HOST_MODEL_NAME, Qwen3-235B)
        """

    def generate_host_speech(self, forum_logs: List[str]) -> Optional[str]:
        """
        Generate moderator speech from agent log lines.

        Args:
            forum_logs: List of formatted log lines
                        (e.g., "[HH:MM:SS] [INSIGHT] content...")

        Returns:
            Formatted host speech string (≤1000 chars), or None on failure
        """

# Module-level convenience function
def generate_host_speech(forum_logs: List[str]) -> Optional[str]:
    """Convenience function that creates ForumHost and calls generate_host_speech."""

Import

from ForumEngine.llm_host import ForumHost, generate_host_speech

I/O Contract

Inputs

Name Type Required Description
forum_logs List[str] Yes Recent agent speech log lines

Outputs

Name Type Description
speech Optional[str] Moderator speech (≤1000 chars) or None if failed

Usage Examples

Generate Moderator Speech

from ForumEngine.llm_host import ForumHost

host = ForumHost()  # Uses settings from .env

logs = [
    "[10:30:15] [INSIGHT] AI教育技术在高校应用广泛,主要集中在线上教学...",
    "[10:31:22] [MEDIA] 搜索到AI教育相关图片和视频,显示在线教育平台增长...",
    "[10:32:10] [QUERY] 最新政策支持AI教育,教育部发布新指导意见...",
    "[10:33:05] [INSIGHT] 情感分析显示公众对AI教育持正面态度,占65%...",
    "[10:34:18] [MEDIA] 多模态数据显示AI教育内容在社交媒体热度上升..."
]

speech = host.generate_host_speech(logs)
if speech:
    print(speech)  # Moderator guidance with timeline, integration, prediction

Related Pages

Implements Principle

Requires Environment

Page Connections

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