Metadata-Version: 2.4
Name: kani-multimodal-core
Version: 0.0.4
Summary: Core shared libraries for multimodal Kani extensions.
Project-URL: Homepage, https://github.com/zhudotexe/kani-multimodal-core
Project-URL: Bug Tracker, https://github.com/zhudotexe/kani-multimodal-core/issues
Author-email: Andrew Zhu <andrew@zhu.codes>
License: MIT License
        
        Copyright (c) 2025-present Andrew Zhu
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: aiohttp<4.0.0,>=3.0.0
Requires-Dist: audioop-lts>=0.2.1; python_version >= '3.13'
Requires-Dist: kani<2.0.0,>=1.6.0
Requires-Dist: numpy<3.0.0,>=2.0.0
Requires-Dist: pillow>=9.0.0
Requires-Dist: pydub<1.0.0,>=0.20.0
Requires-Dist: torchcodec<1.0.0,>=0.8.0
Description-Content-Type: text/markdown

# kani-multimodal-core

This package contains core extensions for using Kani with multimodal language models.

## Installation

kani-multimodal-core should be installed alongside the core kani install using an extra:

```shell
$ pip install "kani[multimodal]"
```

However, you can also explicitly specify a version and install the core package itself:

```shell
$ pip install kani-multimodal-core
```

## Features

This package provides the core multimodal extensions that engine implementations can use -- it does not provide any
engine implementations on its own.

The package adds support for:

- Images (`kani.ext.multimodal_core.ImagePart`)
- Audio (`kani.ext.multimodal_core.AudioPart`)
- Video (`kani.ext.multimodal_core.VideoPart`)
- Other binary files, such as PDFs (`kani.ext.multimodal_core.BinaryFilePart`)

When installed, these core kani engines will automatically use the multimodal parts:

- OpenAIEngine
- AnthropicEngine
- GoogleAIEngine

Additionally, the core kani `chat_in_terminal` method will support attaching multimodal data from a local drive or
from the internet using `@/path/to/media` or `@https://example.com/media`.

### Message Parts

The main feature you need to be familiar with is the `MessagePart`, the core way of sending messages to the engine.
To do this, when you call the kani round methods (i.e. `Kani.chat_round` or `Kani.full_round` or their str variants),
pass a *list* of multimodal parts rather than a string:

```python
from kani import Kani
from kani.engines.openai import OpenAIEngine
from kani.ext.multimodal_core import ImagePart

engine = OpenAIEngine(model="gpt-4.1-nano")
ai = Kani(engine)

# notice how the arg is a list of parts rather than a single str!
msg = await ai.chat_round_str([
    "Please describe this image:",
    ImagePart.from_file("path/to/image.png")
])
print(msg)
```

See the docs (https://kani-multimodal-core.readthedocs.io) for more information about the provided message parts.

### Terminal Utility

When installed, kani-multimodal-core augments the `chat_in_terminal` utility provided by kani.

This utility allows you to provide multimodal media on your disk or on the internet inline by prepending it with an
@ symbol:

```pycon
>>> from kani import chat_in_terminal
>>> chat_in_terminal(ai)
USER: Please describe this image: @path/to/image.png and also this one: @https://example.com/image.png
```
