kandor

Kandor

Kandor is a Python library for simulated fictional worlds with temporal knowledge graph memory.

A bottle-city engine for worldbuilding, simulation, and temporal memory.

V1 Demo Features

Install

python3 -m pip install kandor

Optional extras:

python3 -m pip install 'kandor[widgets]'

Quickstart

python3 - <<'PY'
from kandor import WorldBuilder
from kandor.llm.mock import MockLLM

llm = MockLLM(
    responses={
        "god_agent": {
            "premise": "A broken empire of sandglass cities.",
            "genre": "fantasy",
        }
    }
)

builder = WorldBuilder(llm=llm)
blueprint = builder.create_world(prompt="Make a desert empire with unstable time magic.")
print(blueprint.spec)
PY

Notebook Examples

Introduction: Kandor now includes starter Jupyter notebooks for the most common library workflows.

Usage: These notebooks live in the source repository under examples/notebooks/.

Current status:

Docs

A lightweight static documentation site lives under docs/ and is deployed through GitHub Pages.

Real LLM smoke test

Expected environment variables:

Example provider usage:

from kandor.builders.world_builder import WorldBuilder
from kandor.llm.openai import OpenAICompatibleLLM

llm = OpenAICompatibleLLM()
builder = WorldBuilder(llm=llm)
blueprint = builder.create_world(
    prompt="Create a world of fractured moon colonies linked by ritual trade."
)

Temporal KG widget

A notebook widget can visualize a temporal KG snapshot with anywidget and d3.js.

Install optional widget dependencies:

python3 -m pip install 'kandor[widgets]'

Then in a notebook:

from kandor import TemporalKGWidget
widget = TemporalKGWidget('reports/smoke/openai-smoke-kg-2026-03-24.json')
widget

You can also load the snapshot data directly:

from kandor import load_temporal_kg_snapshot

data = load_temporal_kg_snapshot("reports/smoke/openai-smoke-kg-2026-03-24.json")

Minimal Usage

from kandor import LoreGenerator, SimulationRunner, WorldBuilder
from kandor.llm.mock import MockLLM

llm = MockLLM(
    responses={
        "god_agent": {
            "premise": "A broken empire of sandglass cities.",
            "genre": "fantasy",
        }
    }
)

builder = WorldBuilder(llm=llm)
blueprint = builder.create_world(prompt="Make a desert empire with unstable time magic.")
memory = builder.create_memory(blueprint)
runner = SimulationRunner(world=blueprint.spec, memory=memory)
lore = LoreGenerator(llm=llm)

Source Repository Extras

Introduction: The source repository also includes demo scripts, notebooks, and docs for local exploration.

Usage:

Current status: