Microframework for chat-based language models with tool use/function calling
Top 56.2% on sourcepulse
Kani is a lightweight, highly customizable Python framework for building chat-based language model applications, specifically designed for researchers and developers who need fine-grained control over the interaction flow. It simplifies integrating various language models, managing chat history, and implementing function calling, offering a more flexible alternative to opinionated, heavyweight frameworks.
How It Works
Kani employs a model-agnostic engine architecture, allowing seamless switching between different language models (OpenAI, Anthropic, Hugging Face via transformers
or llama.cpp
) with minimal code changes. It handles automatic chat memory management to prevent token limits from breaking conversations and provides a straightforward mechanism for function calling with built-in feedback and retry logic. The framework is built with an asynchronous design from the ground up for parallel processing.
Quick Start & Requirements
pip install "kani[<engine>]"
(e.g., kani[openai]
, kani[huggingface]
, or kani[all]
).kani[openai]
.Highlighted Details
@ai_function
decorator.Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
The README does not specify a license, which may pose a barrier for commercial or closed-source use.
2 weeks ago
1 day