Skip to content

HorseNPC is a Discord bot that uses OpenAI's GPT-3.5-turbo language model to (eventually) be able to act as one or more NPCs in a Pathfinder or other fantasy role-playing game.

License

Notifications You must be signed in to change notification settings

dylanwh/horse-npc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HorseNPC: Discord Bot

HorseNPC is a Discord bot that uses OpenAI's GPT-3.5-turbo language model to (eventually) be able to act as one or more NPCs in a Pathfinder or other fantasy role-playing game.

The bot listens to messages in which it is mentioned and replies, currently with horse-based puns.

This is a toy of a project, which uses serenity-rs library to interact with Discord, async-openai to interact with OpenAI, and tokio-rusqlite to save conversation state in a simple sqlite db.

The bot also uses OpenAI's moderation API to filter out potentially unsafe content, although in practice this is not very effective.

Features

  • Generates horse-themed puns and responses using OpenAI's GPT-3.5-turbo language model. Eventually the system prompt (and initial user prompt, since the system prompt is often ignored) will be customizable at runtime.
  • Listens to messages in which it is mentioned and replies accordingly.
  • Moderates the content generated by the language model to comply with OpenAI guidelines.
  • Supports both guild (server) messages and direct messages.
  • Has situational awareness of its the time, its name, the speaker's name, the current channel, the channel topic (if any), and the name of the discord server.

Prerequisites

  • rust toolchain (from https://rustup.rs)
  • A Discord bot token.
  • An OpenAI API key.
  • SQLite development headers

Setup and Installation

  1. Clone the repository
git clone https://github.com/dylanwh/horse-npc.git
cd horse-npc
  1. Set the required environment variables:
export DISCORD_TOKEN=your_discord_bot_token
export OPENAI_KEY=your_openai_api_key

To get a DISCORD_TOKEN I follow the non-shuttle parts of this logrocket blog post.

Getting an OpenAI token can be done from OpenAI's Platform page.

  1. Build and run the bot:
cargo build --release
./target/release/horse-npc

Usage

The bot responds when it is mentioned. No effort is made to resolve discord mentions, so it knows the discord id (in the form of <@123456789>) of itself, the speaker, and anyone else that is mentioned. While the model doesn't really support having multiple people talking at once, it actually works out ok most of the time. It may start mentioning the person that talks to it the most when other people are talking to it, and it often can answer "Who am I?" in a pretty convincing way.

License

This project is licensed under the MIT license

About

HorseNPC is a Discord bot that uses OpenAI's GPT-3.5-turbo language model to (eventually) be able to act as one or more NPCs in a Pathfinder or other fantasy role-playing game.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published