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:4thfever Cultivation world simulator StoryTeller

From Leeroopedia
Knowledge Sources
Domains Narrative_Generation, LLM_Applications
Last Updated 2026-10-22 14:00 GMT

Overview

Concrete tool for LLM-driven narrative text generation from factual events using locale-specific templates, provided by the Cultivation World Simulator story teller system.

Description

The StoryTeller class provides static methods for generating story text from factual events via LLM:

  • tell_story: generates a single or dual-actor story. Selects `story_single.txt` or `story_dual.txt` template based on `allow_relation_changes` and actor count. Builds avatar info, world info, lore, and a random story style into the template, calls the LLM, and falls back to `"{event}. {res}."` if the LLM returns empty.
  • tell_gathering_story: generates a multi-actor gathering story using `story_gathering.txt`. Falls back to `events_text` if LLM returns empty.

Templates are locale-specific (loaded from `CONFIG.paths.templates / filename`).

Usage

Import and call these methods when:

  • Story event creation: called by `StoryEventService.maybe_create_story` and `maybe_create_gathering_story`
  • Direct narrative generation: can be called directly for custom storytelling needs

Code Reference

Source Location

Signature

class StoryTeller:
    TEMPLATE_SINGLE_FILE = "story_single.txt"
    TEMPLATE_DUAL_FILE = "story_dual.txt"
    TEMPLATE_GATHERING_FILE = "story_gathering.txt"

    @staticmethod
    async def tell_story(
        event: str,
        res: str,
        *actors: "Avatar",
        prompt: str = "",
        allow_relation_changes: bool = False
    ) -> str:
        """Generate a story from factual event text and result via LLM."""

    @staticmethod
    async def tell_gathering_story(
        gathering_info: str,
        events_text: str,
        details_text: str,
        related_avatars: list["Avatar"],
        prompt: str = ""
    ) -> str:
        """Generate a gathering story via LLM."""

Import

from src.classes.story_teller import StoryTeller

I/O Contract

Inputs (tell_story)

Name Type Required Description
event str Yes Factual event start text
res str Yes Factual event result text
*actors Avatar Yes 1-2 participating actors
prompt str No Enriched story prompt (default "")
allow_relation_changes bool No If True and 2+ actors, uses dual template (default False)

Outputs

Name Type Description
return str LLM-generated story text, or fallback "{event}. {res}." if empty

Usage Examples

Generate Single-Actor Story

from src.classes.story_teller import StoryTeller

story = await StoryTeller.tell_story(
    event="张三 found a rare spirit herb in the cave.",
    res="He successfully harvested it without attracting beasts.",
    avatar,
)
print(story)  # Rich narrative text

Generate Dual-Actor Story

story = await StoryTeller.tell_story(
    event="张三 and 李四 encountered each other at the market.",
    res="They exchanged pleasantries and traded items.",
    avatar_a, avatar_b,
    allow_relation_changes=True,
)

Related Pages

Implements Principle

Required Environments

Uses Heuristics

Page Connections

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