Skip to content

lituus-io/kkachi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kkachi

CI Security Release crates.io PyPI

High-performance LLM prompt optimization library with composable pipelines.

Features

  • Composable Pipelines — Chain steps: refine, best_of, ensemble, reason, extract, map
  • Concurrent Execution — Run multiple pipelines concurrently with shared LLM and rate limiting
  • Step Combinators — then, race, par, retry, fallback, when
  • DSPy-Style Modules — Chain of Thought, Best of N, Ensemble, Program of Thought, ReAct Agent
  • Jinja2 Templates — Dynamic prompt generation
  • CLI Validators — External tool validation with composition (.and_(), .or_())
  • Memory & RAG — Persistent vector store with DuckDB
  • Pattern Validation — Regex, substring, length checks
  • LLM-as-Judge — Semantic validation
  • Multi-Objective Optimization — Pareto-optimal prompt tuning
  • Skills & Defaults — Reusable instruction injection and runtime substitution
  • Zero-Copy Core — GATs over async/await, lifetimes over Arc, minimal cloning

Python Installation

pip install kkachi

Quick Start (Python)

from kkachi import pipeline, concurrent, reason, Checks, ApiLlm

llm = ApiLlm.auto()

# Simple pipeline
result = pipeline(llm, "Write a URL parser in Rust") \
    .refine(Checks().has("fn parse"), max_iter=5, target=1.0) \
    .extract("rust") \
    .go()

# Concurrent pipelines
results = (
    concurrent(llm)
    .task("task_a", "Write tests", lambda p: p.refine(checks_a))
    .task("task_b", "Write docs", lambda p: p.refine(checks_b))
    .max_concurrency(2)
    .go()
)

Quick Start (Rust)

use kkachi::prelude::*;

let llm = ApiLlm::auto()?;

// Composable pipeline
let result = pipeline(&llm, "Write a URL parser")
    .refine_with(checks, 5, 1.0)
    .extract("rust")
    .go();

// Concurrent execution
let results = ConcurrentRunner::new(&llm)
    .task("tests", |llm| Pipeline::new_owned(llm, prompt_a).refine_with(checks_a, 5, 1.0))
    .task("docs", |llm| Pipeline::new_owned(llm, prompt_b).refine_with(checks_b, 3, 1.0))
    .max_concurrency(2)
    .go();

Repository Structure

  • crates/kkachi — Core Rust library
  • crates/kkachi-python — Python bindings (PyO3 + maturin)
  • examples/ — Rust and Python usage examples
  • benches/ — Benchmarks

License

Dual-licensed: AGPL-3.0-or-later for open source use, commercial license available. See LICENSE for details.

About

kkachi - High-Performance LM Optimization Library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors