2.1.0 • Published 12 months ago

stormworkschatgpt v2.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

Stormworks Chatbot

This is a Node.js server script that allows a chatbot to communicate with players in the game Stormworks. The script uses HTTP to receive messages from the Stormworks server through GET requests. The received messages are then sent to OpenAI's API for processing using the GPT-3.5 language model. The model generates a response that is sent back to the Stormworks server and displayed in the in-game chat.

The conversation history is stored in an array called conversationLog, which keeps track of the role of the participant (user or assistant) and the message content. The server listens on port 3000 for incoming HTTP GET requests from the Stormworks server, and if the requested URL matches /127.0.0.1, the response is sent back to the Stormworks server and displayed in the in-game chat. If the requested URL does not match /127.0.0.1, a 404 Not Found error message is sent.

The script uses the dotenv package to load environmental variables from a .env file, including the OpenAI API access token used for authentication.

Installation

  1. Subscribe to the addon on the Steam Workshop
  2. Install Node.js https://nodejs.org/en/download
  3. Install the required dependencies using npm i stormworkschatgpt
  4. Create a .env file and add the following variable with your OpenAI API key:
OPENAI_ACCESS_TOKEN=your_api_key_here

Feel free to contact me on discord if you need any extra help: Foll#8000 Temporary Api key may be granted if asked nicely

Usage

  1. Start the server using npm start
  2. In Stormworks, start a server with the addon enabled
  3. Now open Stormworks chat and send a message
  4. The chatbot will respond with a message generated by the OpenAI GPT-3.5 model

Commands

The following commands can be used in-game to interact with the chatbot:

  • ?pm [text] - Sends a private message to the chatbot. Replace [text] with the message you want to send.
  • ?cao - Toggles Admin-only mode.
  • ?cpmo - Toggles private messages only mode.
  • ?ctr [number] - Changes the timeout retry time. Replace [number] with the desired retry time in seconds.

Dependencies

  • http - Node.js HTTP module for creating the server
  • url - Node.js module for parsing URL strings
  • dotenv - loads environmental variables from a .env file
  • openai - a Node.js client for OpenAI's API

License

This project is licensed under the ISC License - see the LICENSE file for details.

2.1.0

12 months ago

2.0.0

1 year ago