Kani

Latest version: v1.4.0

Safety actively analyzes 723217 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 6

1.4.0

Mainly improvements to the llama.cpp engine in this release.

Improvements
- Update the `LlamaCppEngine` to not use the Llama 2 prompt pipeline by default. Prompt pipelines must now be explicitly passed.
- The `LlamaCppEngine` will now automatically download additional GGUF shards when a sharded model is given.
- Added `ChatTemplatePromptPipeline.from_pretrained` to create a prompt pipeline from the chat template of any model on the HF Hub, by ID.
- Added examples and documentation for using DeepSeek-R1 (quantized).

Fixes
- `chat_in_terminal_async` no longer blocks the asyncio event loop when waiting for input from the terminal.
- Fixed the `LlamaCppEngine` not passing functions to the provided prompt pipeline.

1.3.0

Enhancements
- Added `ToolCallParser`s -- these classes are wrappers around Kani `Engine`s that parse raw text generated by a model, and return Kani-format tool calls. This is an easy way to enable tool calling on open-source models!

Example:
python
from kani.engines.huggingface import HuggingEngine
from kani.prompts.impl.mistral import MISTRAL_V3_PIPELINE
from kani.tool_parsers.mistral import MistralToolCallParser
model = HuggingEngine(model_id="mistralai/Mistral-Small-Instruct-2409", prompt_pipeline=MISTRAL_V3_PIPELINE)
engine = MistralToolCallParser(model)


- Added `NaiveJSONToolCallParser` (e.g., Llama 3)
- Added `MistralToolCallParser`
- Added `DeepseekR1ToolCallParser`

Bug Fixes et al.
- Fix compatibility issues with Pydantic 2.10
- Update documentation to better reflect supported HF models

1.2.4

- Pin the Pydantic dependency to `pydantic<2.10.0` as this version breaks JSON schema generation and MessagePart serialization

1.2.3

- Fixes Anthropic tool calling being broken with anthropic-sdk>0.26.0
- Fixes an issue where Anthropic prompts were over-eagerly trimming prompts that did not start with a user message
- Added support for tool calling while streaming with Anthropic models

1.2.2

- fix(mistral): ensure prompt and completion tokens are passed through in the MistralFunctionCallingAdapter when streaming
- fix(streaming): don't emit text in DummyStream if it is None
- feat: add standalone width formatters
- docs: gpt-3.5-turbo -> gpt-4o-mini defaults
- fix(streaming): potential line len miscount in format_stream

1.2.1

- Fixes various issues in the `MistralFunctionCallingAdapter` wrapper engine for Mistral-Large and Mistral-Small function calling models.
- Fixes an issue in `PromptPipeline.explain()` where manual examples would not be explained.
- Fixes an issue in `PromptPipeline.ensure_bound_function_calls()` where passing an ID translator would mutate the ID of the underlying messages

Page 1 of 6

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.