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

Uploaded CPython 3.12Windows x86-64

kkachi-0.1.7-cp312-cp312-manylinux_2_28_x86_64.whl (14.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

kkachi-0.1.7-cp312-cp312-manylinux_2_28_aarch64.whl (13.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

kkachi-0.1.7-cp312-cp312-macosx_11_0_arm64.whl (13.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kkachi-0.1.7-cp312-cp312-macosx_10_12_x86_64.whl (14.4 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

kkachi-0.1.7-cp311-cp311-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.11Windows x86-64

kkachi-0.1.7-cp311-cp311-manylinux_2_28_x86_64.whl (14.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

kkachi-0.1.7-cp311-cp311-manylinux_2_28_aarch64.whl (13.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

kkachi-0.1.7-cp311-cp311-macosx_11_0_arm64.whl (13.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kkachi-0.1.7-cp311-cp311-macosx_10_12_x86_64.whl (14.4 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

kkachi-0.1.7-cp310-cp310-win_amd64.whl (12.8 MB view details)

Uploaded CPython 3.10Windows x86-64

kkachi-0.1.7-cp310-cp310-manylinux_2_28_x86_64.whl (14.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

kkachi-0.1.7-cp310-cp310-manylinux_2_28_aarch64.whl (13.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

kkachi-0.1.7-cp310-cp310-macosx_11_0_arm64.whl (13.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kkachi-0.1.7-cp310-cp310-macosx_10_12_x86_64.whl (14.4 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: kkachi-0.1.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.8 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.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 006ad3e99496cec7ac642088b34290d47c5c45e0590ce81e564ad77f1fdc7f05
MD5 0bb331ff211d0e5378432bd1a8af7fbb
BLAKE2b-256 de9c313409c57ec7bfa6b55527b6f979f1b238d85188b94ce34cd0c07376d146

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dc112ea22434f50b0c6757113f3b800ecc347353c7b35ddbc17fbd35958a5433
MD5 78b595565f28c22c02db13332edcfa91
BLAKE2b-256 e78b93a59b5ad52bc4da9d84cf11c3671d806f35ec27d960f03b30eac4085058

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 046fad2c96419a2e220a053b77dadf3d7c14e14fd3dd05cd2e50de22d633bce6
MD5 81e85089f172fa0545c3def913ec5b46
BLAKE2b-256 64a60567253d7826ad33cca20014323c8a2b71a476b440a711c7017b5d5d2799

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bcadb7b96ee7bf32a125710726593a1e96b192a934da04383b060b7bee53916a
MD5 fe0f675d000ab249d4177fa5df3eb3f6
BLAKE2b-256 ad0adbb98af0dd262c9810c5903851c5b34ac1b2ccea261be0c2ebc22ee29ace

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8d6f8eb0d81451de99493105b83c2419d4ea08b7a8acd3b64d55f6b49ad6a7f0
MD5 ef8c80c23a8c6bc8b82cb54c17402bb1
BLAKE2b-256 9e1b67321181ec1ef8c7a2b55e841e43f39333d05e2e1f02d975f362a0a0ae3d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kkachi-0.1.7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 12.8 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.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3ad33b119e922627b4985b7cb3bb3bbc36537dc04c432cf54db1da3ee7630dea
MD5 ec80ea8c361f2eaa765697397b5d6f8d
BLAKE2b-256 bc32350e6983d4b1fdebb6c0c6b78bc4b4893f90054f7a63457ed67e6069e9bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c6b6e4a1f0cf2c4aa77660d3ad8601efd76ae061b5b61f54b034203adfb85de
MD5 66fbb0b7c1d4aa8fb4579567e98c3381
BLAKE2b-256 b0f0c23bc676b76ae9a1a95a1998e122e52fcf90e2790d64434a2063c291135b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 692aeb4c833a66ffeb31d2b0ddd9cd57f12c49dbb11cd0ec05330e849a273ec0
MD5 1d87426a734a8330eaf77fa5058e09fe
BLAKE2b-256 27d62bd3c27ea66f3e91c9515c9dd7d1fbf8f27d2aa8dc458d1806f4cd8075be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31afd6a42cee1cc7407932431f156ab11b0d46a82c5ef9b6b5e0ca55b86dd55c
MD5 2d24837c13fa29046d5e4cc35902ab4e
BLAKE2b-256 736ff8ac42a2c1bd68c4122464489c459944fba625d5cab573741a4a98b15e74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a89dadc632ea810f9acbc2e3a1808d52d7c6caae97b82005195c137546b1de12
MD5 48499147e6e9056bc456c6db6d4e7cc2
BLAKE2b-256 06ae7a14b613b8bdbf52c0a1e11d9e2d2319716d9e44f481309597a7362f5a2d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kkachi-0.1.7-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 12.8 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.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a95a8f712f1c15852681a1f9fdf2723de61b6903083d93e3a8287fdf802b0da9
MD5 7b14841253bf6e8d8a2faeb6016d3340
BLAKE2b-256 86f000388c55f31fd8d1bcb5b9ad4e5d0d5c451170062b5b4537d40713f951bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 25a1a734e0710c53b7ca0f86ff53b744915998b9d35b3b87d4342caad87c654c
MD5 6b91f6a1fd173373127346c7af317fc1
BLAKE2b-256 b118db0ef793e502dc92950548eada8110f917d9f54a5e113f0db775d07b9a4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8641e680b05858a8e054b4c23577ca962e11798393c2f4f650c04faec2c27607
MD5 9293b8911970c9a69d1b69807a6ae1bc
BLAKE2b-256 2f5981c8ccadd6c07f81879c5a22410b7881bd5feb901c2d18dc0990e8a52697

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 64f98be6e36b45e87dedeb51509bbffe331996f6882135c4f31cfbe3075ba6f8
MD5 61746fbfd4863e2f08eecc7de15b762d
BLAKE2b-256 15b2c4d061756e5ea4bf78d6da859902e54cfddcbaa7771027fb81a479fe7901

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.7-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 823f96a78298e1eb066753b98d583c37cf9fdd79f161a30b48f74a9f8ca84fea
MD5 ce57508eb9062c6e55f9a702544fa59c
BLAKE2b-256 b46c9ac9b7f3050a9706dddfa6f94d80f7bbcfb9dbbadfb2605b534573d3cf0f

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