Implementation:AIScientists Dev WorldSeed GazetteContext
Appearance
| Knowledge Sources | |
|---|---|
| Domains | LLM, Content_Generation |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
Concrete scene-agnostic context builder for gazette generation that loads run data from the event-sourcing stream and assembles a structured LLM context with six sections and a journalism-style system prompt.
Description
The gazette context module (`gazette/context.py`) contains three key functions:
- load_run_data: Reads `meta.json`, `config.yaml`, `stream.jsonl`, and `state_final.json` from a run directory into a dict.
- detect_language: Uses a CJK heuristic on the scene description to determine "zh" or "en".
- build_context: Assembles six sections: SCENE, DRAMATIS PERSONAE, ACTION VOCABULARY, EVENT TIMELINE, FINAL WORLD STATE, AVAILABLE IMAGES. Uses action definitions (not hardcoded names) to format action records.
- build_system_prompt: Creates journalism-style instructions (inverted pyramid, short paragraphs, quotes, concrete facts).
Usage
Import these functions to build gazette LLM context. Called by the gazette API route handler.
Code Reference
Source Location
- Repository: WorldSeed
- File: src/worldseed/gazette/context.py
Signature
def load_run_data(run_id: str) -> dict[str, Any]: ...
def detect_language(config: dict[str, Any]) -> str: ...
def build_context(
data: dict[str, Any], language: str, assets: dict[str, str] | None = None,
) -> str: ...
def build_system_prompt(language: str) -> str: ...
Import
from worldseed.gazette.context import (
load_run_data, detect_language, build_context, build_system_prompt,
)
Usage Examples
from worldseed.gazette.context import load_run_data, build_context, build_system_prompt, detect_language
data = load_run_data("run_001")
language = detect_language(data["config"])
context = build_context(data, language)
system_prompt = build_system_prompt(language)
# Now call LLM with these prompts
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment