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

Uploaded CPython 3.12Windows x86-64

kkachi-0.1.5-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.5-cp312-cp312-manylinux_2_28_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

kkachi-0.1.5-cp311-cp311-win_amd64.whl (12.7 MB view details)

Uploaded CPython 3.11Windows x86-64

kkachi-0.1.5-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.5-cp311-cp311-manylinux_2_28_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.12+ x86-64

kkachi-0.1.5-cp310-cp310-win_amd64.whl (12.7 MB view details)

Uploaded CPython 3.10Windows x86-64

kkachi-0.1.5-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.5-cp310-cp310-manylinux_2_28_aarch64.whl (12.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

kkachi-0.1.5-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.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: kkachi-0.1.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 12.7 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.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dff4569cdbd43e15adf9dd8481eeb93005ac205a5ec10ba02c41530d576667c6
MD5 4ae79dce767c88ec7b764bb9ca787a80
BLAKE2b-256 bed450059ad5ade8a6cffb0628fac9917a6e9dc9c4193f4a09cff3da45f7932c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3d1f9fdde61856de57eca8b6f2105a6be207da3697e0bd8900e52b665ae2c7e7
MD5 6c5011de84c7b80bcad6d527b95deec5
BLAKE2b-256 147bb7023315cf5bb4ed57eb762f7cd4ada4d9673d701291a842b15bcaa8743c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 caa63dca21ba69001f77b59a7105413759a1309f98115b8b6b09ef98658ad9b9
MD5 9d23dc9eaea8b1a5929ea79c50a447e6
BLAKE2b-256 29d8bb87245b5d912159bdaedae590866f85060a6ef059219c3c44e21884bfb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f6c09c330c0455c0c1a36e7e8ec78b96779a4fca334a2f833f627a979e710de2
MD5 899d9dcd8ae9ee966fc8824627e6b5ab
BLAKE2b-256 8cfb4c2d4d5721349428a9cdb2674d896dfd72c4e8d259753ff67576555398c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 672e17304bd2fefc20b22b04a772a6f3ebaa598ca6e01268807a793c6c4e4296
MD5 b97c6c58bc010aa09a44458dbcf3eaab
BLAKE2b-256 9f9c7dbbc0d020aedb21b9840390ac9805ec9cda09982415a6be7629c7a1c425

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kkachi-0.1.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 12.7 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.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 699c5e8a3e3670635f43d7242b58eab8d1ff8a2cfe33a138d3ea28d33d3f3796
MD5 d00268d3ccd7984ed6f0c951c8e9a796
BLAKE2b-256 42a1bab7cab61d8a3748710ee77b3e644db669ee9339f70262f99bbd6479d343

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 14b4aabf8701d2fd3bd6f3d23b87d4585a33ddecdfab92f81fd6ca4360fcf4cb
MD5 9512cecfefdf621aa588274ea7484000
BLAKE2b-256 f62175ebfdc363df733cb54197fdc3123d4a2cb3df2c08d1747ac97dedc7c974

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c00dc853a4f39d1cda41da94ef50acd21311e50782d0df55d6ae46626aa90bf9
MD5 aa455ff4361c3b6f9e76022f625851bc
BLAKE2b-256 bf8931031998f40df07e9d8c53cf43b2cc250509e803c429586616515f9a90f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f2cc3533273205138432501ae11342e184c1c616313b9da79f3d78c37d54cf9
MD5 05a84da803f7837c9e586040a0184a1a
BLAKE2b-256 e3c9bacac07f1766a061adf78d31dab49849540d5681d91b32a6f6a79e0e1879

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d2982d403b4d89f0b710f3728658d99ecb12b1b291a94e6e8efca6066e6547ea
MD5 f0650b817f8aac0345c260add9a8e33c
BLAKE2b-256 22c411e7094dfc457f21c3ffaa0e02ca14f3dba1d1b908e8cd8454ffd56ae22b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kkachi-0.1.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 12.7 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.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 93ea2be66e3da18d68c0cfc0eb2e387e9cbe33a873f05bb40c814729ed1c2bd2
MD5 35f2caa56eec4b7ee32590999e9c1722
BLAKE2b-256 4752a65dea2adade19e373ac21f7d20a43dd5a779c48b1d6619f0387fb99ff79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8b6fb4dad67fe0a72660ff7c3e00e5cd43297ffe670501e40b1f1db9e459a4ba
MD5 4b34dd406ae208e22038bf32270164cb
BLAKE2b-256 08bb92ff717de155d9f95670458a64bb1ed2c5225230b043c8f75fc43add380d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bdf539043073af75374edbb5f53a92d11176f4aa51ef0a4216bcfca155468b20
MD5 f8e28fae2e7d42539dae0b8d25e095a1
BLAKE2b-256 2f0ceab8993ef0a1b9e4da369edbed6d55f142d2178cac4ebf2932a89754ea1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6f0c0b76c59ca98daa2ea9e4c7680b9ec5dcefd3de99b8e1d45d6694d2d9efcf
MD5 ec9d9b3958eb1f26730647f665936222
BLAKE2b-256 07fddb788bbffcbd7aebd1a7335caf6e81adc56953aa1641ee4a457a948e88b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.5-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3a41bd8887b2d10733ef9fbc4fde2ea4f4b257ef644c799d7913e27d66024aa7
MD5 93b7a224b8006d5ffb0897f07fb6e0ea
BLAKE2b-256 964d1522a8edf22aec6aa56255336b0b6c4eeb53ac02b95565c71cd1e30a9a2d

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