Skip to main content

High-performance LLM prompt optimization library

Project description

kkachi-python

Python bindings for the kkachi LLM optimization library.

Installation

pip install kkachi

Usage

from kkachi import Signature, Example

sig = Signature("question -> answer")
ex = Example({"question": "What is 2+2?", "answer": "4"})

Memory / RAG with Persistent Storage

The Memory class provides a vector store for RAG (Retrieval-Augmented Generation) with full CRUD operations and optional persistent storage using DuckDB.

Basic Usage (In-Memory)

from kkachi import Memory

# Create in-memory store
mem = Memory()

# CREATE: Add documents
doc_id = mem.add("Document content here")
mem.add_with_id("custom-id", "Another document")
mem.add_tagged("category", "Tagged document")

# READ: Retrieve documents
content = mem.get(doc_id)
results = mem.search("query text", k=3)

# UPDATE: Modify existing documents
mem.update(doc_id, "Updated content")

# DELETE: Remove documents
mem.remove(doc_id)

Persistent Storage

Enable DuckDB-backed persistent storage to preserve data across program restarts:

from kkachi import Memory

# Create or open a persistent database
mem = Memory().persist("./my_rag_db.db")

# Add documents (persists to disk)
mem.add("Important knowledge that survives restarts")
mem.add("More documents here")

# Data persists across program runs
results = mem.search("knowledge", k=3)

# Close and reopen
del mem
mem = Memory().persist("./my_rag_db.db")  # Data is still there!

The database file will be created if it doesn't exist. Subsequent calls to .persist() with the same path will reopen the existing database.

Requirements:

  • The storage feature is enabled by default in pip package
  • DuckDB native library (usually handled automatically)

Complete Example

See examples/memory_persist.py for a complete demonstration of CRUD operations with persistent storage.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

kkachi-0.1.4-cp312-cp312-win_amd64.whl (12.6 MB view details)

Uploaded CPython 3.12Windows x86-64

kkachi-0.1.4-cp312-cp312-manylinux_2_28_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

kkachi-0.1.4-cp312-cp312-manylinux_2_28_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

