Giter Club home page Giter Club logo

cf-workers-chatgpt-discord-bot's Introduction

cf-workers-chatgpt-discord-bot

Logo

Description

Example

Serverless Discord bot in webhook mode to quickly interface with OpenAI's Chat Completion API

Note: This is mainly for personal use, if you would like to add features, do fork the repository. Do perform PRs back if you would be so kind!

Prerequisites

Getting Started

Wrangler

  1. Clone this repository
  2. Run npm ci or yarn install
  3. Replace {DISCORD_TOKEN} and {DISCORD_APPLICATION_ID} in the following DISCORD_TOKEN={DISCORD_TOKEN} DISCORD_APPLICATION_ID={DISCORD_APPLICATION_ID} npx node src/register.js and run it to register the bot commands
  4. Run npx wrangler secret put DISCORD_APPLICATION_ID and set the Discord app's ID
  5. Run npx wrangler secret put DISCORD_PUBLIC_KEY and set the Discord app's public key
  6. Run npx wrangler secret put DISCORD_TOKEN and set the Discord bot's token
  7. Run npx wrangler secret put OPENAI_API_KEY and set the OpenAI API key
  8. Add space-delimited user IDs to whitelist in DISCORD_USERID_WHITELIST in wrangler.toml
  9. (Optional) To allow extra lines of context, run npx wrangler kv:namespace create context and replace the ID of CHATGPT_DISCORD_BOT_KV and increase CONTEXT to more than 0 in wrangler.toml (will consume a lot more tokens), else remove kv_namespaces block entirely from wrangler.toml
  10. (Optional) To change the model, update CHATGPT_MODEL in wrangler.toml to whatever you want as documented at https://platform.openai.com/docs/api-reference/chat/create#chat/create-model
  11. (Optional) To include a system message to set the AI's behavior, update CHATGPT_BEHAVIOR in wrangler.toml
  12. Run npx wrangler publish to deploy to Cloudflare Workers
  13. Set the Interactions Endpoint URL of your Discord application to the URL of the deployed worker

cf-workers-chatgpt-discord-bot's People

Contributors

jarylc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nijamadev bpawnzz

cf-workers-chatgpt-discord-bot's Issues

Give the ability to set a system message

Sending a system message is an easy way of customizing the chatbot. With the help of it, a developer can customize the behavior of the endpoint. Example: You're a class mentor chatbot developed by @jarylc. Only respond to math questions., etc.

KV Namespace needs to be created

Hey @jarylc, I gave this a try and it looks good, thank you!
I might be creating a pull request regarding this issue, and a few other things on my mind. For now, here's the issue.
The kv_namespaces in wrangler.toml needs to be set up.
https://github.com/jarylc/cf-workers-chatgpt-discord-bot/blob/66d1205c25bdeb9c1b8bda5ea60cc66292010d9a/wrangler.toml#LL7C62-L7C62
I ran npx wrangler kv:namespace create CHATGPT_DISCORD_BOT_KV in order to create a new namespace and pasted that ID in my wrangler.toml. This should be a step in 'Getting Started'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.