swarmauri_base
swarmauri_base
Reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure.
Overview · Installation · Quick Start · Usage · API · Contributing · Governance · License
Overview
Summary
swarmauri_base: Reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure.
Why This Package
swarmauri_base turns Swarmauri interfaces into reusable component foundations. It gives implementation packages consistent Pydantic modeling, resource metadata, dynamic subtype registration, serialization, and family-specific base behavior.
When to Use
Use swarmauri_base when implementing a Swarmauri component that needs serialization, registration, and shared base behavior. Use swarmauri_core when you only need interface definitions. Use implementation packages such as swarmauri_standard or individual component packages when you need ready-to-run behavior.
Features
ComponentBasefor Pydantic-backed Swarmauri components withtype,resource,name, andversionfields.DynamicBaseandSubclassUnionfor discriminated-union deserialization from concretetypevalues.- JSON, YAML, and TOML serialization through Pydantic plus Swarmauri mixins.
- Base classes for agents, chains, chunkers, conversations, documents, embeddings, LLMs, tools, toolkits, vector stores, parsers, prompts, transports, middleware, signing, crypto, key providers, tokens, billing, XMP, and more.
- Default mixins for logging, service metadata, batch behavior, retrieval behavior, storage behavior, and component-family-specific workflows.
- Python 3.10, 3.11, 3.12, 3.13, and 3.14 support.
Non-Goals
swarmauri_base owns reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure. Its imports do not by themselves configure credentials, deploy a service, or certify the behavior of its consumers. Dependencies and neighboring packages retain their own documented responsibilities.
Getting Started
Prerequisites
Python >=3.10,<3.15 is required. The manifest declares runtime dependencies including pyyaml, httpx, numpy, pydantic, starlette, swarmauri-core, swarmauri-typing, toml, tomli. Read the example’s inputs and service requirements before execution.
Installation
Install with uv:
uv add swarmauri_base
Install with pip:
pip install swarmauri_base
uv
uv add swarmauri_base
pip
python -m pip install swarmauri_base
Poetry
poetry add swarmauri_base
Quick Start
Example
Source: docs/readme/quick_start.py.
from typing import Literal
from swarmauri_base.ComponentBase import ComponentBase
@ComponentBase.register_model()
class StoreConfig(ComponentBase):
type: Literal["StoreConfig"] = "StoreConfig"
name: str
Expected Result
The example demonstrates the documented swarmauri_base source boundary or workflow. Complete its required configuration first. README CI checks the maintained source’s syntax and declarations; it does not claim that external services or the application workflow were exercised.
Usage
Common Workflows
Source: docs/readme/usage.py.
from typing import Literal
from swarmauri_base.ComponentBase import ComponentBase
@ComponentBase.register_model()
class StoreConfig(ComponentBase):
type: Literal["StoreConfig"] = "StoreConfig"
name: str
Create a typed component by inheriting from ComponentBase:
Register and hydrate concrete subtypes with SubclassUnion:
from typing import Literal
from pydantic import BaseModel
from swarmauri_base.ComponentBase import ComponentBase
from swarmauri_base.DynamicBase import SubclassUnion
@ComponentBase.register_model()
class StoreConfig(ComponentBase):
type: Literal["StoreConfig"] = "StoreConfig"
name: str
@ComponentBase.register_type(StoreConfig, "SqliteStoreConfig")
class SqliteStoreConfig(StoreConfig):
type: Literal["SqliteStoreConfig"] = "SqliteStoreConfig"
path: str
class StoreEnvelope(BaseModel):
store: SubclassUnion[StoreConfig]
envelope = StoreEnvelope.model_validate_json(
'{"store":{"type":"SqliteStoreConfig","name":"local","path":"./data.db"}}'
)
assert isinstance(envelope.store, SqliteStoreConfig)
Build a concrete tool from ToolBase:
from typing import Any, Literal
from swarmauri_base.tools.ToolBase import ToolBase
class EchoTool(ToolBase):
type: Literal["EchoTool"] = "EchoTool"
name: str = "echo"
description: str = "Return the input payload."
def __call__(self, payload: Any) -> Any:
return payload
tool = EchoTool()
assert tool("hello") == "hello"
assert tool.batch(["a", "b"]) == ["a", "b"]
Configuration
The package source references configuration keys PATH, PEAGEN_CONFIG. Consult the constructor or function signature before supplying them; a referenced key is not necessarily a global environment variable.
Error Handling
The inspected swarmauri_base source raises CapabilityError, DuplicateToolCallError, EvaluationError, FileNotFoundError, IndexError, KeyError, NotImplementedError, PoPBindingError, PoPParseError, PoPVerificationError. Handle these at the calling boundary and consult the implementation for the triggering conditions.
Best Practices
Use the explicit swarmauri_base imports documented below and keep collaborator configuration with the caller. Run the package’s relevant tests after changing FullUnion, SubclassUnion, register_model, register_type; an import or successful installation alone does not establish its runtime guarantees.
Package Boundary
What It Owns
swarmauri_base is located in base and owns reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure. Source-declared APIs include FullUnion, SubclassUnion, register_model, register_type. The manifest records its direct dependency boundary.
Public API and Import Surfaces
Import namespace: swarmauri_base.
Source-declared exports or types: FullUnion, SubclassUnion, register_model, register_type.
Inspect package source for exact signatures; this inventory does not designate every internal module as stable.
Entry Points
This package declares no command-line, GUI, or plugin entry points in its manifest.
Injected Dependencies
The direct installation dependencies of swarmauri_base are pyyaml, httpx, numpy, pydantic, starlette, swarmauri-core, swarmauri-typing, toml, tomli. These declarations do not imply automatic provider selection. Pass collaborators through the explicit constructors or call signatures in package source.
Protocol Consumers
Direct consumers in this checkout’s package manifests include swarmauri-demo-package-maintenance, swarmauri_billing_adyen, swarmauri_billing_authorize_net, swarmauri_billing_braintree, swarmauri_billing_paypal, swarmauri_billing_paystack, swarmauri_billing_razorpay, swarmauri_billing_square, swarmauri_certs_acme, swarmauri_certs_azure, swarmauri_certs_cfssl, swarmauri_certs_crlverifyservice, swarmauri_certs_csronly, swarmauri_certs_ocspverify, swarmauri_certservice_aws_kms. These edges describe declared dependencies, not protocol-conformance evidence.
Extensions
For swarmauri_base, use the source-declared public interfaces (FullUnion, SubclassUnion, register_model, register_type) when composing or extending behavior. Its entry-point section below is authoritative for registered plugins; no additional extension loader is inferred from the package name.
Operations and Readiness
Operational Requirements
Operate swarmauri_base according to its actual entry points and collaborators. The dependency and Python requirements in the manifest are prerequisites; deployment topology, credentials, and readiness remain the responsibility of the consuming application unless explicitly documented above.
Health and Observability
This README does not establish a standalone health endpoint for swarmauri_base. Observe the concrete caller’s results, exceptions, and existing test reports. An application that embeds this package must define its own health and telemetry contract.
Security and Resource Limits
Apply the input, credential, and resource constraints implemented in package source. The swarmauri_base README gate is a documentation check, not a security review or a substitute for the implementation’s limits and caller authorization.
Compatibility
This source version of swarmauri_base declares Python >=3.10,<3.15. Consult its dependency constraints before upgrading. Source-version and registry-version badges have separate meanings; this migration makes no additional platform or interoperability certification claim.
Verification
Tests
Run python -m pytest tests/unit/test_readme_sources.py from the swarmauri_base package directory for the maintained example source checks (Python compilation and non-Python file presence). Existing package tests include:
- tests/integration/test_middleware_starlette.py
- tests/unit/test_chain_context_base.py
- tests/unit/test_dynamic_schema_examples.py
- tests/unit/test_embedxmp_base.py
- tests/unit/test_git_filter_base.py
The repository README gate also checks the required heading tree, metadata, managed fragments, and referenced files.
Certification Status
No external certification is asserted for swarmauri_base by this documentation migration. README conformance, example syntax, runtime tests, and protocol or security certification are distinct evidence scopes.
Evidence
The README standards CI records mechanical documentation results for its tested commit. The package source and example sources support the package-boundary description; external runtime behavior requires its own test evidence.
FAQ
Why
Q: What is ComponentBase?
A: ComponentBase is the common Pydantic-backed base for Swarmauri components. It carries fields such as type, resource, name, and version, and participates in dynamic component registration.
Q: What is SubclassUnion used for?
A: SubclassUnion lets Pydantic models hydrate registered concrete component types from serialized payloads that include a type discriminator.
How
How do I start? Install or synchronize the environment under Getting Started, follow the maintained example for swarmauri_base, and consult package source for the exact types and signatures involved.
When
Q: When should I use swarmauri_base instead of swarmauri_core?
A: Use swarmauri_base when building a real component implementation. Use swarmauri_core when you only need the abstract interface contract.
Documentation and Related Packages
More Documentation
The repository contribution guide, package source, and manifest provide the supporting context for swarmauri_base. The README policy defines the common document structure.
Related Packages
Foundational packages:
- swarmauri_core provides the interface contracts that these base classes implement.
- swarmauri provides namespace imports and plugin discovery.
- swarmauri_standard provides first-party components built from these base classes.
- swarmauri_typing provides typing utilities used by dynamic union machinery.
Packages built on component-kind bases:
- swarmauri_signing_ed25519 builds on signing base behavior.
- swarmauri_crypto_composite builds on crypto base behavior.
- swarmauri_keyprovider_inmemory builds on key provider base behavior.
- swarmauri_storage_memory builds on storage adapter base behavior.
- swarmauri_transport_stdio builds on transport base behavior.
- swarmauri_middleware_jsonrpc builds on middleware base behavior.
Project Links
Contributing
How to Contribute
When adding or changing a base class, keep it aligned with the corresponding swarmauri_core interface, preserve direct plugin instantiation patterns, update exports and tests, and follow the Swarmauri SDK contribution guide.
Development Setup
Work from the pkgs/20-bases/swarmauri_base checkout. Synchronize its declared development environment with uv, then run the relevant package tests and python -m pytest tests/unit/test_readme_sources.py. The repository’s dedicated README job installs readme-standards==0.1.3 without resolving unrelated runtime packages.
Notes for Maintainers
Composable execution bases
Matching executions, tasks, workflows, permissions, delegation and
invocations modules provide abstract component bases for interchangeable
implementations. They do not add a transport or authenticator family.
See the composition guide.
swarmauri_base provides the reusable base classes, mixins, and dynamic component model used by Swarmauri SDK implementations. It builds on swarmauri_core interfaces and adds Pydantic models, typed component registration, JSON/YAML/TOML serialization, logging helpers, service helpers, and base classes for each major component family.
Component Families
swarmauri_base includes base classes and mixins for these component kinds:
- AI and agent workflow: agents, chains, conversations, prompts, prompt templates, pipelines, swarms, task management strategies, tool LLMs, tools, toolkits, LLMs, VLMs, OCR, STT, and TTS.
- Data and retrieval: documents, document stores, embeddings, vectors, vector stores, parsers, schema converters, data connectors, state, service registries, and storage adapters.
- Math and evaluation: vector-store comparators, deprecated distance compatibility shims, inner products, matrices, measurements, metrics, norms, pseudometrics, seminorms, similarities, tensors, evaluators, evaluator pools, and evaluator results.
- Runtime and infrastructure: transports, middleware, publishers, rate limits, logging handlers, logging formatters, loggers, tracing-oriented mixins, services, and programs.
- Security and trust: cert services, crypto, MRE crypto, cipher suites, signing, proof-of-possession helpers, key providers, token services, XMP embedding, and git filters.
- Business integrations: billing provider base classes and mixins for customers, hosted checkout, payments, invoices, subscriptions, refunds, payouts, reports, promotions, risk, marketplace, and webhooks.
Component Author Workflow
- Start with the relevant interface in swarmauri_core.
- Inherit the matching base class from
swarmauri_base. - Add a stable
typeliteral andresourcevalue. - Register the model or subtype with
ComponentBase.register_model()orComponentBase.register_type(...). - Add package entry points or namespace mappings through swarmauri when the implementation should be discoverable.
- Document installation, direct instantiation, serialization behavior, and any provider-specific configuration in the implementation package README.
Run storage
swarmauri_base.run_stores.RunStoreBase implements shared checkpoint revision
rules. A backend supplies an insert, a read, and an atomic compare-and-swap.
HTTP TTS transport
tts.HttpTTSMixin shares file, streaming and bounded async batch transport for
standalone TTS providers. Provider packages own request schemas, fixed URLs and
stream decoding. _speech_endpoint(streaming) selects provider-owned unary
and streaming routes; _audio_content(response) decodes unary JSON audio when
needed. _speech_request(payload, streaming) prepares headers and body once for
providers that require XML or an exact body signature. Existing JSON/binary
providers retain their default behavior. Transport does
not replay potentially billable requests.
tts.JsonAudioTTSMixin decodes complete base64/data-URI audio from JSON for
file and batch workflows. It rejects URL audio and malformed/empty data, and
checks WAV headers when WAV is requested. Providers validate their own status
and format fields. Its stream/astream methods raise locally; a complete JSON
response is never labeled an incremental stream.
Governance
Ownership and Decision Making
Changes to swarmauri_base follow the maintainer review process of swarmauri/swarmauri-sdk and its contribution guide. Author attribution remains in the manifest; this README does not assign new publishing or administrative authority.
Standards and Policies
swarmauri_base follows the versioned package-guide-v1 outline. All fixed headings, hierarchy, order, separators, and package-specific branding are checked by CI; reviewers assess the accuracy and usefulness of authored claims.
Lifecycle and Migration
The swarmauri_base source version is 0.11.0.
License and Attribution
License
Licensed under Apache-2.0. See LICENSE.
Apache-2.0
Notices
See NOTICE for attribution.
Metadata
Release files for swarmauri_base 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swarmauri_base-0.11.0.tar.gz | 121.1 kB | Without provenance | Details for swarmauri_base-0.11.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarmauri_base-0.11.0-py3-none-any.whl | Python 3 | none | any | Details for swarmauri_base-0.11.0-py3-none-any.whl |
Total release size: 345.3 kB
Release files / swarmauri_base-0.11.0.tar.gz
| Download URL | swarmauri_base-0.11.0.tar.gz |
|---|---|
| Size | 121.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3508d9d52e8dc64f80b0c10ed29c231a2f716cee8586156d6bc9bd69c5d1a333
|
|
BLAKE2b-256 checksum How to use checksums |
e40775875e758d897aa22618e56837bf2187f502c4b3d1e684aa3b6865e41b17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / swarmauri_base-0.11.0-py3-none-any.whl
| Download URL | swarmauri_base-0.11.0-py3-none-any.whl |
|---|---|
| Size | 224.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59881a26543a88fe2593ca77a400981aedd1936b41a1d758f8fc8ef6f3953147
|
|
BLAKE2b-256 checksum How to use checksums |
96b932ded940164f85104990c40306fb73d3ae1a17019f6512300a6d89224710
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for swarmauri_base 0.11.0
Provenance
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.