jakobdylanc/llmcord
关于
将 Discord 用作 LLM 前端
网站与应用开发实测星标增长
- 24小时
- +1
- 7天
- +3
- 15天
- +4
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文llmcord
Talk to LLMs with your friends!
llmcord transforms Discord into a collaborative LLM frontend. It works with practically any LLM, remote or locally hosted.
Features
Reply-based conversations:
Just @ the bot to start a conversation and reply to continue. Build conversations with reply chains!
The reply chain is the conversation history, stored entirely in Discord. No database required.
You can:
- Branch conversations endlessly
- Continue other people's conversations
- @ the bot while replying to ANY message to include it in the conversation
Additionally:
- When DMing the bot, conversations continue automatically (no reply required). To start a fresh conversation, just @ the bot. You can still reply to continue from anywhere.
- You can branch conversations into threads. Just create a thread from any message and @ the bot inside to continue.
- Back-to-back messages from the same user are automatically chained together. Just reply to the latest one and the bot will see all of them.
Model switching with /model:
llmcord supports remote models from:
Or run local models with:
...Or use any other OpenAI /v1/chat/completions compatible API server.
And more:
- Supports image attachments when using a vision model
- Supports text file attachments (.txt, .py, .c, etc.)
- Customizable personality (aka system prompt)
- Distinguishes users via their Discord IDs
- Streamed responses (turns green when complete, automatically splits into separate messages when too long)
- Hot reloading config (you can change settings without restarting the bot)
- Displays helpful warnings when appropriate (like "⚠️ Only using last 25 messages" when the customizable message limit is exceeded)
- Caches message data in a size-managed (no memory leaks) and mutex-protected (no race conditions) global dictionary to maximize efficiency and minimize Discord API calls
- Fully asynchronous
- 1 Python file, ~300 lines of code
Instructions
Clone the repo:
git clone https://github.com/jakobdylanc/llmcord cd llmcordSet up
config.yaml:
Any setting can be read from an environment variable by appending
_envto its name (e.g.bot_token_env: DISCORD_BOT_TOKEN).
Discord settings:
| Setting | Description |
|---|---|
| bot_token | Create a new Discord bot at discord.com/developers/applications and generate a token under the "Bot" tab. Also enable "MESSAGE CONTENT INTENT". |
| client_id | Found under the "OAuth2" tab of the Discord bot you just made. |
| status_message | Set a custom message that displays on the bot's Discord profile. Max 128 characters. |
| max_text | The maximum amount of text allowed in a single message, including text from file attachments. Default: 100,000 |
| max_images | The maximum number of image attachments allowed in a single message. Default: 5Set to 0 to disable image attachments. |
| max_messages | The maximum number of messages allowed in a reply chain. When exceeded, the oldest messages are dropped. Default: 25 |
| use_plain_responses | When set to true the bot will use plaintext responses instead of embeds. Plaintext responses have a shorter character limit so the bot's messages may split more often.Default: falseAlso disables streamed responses and warning messages. |
| allow_dms | Set to false to disable direct message access.Default: true |
| permissions | Configure access permissions for users, roles and channels, each with a list of allowed_ids and blocked_ids.Control which users are admins with admin_ids. Admins can change the model with /model and DM the bot even if allow_dms is false.Leave allowed_ids empty to allow ALL in that category.Role and channel permissions do not affect DMs. You can use category IDs to control channel permissions in groups. |
LLM settings:
| Setting | Description |
|---|---|
| providers | Add the LLM providers you want to use, each with a base_url and optional api_key entry. Popular providers (openrouter, openai, ollama, etc.) are already included.Only supports OpenAI /v1/chat/completions compatible APIs. Some providers may need extra_headers / extra_query / extra_body entries for extra HTTP data. See the included azure-openai provider for an example. |
| models | Add the models you want to use in <provider>/<model>: <parameters> format (examples are included). When you run /model these models will show up as autocomplete suggestions.Refer to each provider's documentation for supported parameters. The first model in your models list will be the default model at startup. |
| system_prompt | Write anything you want to customize the bot's behavior! Leave blank for no system prompt. You can use the {date} and {time} tags in your system prompt to insert the current date and time, based on your host computer's time zone.It is recommended to include something like "User messages are prefixed with their Discord ID as <@ID>. Use this format to mention users." in your system prompt to help the bot understand the user message format. |
Run the bot:
No Docker:
python -m pip install -U -r requirements.txt python llmcord.pyWith Docker:
docker compose up
Notes
If you're having issues, try my suggestions here
PRs are welcome :)
探索相关项目
加载中…