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.3-cp312-cp312-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.12Windows x86-64

kkachi-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

kkachi-0.1.3-cp312-cp312-manylinux_2_28_aarch64.whl (12.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

kkachi-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kkachi-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kkachi-0.1.3-cp311-cp311-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.11Windows x86-64

kkachi-0.1.3-cp311-cp311-manylinux_2_28_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

kkachi-0.1.3-cp311-cp311-manylinux_2_28_aarch64.whl (12.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

kkachi-0.1.3-cp311-cp311-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kkachi-0.1.3-cp311-cp311-macosx_10_12_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kkachi-0.1.3-cp310-cp310-win_amd64.whl (12.5 MB view details)

Uploaded CPython 3.10Windows x86-64

kkachi-0.1.3-cp310-cp310-manylinux_2_28_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

kkachi-0.1.3-cp310-cp310-manylinux_2_28_aarch64.whl (12.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

kkachi-0.1.3-cp310-cp310-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kkachi-0.1.3-cp310-cp310-macosx_10_12_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: kkachi-0.1.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.5 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 000ab2691535bb93f4e04021f454f1d3deb2acf5842b8877cab8545e3cff07dc
MD5 d4a3cfe1e7c36a0b73a5900db861efaa
BLAKE2b-256 8f8780ceda9ac318847b0fca083932dd68526340d823d067d0c5a8d3bbc4c2b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 473f000ee9914da866d3c215cae2927e413378e61bca205b7bfb69b931a24987
MD5 6548de5ff91a9c6f8160b283b6fe8650
BLAKE2b-256 f24e14e1c3db056849ac54c3f057044fec7560418f0b23753775a2a8d29ba1f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 45cbd75598c324c60012d232e5aaf6b0bdb660d03aee5a66712da03ec878ba1b
MD5 e5bc33a6b3181ea309bd2bff3cb40df7
BLAKE2b-256 623a23bef95b93493b1a32320930b3b2c1885ac3baca9da1fc1011007c94c43c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9679118bf055737203e8593cfe60ca10df9ebc0743cf9b09df29a920aa729ba
MD5 bcdf620b64651abec979286d576097d4
BLAKE2b-256 fb920e61786d92bba3e58fc6a1f45519f122e010695c080dd4d011d419915643

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8b8133eb20f8baef0a549cb23471fca94ffb1af6cb3b4522d071f2605b5ee625
MD5 e27797bfed73f8316cea7e7236bf9281
BLAKE2b-256 feeba41fc00f46fd4524b3845e91d78dc732196620fdc9851849ca2f6180dc8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kkachi-0.1.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 12.5 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 55cce9190a7ee12dd2d49117619610d817daa5dbe55bab8f9a5e21b2ef24622a
MD5 234c9081fae6ba89a93ebeadf50bcb4c
BLAKE2b-256 6b6cf5e72cad6f5de1158a9003c6f754edcb01058ee89979463ff4e311b80d1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3b4229a3dd817951278ce1668e19bd0057970f67d1144001385c6cacb099cc60
MD5 4b8bee035d9de963dcb5e64ddc058e1e
BLAKE2b-256 97d79438749ba48cac6ca7ef72085a5715c3f70283499cf0f08500725c291c0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e517d53b9b78237da2bdaa4d5910d5391d1ac28a68e2d5259d510a7339f2c4f5
MD5 ef2330a01ec3a8d1cce0998154fcc53a
BLAKE2b-256 6235f714869f79fed6f3e6da855acec3a65ae71ad357ac8343f35f87c53aa9aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 401eca11be47de2c8306b1d92bbf3c170f23846f72701d13c068f42c0321f846
MD5 b66770ae4f7a348c45da2935a3628bee
BLAKE2b-256 ba58cbcdd24b069c33d4f34bf227bf45d71fb9efc2d3d030ee38ba53d09d459b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 be73d950f22be886a2a5055ce2b6ead3d8672b3f22508fb6a6aaed608094fbb2
MD5 d0e2558146b923a352a8caaecca96dfe
BLAKE2b-256 138d0663fe096cd73a46233b390802a394f11e9bb5b5846ff02f2db00728b770

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kkachi-0.1.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 12.5 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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c23db9eaa97da69efc721cf68b0279d3077ab2a8ad367671a5706b9b0a360332
MD5 23c8e349320307d469f2502ece932fb7
BLAKE2b-256 ba8916e511e2b073e3b86060369736d4c155da26ff0610a9645096f643d9a1c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a1c894512cde7599363af9e428625c033ce642dba656267aece6e0af30aa8e11
MD5 b50c998348a44c628440fb78fb889bea
BLAKE2b-256 aae227450efff2274dba0f9e68921501271266bedff79257be3328c63e3e3483

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0f1547ec70e7e88cc72e664c6f2b4cd9b83491ffa88124711a6a6edcfaf6041d
MD5 342735d843c18ab1c0b027e7824c89e7
BLAKE2b-256 c9ec04dc3af9202d13732d59c18ec4e1afd5d831ac75a0ac526a8795bd37b1cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 615e87238e45644354e79141d36b970e6de55abe66a7faf288a1d1ab60ebc0b0
MD5 60ea5088b54114bbf06193c7eedabd87
BLAKE2b-256 03642ecf90c6a43893dc4ec2c5ad13a7008bf555f518262eeca62e4a0fd6376a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.3-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 137f586c8f04639d9775ccd00036a40909f92e0513873b4fdda04a9abc51353b
MD5 61baabedd7a116bc8d578c367b9795d7
BLAKE2b-256 5e0a0178a038307c5266c36a3d5f10cf472c7d2b6b735a987600773be1089472

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