Skip to main content

Core shared libraries for multimodal Kani extensions.

Project description

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:

$ pip install "kani[multimodal]"

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

$ 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:

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:

>>> 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kani_multimodal_core-0.0.3.tar.gz (47.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kani_multimodal_core-0.0.3-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file kani_multimodal_core-0.0.3.tar.gz.

File metadata

  • Download URL: kani_multimodal_core-0.0.3.tar.gz
  • Upload date:
  • Size: 47.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kani_multimodal_core-0.0.3.tar.gz
Algorithm Hash digest
SHA256 dc170d5ca5d0ff77f568ff594c5962aca0c919998c153d0194c26b1a00f2786b
MD5 cb71f7e45e925ed0def7dfa22126168f
BLAKE2b-256 3597f8493e67ea694f84d709b238e9b66e2e0b9794bd7021d0d36ad92d09047e

See more details on using hashes here.

Provenance

The following attestation bundles were made for kani_multimodal_core-0.0.3.tar.gz:

Publisher: pythonpublish.yml on zhudotexe/kani-multimodal-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kani_multimodal_core-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for kani_multimodal_core-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 43f9ab33164b79faf80ef8d0448c1b974f9d8b0933e109b57578ec94f7598741
MD5 b1d9f4767c6d860d90bb1d1055be8a6e
BLAKE2b-256 72448c706858de1809bc0c7f4ab6acc571f361e248e46ad54ceb874462b77798

See more details on using hashes here.

Provenance

The following attestation bundles were made for kani_multimodal_core-0.0.3-py3-none-any.whl:

Publisher: pythonpublish.yml on zhudotexe/kani-multimodal-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page