dborodin836 / TF2-GPTChatBot

An AI-powered chatbot for Team Fortress 2 fans and players.
GNU General Public License v3.0
13 stars 1 forks source link
gpt3 openai teamfortress2

TF2-GPTChatBot

alt text

An AI-powered chatbot for Team Fortress 2 fans and players.

[!NOTE] If you're interested, you can check out the new updated version here, but beware — here be dragons nothing is documented yet and stability is not guaranteed.

Table Of Contents

Running Using Binary

Prerequisites

1. Download the latest release from GitHub

2. Edit the configuration file:

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-************************************************

...

3. Add launch options to TF2 on Steam:

  1. Right-click on Team Fortress 2 in your Steam library and select "Properties"
  2. Click "Set Launch Options" under the "General" tab
  3. Add the following options:
-rpt -usercon +ip 0.0.0.0 +rcon_password password +hostport 42465 +con_timestamp 1 +net_start

4. Launch Team Fortress 2

5. Launch TF2-GPTChatBot

Running from Source

Prerequisites

1. Installation

Clone the project repository:

git clone https://github.com/dborodin836/TF2-GPTChatBot.git

2. Navigate to the project directory:

cd TF2-GPTChatBot

3. (Optional) Create and activate a new virtual environment:

Linux:

python3 -m venv venv
source venv/bin/activate

Windows:

py -m venv venv
venv/bin/activate

4. Install the project dependencies using pip:

pip install -r requirements.txt

5. Edit configuration file

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-************************************************

...

6. Add launch options to TF2 on Steam:

  1. Right-click on Team Fortress 2 in your Steam library and select "Properties"
  2. Click "Set Launch Options" under the "General" tab
  3. Add the following options:
-rpt -usercon +ip 0.0.0.0 +rcon_password password +hostport 42465 +con_timestamp 1 +net_start

7. Launch Team Fortress 2

8. Start the application:

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

Usage

Basic Chat Commands

Program comes with built-in chat commands. You can customize existent ones or add new ones to your liking. This section only commands that are provided by OpenAI. This is because app was originally designed to support OpenAI, but with time it has evolved to support any provider. But there are many other commands and providers (GroqCloud, TextGenerationWebUI, etc.) available, and some of them are free to use. But they are not enabled by default, and you need to enable them manually.

There are also thing so-called prompts which allow you to customize how the model will response.

Check project Wiki for more info.

Quick-query commands

These commands are used to generate a quick response from a language model.

Available commands: !gpt3, !gpt4 and more!

Usage examples

!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.

Chats

These commands are used to engage in conversations with the AI language model. In this community, chats are divided into two main categories: Global and Private.

Available commands: !cgpt(global), !pc(private) and more!

!cgpt Usage examples

!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.

!clear

Simply clears the chat history for specified command(s).

Command: !clear [\global] [\user='username'] [commands]

Description: Clears the chat history for specified command(s).

Calling without arguments clears own private chat history for any user.

Global Option (admin only):
  \global  Clears global chat history for specified command(s).

User Option (admin only):
  \user='username'  Clears private chat history for the specified user(s) for specified command(s).

Examples:
  For admin:
    !clear \global solly
    - Will clear global chat for solly command

    !clear \global \user='Pootis' \user='Soldier' solly
    - Will clear global and private chat for solly command for users with username "Pootis" and "Soldier"

  For everyone:
    !clear solly heavy
    - Will clear private chats for 'solly' and 'heavy' commands

Custom language models (oobabooga / text-generation-webui)

Please follow these steps to set up a custom model for text generation using the oobabooga/text-generation-webui project:

  1. Open the config.ini file and set the ENABLE_CUSTOM_MODEL variable to 1.

  2. Next, install the oobabooga/text-generation-webui using installer. You can find the installation instructions easily in the README.md file of that repository.

  3. Download the model of your choice for text generation.

  4. 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.

  1. After the application starts, copy the OpenAI-compatible API URL provided by the application.

  2. Open the config.ini file once more and find the CUSTOM_MODEL_HOST variable. Paste the previously copied URL as the value for this variable.

  3. Save the changes made to the config.ini file.

That's all?

Of course not! It's impossible to explain everything in one place. If you want to know more here are listed some things that were left unexplained, and some tips and tricks: unexplained_explained.md or at project Wiki.

Screenshots

image.png

Known Issues

Nickname Limitations

You cannot have a nickname that starts with a command name, such as !cgpt .

Game language limitations

In non-English localizations of the game, some of the features may be broken

TF2 Bot Detector Cooperation (TF2BD)

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.

Contributing

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 :).