Skip to main content

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

  • GodAgent compiles a user prompt into a structured world blueprint
  • TemporalKGMemory stores relations and events over time
  • SimulationRunner advances the world through event application
  • LoreGenerator turns structured memory into readable summaries
  • MockLLM makes the full pipeline testable without external model calls
  • OpenAICompatibleLLM lets the same pipeline run against an OpenAI-compatible chat API
  • TemporalKGWidget renders 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.ipynb walks through world creation, simulation, and lore generation
  • examples/notebooks/02_temporal_kg_queries.ipynb focuses on temporal memory queries and retrieval
  • examples/notebooks/03_temporal_kg_widget.ipynb shows the notebook widget for saved KG snapshots
  • examples/notebooks/04_openai_world_pipeline.ipynb runs 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 widgets extras
  • the OpenAI backend notebook expects OPENAI_API_KEY plus optional OPENAI_MODEL and OPENAI_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.html
  • docs/getting-started.html
  • docs/architecture.html
  • docs/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.py before 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kandor-0.1.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kandor-0.1.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

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

Hashes for kandor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3750d56cc7e4b82176738bacdd30e0e0c701ded826aa8b5beed79d6daf7016bb
MD5 b474a1921bc94785c74fe109789136bd
BLAKE2b-256 cd124a5572c823f721db31b6301fdee4393868eb7d01089466e479f2831cd37a

See more details on using hashes here.

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

Hashes for kandor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 392e60050488bf7d74d030ee57ea78c9e655ea1a28aa2f5d0ccbf7352184b39f
MD5 6bd0d9c5098aa979c1859634fb492d4d
BLAKE2b-256 0ad9b00a5d9f7cb3277d3871c800f74c07504a4a312508fc64dd05968dfa0f98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page