Skip to main content Switch to mobile version kiarina-agi-data 2.47.0 Data models and utilities for AI agents
pip install kiarina-agi-data==2.47.0 Copy PIP instructions
pip install kiarina-agi-data Features
Messages and events Manage system, human, AI, and tool messages and streaming chunks as chronological events.
Content and file metadata Represent text and files together, estimate tokens, convert to XML, shrink content, and move file data to and from a shared pool.
History Keep events, files, tools, and a working memory graph in one state and query or update them by purpose.
Memory graphs Represent text, assets, vectors, and metadata as connected memories with permanent or decaying edges.
Embeddings Normalize vectors, calculate cosine similarity, and search for the highest-scoring candidates.
File bundles Package text and media in a ZIP with a manifest and convert it to and from bytes or a MIME blob.
Tool schemas Create tool definitions from Pydantic models or JSON Schema and manage their execution state.
Build a Conversation History
Messages added to History are converted to events. File metadata inside messages is moved to a shared pool to avoid duplication.
from kiarina.agi.history import History from kiarina.agi.message import AIMessage, HumanMessage history = History() history.add_message(HumanMessage.create("What is the weather in Tokyo?")) history.add_message(AIMessage.create("The forecast is sunny.")) messages = history.get_messages() assert len(messages) == 2 assert messages[-1].to_text() == "The forecast is sunny." Search Embeddings
search_embeddings returns results in descending cosine similarity order.
import numpy as np from kiarina.agi.embedding import Embedding, search_embeddings candidates = [ Embedding(kind="document", space_id="example", vector=[1.0, 0.0]), Embedding(kind="document", space_id="example", vector=[0.0, 1.0]), ] results = search_embeddings(np.array([0.9, 0.1]), candidates, top_k=1) assert results[0].embedding == candidates[0] Create a File Bundle
from kiarina.agi.file_bundle import FileBundle bundle = FileBundle.create( [ {"type": "text", "text": "Summary"}, { "type": "image", "file_path": "images/chart.png", "mime_type": "image/png", }, ], files={"images/chart.png": b"PNG data"}, ) restored = FileBundle.from_bytes(bundle.to_bytes()) assert restored.files["images/chart.png"] == b"PNG data" API Reference
Pydantic model constructors accept the listed fields as keyword arguments. Fields shown with Field(default_factory=...) may be omitted.
kiarina.agi.chat_estimates
from kiarina.agi.chat_estimates import ChatEstimates class ChatEstimates: token_count: int = 0 file_size: int = 0 text_file_count: int = 0 text_token_count: int = 0 image_file_count: int = 0 image_token_count: int = 0 audio_duration: float = 0.0 audio_file_count: int = 0 audio_token_count: int = 0 video_duration: float = 0.0 video_file_count: int = 0 video_token_count: int = 0 pdf_page_count: int = 0 pdf_file_count: int = 0 pdf_token_count: int = 0 @property def summary(self) -> str: ... @property def text(self) -> str: ... @property def image(self) -> str: ... @property def audio(self) -> str: ... @property def video(self) -> str: ... @property def pdf(self) -> str: ... def add_token_count( self, target: Literal["text", "image", "audio", "video", "pdf"], token_count: int, ) -> None: ... def to_string(self) -> str: ... kiarina.agi.chat_limits
from kiarina.agi.chat_limits import ChatLimits, ChatLimitsSpecifier ChatLimitsSpecifier: TypeAlias = str class ChatLimits: token_count_limit: int = 772_000 file_size_limit: int = 20_000_000 image_file_count_limit: int = 100 audio_duration_limit: float = 34_200.0 audio_file_count_limit: int = 7 video_duration_limit: float = 3_600.0 video_file_count_limit: int = 7 pdf_page_count_limit: int = 100 pdf_file_count_limit: int = 7 @property def token_count(self) -> str: ... @property def file_size(self) -> str: ... @property def image(self) -> str: ... @property def audio(self) -> str: ... @property def video(self) -> str: ... @property def pdf(self) -> str: ... def to_string(self) -> str: ... @classmethod def from_specifier(cls, specifier: ChatLimitsSpecifier) -> Self: ... kiarina.agi.content
from kiarina.agi.content import Content, dehydrate_content, hydrate_content def dehydrate_content( content: Content, pool: FileInfoPool, ) -> tuple[Content, FileInfoPool]: ... def hydrate_content( content: Content, pool: FileInfoPool, ) -> tuple[Content, FileInfoPool]: ... class Content: payload: dict[str, Any] | None = None text: str = "" files: list[FileInfo] = [] cache_control: dict[str, Any] | None = None tag: str = "files" description: str = "" template: str = "<{tag}{attributes}>\n{inner_xml}\n{tag}>" file_tags: dict[FileType, str] = {} @property def xml_attributes(self) -> dict[str, Any]: ... def to_estimates(self) -> ChatEstimates: ... def to_xml(self, inner_xml: str | None = None) -> str: ... def to_text(self) -> str: ... kiarina.agi.display_content
from kiarina.agi.display_content import ( BaseDisplayContent, DisplayContent, DisplayContentType, FileDisplayContent, TextDisplayContent, ) DisplayContentType = Literal["text", "file"] DisplayContent: TypeAlias = TextDisplayContent | FileDisplayContent class BaseDisplayContent: type: DisplayContentType mime_type: str class FileDisplayContent(BaseDisplayContent): type: Literal["file"] = "file" mime_type: str = "application/octet-stream" uri_or_file_path: str display_name: str | None = None @property def uri(self) -> str: ... class TextDisplayContent(BaseDisplayContent): type: Literal["text"] = "text" mime_type: str = "text/plain" text: str start_line: int = 1 kiarina.agi.embedding
from kiarina.agi.embedding import ( Embedding, EmbeddingID, EmbeddingKind, EmbeddingSearchResult, EmbeddingSpace, EmbeddingSpaceID, EmbeddingVector, calc_cosine_similarity, l2_normalize, search_embeddings, ) EmbeddingID: TypeAlias = str EmbeddingKind: TypeAlias = str EmbeddingSpaceID: TypeAlias = str EmbeddingVector: TypeAlias = Float32[np.ndarray, "dimensions"] def calc_cosine_similarity( x: Embedding | np.ndarray, y: Embedding | np.ndarray, ) -> float: ... def l2_normalize(vector: np.ndarray) -> EmbeddingVector: ... def search_embeddings( query: Embedding | np.ndarray, candidates: Iterable[Embedding], *, top_k: int = 10, min_score: float | None = None, ) -> list[EmbeddingSearchResult]: ... class Embedding: id: EmbeddingID =
from kiarina.agi.event import ( AIMessageChunkEvent, AIMessageEvent, BaseEvent, CustomEvent, Event, EventType, HumanMessageEvent, ToolMessageEvent, dehydrate_event, dehydrate_events, message_to_event, ) EventType = Literal[ "human_message", "ai_message", "ai_message_chunk", "tool_message", "custom" ] Event: TypeAlias = ( HumanMessageEvent | AIMessageEvent | AIMessageChunkEvent | ToolMessageEvent | CustomEvent ) def dehydrate_event( event: Event, pool: FileInfoPool, ) -> tuple[Event, FileInfoPool]: ... def dehydrate_events( events: list[Event], pool: FileInfoPool, ) -> tuple[list[Event], FileInfoPool]: ... def message_to_event(message: Message) -> Event: ... class BaseEvent: type: EventType id: str =
kiarina.agi.file_bundle
kiarina.agi.file_info
from kiarina.agi.file_info import ( AudioFileInfo, BaseFileInfo, FileID, FileInfo, FileType, Group, ImageFileInfo, OtherFileInfo, PDFFileInfo, TextFileInfo, UniqueKey, VideoFileInfo, deduplicate_file_infos, detect_file_type, shrink_file_infos, ) FileID: TypeAlias = str Group: TypeAlias = str UniqueKey: TypeAlias = str FileType = Literal["text", "image", "audio", "video", "pdf", "other"] FileInfo: TypeAlias = ( TextFileInfo | ImageFileInfo | AudioFileInfo | VideoFileInfo | PDFFileInfo | OtherFileInfo ) def deduplicate_file_infos(file_infos: list[FileInfo]) -> list[FileInfo]: ... def detect_file_type(file_blob: FileBlob) -> FileType: ... def shrink_file_infos( file_infos: list[FileInfo], *, reduce: TokenCount, reserve: TokenCount = 0, ) -> tuple[list[FileInfo], TokenCount]: ... class BaseFileInfo: type: FileType id: FileID =
class TextFileInfo(BaseFileInfo): type: Literal["text"] = "text" start_line: int = 1 end_line: int = -1 line_count: int raw_text: str | None @property def normalized_start_line(self) -> int: ... @property def normalized_end_line(self) -> int: ... @property def segment_line_count(self) -> int: ... def shrink_by_line(self, keep_line_count: int) -> Self: ... class ImageFileInfo(BaseFileInfo): type: Literal["image"] = "image" width: int height: int class AudioFileInfo(BaseFileInfo): type: Literal["audio"] = "audio" start_time: float = 0.0 end_time: float = -1.0 duration: float @property def normalized_start_time(self) -> float: ... @property def normalized_end_time(self) -> float: ... @property def segment_duration(self) -> float: ... class VideoFileInfo(BaseFileInfo): type: Literal["video"] = "video" start_time: float = 0.0 end_time: float = -1.0 width: int height: int fps: float analysis_fps: float = 1.0 duration: float @property def normalized_start_time(self) -> float: ... @property def normalized_end_time(self) -> float: ... @property def segment_duration(self) -> float: ... class PDFFileInfo(BaseFileInfo): type: Literal["pdf"] = "pdf" start_page: int = 1 end_page: int = -1 page_count: int analysis_dpi: int = 144 @property def normalized_start_page(self) -> int: ... @property def normalized_end_page(self) -> int: ... @property def segment_page_count(self) -> int: ... class OtherFileInfo(BaseFileInfo): type: Literal["other"] = "other" Concrete classes also implement content-specific xml_attributes, optional_export_fields, and to_content_estimates().
kiarina.agi.file_info_pool
from kiarina.agi.file_info_pool import ( FileInfoPool, dehydrate_file_infos, find_file_index, hydrate_file_infos, ) FileInfoPool: TypeAlias = list[FileInfo] def dehydrate_file_infos( file_infos: list[FileInfo], pool: FileInfoPool, ) -> tuple[list[FileInfo], FileInfoPool]: ... def find_file_index(pool: FileInfoPool, file_id: FileID) -> int | None: ... def hydrate_file_infos( file_infos: list[FileInfo], pool: FileInfoPool, ) -> tuple[list[FileInfo], FileInfoPool]: ... kiarina.agi.history
from kiarina.agi.memory import Memory, MemoryID, MemoryType MemoryID: TypeAlias = str MemoryType: TypeAlias = str class Memory: id: MemoryID =
from kiarina.agi.memory_graph import DecayTime, MemoryGraph, MemorySearchHit DecayTime: TypeAlias = float class MemorySearchHit: id: MemoryID score: float class MemoryGraph: nodes: dict[MemoryID, Memory] = {} edges: dict[MemoryID, dict[MemoryID, DecayTime]] = {} def clear(self) -> None: ... def count(self) -> int: ... def get(self, id: MemoryID) -> Memory | None: ... def mget(self, ids: list[MemoryID]) -> list[Memory]: ... def set(self, memory: Memory) -> None: ... def mset(self, memories: list[Memory]) -> None: ... def delete(self, id: MemoryID) -> None: ... def connect( self, source_id: MemoryID, target_id: MemoryID, *, bidirectional: bool = True, remaining_time: float = 0, ) -> None: ... def disconnect( self, source_id: MemoryID, target_id: MemoryID, *, bidirectional: bool = True, ) -> None: ... def forget( self, source_id: MemoryID, target_id: MemoryID, *, bidirectional: bool = True, acceleration_time: float = 0, ) -> None: ... def find_ids( self, *, memory_type: MemoryType | None = None, offset: int = 0, limit: int = 0, ) -> list[MemoryID]: ... def search_ids( self, query_vector: list[float], *, k: int = 3, memory_type: MemoryType | None = None, ids: list[MemoryID] | None = None, min_score: float | None = None, ) -> list[MemorySearchHit]: ... def find_adjacent_ids( self, id: MemoryID, *, depth: int = 1, memory_type: MemoryType | None = None, offset: int = 0, limit: int = 0, ) -> list[MemoryID]: ... find_ids returns IDs by descending activated_at, then ascending ID for ties. Type filtering precedes pagination. offset and limit must be nonnegative; limit=0 means all remaining matches. Enumeration includes memories without vectors.
search_ids returns up to k hits with a memory ID and its cosine similarity score, ordered by descending score and ascending ID for ties. It delegates scoring to search_embeddings. ids=None searches all nodes; ids=[] searches none. Duplicate IDs are deduplicated and absent IDs ignored. Type and ID restrictions are intersected before ranking. Missing/empty vectors are skipped. k must be positive and optional min_score is inclusive and in [-1, 1]. An empty, zero, non-finite or non-1D query, or an invalid/nonmatching candidate vector, raises ValueError. Neither method activates memories or changes the graph.
find_adjacent_ids follows active edges up to depth hops. The starting ID is excluded. Intermediate nodes can have any type. The memory_type filter applies to the returned nodes before pagination. Results are sorted by descending active outgoing edge count, then ascending ID.
Callers ensure that query and candidate vectors belong to compatible embedding spaces, including migrations when a model changes. Equal dimensions do not prove compatibility. MemoryGraph does not interpret model names or embedding hashes. These methods are synchronous; storage-backed repositories may provide async operations with the same parameter and ordering semantics.
ids = graph.find_adjacent_ids(emotion_id) hits = graph.search_ids(query_vector, ids=ids, k=2) memories = graph.mget([hit.id for hit in hits]) kiarina.agi.message
from kiarina.agi.message import ( AIMessage, AIMessageChunk, BaseMessage, HumanMessage, Message, MessageType, SystemMessage, ToolCall, ToolCallChunk, ToolMessage, dehydrate_message, hydrate_messages, ) MessageType = Literal["system", "human", "ai", "ai_chunk", "tool"] Message: TypeAlias = ( SystemMessage | HumanMessage | AIMessage | AIMessageChunk | ToolMessage ) def dehydrate_message( message: Message, pool: FileInfoPool, ) -> tuple[Message, FileInfoPool]: ... def hydrate_messages( messages: list[Message], pool: FileInfoPool, ) -> tuple[list[Message], FileInfoPool]: ... class BaseMessage: type: MessageType contents: list[Content] = [] metadata: dict[str, Any] = {} # free data, never sent to a model def get_file_infos(self) -> list[FileInfo]: ... def contents_to_text(self) -> str: ... def to_estimates(self) -> ChatEstimates: ... def to_text(self) -> str: ... def replace_content(self, old: Content, new: Content) -> Self: ... def shrink( self, pool: FileInfoPool, reduce: TokenCount, reserve: TokenCount = 0, ) -> tuple[FileInfoPool, TokenCount]: ... class SystemMessage(BaseMessage): type: Literal["system"] = "system" @classmethod def create( cls, text: str = "", files: list[FileInfo] | None = None, ) -> Self: ... class HumanMessage(BaseMessage): type: Literal["human"] = "human" @classmethod def create( cls, text: str = "", files: list[FileInfo] | None = None, ) -> Self: ... class AIMessage(BaseMessage): type: Literal["ai"] = "ai" tool_calls: list[ToolCall] = [] @classmethod def create( cls, text: str = "", files: list[FileInfo] | None = None, *, tool_calls: list[ToolCall] | None = None, ) -> Self: ... class AIMessageChunk(AIMessage): type: Literal["ai_chunk"] = "ai_chunk" tool_call_chunks: list[ToolCallChunk] = [] class ToolMessage(BaseMessage): type: Literal["tool"] = "tool" tool_name: str tool_call_args: dict[str, Any] = {} tool_call_id: str return_direct: bool = False failed: bool = False artifact: dict[str, Any] = {} display_contents: list[DisplayContent] = [] @classmethod def create( cls, text: str = "", files: list[FileInfo] | None = None, *, tool_name: str, tool_call_args: dict[str, Any] | None = None, tool_call_id: str, ) -> Self: ... class ToolCall: id: str =
from kiarina.agi.tool_info import ( ToolChoice, ToolInfo, ToolName, ToolState, create_tool_info, ) ToolName: TypeAlias = str ToolChoice: TypeAlias = Literal["auto", "any"] | ToolName ToolState = Literal["active", "inactive", "disabled"] def create_tool_info( source: type[BaseModel] | dict[str, Any], name: ToolName | None = None, description: str | None = None, cache_control: dict[str, Any] | None = None, ) -> ToolInfo: ... class ToolInfo: name: ToolName description: str args_schema: dict[str, Any] = {} cache_control: dict[str, Any] | None = None state: ToolState = "active" def to_estimates(self) -> ChatEstimates: ... def to_json_schema(self) -> dict[str, Any]: ... Project links
Released: Nov 29, 2026
Author/Maintainer: kiarina
Both files in this release have provenance metadata.
View provenance details
MIT View SPDX License List
agents ai data-models embeddings events messages
Development Status 4 - Beta
Intended Audience Developers
Operating System OS Independent
Programming Language Python :: 3
Topic Software Development :: Libraries :: Python Modules
Release files for kiarina-agi-data 2.47.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 105.5 kB
Release files / kiarina_agi_data-2.47.0.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Release files / kiarina_agi_data-2.47.0-py3-none-any.whl
Security for kiarina-agi-data 2.47.0
Both files in this release have been uploaded with provenance metadata.
With provenance kiarina_agi_data-2.47.0.tar.gz Nov 29, 2026
Attestation for kiarina_agi_data-2.47.0.tar.gz
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Nov 29, 2026 2 release files Full provenance
Nov 16, 2026 2 release files Full provenance
Nov 6, 2026 2 release files Full provenance
Oct 7, 2026 2 release files Full provenance
Sep 30, 2026 2 release files Full provenance
Sep 15, 2026 2 release files Full provenance
Jul 27, 2026 2 release files Full provenance
Jul 6, 2026 2 release files Full provenance
Jul 3, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from fc0d8e6