kkachi-0.1.4-cp312-cp312-macosx_11_0_arm64.whl (12.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kkachi-0.1.4-cp312-cp312-macosx_10_12_x86_64.whl (14.2 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kkachi-0.1.4-cp311-cp311-win_amd64.whl (12.6 MB view details)

Uploaded CPython 3.11Windows x86-64

kkachi-0.1.4-cp311-cp311-manylinux_2_28_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

kkachi-0.1.4-cp311-cp311-manylinux_2_28_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

kkachi-0.1.4-cp311-cp311-macosx_11_0_arm64.whl (12.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kkachi-0.1.4-cp311-cp311-macosx_10_12_x86_64.whl (14.2 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kkachi-0.1.4-cp310-cp310-win_amd64.whl (12.6 MB view details)

Uploaded CPython 3.10Windows x86-64

kkachi-0.1.4-cp310-cp310-manylinux_2_28_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

kkachi-0.1.4-cp310-cp310-manylinux_2_28_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

kkachi-0.1.4-cp310-cp310-macosx_11_0_arm64.whl (12.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kkachi-0.1.4-cp310-cp310-macosx_10_12_x86_64.whl (14.2 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

Details for the file kkachi-0.1.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: kkachi-0.1.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.6 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kkachi-0.1.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9916a0fca81a9f680fcbe57b61e59c5aabab8eb4617aa349b6b5d5f1e99f312f
MD5 acbad6deba85aafe53131df6f379535f
BLAKE2b-256 d2bb4605cb6e08df81cf47c82d524ac15d8a1bfa94a272f9f12455fb45c49b55

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d7d3b65ebdf5ed83839839a46bb02d3b376ddde036c9caeb55a8596d2044764
MD5 2eb67e96de2e35165c0ae6718eba31fa
BLAKE2b-256 ec86bae47d0418ecd9efe706e21a8b984f165d2dbbadf82e40678f1d6ad2e614

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5038873793ebf0bb7fe1c5ae38707f6d03e8121fe48ca8ea862aa2d7678ca49c
MD5 b0d0ee240597b0db1389d8cc9e3e66bf
BLAKE2b-256 4d3fe9a5909ad652bf990a2d0fd0ab2c255fb0f363a18668d63dc69eb44d8f2c

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7cdcea496f33ff377c52c6c9ae1b47c79f34e2b769777e16b627a538071814cc
MD5 d1bd376c47115857024771aa1d1bf9fe
BLAKE2b-256 1aeee5186e573bd5226b042f37cbdaae229346a0ac3a013b89aa93253564d184

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 886997ece165b007d8547b4d8afd76cc9dae916118eab1b6a17d0d723d67f587
MD5 00477255e44868725049d266b884b67c
BLAKE2b-256 270019a0a3039c4f14960c15b635e0c1b76d437447c073ace701ba4295f544f7

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: kkachi-0.1.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 12.6 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kkachi-0.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 160f5e28ef3087764663561f5b655f14f6f65de9724bfc22e8ce6b050c0fa6f4
MD5 83185f265207f4bdb901c87c9051c957
BLAKE2b-256 3abff0c5e7155fe2e6df9c565d413264813caae3cbe4a4d674955607c2049488

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e6e22dcf4fd2a31eb9e5ea4ede8de91f7df8161047dbefacd26016364bc952ea
MD5 9647461b0e96457d416d4ade23ddc3d4
BLAKE2b-256 00e1188537de01d0a3285eeebc9fe2e7c486b140b2eb3e22b6ff45281c79b417

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6cd3d6376a142d98411da10aafa906a08ee3b936fbd3e6960cd8ecffa5cd6e95
MD5 4b757a06e7bd9271489cbc05b583be73
BLAKE2b-256 05a12b38021459014b1c3f8e638ff276e92613cac7f131158acb2d09e1d30c6c

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 84e348cf065f516bd29672aabd0f20e785dbb31c99be8dbbfe94ac6385440256
MD5 2deff23847f45606196d553da5c53128
BLAKE2b-256 f3bdd2f2f40133633329dde220feac5dcaaaa293d37d5692256d499bf5f664a5

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d36dc519e9d6b95a05536a85c0b7cd00bdc75d2f2ce673b12853e357420601d7
MD5 b25171f459b00af9901701ecdb03b204
BLAKE2b-256 f07384609dc78b8431a41dce36f83a000f0733b8e9ebb8f733c23fccfff9722b

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: kkachi-0.1.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 12.6 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kkachi-0.1.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fb202b607ff71f99b55f7f32100c43e1c41fed564126cada9754007cb977df4d
MD5 9e59febb1f1a14fa756892a863de1c55
BLAKE2b-256 68242c7d7b64595db2e350e9e42362d4fbb17eb18a9a4df3f99f651eca645f64

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 958c29f6e67a1d0d45dd773b455db952800839b246a3fec6fe5b55fe48967f64
MD5 0555ed3b89585fcd4df40370192e3e11
BLAKE2b-256 28ce16112a6d99baa987e44a834b377d4463acef6693f69d48f58d736ee8a943

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1ff1d4c12cdb58350a2143b153fa4fa0ae5e6582401341af1da771c06289fef5
MD5 7d259a8886319e3f96fb4d7964149b1a
BLAKE2b-256 bf1779fee725be28f02b3909a7d730486bfb4a79329e1c1a289f689743896e88

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a35aff081acd99911fe6025d77e27d3525338725314d7c0373a292dad9d14158
MD5 9885362ddeec7e8f0f07805640d9de88
BLAKE2b-256 bfcab42c048eab9133fd84b9ef91a3bfe466444127206ba65098ce5845909d90

See more details on using hashes here.

File details

Details for the file kkachi-0.1.4-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for kkachi-0.1.4-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a45471c3cb85858c2f815ef0e932f0fce94668da4d0b7765131a6219bce19ca0
MD5 a294129a7a937687ed3a39f1e49dcbc7
BLAKE2b-256 a6e3f3572e67b122e6412890f555c1ca7fcc3f6b9034e3f345f55ed20a1f6544

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