Skip to main content

Data building utilities for AI agents

Project description

kiarina-agi-data-builder

English | 日本語

What is this?

kiarina-agi-data-builder provides builders for AI agent messages, events, histories, tool info, file info, and file segments.

Dependencies

Required Dependencies

Package Version License
kiarina-agi-audio >=2.9.0 MIT
kiarina-agi-base >=2.7.0 MIT
kiarina-agi-data >=2.7.0 MIT
kiarina-agi-file >=2.8.0 MIT
kiarina-agi-tool >=2.12.0 MIT
kiarina-agi-video >=2.10.0 MIT
kiarina-i18n >=2.3.1 MIT
kiarina-utils-app >=2.4.0 MIT
kiarina-utils-common >=2.8.0 MIT
kiarina-utils-file >=2.3.1 MIT
Pydantic >=2.11.7,<3 MIT
pydantic-settings >=2.10.1,<3 MIT
pydantic-settings-manager >=3.2.0 MIT
PyYAML >=6.0.2 MIT

Optional Dependencies

Package Extras
imageio-ffmpeg file-info-builder-audio
file-info-builder-video
Pillow file-info-builder-image
file-info-builder-pdf
file-info-builder-video
pypdf file-info-builder-pdf
pypdfium2 file-info-builder-pdf
soundfile file-info-builder-audio

The all Extra installs every optional dependency listed above.

Installation

pip install "kiarina-agi-data-builder[all]"

Features

Capability-aware PDF fallback

PDF analysis bundles select content from chat model capabilities.

Capabilities Content
Text only Extracted PDF text
Image Page-numbered page images and extracted PDF text
PDF The original PDF or selected page segment

Set analysis_dpi on the PDF file specification to control the resolution of fallback page images.

from kiarina.agi.file_info_builder_impl.pdf import create_pdf_file_info_builder
from kiarina.agi.run_context import RunContext
from kiarina.utils.file.asyncio import read_file


async def build_pdf_info():
    file_blob = await read_file("/path/to/document.pdf")
    assert file_blob is not None
    builder = create_pdf_file_info_builder(analysis_enabled=True)
    return await builder.build(
        {
            "uri_or_file_path": file_blob.file_path,
            "analysis_dpi": 144,
        },
        file_blob,
        run_context=RunContext(),
    )

Capability-aware video fallback

Video analysis bundles select content from chat model capabilities.

Capabilities Content
Text only Audio transcript and ambient analysis
Image Timestamped video frames, transcript, and ambient analysis
Video Video with its audio track

Set analysis_fps on the video file specification to control the frame rate of the prepared video and fallback images.

from kiarina.agi.file_info_builder_impl.video import (
    create_video_file_info_builder,
)
from kiarina.agi.run_context import RunContext
from kiarina.utils.file.asyncio import read_file


async def build_video_info():
    file_blob = await read_file("/path/to/video.mp4")
    assert file_blob is not None
    builder = create_video_file_info_builder(
        analysis_enabled=True,
        audio_consumers=["stt", "ambient"],
    )
    return await builder.build(
        {
            "uri_or_file_path": file_blob.file_path,
            "analysis_fps": 1.0,
        },
        file_blob,
        run_context=RunContext(),
    )

API Reference

kiarina.agi.file_info_builder_impl.pdf

from kiarina.agi.file_info_builder_impl.pdf import (
    PDFFileInfoBuilder,
    PDFFileInfoBuilderSettings,
    create_pdf_file_info_builder,
    settings_manager,
)

create_pdf_file_info_builder

def create_pdf_file_info_builder(**kwargs: Any) -> PDFFileInfoBuilder: ...

Creates a PDF file info builder from managed settings and optional overrides.

PDFFileInfoBuilder

class PDFFileInfoBuilder(BaseFileInfoBuilder):
    def __init__(self, settings: PDFFileInfoBuilderSettings) -> None: ...

    async def build(
        self,
        file_info_spec: FileInfoSpec,
        file_blob: FileBlob,
        *,
        run_context: RunContext,
    ) -> BuildResult: ...

PDFFileInfoBuilderSettings

class PDFFileInfoBuilderSettings(BaseSettings):
    analysis_enabled: bool = False

settings_manager is the SettingsManager[PDFFileInfoBuilderSettings] instance used by the factory.

kiarina.agi.file_info_builder_impl.video

from kiarina.agi.file_info_builder_impl.video import (
    VideoFileInfoBuilder,
    VideoFileInfoBuilderSettings,
    create_video_file_info_builder,
    settings_manager,
)

create_video_file_info_builder

def create_video_file_info_builder(**kwargs: Any) -> VideoFileInfoBuilder: ...

Creates a video file info builder from managed settings and optional overrides.

VideoFileInfoBuilder

class VideoFileInfoBuilder(BaseFileInfoBuilder):
    def __init__(self, settings: VideoFileInfoBuilderSettings) -> None: ...

    async def build(
        self,
        file_info_spec: FileInfoSpec,
        file_blob: FileBlob,
        *,
        run_context: RunContext,
    ) -> BuildResult: ...

VideoFileInfoBuilderSettings

class VideoFileInfoBuilderSettings(BaseSettings):
    analysis_enabled: bool = False
    audio_source: AudioSourceSpecifier = "file?sample_rate=16000&start_timestamp=0.0"
    audio_consumers: list[AudioConsumerSpecifier] = [
        "stt?diarization_enabled=true",
        "ambient?window_seconds=10.0&top_k=3",
    ]
    audio_event_bundlers: list[AudioEventBundlerSpecifier] = ["stt", "ambient"]

settings_manager is the SettingsManager[VideoFileInfoBuilderSettings] instance used by the factory.

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

kiarina_agi_data_builder-2.19.0.tar.gz (67.6 kB view details)

Uploaded Source

Built Distribution

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

kiarina_agi_data_builder-2.19.0-py3-none-any.whl (100.5 kB view details)

Uploaded Python 3

File details

Details for the file kiarina_agi_data_builder-2.19.0.tar.gz.

File metadata

File hashes

Hashes for kiarina_agi_data_builder-2.19.0.tar.gz
Algorithm Hash digest
SHA256 70467b078dc51ba14a74425d22ce5c3cb1c5f5fc91e0c044f57ac15d996b732d
MD5 2df6685507f7b54a47f21d85292fb95e
BLAKE2b-256 9a49ae32957526da4d22fcb6e00d07fcd32b9273daf70fd0e1b2c4f9622960b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for kiarina_agi_data_builder-2.19.0.tar.gz:

Publisher: release-pypi.yml on kiarina/kiarina-python

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

File details

Details for the file kiarina_agi_data_builder-2.19.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kiarina_agi_data_builder-2.19.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4344fcb1c5e40daee5872afd90aee6fcf5c48095a24469f6bd73ee082c253cad
MD5 190f330d09e5c6eed92a57e5971e0687
BLAKE2b-256 7777d4e94aaea0e700ab1379960fece74bf4c66538b537820cce156284bdca8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for kiarina_agi_data_builder-2.19.0-py3-none-any.whl:

Publisher: release-pypi.yml on kiarina/kiarina-python

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