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

Uploaded CPython 3.12Windows x86-64

kkachi-0.1.2-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.2-cp312-cp312-manylinux_2_28_aarch64.whl (12.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: kkachi-0.1.2-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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5ee1371009238289e7081a33e6d388509a7d39485d55be94000fae62e8c0a398
MD5 f17c3fe81faa2bb37b080782a855a8eb
BLAKE2b-256 64a3e5a6ff0bee1fa2f26007040d18ac9b441e7b43507345fce2f268c01bd85d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00a3a559993e0ecc585df2a742b7e6dda06b33d24fb080784e61b9da71477ea1
MD5 8c41ca5b81eed6265c91024d66472512
BLAKE2b-256 8ca26fec0aaa3a60d0a6c1c15f98c2fb2688d1673ae90797e3b7699e36af4604

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8f6babfddb1f39dfafb1dfa4b7c4b3abd13efc766aaf60f317483bcc6fb8198f
MD5 ce6e5671b04a03b8dc3b975946e7900f
BLAKE2b-256 cbc4689a2f902c69a1c98b40b94d2d9f3fc1754ec023d100b94b622a3b234d7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c8eaabaaf7defea3c74b0cf39b80cb8680507c225d4f776b3c4b981d0dcc247
MD5 9518e58d1dd647dc7ec2bfb4b938b7d6
BLAKE2b-256 e530d51e9e2137c406e5077ca0a5f242ac9614c4bb614048cb11b5c11a541b09

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kkachi-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 71330dbc00f5db66e172f65532f084e171cc5ec2867ef41f181c801f7fe0283a
MD5 73e08b6d2e807bced8b0d9fbfea96937
BLAKE2b-256 25986a5fcf74d337ddd0fb264899c5df47a57e3676da26851e2ed9b697e50908

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