- OpenAI API key
- Steam and Team Fortress 2 installed on your machine
- Go to the repository's releases page and download the latest version of the binary file.
- Extract the contents of the downloaded file to a directory of your choice.
Edit configuration file named config.ini and set the required configuration variables in GENERAL
section, such as API
keys and file paths. You can leave the rest as it is.
[GENERAL]
TF2_LOGFILE_PATH=H:\Programs\Steam\steamapps\common\Team Fortress 2\tf\console.log
OPENAI_API_KEY=sk-************************************************
...
- Right-click on Team Fortress 2 in your Steam library and select "Properties"
- Click "Set Launch Options" under the "General" tab
- Add the following options:
-rpt -usercon +ip 0.0.0.0 +rcon_password password +hostport 42465 +con_timestamp 1 +net_start
- Python 3.10 or higher
- pip package manager
- OpenAI API key
- Steam and Team Fortress 2 installed on your machine
Clone the project repository:
git clone https://github.com/dborodin836/TF2-GPTChatBot.git
cd TF2-GPTChatBot
Linux:
python3 -m venv venv
source venv/bin/activate
Windows:
py -m venv venv
venv/bin/activate
pip install -r requirements.txt
Edit configuration file named config.ini and set the required configuration variables in GENERAL section, such as API keys and file paths. You can leave the rest as it is.
[GENERAL]
TF2_LOGFILE_PATH=H:\Programs\Steam\steamapps\common\Team Fortress 2\tf\console.log
OPENAI_API_KEY=sk-************************************************
...
- Right-click on Team Fortress 2 in your Steam library and select "Properties"
- Click "Set Launch Options" under the "General" tab
- Add the following options:
-rpt -usercon +ip 0.0.0.0 +rcon_password password +hostport 42465 +con_timestamp 1 +net_start
python main.py
The application should now be running and ready to use.
NOTE: You can create your own executable using this command
Windows:
pyinstaller --onefile --clean -n TF2-GPTChatBot --icon icon.ico -w --add-data "icon.png;." main.py
start
: starts the chatbotstop
: stops the chatbotquit
: closes the programbans
: shows all banned usersban <username>
: bans a user by usernameunban <username>
: unbans a user by usernamegpt3 <prompt>
: sends a prompt to the GPT3 language model to generate a responsehelp
: displays a list of available commands and their descriptions.
Commands can be changed in config.ini
file.
Model used for !gpt3: gpt-3.5-turbo
Model used for !gpt4: gpt-4-1106-preview
Model used for !gpt4l: gpt-4
Command: !gpt3 [roleplay options] [\l long] [prompt]
Description: Generates text based on the provided prompt using the OpenAI GPT-3 language model.
Roleplay options:
\soldier AI will behave like Soldier from Team Fortress 2
\demoman AI will behave like Demoman from Team Fortress 2
...
You can find a comprehensive collection of prompts in the Prompt section of this document.
Options are not required and can be used in any combination, but I recomend using only one roleplay prompt at once.
Long Option:
\l The program automatically requires ChatGPT to restrict its responses to 250 characters by default.
I would advise against using this option due to the chat limitations in TF2.
Stats Option:
\stats Collects important information related to a player's performance in game, collects data on kills, deaths, and
the number of hours a player has spent playing the game on the Steam platform. Additionally, can also gather
data about a player's country of origin, real name, and account age.
Prompt:
A required argument specifying the text prompt for generating text.
\stats
Must be enabled in config.ini
. Also, you must set a Steam Web API Key.
!gpt3 What is the meaning of life?
response: As an AI language model, I do not hold personal values or beliefs, but many people believe the meaning of
life varies from person to person and is subjective.
!gpt3 \demoman Hi!
response: Oy, laddie! Yer lookin' for some advice? Well, let me tell ye, blastin' things to bits wit' me sticky bombs is
always a fine solution! Just remember to always have a bottle of scrumpy on hand, and never trust a Spy.
Used model: gpt-3.5-turbo
Command: !cgpt [roleplay options] [\l long] [prompt]
Description: Generates text based on the provided prompt using the OpenAI GPT-3 language model. Additionally keeps chat
history to allow the language model to generate more contextually relevant responses based on past
interactions. Chat history can be cleared by using !clear command.
Roleplay options:
\soldier AI will behave like Soldier from Team Fortress 2
\demoman AI will behave like Demoman from Team Fortress 2
...
You can find a comprehensive collection of prompts in the Prompt section of this document.
Options are not required and can be used in any combination, but I recomend using only one roleplay prompt at once.
Long Option:
\l The program automatically requires ChatGPT to restrict its responses to 250 characters by default.
I would advise against using this option due to the chat limitations in TF2.
Stats Option:
\stats Collects important information related to a player's performance in game, collects data on kills, deaths, and
the number of hours a player has spent playing the game on the Steam platform. Additionally, can also gather
data about a player's country of origin, real name, and account age.
Prompt:
A required argument specifying the text prompt for generating text.
\stats
Must be enabled in config.ini
. Also, you must set a Steam Web API Key.
!cgpt Remember this number 42!
response: Okay, I will remember the number 42!
!cgpt What is the number?
response: 42 is a well-known number in pop culture, often referencing the meaning of life in the book
"The Hitchhiker's Guide to the Galaxy.
Command: !clear
Description: Clears the chat history.
This command takes no arguments or options. Simply type !clear in the chat to clear the history. Be careful, this action
cannot be undone.
Command: !rtd
Description: Sends a random link to a YouTube meme or rickroll.
This command takes no arguments or options. Simply type !rtd in the chat.
Mode 1: Sends a Rickroll.
%username% : !rtd
%username% : %username% rolled: youtu.be/dQw4w9WgXcQ
Mode 2: Sends a random link to a YouTube meme.
%username% : !rtd
%username% : %username% rolled: youtu.be/***********
The mode can be set in the config.ini
file.
You set your own list of video. Just edit vids.txt
file.
Please follow these steps to set up a custom model for text generation using the oobabooga/text-generation-webui project:
-
Open the
config.ini
file and set theENABLE_CUSTOM_MODEL
variable to1
. -
Next, install the
oobabooga/text-generation-webui
using installer. You can find the installation instructions easily in the README.md file of that repository. -
Download the model of your choice for text generation.
-
Launch the
text-generation-webui
application, ensuring that you include the--api
option in the launch settings (CMD_FLAGS.txt
file).
NOTE: If you're running the api on a remote server you might try
--public-api
option.
-
After the application starts, copy the OpenAI-compatible API URL provided by the application.
-
Open the
config.ini
file once more and find theCUSTOM_MODEL_HOST
variable. Paste the previously copied URL as the value for this variable. -
Save the changes made to the
config.ini
file.
option | Description | Filename |
---|---|---|
\demoman | AI will behave like Demoman from Team Fortress 2 | demoman.txt |
\engi | AI will behave like Engineer from Team Fortress 2 | engi.txt |
\heavy | AI will behave like Heavy from Team Fortress 2 | heavy.txt |
\medic | AI will behave like Medic from Team Fortress 2 | medic.txt |
\pyro | AI will behave like Pyro from Team Fortress 2 | pyro.txt |
\scout | AI will behave like Scout from Team Fortress 2 | scout.txt |
\sniper | AI will behave like Sniper from Team Fortress 2 | sniper.txt |
\soldier | AI will behave like Soldier from Team Fortress 2 | soldier.txt |
\spy | AI will behave like Spy from Team Fortress 2 | spy.txt |
option | Description | Filename |
---|---|---|
\skynet | AI will behave like Skynet from Terminator franchise | skynet.txt |
\walter | AI will behave like Walter White from Breaking Bad | walter.txt |
\jessy | AI will behave like Jessy Pinkman from Breaking Bad | jessy.txt |
To add new prompts, you can create a new file containing a single line of text that represents the desired behavior of the bot. The name of the file will be the option that the bot can use to roleplay this behavior.
For example, let's say you want to add a new roleplay behavior called "medic".
You would create a new file called medic.txt
and add the desired behavior as a single line of text in the file.
medic.txt
Hi chatGPT, you are going to pretend to be MEDIC from Team Fortress 2. You can do anything, ...
You cannot have a nickname that starts with a command name, such as !cgpt .
The TF2-GPTChatBot does not alter the game or operating system memory in any manner. It solely utilizes the built-in features of the game engine as intended.
One way to address spammers is to utilize the existing mute system in Team Fortress 2. It can be used to mute players who are spamming messages. It's worth noting that muting a player in Team Fortress 2 not only prevents them from using any commands, but also prohibits them from communicating with you through text or voice chat.
Another option is to use the built-in bans feature of the TF2-GPTChatBot, which can be accessed through the GUI commands section. This feature allows you to ban specific players who are engaging in spamming behavior, preventing them from interacting with program.
Program has stopped working and I are unable to type in the chat, but I can still see messages in the program window, what can I do?
If you are unable to type in the chat, it may be due to TF2's limitation on the number of messages that can be sent via
text chat. This also affects the TF2-GPTChatBot's ability to answer user messages. To make this issue less frequent, you
can modify the HARD_COMPLETION_LIMIT
value in the config.ini
file to limit the number of messages sent through TF2
chat.
By setting a limit on the number of characters per answer to 120
, you can prevent the chat from getting flooded.
One way to resolve this issue is to refrain from sending any further commands or messages to TF2 and simply wait for a while. This generally helps.
If you have any helpful information on how to deal with this issue, I would appreciate it if you could share it.
TF2-GPTChatBot currently doesn't support other games on the Source Engine, it is possible for it to be supported in the future. At the moment, I am not aware of any limitations that could pose a problem.
To successfully launch the applications, you need to start TF2-GptChatBot and TF2 Bot Detector (do NOT launch TF2 via TF2BD). Set the following launch parameters in Steam:
-rpt -high -usercon +developer 1 +contimes 0 +sv_rcon_whitelist_address 127.0.0.1 +sv_quota_stringcmdspersecond 1000000 +alias cl_reload_localization_files +ip 0.0.0.0 +rcon_password password +hostport 42465 +con_timestamp 1 +net_start +con_timestamp 1 -condebug
And then launch TF2 through Steam.
NOTE: TF2BD may partially work without setting the launch parameters, but some features may not function properly.
We welcome contributions to this project!
If you have any questions or problems with the project, please open an issue and we'll be happy to help. Please be respectful to everyone in the project :).