Skip to main content

Ketju

Ketju is a small RAG-focused codebase for experimenting with document ingestion and question answering. Its goal is to be a lightweight RAG engine enabling rapid prototyping, experimentation, and iteration.

Installation

Using uv (recommended)

uv sync

Install extras as needed:

uv sync --extra rag
uv sync --extra pgvector
uv sync --extra docling
uv sync --extra agent
uv sync --extra agui
uv sync --extra observability
uv sync --extra examples
uv sync --extra dev

Examples

Chat with pdf's

paste in file paths you paths in the conversation. Launch via.

uv run python -m ketju.examples.basic_usage

Chat with docs using pgvector

➜  ketju git:(main) uv run python -m ketju.examples.pgvector_example --database-url "postgresql://postgres:admin123@127.0.0.1:5432/ketju_db"

Starting the agent...

You can ask questions about contents in pdf files, just paste the path to the file in the chat.

ketju-agent ➤ compare the time travel properties of docs/interdimensional-systems/Infini
te_Improbability_Drive_Technical_Manual.pdf and docs/interdimensional-systems/Flux_Capac
itor_Technical_Reference_Manual.pdf present tehcnical specs in a table

Below is a comparative table of the time travel properties and technical specifications 
of the Infinite Improbability Drive and the Flux Capacitor:                             

                                                                                        
                           Infinite Improbability Drive                                 
  Specification            (IID)                          Flux Capacitor                
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 
  Functionality            Probabilistic                  Temporal Displacement         
                           Faster-Than-Light Propulsion                                 
  Transit Duration         0.8 to 1.3 seconds (nominal    Temporal energy delivery      
                           1.0 second)                    within 2.3 milliseconds       
  Improbability Index      10^6:1 to 10^24:1              N/A                           
  Quantum Field Density    4.2e9 to 9.5e9 J/m³            Chroniton Flux Density:       
                                                          3.6e12 particles/cm³          
  Reality Phase Variance   0.002 to 0.0005 Δφ             N/A                           
  Causality Drift          ±0.05 to ±1.2 milliseconds     N/A                           
  Power Requirements       Peak: 2.8e15 Joules;           Nominal Input: 1.21           
                           Sustained: 3.5e12 Watts        Gigawatts                     
  Cooling Medium           N/A                            Liquid Nitrogen               
  Weight                   N/A                            15.4 kg                       
  Housing Material         N/A                            Reinforced Titanium Alloy     
  Dimensions               N/A                            450 x 320 x 150 mm            
  Warnings                 Risk of uncontrolled           Improper synchronization can  
                           metaphysical side effects      lead to spacetime shear       
                                                          events or disintegration      
  Primary Risk Vector      Reality Instability            Causality Disruption          
                                                                                        

### Key Observations:

 • The IID operates based on improbability levels and focuses on navigation through     
   controlled quantum fields, while the Flux Capacitor is centered around achieving time
   travel via temporal displacement.                                                    
 • The IID does not provide precise time travel capabilities, whereas the Flux Capacitor
   requires a specific speed and energy input to achieve temporal displacement with high
   accuracy.                                                                            
 • The IID emphasizes energy at a much higher scale compared to the Flux Capacitor,     
   which requires relatively lower energy for its operations.                           

Let me know if you need any more information or additional comparisons!                 
ketju-agent ➤

AG-UI

Start backend

uv run python -m ketju.examples.agui_agent

or

uv run python -m ketju.examples.agui_agent --path=a/path/to/a/folder/or/pdf/file

and then start the frontend

cd ui
pnpm install
next dev

Using pip (fallback)

pip install -e .
pip install -e '.[rag]'

Running examples

Examples are available as importable modules under ketju.examples:

uv run python -m ketju.examples.basic_usage
uv run python -m ketju.examples.rag_comparison
uv run python -m ketju.examples.agui
uv run python -m ketju.examples.pgvector_example --database-url "postgresql://postgres:password@127.0.0.1:5432/ketju_db"

An instrumentation demo that prints spans to the console:

uv sync --extra rag --extra observability
uv run python -m ketju.examples.instrumentation_demo

To reduce noisy third-party logs while using the interactive CLI:

uv run python -m ketju.examples.basic_usage --log-level WARNING

To see all logs again:

uv run python -m ketju.examples.basic_usage --no-quiet

The top-level examples/ scripts remain as thin wrappers for convenience:

uv run python examples/basic_usage.py

Development

Tests

uv run pytest

With coverage (requires pytest-cov):

pytest --cov=ketju --cov-report=term-missing

Linting

uv run ruff check src tests

Project layout

ketju/
├── src/ketju/               # library code
├── tests/                   # unit tests (no optional deps required)
├── examples/                # wrapper scripts + docs
└── pyproject.toml           # metadata + dependency groups (extras)

Metadata

Release files for ketju 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ketju 0.1.1
File Size Uploaded Provenance
ketju-0.1.1.tar.gz 360.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ketju 0.1.1
File Interpreter ABI Platform
ketju-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 408.1 kB

Release files / ketju-0.1.1.tar.gz

Download URL ketju-0.1.1.tar.gz
Size 360.2 kB
Tags Source
SHA-256 checksum
How to use checksums
620024949a395a54507bc081f36908b7194d4eae831cd5180c475869abc165de
BLAKE2b-256 checksum
How to use checksums
5da78dcf7a747bd04369fd93cf00f9860b48327b0303b4a2a53747afb76c833c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 20, 2026.

Transparency log

Release files / ketju-0.1.1-py3-none-any.whl

Download URL ketju-0.1.1-py3-none-any.whl
Size 47.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00751b719d7e70f40613333e689caeb36502ad006d739523e40299071b24cb0e
BLAKE2b-256 checksum
How to use checksums
9f1b3613596f5e2536421e367d03e3a42ddfe527130e288837ce94af337b7060
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 20, 2026.

Transparency log

Security for ketju 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ketju-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page