Chat and text embedding abstractions for AI agents
Project description
kiarina-agi-text
English | 日本語
[!NOTE] What is this? Provides interchangeable chat models, chat logging, and text embeddings for AI agents.
Dependencies
Required Dependencies
| Package | Version | License |
|---|---|---|
| kiarina-agi-base | >=2.6.0 |
MIT |
| kiarina-agi-data | >=2.6.0 |
MIT |
| kiarina-agi-file | >=2.6.0 |
MIT |
| kiarina-utils-app | >=2.4.0 |
MIT |
| kiarina-utils-common | >=2.3.0 |
MIT |
| kiarina-utils-file | >=2.3.1 |
MIT |
| LangChain | >=1.0.0,<2 |
MIT |
| langchain-core | >=1.0.0,<2 |
MIT |
| Pydantic | >=2.11.7 |
MIT |
| pydantic-settings | >=2.10.1 |
MIT |
| pydantic-settings-manager | >=3.2.0 |
MIT |
Optional Dependencies
| Package | Version | License | Extras |
|---|---|---|---|
| anthropic | >=0.84.0,<1 |
MIT | chat-provider-lc-anthropicchat-provider-lc-anthropic-vertex |
| google-genai | >=1.65.0,<3 |
Apache-2.0 | chat-provider-lc-google-genaitext-embedding-provider-google |
| kiarina-lib-google | >=2.3.1 |
MIT | chat-provider-lc-anthropic-vertexchat-provider-lc-google-genaitext-embedding-provider-google |
| kiarina-lib-openai | >=2.3.1 |
MIT | chat-provider-lc-openaitext-embedding-provider-openai |
| langchain-anthropic | >=1.0.0,<2 |
MIT | chat-provider-lc-anthropicchat-provider-lc-anthropic-vertex |
| langchain-google-genai | >=4.0.0,<5 |
MIT | chat-provider-lc-google-genai |
| langchain-google-vertexai | >=3.0.0,<4 |
MIT | chat-provider-lc-anthropic-vertex |
| langchain-openai | >=1.0.0,<2 |
MIT | chat-provider-lc-openai |
| NumPy | >=2.0 |
BSD-3-Clause | text-embedding-provider-googletext-embedding-provider-mocktext-embedding-provider-openai |
| openai | >=2.0.1,<3 |
Apache-2.0 | chat-provider-lc-openaitext-embedding-provider-openai |
| tiktoken | >=0.13.0 |
MIT | text-embedding-provider-openai |
| ulid-py | >=1.1.0 |
Apache-2.0 | chat-provider-mock |
The all Extra installs every optional dependency listed above.
Installation
pip install "kiarina-agi-text[all]"
Features
- Chat Models Select a model by name or alias and receive one response or a stream. Tool calls and image, audio, video, and PDF inputs and outputs are also supported.
- Text Embeddings Select a registered model and vectorize text through one API.
API Reference
kiarina.agi.chat_model
from kiarina.agi.chat_model import (
ChatModel,
ChatModelAlias,
ChatModelConfig,
ChatModelName,
ChatModelSettings,
ChatModelSpecifier,
ChatOptions,
chat_model_registry,
invoke_chat,
run_chat,
settings_manager,
stream_chat,
)
async def invoke_chat(
messages: list[Message],
*,
tool_infos: list[ToolInfo] | None = None,
chat_options: ChatOptions | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> AIMessage: ...
async def run_chat(
messages: list[Message],
*,
tool_infos: list[ToolInfo] | None = None,
chat_options: ChatOptions | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> AsyncIterator[AIMessageChunk | AIMessage]: ...
async def stream_chat(
messages: list[Message],
*,
tool_infos: list[ToolInfo] | None = None,
chat_options: ChatOptions | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> AsyncIterator[AIMessageChunk | AIMessage]: ...
class ChatModel:
def __init__(self, name: ChatModelName, config: ChatModelConfig) -> None: ...
@property
def provider_name(self) -> ChatProviderName: ...
@property
def provider_config(self) -> dict[str, Any]: ...
@property
def token_scale_factor(self) -> float: ...
@property
def provider(self) -> ChatProvider: ...
def get_capabilities(self) -> ChatCapabilities: ...
async def run(
self,
messages: list[Message],
*,
tool_infos: list[ToolInfo] | None = None,
tool_choice: ToolChoice | None = None,
parallel_tool_calls: bool | None = None,
streaming: bool | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> AsyncIterator[AIMessageChunk | AIMessage]: ...
class ChatModelConfig(BaseModel):
provider_name: ChatProviderName
provider_config: dict[str, Any] = {}
token_scale_factor: float = 1.0
visible: bool = True
class ChatOptions(TypedDict, total=False):
chat_model: ChatModel | ChatModelSpecifier | None
tool_choice: ToolChoice | None
parallel_tool_calls: bool | None
streaming: bool | None
ChatModelName: TypeAlias = str
ChatModelAlias: TypeAlias = str
ChatModelSpecifier: TypeAlias = ChatModelName | ChatModelAlias | str
chat_model_registry: ObjectRegistry[ChatModel, ChatModelConfig]
settings_manager: SettingsManager[ChatModelSettings]
ChatModelSettings is a Pydantic settings class with default, aliases, presets, and customs fields.
kiarina.agi.text_embedding_model
from kiarina.agi.text_embedding_model import (
TextEmbeddingModel,
TextEmbeddingModelAlias,
TextEmbeddingModelConfig,
TextEmbeddingModelName,
TextEmbeddingModelSettings,
TextEmbeddingModelSpecifier,
TextEmbeddingOptions,
embed_text,
settings_manager,
text_embedding_model_registry,
)
async def embed_text(
text: str,
*,
text_embedding_options: TextEmbeddingOptions | None = None,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> Embedding: ...
class TextEmbeddingModel:
def __init__(
self, name: TextEmbeddingModelName, config: TextEmbeddingModelConfig
) -> None: ...
@property
def provider_name(self) -> TextEmbeddingProviderName: ...
@property
def provider_config(self) -> dict[str, Any]: ...
@property
def provider(self) -> TextEmbeddingProvider: ...
def get_space(self) -> EmbeddingSpace: ...
async def embed(
self,
text: str,
*,
cost_recorder: CostRecorder | None = None,
run_context: RunContext,
) -> Embedding: ...
class TextEmbeddingModelConfig(BaseModel):
provider_name: TextEmbeddingProviderName
provider_config: dict[str, Any] = {}
visible: bool = True
class TextEmbeddingOptions(TypedDict, total=False):
text_embedding_model: TextEmbeddingModel | TextEmbeddingModelSpecifier | None
TextEmbeddingModelName: TypeAlias = str
TextEmbeddingModelAlias: TypeAlias = str
TextEmbeddingModelSpecifier: TypeAlias = (
TextEmbeddingModelName | TextEmbeddingModelAlias | str
)
text_embedding_model_registry: ObjectRegistry[
TextEmbeddingModel, TextEmbeddingModelConfig
]
settings_manager: SettingsManager[TextEmbeddingModelSettings]
TextEmbeddingModelSettings has default, aliases, presets, and customs fields.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kiarina_agi_text-2.7.0.tar.gz.
File metadata
- Download URL: kiarina_agi_text-2.7.0.tar.gz
- Upload date:
- Size: 59.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d32a3af9025182864b2d7d434477a8974dff63dffb77df30bd1fbacbfd91cba3
|
|
| MD5 |
8259b5a44c811fb7734146e630e0ea68
|
|
| BLAKE2b-256 |
2a65f018c2faaced6c8b31b5d3fa74233b2d5a4eb74e90cdc9a9068b463c45d5
|
Provenance
The following attestation bundles were made for kiarina_agi_text-2.7.0.tar.gz:
Publisher:
release-pypi.yml on kiarina/kiarina-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kiarina_agi_text-2.7.0.tar.gz -
Subject digest:
d32a3af9025182864b2d7d434477a8974dff63dffb77df30bd1fbacbfd91cba3 - Sigstore transparency entry: 2083880885
- Sigstore integration time:
-
Permalink:
kiarina/kiarina-python@4f655f103f5ef96cb29dc67af4c634052ca55f1f -
Branch / Tag:
refs/tags/v2.7.0 - Owner: https://github.com/kiarina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@4f655f103f5ef96cb29dc67af4c634052ca55f1f -
Trigger Event:
push
-
Statement type:
File details
Details for the file kiarina_agi_text-2.7.0-py3-none-any.whl.
File metadata
- Download URL: kiarina_agi_text-2.7.0-py3-none-any.whl
- Upload date:
- Size: 86.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13054527ba6f9cf986fef846772375e91b9143383536bd4fbbd58d9ceb1134a5
|
|
| MD5 |
f86c339940c9f78d3c1aa9fdf1fe8761
|
|
| BLAKE2b-256 |
8d59373145ba54e0ec27f1b1a4c5471a02d189b84da754f9ffd53bf624a37f1a
|
Provenance
The following attestation bundles were made for kiarina_agi_text-2.7.0-py3-none-any.whl:
Publisher:
release-pypi.yml on kiarina/kiarina-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kiarina_agi_text-2.7.0-py3-none-any.whl -
Subject digest:
13054527ba6f9cf986fef846772375e91b9143383536bd4fbbd58d9ceb1134a5 - Sigstore transparency entry: 2083880914
- Sigstore integration time:
-
Permalink:
kiarina/kiarina-python@4f655f103f5ef96cb29dc67af4c634052ca55f1f -
Branch / Tag:
refs/tags/v2.7.0 - Owner: https://github.com/kiarina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@4f655f103f5ef96cb29dc67af4c634052ca55f1f -
Trigger Event:
push
-
Statement type: