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_OTLP_ENDPOINT (falling back to the superseded RATEL_URL, which warns) and RATEL_API_KEY, wires trace and Logs exporters, and returns a shutdown handle. It exports only gen_ai.*/ratel.* signal spans and EventRecords by default — export_all_spans=True widens spans only. Message/tool content stays off by default; opt in with capture_content/include_span_and_events (see the telemetry guide for the capture modes and their privacy implications). Hosts that already own OpenTelemetry providers add both ratel_span_processor and ratel_log_record_processor instead.

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

Uploaded CPython 3.9+Windows x86-64

ratel_ai-0.5.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

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

ratel_ai-0.5.2-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.5.2-cp39-abi3-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ratel_ai-0.5.2-cp39-abi3-macosx_10_12_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file ratel_ai-0.5.2.tar.gz.

File metadata

  • Download URL: ratel_ai-0.5.2.tar.gz
  • Upload date:
  • Size: 131.5 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.5.2.tar.gz
Algorithm Hash digest
SHA256 ff702db0d87c8d05a84824f680f2fd5338450bab4662df1538359917ef621fce
MD5 fa20205c53d7d18397d35d4c7d0237d5
BLAKE2b-256 cd0aff61b9c678dfb3a2b379ccc1e97e4dd729344baedc8207613e8120a3ce2e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: ratel_ai-0.5.2-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.14

File hashes

Hashes for ratel_ai-0.5.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 41815977d3bfd397f31dbd19d8e2ccb59ab513519404cafd2812b40aaee41e36
MD5 e0e15d377aa018b1c4d9662f8d6acacf
BLAKE2b-256 274652aa112bed0040835ef7128a0a4ab08c5ebbc0cabcf7e5d771f9b21df8ac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ratel_ai-0.5.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e575721e90c5d207d8bb5cdceaf4ca14418dc5cba44ff18d434612840c9e23b
MD5 96a6e776049dbb23653517c279e6ac9e
BLAKE2b-256 53463dc3187eb2a28dab025f528e487fb3ed9f067508d98e29d779948f8db481

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ratel_ai-0.5.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 eaf34dadb109a0919bfc3115ab43a1905f0f72e8bc1e04e2a2f81b5ff1509ffd
MD5 15055caa2186fdc2332e8ed90b62f1a8
BLAKE2b-256 d1c046b73ad4b52f9d7802af049abf64e582b5649afe98e60dd3edb203061671

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ratel_ai-0.5.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 41b4aae67cdadc9925e3f9d8ce34b9bac55336d50cc6e54f854dc310c0cc001f
MD5 5879a7d2c50162f14a56f929b1822853
BLAKE2b-256 64fcb3041ab052616abc4563a6549352eee0bfecba289db51c293b7aea85a736

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for ratel_ai-0.5.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f1d9fda065e537e24091930002792dc526488a588d86708d1514920504030c6e
MD5 e191bf9969ae221dae7a0b79fcbcdc65
BLAKE2b-256 03735c792354b385a0a0033578ea96cbfaf171b13486b50c93a44c2db1ca9445

See more details on using hashes here.

Provenance

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