# AI Chat Summaries Plugin for exteraGram Advanced AI-powered Telegram chat summarization plugin for [exteraGram](https://exteragram.app). ## Features - **ChatGPT OAuth Integration**: Secure browser authorization with automatic tier detection (Free: `luna`, `gpt-4o-mini`; Plus/Pro/Business: `terra`, `sol`, `gpt-4o`, `o1`, `o3-mini`). - **Custom AI Provider**: OpenAI-compatible custom endpoints (OpenRouter, DeepSeek, Together AI, local vLLM/Ollama) with **Multi-Stage Verification**: - Stage 1: URL reachability test. - Stage 2: Lightweight probe test (`max_tokens: 10`, thinking disabled). - Stage 3: Error logs with one-click full sanitized request log copier. - Stage 4: Context window token budgeting (8k to 1M) preserving up to 8,000 characters per message. - **Built-in Connectors**: Direct API key connectors for OpenAI, Anthropic Claude (with Claude 3.7 reasoning tokens), Google Gemini, and Ollama. - **Dual Triggers**: 1. **Pinned Header AI Button**: Top-right AI action button next to the pinned message bar. 2. **Unread Badge Long-Press**: Long-press on floating unread badge or unread divider in chat with auto-filled message count. 3. **Chat Action Bar Menu**: Fallback action item for universal accessibility. - **Animated Progress Widget**: Dynamic in-header pulsing progress indicator that shrinks `PinnedMessageView` to prevent text overlap. - **Live Thinking Stream Preview**: Real-time streaming inspector for reasoning and thought process tokens (`reasoning_content`, `...`, `delta.thought`). Can be toggled off in settings to save mobile bandwidth. - **Per-Chat Customization**: Pre-request bottom sheet with message count slider, style chips (Brief, Detailed, Key Highlights, Custom), and per-chat prompt override. - **Rich Result Dialog**: Formatted Markdown rendering with Share, Copy Summary, Copy Full Prompt & Data, Regenerate, and Insert into Chat Composer. - **Localization**: Full English (`en`) and Russian (`ru`) translations. ## Project Structure ``` exteragram-chat-summaries/ ├── ai_chat_summary.plugin # Main entrypoint & metadata header ├── build.py # Standalone bundler & syntax validator ├── src/ │ ├── config.py # Configuration constants & model tiers │ ├── localization.py # LocalizationManager (EN/RU dictionaries) │ ├── providers/ │ │ ├── base.py # Base provider interface, debug logger, prompt builder │ │ ├── oauth.py # ChatGPT OAuth handler & tier mapper │ │ ├── custom.py # Custom provider with multi-stage verification │ │ ├── builtin.py # OpenAI, Anthropic, Gemini, Ollama direct handlers │ │ └── dispatcher.py # Unified dispatcher & live streaming state manager │ ├── services/ │ │ └── message_fetcher.py # TLRPC history pagination & media formatting │ ├── ui/ │ │ ├── settings.py # Dynamic settings layout & verification dialogs │ │ ├── pre_request.py # Pre-request bottom sheet & prompt customizer │ │ ├── progress_widget.py # In-header progress widget & pinned view shrinker │ │ ├── thinking_sheet.py # Live streaming reasoning viewer │ │ └── summary_dialog.py # Markdown result presentation & error log viewer │ └── hooks/ │ ├── pinned_hook.py # PinnedMessageView top bar hook │ └── unread_hook.py # ChatUnreadCell & floating badge long-press hook ├── tests/ │ └── test_plugin.py # Unit & simulation test suite └── dist/ └── ai_chat_summary.plugin # Bundled single-file distributable artifact ``` ## Bundling & Testing To bundle into a single-file distributable artifact: ```bash python3 build.py ``` To run the unit and simulation test suite: ```bash python3 -m unittest discover -s tests -v ```