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.6.0rc0.tar.gz (193.7 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.6.0rc0-cp39-abi3-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.9+Windows x86-64

ratel_ai-0.6.0rc0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

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

ratel_ai-0.6.0rc0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

ratel_ai-0.6.0rc0-cp39-abi3-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ratel_ai-0.6.0rc0-cp39-abi3-macosx_10_12_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file ratel_ai-0.6.0rc0.tar.gz.

File metadata

  • Download URL: ratel_ai-0.6.0rc0.tar.gz
  • Upload date:
  • Size: 193.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ratel_ai-0.6.0rc0.tar.gz
Algorithm Hash digest
SHA256 fbbb6b1ba3105ecba0336029ce20b4fa64aebbddb5d327d6e9be8f5b416fc9e0
MD5 c4958e8b02f944beb0e9745ca870480c
BLAKE2b-256 fdc88e8a2e5187202baa40b6a14e105135425c48419e0ec8a1ac362962b10053

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.6.0rc0.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.6.0rc0-cp39-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for ratel_ai-0.6.0rc0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0451621abb873656ea9e6406588536eb2a524fd5434137815d098e3f33d1f66a
MD5 81b322fee03141fb12b6b8f3f9898f15
BLAKE2b-256 650a6626bbbf7789f7ddbff5c1749f1bf35d6bf7e4fb3de6c8b422dd277b88f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.6.0rc0-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.6.0rc0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.6.0rc0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 20d174547b3e792bdb766e1a786c489a29a85811f3b3f3a331f6978c55098cda
MD5 4da3bee3a75cab3e0aa29f17da9d9216
BLAKE2b-256 c3ce2276399b384a0b81e44db47c214bf8cff8fcfd680f9c36825911b6d7478e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.6.0rc0-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.6.0rc0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.6.0rc0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 38d8e27751206c38f68e3e2e9a3eecaaf99f8d3afcb7f302dd8123f634561c64
MD5 e1e0eee4453595399fdbc0d2fff5704b
BLAKE2b-256 8fc64e90b29bf7209da97f8f1e25c9936f9e6bb2ac6e3ff5ef41cc74de1432ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.6.0rc0-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.6.0rc0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.6.0rc0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 58b6b69c226ffa3f7a3f1853bd8808b7d4d55268aec110158f02357766b3a53b
MD5 17bdc4b0576862791ce90cbac6bb965e
BLAKE2b-256 e22e98396bf5f5cd58740f67fd8d692dc94a2171a6a4416c63a29b313588416a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ratel_ai-0.6.0rc0-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.6.0rc0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ratel_ai-0.6.0rc0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 556202967fc2739c2cbc77f85b35051663620588d877f95531654167230d3104
MD5 18a431a8a6073fcef2593d4d2e2201e0
BLAKE2b-256 4e9e962393c2136dd59be3185f10e8fddd2b0403e728528f6fbff1ddd27f7806

See more details on using hashes here.

Provenance

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