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.0rc1.tar.gz (125.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.0rc1-cp39-abi3-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

ratel_ai-0.5.0rc1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.9 MB view details)

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

ratel_ai-0.5.0rc1-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.0rc1-cp39-abi3-macosx_11_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ratel_ai-0.5.0rc1-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.0rc1.tar.gz.

File metadata

  • Download URL: ratel_ai-0.5.0rc1.tar.gz
  • Upload date:
  • Size: 125.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.0rc1.tar.gz
Algorithm Hash digest
SHA256 4eb4cde91db5f43a5fa34951b05f0196acd53df8502a606af5dfb2a42ab1d373
MD5 a7fee1bfed0933c00224c437c472f4d7
BLAKE2b-256 78ec7726555aaf2a0a53eefcb4e51029cfd8983c0c45c757326270062ea624c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc1.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.0rc1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: ratel_ai-0.5.0rc1-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.0rc1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2fe61ca62077e9d86d8ac4bb508c4fe10b7fdb6bf61682ca1a3398c741a8edc6
MD5 da05cee837a1568f98bcbf4242a5b11b
BLAKE2b-256 9cb456b6339d3d83f00881f3983f4502fe86e6871abae5cd70a533c4f460edb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc1-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.0rc1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.5.0rc1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 863196a3e146c72b32f0b05f9244b3e200b060605f81d1244580d5379dcef912
MD5 0653b5b664e5ed7c55effbd319535467
BLAKE2b-256 0f171214a3c6d742cfafccf152dab22dd8094d6386fe8f01992d08ae3879fbe3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc1-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.0rc1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.5.0rc1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3bc53af175f41195ccae1371c00b9f3300708e7af0781f442286836c3edf89e4
MD5 8e3dc4edb4153d961ed2fcc8b63aff78
BLAKE2b-256 98926d2090fde7a1c50b64305e34b4c7fe653bd3f4b837c0d1b57bee6b3065c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc1-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.0rc1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.5.0rc1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 724c7beeec5012e5ba29521928d29df43f1fcd12cc0cda7272353d9521fa1d68
MD5 ee3fcd5fe22dfedc26781064def86145
BLAKE2b-256 674f395f264c3946df062e08c36b47ffc55bf0ff3442496acb18ddb93384c7b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc1-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.0rc1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.5.0rc1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2e64832c0e11fbdf0e34296cd186053983ab1abc8d64db251533fef9bc07779d
MD5 8aa9eebd1b6d7caaf1cf95adb2cdbb58
BLAKE2b-256 7071ea7fb604b604d9f34c9cbe1c2a4aa80f0a70b34ea5e14cc97d014f07544f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.5.0rc1-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