Production-ready Telegram and Slack channels for Pydantic AI agents.
Project description
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
AbstractCapabilitywrappers 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 viapip install uvorcurl -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
-
Clone the repository
git clone https://gitlab.com/rzk.ssr/pydantic-ai-channels.git cd pydantic-ai-channels
-
Install dependencies with
uvuv syncThis will create a virtual environment and install all runtime and development dependencies.
-
Activate the virtual environment (optional)
source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Set up pre‑commit hooks (for code quality)
uv run pre-commit install
-
Configure environment variables
Create a.envfile 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:
- Implement a new
ChannelAdapterinchannels/. - Create a corresponding
*Capabilityincapabilities/. - Optionally provide a toolset if the platform supports interactive tools.
Contribution Guidelines
We welcome contributions! Please follow these steps:
- Open an issue – Describe the bug or feature you intend to work on.
- Fork the repository and create a branch with a descriptive name (e.g.,
add-discord-adapter). - Write or adapt tests – All new functionality must be covered by tests.
- Update documentation – If you change the public API, update the docstrings and any relevant example.
- Run the full test suite and ensure 100% coverage where possible.
- 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:
-
Prioritize the project’s users and maintainers over the immediate request.
- Example: When implementing a new Telegram tool, consider how it fits the existing
TelegramToolsetpattern and whether it should be a separate capability.
- Example: When implementing a new Telegram tool, consider how it fits the existing
-
Always gather full context before writing code:
- Read the issue/merge request and any linked discussions.
- Check the
pyproject.tomlfor dependencies and tool configurations. - Examine existing implementations (e.g.,
telegram.py) to mimic style and error handling.
-
Question assumptions – If a request asks for something that breaks backward compatibility or adds unnecessary complexity, propose an alternative.
-
Test changes locally – Use
uv run pytestand ensure the code passes linting. -
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_ai_channels-0.1.2.tar.gz.
File metadata
- Download URL: pydantic_ai_channels-0.1.2.tar.gz
- Upload date:
- Size: 578.5 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b4517cb708755fe6c7e949c4ca356fd5635eb178e014a6780b6fbdd8500231c
|
|
| MD5 |
7fe37f8863d7ce4ed87f33dc1c80e4ec
|
|
| BLAKE2b-256 |
9eacf958a36d4980f97eed78662e2f435a5c1cbcc5866954dd7fa6bf34d5e006
|
File details
Details for the file pydantic_ai_channels-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pydantic_ai_channels-0.1.2-py3-none-any.whl
- Upload date:
- Size: 32.0 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aaa35b0c094f233d19ac4c2e3ce12aea8138220baca5ad8e2e1a57ece1c3407
|
|
| MD5 |
c43b3bc29394787e6fc406562f18da5c
|
|
| BLAKE2b-256 |
99ee28aee7bf6d6c097d0929e3cc3edb454d274ca82c20c0fe4335f2efa646a2
|