A bottle-city engine for simulated fictional worlds with temporal knowledge graph memory.
Project description
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
GodAgentcompiles a user prompt into a structured world blueprintTemporalKGMemorystores relations and events over timeSimulationRunneradvances the world through event applicationLoreGeneratorturns structured memory into readable summariesMockLLMmakes the full pipeline testable without external model callsOpenAICompatibleLLMlets the same pipeline run against an OpenAI-compatible chat APITemporalKGWidgetrenders saved KG snapshots inside notebooks
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/.
examples/notebooks/01_quickstart_world_pipeline.ipynbwalks through world creation, simulation, and lore generationexamples/notebooks/02_temporal_kg_queries.ipynbfocuses on temporal memory queries and retrievalexamples/notebooks/03_temporal_kg_widget.ipynbshows the notebook widget for saved KG snapshotsexamples/notebooks/04_openai_world_pipeline.ipynbruns the same pipeline against a real OpenAI-compatible backend
Current status:
- these notebooks are starter examples for local exploration
- they are designed to run with the current mock pipeline and bundled snapshot data
- the widget notebook requires the optional
widgetsextras - the OpenAI backend notebook expects
OPENAI_API_KEYplus optionalOPENAI_MODELandOPENAI_BASE_URL, which can come from the environment or the repository.env - they are not included in the published wheel, so use a source checkout if you want the bundled notebooks and demo scripts
Docs
A lightweight static documentation site lives under docs/ and is deployed through GitHub Pages.
docs/index.htmldocs/getting-started.htmldocs/architecture.htmldocs/api.html
Real LLM smoke test
Expected environment variables:
OPENAI_API_KEY- optional:
OPENAI_MODEL - optional:
OPENAI_BASE_URL
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:
- clone the repository if you want
examples/demo.py,examples/smoke_openai.py, or the bundled notebooks - run
python3 scripts/check_installed_wheel.pybefore a release to verify the built wheel from a clean environment
Current status:
- the published package is focused on the library itself
- repository extras are maintained as release validation and onboarding material
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kandor-0.1.0.tar.gz.
File metadata
- Download URL: kandor-0.1.0.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3750d56cc7e4b82176738bacdd30e0e0c701ded826aa8b5beed79d6daf7016bb
|
|
| MD5 |
b474a1921bc94785c74fe109789136bd
|
|
| BLAKE2b-256 |
cd124a5572c823f721db31b6301fdee4393868eb7d01089466e479f2831cd37a
|
File details
Details for the file kandor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kandor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
392e60050488bf7d74d030ee57ea78c9e655ea1a28aa2f5d0ccbf7352184b39f
|
|
| MD5 |
6bd0d9c5098aa979c1859634fb492d4d
|
|
| BLAKE2b-256 |
0ad9b00a5d9f7cb3277d3871c800f74c07504a4a312508fc64dd05968dfa0f98
|