{"id":23217647,"url":"https://github.com/johndotpub/discordianai","last_synced_at":"2026-02-28T20:32:53.804Z","repository":{"id":172958355,"uuid":"650024301","full_name":"johndotpub/DiscordianAI","owner":"johndotpub","description":"A ChatGPT based Discord bot that uses GPT models to provide chat-based interactions with users in Discord channels and via DMs. Supports OpenAI and Perplexity API backends!","archived":false,"fork":false,"pushed_at":"2025-08-11T08:42:49.000Z","size":480,"stargazers_count":19,"open_issues_count":6,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-11T08:47:26.208Z","etag":null,"topics":["ai","chatgpt","discord","openai-api","perplexity-api","python"],"latest_commit_sha":null,"homepage":"https://github.com/johndotpub/DiscordianAI","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johndotpub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"johndotpub"}},"created_at":"2023-06-06T07:06:16.000Z","updated_at":"2025-08-04T15:19:56.000Z","dependencies_parsed_at":"2023-11-13T02:30:53.645Z","dependency_job_id":"97f580e0-1119-4ee5-b106-cdf416d64dc3","html_url":"https://github.com/johndotpub/DiscordianAI","commit_stats":null,"previous_names":["rlywtf/discordianai","johndotpub/discordianai"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/johndotpub/DiscordianAI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johndotpub%2FDiscordianAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johndotpub%2FDiscordianAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johndotpub%2FDiscordianAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johndotpub%2FDiscordianAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johndotpub","download_url":"https://codeload.github.com/johndotpub/DiscordianAI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johndotpub%2FDiscordianAI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271121760,"owners_count":24702870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chatgpt","discord","openai-api","perplexity-api","python"],"created_at":"2024-12-18T20:49:01.675Z","updated_at":"2026-02-28T20:32:53.758Z","avatar_url":"https://github.com/johndotpub.png","language":"Python","funding_links":["https://github.com/sponsors/johndotpub"],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/johndotpub/DiscordianAI/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/johndotpub/DiscordianAI/actions/workflows/ci.yml)\n[![CodeQL](https://github.com/johndotpub/DiscordianAI/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/johndotpub/DiscordianAI/actions/workflows/github-code-scanning/codeql)\n[![codecov](https://codecov.io/github/johndotpub/DiscordianAI/graph/badge.svg?token=4WOMJ952A2)](https://codecov.io/github/johndotpub/DiscordianAI)\n[![Security: pip-audit](https://img.shields.io/badge/security-pip--audit-blueviolet)](https://pypi.org/project/pip-audit/)\n\n[![Tests: py312 required](https://img.shields.io/github/actions/workflow/status/johndotpub/DiscordianAI/ci.yml?branch=main\u0026label=tests%20py312%20required\u0026logo=githubactions)](https://github.com/johndotpub/DiscordianAI/actions/workflows/ci.yml)\n[![Python 3.12+ required](https://img.shields.io/badge/python-3.12%2B-required-3776AB.svg?logo=python\u0026logoColor=white)](https://www.python.org/downloads/)\n\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://pre-commit.com/)\n\n[![Discord.py](https://img.shields.io/badge/discord.py-2.6.4-5865F2.svg?logo=discord\u0026logoColor=white)](https://discordpy.readthedocs.io/)\n[![OpenAI](https://img.shields.io/badge/OpenAI-GPT--5-412991.svg?logo=openai\u0026logoColor=white)](https://openai.com/)\n[![Perplexity](https://img.shields.io/badge/Perplexity-Sonar--Pro-20B2AA.svg)](https://www.perplexity.ai/)\n[![License: Unlicense](https://img.shields.io/badge/license-Unlicense-blue.svg)](http://unlicense.org/)\n\n[![GitHub release](https://img.shields.io/github/v/release/johndotpub/DiscordianAI)](https://github.com/johndotpub/DiscordianAI/releases)\n[![GitHub stars](https://img.shields.io/github/stars/johndotpub/DiscordianAI)](https://github.com/johndotpub/DiscordianAI/stargazers)\n[![Docker](https://img.shields.io/badge/docker-ready-2496ED.svg?logo=docker\u0026logoColor=white)](https://github.com/johndotpub/DiscordianAI/pkgs/container/discordianai)\n[![GitHub issues](https://img.shields.io/github/issues/johndotpub/DiscordianAI)](https://github.com/johndotpub/DiscordianAI/issues)\n\n# DiscordianAI\n\nDiscordianAI is a production-ready Discord bot that blends OpenAI GPT-5 frontier models with Perplexity Sonar-Pro web search. It focuses on conversation consistency, deterministic routing, and Discord-native formatting so answers stay contextual, accurate, and easy to read.\n\n## What Makes It Different\n\n- **Hybrid intelligence**: GPT-5 handles reasoning/creative prompts while Sonar-Pro covers current events with structured citations.\n- **Conversation consistency**: Follow-up detector keeps a thread on the same AI service, preventing jarring context shifts.\n- **Discord-first UX**: Citation-aware embeds, smart message splitting, and automatic embed suppression keep chats readable.\n- **Operations minded**: HTTP/2 connection pooling, circuit breakers, and health checks keep long-running bots stable.\n- **Single-source configuration**: `config.ini` drives every runtime mode, and validators catch unsupported parameters early.\n\n## Operation Modes\n\n| Mode | Description |\n|------|-------------|\n| 🧠 **Smart Hybrid** | Analyze each message, then route to GPT-5 or Sonar-Pro with follow-up consistency.\n| 🤖 **OpenAI Only** | Force GPT-5 for every response; great for creative and coding-focused servers.\n| 🔍 **Perplexity Only** | Force Sonar-Pro for every response; ideal for research or news-heavy servers.\n\n## Quick Start\n\n1. **Install Python 3.12 or newer** and create a virtual environment.\n2. **Clone \u0026 install**: `pip install -e .[dev]`\n3. **Copy config**: `cp config.ini.example config.ini`\n4. **Set tokens** in `config.ini` (Discord, OpenAI, Perplexity as needed).\n5. **Run the bot**: `python -m src.main --conf config.ini`\n6. **Run tests** before shipping: `pytest` (coverage gate: 84% via tox/Codecov)\n\nNeed the full Discord bot creation walkthrough and environment prep? See [docs/Setup.md](docs/Setup.md).\n\n### Running directly\n\n```bash\npython -m src.main --conf config.ini --folder /path/to/base/folder\n```\n\n- `--conf` points at the config file.\n- `--folder` (optional) makes config/log paths relative to a base directory (useful for Docker or systemd units).\n\n## Configuration Essentials\n\n| Key | Purpose |\n|-----|---------|\n| `DISCORD_TOKEN` | Bot authentication token from the Discord Developer Portal.\n| `GPT_MODEL` | GPT-5 series model (`gpt-5-mini`, `gpt-5`, `gpt-5-nano`, `gpt-5-chat`).\n| `PERPLEXITY_MODEL` | Perplexity Sonar model (`sonar-pro` default, `sonar` fallback).\n| `INPUT_TOKENS` / `OUTPUT_TOKENS` | Caps for prompt and completion tokens (GPT-5 uses `max_completion_tokens`).\n| `LOOKBACK_MESSAGES_FOR_CONSISTENCY` | How many prior turns to inspect when enforcing AI service consistency.\n| `OPENAI_MAX_CONNECTIONS` / `PERPLEXITY_MAX_CONNECTIONS` | HTTP/2 pooling limits for each API client.\n\n### Minimal hybrid config\n\n```ini\n[Discord]\nDISCORD_TOKEN=your_discord_bot_token\n\n[Default]\nOPENAI_API_KEY=sk-your-openai-key\nOPENAI_API_URL=https://api.openai.com/v1/\nGPT_MODEL=gpt-5-mini\nPERPLEXITY_API_KEY=pplx-your-perplexity-key\nPERPLEXITY_MODEL=sonar-pro\nINPUT_TOKENS=120000\nOUTPUT_TOKENS=8000\nSYSTEM_MESSAGE=You are a helpful assistant with access to current web information.\n\n[Limits]\nRATE_LIMIT=10\nRATE_LIMIT_PER=60\n```\n\n## Key Components\n\n### AI Orchestration\n- `smart_orchestrator.py` routes messages via semantic analysis, entity detection, and follow-up tracking.\n- `message_processor.py` normalizes Discord input, calls the orchestrator, and records AI metadata for future turns.\n- `openai_processing.py` and `perplexity_processing.py` build strictly supported API payloads (GPT-5 ignores temperature, Sonar-Pro sampling is managed server-side).\n\n### Discord User Experience\n- `discord_embeds.py` formats Perplexity citations into clean embeds with automatic suppression when multiple links exist.\n- `message_splitter.py` enforces Discord limits (2000 / 3840 / 4096 chars) with code-block and citation awareness.\n- `message_router.py` centralizes mention handling, DM routing, and rate-limit responses.\n\n### Reliability \u0026 Ops\n- `connection_pool.py` exposes tuned HTTP/2 clients (50/10 connections for OpenAI, 30/5 for Perplexity).\n- `health_checks.py` verifies API reachability and validates GPT-5/Sonar configurations at startup.\n- `api_validation.py` + `api_utils.py` guard against unsupported model strings and capture structured error metadata.\n\n## Documentation Map\n\n| Topic | Reference |\n|-------|-----------|\n| Setup \u0026 onboarding | [docs/Setup.md](docs/Setup.md)\n| Architecture \u0026 flow | [docs/Architecture.md](docs/Architecture.md)\n| Smart routing internals | [docs/HybridMode.md](docs/HybridMode.md)\n| Configuration deep dive | [docs/Configuration.md](docs/Configuration.md)\n| OpenAI usage | [docs/OpenAI.md](docs/OpenAI.md)\n| Perplexity usage \u0026 citations | [docs/Perplexity.md](docs/Perplexity.md)\n| Message splitting \u0026 embeds | [docs/MessageSplitting.md](docs/MessageSplitting.md), [docs/EmbedLimits.md](docs/EmbedLimits.md)\n| Web scraping pipeline | [docs/WebScraping.md](docs/WebScraping.md)\n| Connection pooling \u0026 HTTP/2 | [docs/ConnectionPooling.md](docs/ConnectionPooling.md)\n| Docker \u0026 daemonization | [docs/Docker.md](docs/Docker.md), [docs/Daemon.md](docs/Daemon.md)\n| Security \u0026 rate limiting | [docs/Security.md](docs/Security.md)\n| Development workflow | [docs/Development.md](docs/Development.md)\n| API parameter validation | [docs/API_Validation.md](docs/API_Validation.md)\n\n## Development Workflow\n\n```bash\n# Install dev extras\npip install -e .[dev]\n\n# Lint \u0026 format\nruff check --fix .\nblack .\n\n# Run the targeted suites\npytest -q\npytest tests/test_smart_orchestrator_coverage.py\n```\n\nUse `tox` for the CI matrix (`tox`, `tox -e py312`, `tox --parallel auto`, `tox -e audit`). CI runs Ruff, Black, pytest with coverage, and pip-audit; locally run `tox -e audit` to scan runtime + dev deps.\n\n## Security Checklist\n\n- Keep `config.ini` out of version control; copy from `config.ini.example` and set `chmod 600 config.ini` on servers.\n- Prefer environment variables in production (`export DISCORD_TOKEN=...`).\n- Rotate OpenAI (`sk-...`) and Perplexity (`pplx-...`) keys regularly; validators will reject malformed prefixes.\n- Limit Discord bot permissions to the channels where it operates.\n- Monitor logs for rate-limit bursts or scraping failures and adjust `RATE_LIMIT` / `RATE_LIMIT_PER` accordingly.\n\n## Support \u0026 License\n\n- Questions or feedback: [github@john.pub](mailto:github@john.pub)\n- Issues and feature requests: open a GitHub issue.\n- Licensed under the [Unlicense](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohndotpub%2Fdiscordianai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohndotpub%2Fdiscordianai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohndotpub%2Fdiscordianai/lists"}