This project has been archived by its maintainers, and is no longer receiving any updates.
Persona Forge Discord (PFDiscord) (archived)
This project has moved to ForgeLLM. PFDiscord has been renamed and expanded into ForgeLLM, a multi-platform LLM bot framework supporting Discord and Telegram. This repository is a read-only historical snapshot preserved for reference - it receives no further updates.
- New repository: https://github.com/Digital-Heresy/ForgeLLM
- New PyPI package:
pip install digitalheresy-forgellm(replacespip install PFDiscord; the importable package isforgellm, e.g.from forgellm.discord.adapter import DiscordAdapter)
Everything below this notice describes PFDiscord as it existed at v1.0.6, the last release before the ForgeLLM rename.
Persona Forge Discord (PFDiscord)
The basic goal of this project is to create a bridge between a Discord Bot and a Large Langage Model (LLM), like ChatGPT. The interface stems from TeLLMgramBot, but for Discord.
- To use this library, you must have a Discord account. If you don't have one, create one online.
- To set up a new Discord bot with "Manage Server" permissions, see this HowToGeek link.
- This requires priveliged message intents, which can be enabled in the Discord Developer Portal under Bot Settings.
Discord Bot + LLM Encapsulation
- The Discord interface handles special commands, especially on some basic "chatty" prompts and responses that don't require LLM like "Hello".
- Tokens are used to measure the length of all conversation messages between the Discord bot assistant and the user. This is useful to:
- Ensure the length does not go over the ChatGPT model limit. If it does, prune oldest messages to fit within the limit.
- Remember 50% of the past conversations when starting up PFDiscord again.
- Users can also clear their conversation history for privacy.
- A URL in [square brackets] can be mentioned for interpretation.
- Example: "What do you think of this article? [https://some_site/article]"
- This uses another ChatGPT model, preferrably GPT-4, to support more URL content by OpenAI tokens.
Directories
When initializing PFDiscord, the following directories get created:
configs- Contains bot conifguration files.config.yaml(can be a different name)- This file sets parameters for the Discord bot (its user name is given by API) and OpenAI's ChatGPT to process.
- The parameter
url_modelis to read URL content, different thanchat_modelthat the bot normally uses to interact with the user. - An empty
token_limitwould do the maximum amount of tokens supported by thechat_model(e.g. 4097 forgpt-3.5-turbo).
tokenGPT.yaml- This important YAML file contains token size parameters for every ChatGPT model possible supported by OpenAI.
- If the first time, only
gpt-3.5-turboandgpt-4get populated, but the user can specify more models with token size parameters as needed.
prompts- Contains prompt files for how the bot interacts with any user.test_personality.prmpt- This is a sample prompt file as a basis to test this library.
- The user can create more prompt files as needed for different personalities. See OpenAI Playground to test some ideas.
url_analysis.prmpt- This is a crucial prompt file to analysis URL content in brackets
[]in a different ChatGPT model (likelygpt-4or higher).
- This is a crucial prompt file to analysis URL content in brackets
errorlogs- Contains error log files to investigate if there are problems during the interaction.
- User will also get notified to contact the owner.
sessionlogs- Every conversation is stored between the Discord bot assistant and each user.
- If a user types
!forget, any session log files between the bot and the user will all be removed.
API Keys
Three API keys are required for operation:
- OpenAI - Drives the actual GPT AI.
- Discord - Found by creating a new bot application.
- VirusTotal - Performs safety checks on URLs.
There are two ways to populate each API key: environment variables or .key files.
Environment Variables
PFDiscord uses the following environment variables that can be pre-loaded with the three API keys respectively:
PFDISCORD_OPENAI_API_KEYPFDISCORD_DISCORD_API_KEYPFDISCORD_VIRUSTOTAL_API_KEY
During spin-up time, a user can call out os.environ[env_var] to set those variables, like the following example:
my_keys = Some_Vault_Fetch_Function()
os.environ['PFDISCORD_OPENAI_API_KEY'] = my_keys['GPTKey']
os.environ['PFDISCORD_DISCORD_API_KEY'] = my_keys['DiscordApplicationToken']
os.environ['PFDISCORD_VIRUSTOTAL_API_KEY'] = my_keys['VirusTotalToken']
This means the user can implement whatever key vault they want to fetch the keys at runtime, without needing key files.
API Key Files
By default, three files are created for the user to input each API key, unless its respective environment variable is defined already as discussed before:
openai.keydiscord.keyvirustotal.key
Bot Setup
This library includes an example script test_local.py, which uses files from the folders configs and prompts to process.
- Ensure the previous sections are followed with the proper API keys and your Discord bot set.
- Install this library via PIP (
pip install PFDiscord) and then import into your project. - Instantiate the bot by passing in various configuration pieces needed below:
discord_bot = PFDiscord.PFDiscord( bot_owner = <Bot owner's Discord username>, bot_nickname = <Bot nickname like 'Botty'>, chat_model = <Conversation ChatGPT model like 'gpt-3.5-turbo'>, url_model = <URL contents ChatGPT model like 'gpt-4'>, token_limit = <Maximum token count set, by default chat_model max>, persona_temp = <LLM factual to creative value [0-2], by default 1.0>, persona_prompt = <System prompt summarizing bot personality> ) - Turn on PFDiscord by calling:
discord_bot.run_bot() - Typing
!helpshows all available commands. - Only as owner, type
!startdirectly to the bot to initiate user conversations.
Resources
- See documentation from discord.py for the Discord API.
- For more information on ChatGPT models like
gpt-3.5-turboand tokens, see the following: - OpenAI Playground is a great place to test out prompts and responses.
Release files for PFDiscord 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pfdiscord-1.0.6.tar.gz | 29.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pfdiscord-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.6 kB
Release files / pfdiscord-1.0.6.tar.gz
| Download URL | pfdiscord-1.0.6.tar.gz |
|---|---|
| Size | 29.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f7fa71116eedff8798fe2039a35b9d6e194058896d5788c9ec0dd4b0ebd62df
|
|
BLAKE2b-256 checksum How to use checksums |
ae494340a775a3f09596446dc374a757d5dfd9d58c798fb7e0284bfb5ad92bae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logRelease files / pfdiscord-1.0.6-py3-none-any.whl
| Download URL | pfdiscord-1.0.6-py3-none-any.whl |
|---|---|
| Size | 32.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60c4e1028b6f9ee007b234ae1d784439c3881e379f6e74aaeca9f57fc8284cc0
|
|
BLAKE2b-256 checksum How to use checksums |
baba2714a330807f6cd92fde209ec93c7ca2198c90bd2956f0f4791829a8176f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency log