Kandor is a Python library for simulated fictional worlds with temporal knowledge graph memory.
A bottle-city engine for worldbuilding, simulation, and temporal memory.
GodAgent compiles a user prompt into a structured world blueprintTemporalKGMemory stores relations and events over timeSimulationRunner advances the world through event applicationLoreGenerator turns structured memory into readable summariesMockLLM makes the full pipeline testable without external model callsOpenAICompatibleLLM lets the same pipeline run against an OpenAI-compatible chat APITemporalKGWidget renders saved KG snapshots inside notebookspython3 -m pip install kandor
Optional extras:
python3 -m pip install 'kandor[widgets]'
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
Introduction: Kandor now includes starter Jupyter notebooks for the most common library workflows.
Usage:
These notebooks live in the source repository under examples/notebooks/.
examples/notebooks/01_quickstart_world_pipeline.ipynb walks through world creation, simulation, and lore generationexamples/notebooks/02_temporal_kg_queries.ipynb focuses on temporal memory queries and retrievalexamples/notebooks/03_temporal_kg_widget.ipynb shows the notebook widget for saved KG snapshotsexamples/notebooks/04_openai_world_pipeline.ipynb runs the same pipeline against a real OpenAI-compatible backendCurrent status:
widgets extrasOPENAI_API_KEY plus optional OPENAI_MODEL and OPENAI_BASE_URL, which can come from the environment or the repository .envA lightweight static documentation site lives under docs/ and is deployed through GitHub Pages.
docs/index.htmldocs/getting-started.htmldocs/architecture.htmldocs/api.htmlExpected environment variables:
OPENAI_API_KEYOPENAI_MODELOPENAI_BASE_URLExample 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."
)
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")
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)
Introduction: The source repository also includes demo scripts, notebooks, and docs for local exploration.
Usage:
examples/demo.py, examples/smoke_openai.py, or the bundled notebookspython3 scripts/check_installed_wheel.py before a release to verify the built wheel from a clean environmentCurrent status: