Skip to main content

Telegram assistant for online media

Project description

Mediagram

A conversational AI assistant powered by Claude that helps with media processing tasks. Works via Telegram or CLI.

Mediagram uses a plugin architecture to extend functionality. The core package provides the agent system and built-in tools, while additional tools can be installed as separate plugins.

Installation

Using pip

pip install mediagram

Using uv (recommended for development)

git clone https://github.com/yourusername/mediagram.git
cd mediagram
uv sync

Configuration

Configure environment variables:

cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEY
# For Telegram: add TELEGRAM_BOT_TOKEN

Installing Plugins

Mediagram has a plugin system for additional tools. Install plugins as needed:

# From PyPI (when published)
mediagram plugin install mediagram-http
mediagram plugin install mediagram-ffmpeg
mediagram plugin install mediagram-yt-dlp

# From GitHub
mediagram plugin install git+https://github.com/user/mediagram-plugin.git

# Development mode
mediagram plugin install -e /path/to/plugin

Usage

Run Mediagram

# Interactive CLI mode
mediagram run cli

# Telegram bot
mediagram run telegram

Run Tools Directly

# List available tools
mediagram tool --help

# Run a specific tool
mediagram tool listdir --path .
mediagram tool grep --pattern "TODO" --path .

Manage Plugins

# List installed plugins
mediagram plugin plugins

# Install a plugin
mediagram plugin install mediagram-http

# Uninstall a plugin
mediagram plugin uninstall mediagram-http -y

Commands

Both drivers support the same commands:

  • /help - Show all available commands
  • /clear - Clear chat history and start a new conversation
  • /model [name] - Change model or show current model
    • Available models: haiku (Claude Haiku 4.5), sonnet (Claude Sonnet 4.5)
  • /tools - List all available tools with their signatures and descriptions
  • /quit or /exit - Exit (CLI only)

Plugin Management

Mediagram provides commands to manage plugins (similar to llm CLI):

List Installed Plugins

# List plugin packages (excludes built-in tools)
mediagram plugin plugins

# List all plugins including built-in
mediagram plugin plugins --all

# Filter by hook
mediagram plugin plugins --hook register_tools

Install Plugins

# From PyPI
mediagram plugin install mediagram-http

# From GitHub
mediagram plugin install git+https://github.com/user/mediagram-plugin.git

# From local directory
mediagram plugin install /path/to/plugin

# Editable/development mode
mediagram plugin install -e /path/to/plugin

# Multiple packages
mediagram plugin install mediagram-http mediagram-ffmpeg mediagram-llm

Uninstall Plugins

# With confirmation prompt
mediagram plugin uninstall mediagram-http

# Skip confirmation
mediagram plugin uninstall mediagram-http -y

# Multiple packages
mediagram plugin uninstall mediagram-http mediagram-ffmpeg -y

Emergency Plugin Disable

If a broken plugin prevents mediagram from running:

# Disable all plugins temporarily
MEDIAGRAM_LOAD_PLUGINS='' mediagram plugin uninstall mediagram-broken-plugin

Plugin Architecture

Mediagram uses a plugin system based on Pluggy. Tools are registered via the mediagram entry point group in pyproject.toml.

Plugin Packages

Plugin packages are distributed separately from the core. Each plugin is self-contained and can be:

  • Published to its own repository
  • Distributed via PyPI
  • Installed from any source (PyPI, GitHub, local path)

Available plugins:

Plugin requirements:

  1. Depend on mediagram>=0.1.0
  2. Define entry point: [project.entry-points.mediagram]

Creating a Plugin

  1. Create a package with this structure:
# my_plugin/__init__.py
from mediagram import hookimpl
from mediagram.agent.tools import tool
from mediagram.agent.callbacks import SuccessMessage

@tool
async def my_tool(arg: str):
    """My custom tool."""
    # Tool logic here
    yield SuccessMessage(f"Processed: {arg}")

@hookimpl
def register_tools(register):
    """Register tools with mediagram."""
    register(my_tool)
  1. Add entry point in pyproject.toml:
[project.entry-points.mediagram]
my_plugin = "my_plugin"
  1. Install and the tool will be available automatically.

Features

  • Persistent conversation history per user
  • Async message handling using llm's async API
  • Support for multiple Claude models
  • Dynamic model switching
  • Two interaction modes: Telegram and CLI
  • Markdown rendering in Telegram (with fallback to plain text)
  • Context-aware system prompts with user information and current time
  • Plugin-based tool system with progress reporting

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

mediagram-0.1.0.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mediagram-0.1.0-py3-none-any.whl (46.9 kB view details)

Uploaded Python 3

File details

Details for the file mediagram-0.1.0.tar.gz.

File metadata

  • Download URL: mediagram-0.1.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for mediagram-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9abd75abdcb1ab1f39071833c18b7ed210c4bfb5a585f5bd3477d9f896ca5493
MD5 49e873698879dc6bae6a93815c01126f
BLAKE2b-256 38c25f49b5dcb573b5c4616d3589ffb03fbb839f195078bc008cd22280b1faa2

See more details on using hashes here.

File details

Details for the file mediagram-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mediagram-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 46.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for mediagram-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93cba54bace1f659467056c94cf801e7530315bcd3b19559eb250cca7f5a43ae
MD5 56886b40ddcd60e2521d1de79373be1f
BLAKE2b-256 4a4734131723981185e75048cf030667d844a497c243d0df5516becd9bedd1c1

See more details on using hashes here.

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