Skip to main content

Python SDK for Ratel — context engineering platform for AI agents. BM25 tool retrieval, MCP ingestion, framework-neutral capability tools.

Project description

ratel-ai

Context engineering for Python agents.

DocsGitHubDiscord

PyPI GitHub stars MIT license

ratel-ai retrieves the tools and skills relevant to each agent turn instead of sending the full catalog to the model. It bundles Ratel's Rust engine in-process: BM25 by default, with configurable semantic and hybrid retrieval available when needed. The default and local-model paths require no API key, vector database, or service. Installing a published package on a supported prebuilt target also requires no Rust toolchain.

Use ToolCatalog for ranked tools with sync or async handlers and SkillCatalog for ranked Markdown playbooks loaded on demand. Expose search_capabilities_tool, invoke_tool_tool, and get_skill_content_tool so an agent can discover tools and skills, invoke tools, and load full skill instructions. Tools from existing MCP servers can be ingested into the tool catalog with the mcp extra.

Semantic and hybrid retrieval use a configurable embedding model (ADR 0012), set per catalog via the embedding argument: the built-in default, a HuggingFace repo or local directory (in-process), or an OpenAI-compatible endpoint (OpenAI, Ollama, TEI, vLLM).

For semantic or hybrid retrieval, register() folds embedding in: it accepts one tool or a whole batch and embeds on a worker thread, so model loading, HTTP, and inference never block the asyncio loop or hold the GIL — and embedding errors surface right at register():

async def retrieve(tools):
    catalog = ToolCatalog(method="semantic", embedding={"ollama": "nomic-embed-text"})
    await catalog.register(tools)                              # embeds the batch here
    return await catalog.search_async("deploy the service", 5)

register() is async for every method (BM25 too); search() stays synchronous for BM25 only, and search_async() covers all three. To change the endpoint's model or vector dimension, construct a new catalog and re-register.

Install

pip install ratel-ai
# MCP ingestion: pip install 'ratel-ai[mcp]'

Quickstart

Save as quickstart.py, then run python quickstart.py:

import asyncio
from ratel_ai import ExecutableTool, ToolCatalog

async def main():
    catalog = ToolCatalog()
    await catalog.register(
        ExecutableTool(
            id="get_weather",
            name="get_weather",
            description="Get the current weather for a city.",
            input_schema={"properties": {"city": {"type": "string"}}},
            output_schema={"type": "object"},
            execute=lambda args: {"forecast": f"Sunny in {args['city']}"},
        )
    )

    hit = catalog.search("What is the weather in Rome?", 1)[0]
    print(await catalog.invoke(hit.tool_id, {"city": "Rome"}))


asyncio.run(main())

Continue with the Python guide, capability tools, API reference, or the Pydantic AI example.

Telemetry export is optional. With the otlp extra installed, configure_telemetry() reads RATEL_URL and RATEL_API_KEY, wires the exporter, and returns a shutdown handle. See the telemetry guide.

Package layout: ratel_ai/ is the Python surface, native/ contains the PyO3 binding, and tests/ exercises both. For local development, create .venv with uv, install maturin, pytest, pytest-asyncio, ruff, and mypy, then run .venv/bin/maturin develop and .venv/bin/pytest.

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

ratel_ai-0.5.0rc2.tar.gz (129.2 kB view details)

Uploaded Source

Built Distributions

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

ratel_ai-0.5.0rc2-cp39-abi3-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

ratel_ai-0.5.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

ratel_ai-0.5.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

ratel_ai-0.5.0rc2-cp39-abi3-macosx_11_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ratel_ai-0.5.0rc2-cp39-abi3-macosx_10_12_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file ratel_ai-0.5.0rc2.tar.gz.

File metadata

  • Download URL: ratel_ai-0.5.0rc2.tar.gz
  • Upload date:
  • Size: 129.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ratel_ai-0.5.0rc2.tar.gz
Algorithm Hash digest
SHA256 9850e344831277580e38b9a3373928688eb123360341ef21c1783f0f7aca3451
MD5 b11b7f12e5a75236b738e6d919b0fc59
BLAKE2b-256 9ba5d9de8790d1132d8220abd961e4f8113c8c97e6259b42c50033310af14e6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc2.tar.gz:

Publisher: release.yml on ratel-ai/ratel

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

File details

Details for the file ratel_ai-0.5.0rc2-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: ratel_ai-0.5.0rc2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ratel_ai-0.5.0rc2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9590d46ed61717fab95888ed3f512e98d0bb52daa9dfc51a87136dd96367e9d3
MD5 92a9fc699d037140feed0d36a3b03041
BLAKE2b-256 e66c4d24a4ea6eab825d9f40801488f1ee5e3ee003845d5a2e17aa831deb5cbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc2-cp39-abi3-win_amd64.whl:

Publisher: release.yml on ratel-ai/ratel

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

File details

Details for the file ratel_ai-0.5.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.5.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 72fcb433f14c1e6af164de7cdb015bd738a252184074bf03ee624917361b3684
MD5 622b74e88f8b6c787b306be73a4e67d7
BLAKE2b-256 c044d4a7277ffbfdcfd32510dde928ddd35f727bb6d044e0d14ab9d290771757

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on ratel-ai/ratel

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

File details

Details for the file ratel_ai-0.5.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.5.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 66084f8345f905cc7ec92ff44bdb89794032ad0f62723edc50edc30986806c45
MD5 ccfc180a79f0a03e844222146a639f66
BLAKE2b-256 6a7b405355ff4cdbcf24db634ee78e04f44ed5464bd817874530cb6f59b6ba8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on ratel-ai/ratel

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

File details

Details for the file ratel_ai-0.5.0rc2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.5.0rc2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4dd50f7102adee984e4bbe6d78937a214687236bc2deff59767d2cd132c2b4e0
MD5 5a5b6bb53cfd4e26a0bd835850ba3cfe
BLAKE2b-256 4823639f116b99fe686bda33b24a72b28ddfc22becc35694bdcdc071df93279e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc2-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on ratel-ai/ratel

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

File details

Details for the file ratel_ai-0.5.0rc2-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.5.0rc2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dffd75f5d3c0cbe25ac33e1c6faf2e688560a59cd5cf376e66222f789598b3fe
MD5 faf3af39d3defe8f14d4bd4a730aaa93
BLAKE2b-256 6d0ddccf9353020a933faa7c70d115cc16fa47fa8ad715ad6799c411bfeea689

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc2-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on ratel-ai/ratel

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