Skip to main content

Project Overview

pydantic-ai-channels is a framework for integrating Pydantic AI agents with real‑world messaging platforms like Telegram and Slack. It provides a clean, type‑safe abstraction for sending and receiving messages, handling webhooks, polling, and tool calling.

Key components:

  • Channel Adapters – Platform‑specific connectors (aiogram for Telegram, slack‑sdk for Slack).
  • Capabilities – Pydantic AI AbstractCapability wrappers that inject platform tools into an agent.
  • Toolsets – Production‑ready function tools for message sending, media uploads, inline keyboards, etc.

The project is built with Python 3.12+, uses uv for dependency management, and follows strict type safety and test coverage standards.


Prerequisites for Development

  • Python 3.12+ (as specified in pyproject.toml)
  • uv – the fast package installer and resolver. Install via pip install uv or curl -LsSf https://astral.sh/uv/install.sh | sh
  • Telegram Bot Token – obtain one from @BotFather for testing
  • (Optional) Slack bot token for Slack integration testing

Setting Up the Development Environment

  1. Clone the repository

    git clone https://gitlab.com/rzk.ssr/pydantic-ai-channels.git
    cd pydantic-ai-channels
    
  2. Install dependencies with uv

    uv sync
    

    This will create a virtual environment and install all runtime and development dependencies.

  3. Activate the virtual environment (optional)

    source .venv/bin/activate   # On Windows: .venv\Scripts\activate
    
  4. Set up pre‑commit hooks (for code quality)

    uv run pre-commit install
    
  5. Configure environment variables
    Create a .env file with:

    TELEGRAM_BOT_TOKEN=your_bot_token_here
    SLACK_BOT_TOKEN=your_slack_token
    

Running Tests

The project uses pytest with pytest-asyncio for asynchronous tests.

  • Run all tests

    uv run pytest
    
  • Run with coverage

    uv run pytest --cov=pydantic_ai_channels --cov-report=term-missing
    
  • Run a specific test file

    uv run pytest tests/test_telegram_adapter.py
    

Note: Some tests may require a live Telegram or Slack connection. In CI, those should be mocked or skipped.


Code Quality & Formatting

The project uses Ruff for linting and formatting, configured in pyproject.toml.

  • Lint

    uv run ruff check .
    
  • Format

    uv run ruff format .
    
  • Type checking (using Pyright / mypy) – run manually with

    uv run pyright
    

All commits are automatically checked by pre-commit. Please fix any warnings before pushing.


Project Structure

pydantic_ai_channels/
├── capabilities/          # Pydantic AI capabilities for each platform
│   └── telegram/
├── channels/              # Channel adapters (base + platform implementations)
│   ├── base.py            # Abstract classes and message models
│   ├── telegram/
│   └── slack/
└── toolsets/              # FunctionToolset implementations
    └── telegram/

examples/                  # Example applications (e.g., gramatic agent)
tests/                     # Unit and integration tests

When adding a new platform (e.g., Discord), you must:

  1. Implement a new ChannelAdapter in channels/.
  2. Create a corresponding *Capability in capabilities/.
  3. Optionally provide a toolset if the platform supports interactive tools.

Contribution Guidelines

We welcome contributions! Please follow these steps:

  1. Open an issue – Describe the bug or feature you intend to work on.
  2. Fork the repository and create a branch with a descriptive name (e.g., add-discord-adapter).
  3. Write or adapt tests – All new functionality must be covered by tests.
  4. Update documentation – If you change the public API, update the docstrings and any relevant example.
  5. Run the full test suite and ensure 100% coverage where possible.
  6. Open a merge request – Fill out the MR template completely.

Coding Standards

  • Python version: 3.12+
  • Type hints: Required for all functions (including __init__ and private methods).
  • Async: All I/O operations must be async def.
  • Docstrings: Use Google style for public functions and classes.
  • Line length: 115 characters (as configured).
  • Imports: Use Ruff’s isort rules (combine‑as‑imports = true).

Commit Message Style

We follow Conventional Commits:

<type>(<scope>): <subject>

<body>

Allowed types: feat, fix, docs, style, refactor, test, chore.
Scopes: telegram, slack, capabilities, toolsets, examples, ci, etc.


Working with AI Agents on This Repository

If you are an AI assistant (like me) helping to maintain or develop this repository:

  1. Prioritize the project’s users and maintainers over the immediate request.

    • Example: When implementing a new Telegram tool, consider how it fits the existing TelegramToolset pattern and whether it should be a separate capability.
  2. Always gather full context before writing code:

    • Read the issue/merge request and any linked discussions.
    • Check the pyproject.toml for dependencies and tool configurations.
    • Examine existing implementations (e.g., telegram.py) to mimic style and error handling.
  3. Question assumptions – If a request asks for something that breaks backward compatibility or adds unnecessary complexity, propose an alternative.

  4. Test changes locally – Use uv run pytest and ensure the code passes linting.

  5. Document as you go – Update docstrings, the README (once populated), or example files when introducing new concepts.

Remember: the public API and developer experience are paramount. Every change should make the framework more intuitive, more type‑safe, and more delightful to use.


License

This project is open source. See the LICENSE file (once added) for details.

Metadata

Release files for pydantic-ai-channels 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-ai-channels 0.1.2
File Size Uploaded Provenance Actions
pydantic_ai_channels-0.1.2.tar.gz 578.5 kB Without provenance Details for pydantic_ai_channels-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-ai-channels 0.1.2
File Interpreter ABI Platform Actions
pydantic_ai_channels-0.1.2-py3-none-any.whl Python 3 none any Details for pydantic_ai_channels-0.1.2-py3-none-any.whl

Total release size: 610.5 kB

Release files / pydantic_ai_channels-0.1.2.tar.gz

Download URL pydantic_ai_channels-0.1.2.tar.gz
Size 578.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3b4517cb708755fe6c7e949c4ca356fd5635eb178e014a6780b6fbdd8500231c
BLAKE2b-256 checksum
How to use checksums
9eacf958a36d4980f97eed78662e2f435a5c1cbcc5866954dd7fa6bf34d5e006
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pydantic_ai_channels-0.1.2-py3-none-any.whl

Download URL pydantic_ai_channels-0.1.2-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2aaa35b0c094f233d19ac4c2e3ce12aea8138220baca5ad8e2e1a57ece1c3407
BLAKE2b-256 checksum
How to use checksums
99ee28aee7bf6d6c097d0929e3cc3edb454d274ca82c20c0fe4335f2efa646a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for pydantic-ai-channels 0.1.2

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.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page