Kani

Latest version: v1.0.2

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

Scan your dependencies

Page 2 of 5

0.7.2

- OpenAI: Added support for Jan 25 models without specifying `max_context_length` explicitly
- OpenAI: Fixed an issue where the token count for parallel function calls would only consider the first function call

0.7.1

- OpenAI: Fixes an issue where a tool call could have an unbound tool call ID when using `always_included_messages` near the maximum context length

0.7.0

New Features
- Added support for the Claude API through the `AnthropicEngine`
- Currently, this is only for chat messages - we don't yet have access to the new function calling API. We plan to add Claude function calling to Kani as soon as we get access!
- Renamed `ToolCallError` to a more general `PromptError`
- Technically a minor breaking change, though a search of GitHub shows that no one has used `ToolCallError` yet

Fixes
- Fixed an issue where parallel tool calls could not be validated (thanks arturoleon!)

0.6.2

- Fixes an issue where emoji in a chat history might cause issues when saving/loading the kani state
- (OpenAI) Fixes an issue where the `content` field might get omitted in certain requests, causing an API error

0.6.1

- Internal changes to the OpenAIEngine to make extending it easier
- No consumer-facing changes

0.6.0

As of Nov 6, 2023, OpenAI added the ability for a single assistant message to request calling multiple functions in
parallel, and wrapped all function calls in a `ToolCall` wrapper. In order to add support for this in kani while
maintaining backwards compatibility with OSS function calling models, a `ChatMessage` now actually maintains the
following internal representation:

`ChatMessage.function_call` is actually an alias for `ChatMessage.tool_calls[0].function`. If there is more
than one tool call in the message, when trying to access this property, kani will raise an exception.

To translate kani's FUNCTION message types to OpenAI's TOOL message types, the OpenAIEngine now performs a translation based on binding free tool call IDs to following FUNCTION messages deterministically.

Breaking Changes

To the kani end user, there should be no change to how functions are defined and called. One breaking change was necessary:

- `Kani.do_function_call` and `Kani.handle_function_call_exception` now take an additional `tool_call_id` parameter, which may break overriding functions. The documentation has been updated to encourage overriders to handle `*args, **kwargs` to prevent this happening again.

New Features

kani can now handle making multiple function calls in parallel if the model requests it. Rather than returning an ASSISTANT message with a single `function_call`, an engine can now return a list of `tool_calls`. kani will resolve these tool calls in parallel using asyncio, and add their results to the chat history in the order of the list provided.

Returning a single `function_call` will continue to work for backwards compatibility.

Page 2 of 5

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.