Framework for collecting and managing LLM context
Project description
llm-kelt
Knowledge · Embedding · Learning · Training
Persistent memory and fine-tuning data for LLM applications, backed by Postgres.
Store the things an LLM needs to know or learn from — facts, feedback, preferences, predictions, directives — under an isolation key. Retrieve them for prompt injection or RAG. Export them to DPO/SFT/classifier datasets. Train LoRA/DPO/Prompt adapters from the exported data.
Requirements
- Python 3.11+
- PostgreSQL 16+ with the
vectorextension (pgvector) - For training: CUDA GPU (or MPS on Apple Silicon)
Install
pip install llm-kelt # runtime
pip install llm-kelt[training] # + torch / transformers / peft / trl
Minimal example
from appinfra.config import Config
from appinfra.log import LogConfig, LoggerFactory
from llm_kelt import ClientContext, ClientFactory
from llm_kelt.inference import ContextBuilder
config = Config("etc/llm-kelt.yaml")
lg = LoggerFactory.create_root(LogConfig.from_params(level="warning"))
kelt = ClientFactory(lg).create_from_config(
context=ClientContext(context_key="my-agent"),
config=config,
)
kelt.atomic.assertions.add("Timezone: UTC", category="settings")
kelt.atomic.assertions.add("Prefers concise, code-first answers", category="style")
system_prompt = ContextBuilder(kelt.atomic.assertions).build_system_prompt(
base_prompt="You are a helpful assistant.",
)
# → "You are a helpful assistant.\n\n## About the user:\n- Timezone: UTC\n- ..."
That's the whole shape: put things in under a context_key, pull them back out grouped for
prompt injection. Everything else (RAG, feedback, preferences, training) builds on the same
model.
Where to go next
- Quickstart — 5 minutes from install to first RAG query.
- Concepts — context keys, schemas, atomic vs KG. Read once before the tutorials.
- Atomic memory — the seven fact clients (assertions, feedback, preferences, predictions, directives, interactions, solutions) and how they relate.
- Context & RAG — embedding facts, semantic search,
ContextQuery. - Conversation — multi-turn sessions, token accounting, compaction, storage.
- Training — manifest workflow, LoRA/DPO/SFT/Prompt, exports, adapter registry.
- Knowledge graph — entities, aliases, hierarchical scopes.
- Multi-schema —
SchemaMode,with_schema(), isolation. - CLI reference —
kelt atomic|proxy|train|session. - Glossary — project-specific terms.
Configuration
The library reads its config from etc/llm-kelt.yaml. Key sections:
dbs:
main:
url: postgresql://user:pass@localhost:5432/llm_kelt
extensions: [vector]
llm:
default_backend: local
backends:
local:
base_url: http://localhost:8000/v1
model: default
embedding:
type: openai
base_url: http://localhost:8001/v1
model: text-embedding-3-small
kelt:
adapters:
lora:
base_path: ~/models/adapters
llm, embedding, and kelt.adapters are only required for the subsystems that use them
(ContextQuery, RAG, and training respectively).
Examples
Runnable scripts in examples/:
01_facts_and_context.py— assertions +ContextBuilder.02_rag_retrieval.py— embeddings,search_similar,ContextQuerywith RAG.03_training_export.py— feedback + preferences → DPO/SFT/classifier JSONL.04_lora_training.py— end-to-end LoRA training.05_conversation.py—Conversation, compaction,FileSessionStorage.
License
Apache 2.0
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
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 llm_kelt-0.4.0.tar.gz.
File metadata
- Download URL: llm_kelt-0.4.0.tar.gz
- Upload date:
- Size: 324.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51e0a730b774761950ad800f79872ca713346720eb5048d37db4fd6452ea2e2e
|
|
| MD5 |
ae7af5443307d309cd9e4e1b0e583554
|
|
| BLAKE2b-256 |
6352dd65720f7df08719ee71ce36dfc15243158df00c9b6fa774e65459269d92
|
Provenance
The following attestation bundles were made for llm_kelt-0.4.0.tar.gz:
Publisher:
release.yml on llm-works/llm-kelt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_kelt-0.4.0.tar.gz -
Subject digest:
51e0a730b774761950ad800f79872ca713346720eb5048d37db4fd6452ea2e2e - Sigstore transparency entry: 2278947765
- Sigstore integration time:
-
Permalink:
llm-works/llm-kelt@c4266c8b63433a4ff4bcb822b5d6fb7173467318 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/llm-works
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c4266c8b63433a4ff4bcb822b5d6fb7173467318 -
Trigger Event:
push
-
Statement type:
File details
Details for the file llm_kelt-0.4.0-py3-none-any.whl.
File metadata
- Download URL: llm_kelt-0.4.0-py3-none-any.whl
- Upload date:
- Size: 238.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ced3febbb6854693451f9a0498e2f7fa436433e9850e60a09f5c758868de146f
|
|
| MD5 |
13c1a061a5d1e0873bdc3abbc1bfa9b4
|
|
| BLAKE2b-256 |
4e394c374a9963bce987459b834ba65cdcfda3e82385f8133b820755cf0f7fdc
|
Provenance
The following attestation bundles were made for llm_kelt-0.4.0-py3-none-any.whl:
Publisher:
release.yml on llm-works/llm-kelt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_kelt-0.4.0-py3-none-any.whl -
Subject digest:
ced3febbb6854693451f9a0498e2f7fa436433e9850e60a09f5c758868de146f - Sigstore transparency entry: 2278947788
- Sigstore integration time:
-
Permalink:
llm-works/llm-kelt@c4266c8b63433a4ff4bcb822b5d6fb7173467318 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/llm-works
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c4266c8b63433a4ff4bcb822b5d6fb7173467318 -
Trigger Event:
push
-
Statement type: