Giter Site home page Giter Site logo

jasonind / chatgpt-discordbot Goto Github PK

View Code? Open in Web Editor NEW
19.0 2.0 1.0 85 KB

An up to date Discord Bot that generates replies using chatGPT

License: GNU General Public License v3.0

Python 95.61% Dockerfile 4.39%
bot chatgpt discord discord-bot openai python edgegpt

chatgpt-discordbot's Introduction

ChatGPT-DiscordBot

An up to date Discord Bot that generates replies using ChatGPT official API. Both browser and browserless options available as well as using the the new Microsoft Edge/Bing GPT which is ChatGPT with internet access! Aimed to be as simple as possible so that people can set it up and modify on their own with ease.

bot.py uses the official OpenAI API I highly recommend you using this one, it does however cost money (uses your tokens).

bot2.py uses unofficial API and you risk having your account being banned, I take no responsibility for what happens to your account if you use this bot.

bot3.py EdgeGPT requires an account with access to Sydney to use.

Features

HoggyGPT GIF

ChatGPT Official API - bot.py

/chat (message) [new_conversation (optional)] [temperature (optional)] - Talk to chatGPT and get a response. You can adjust the temperature from 0-1 which controls how random the output is, by default it is 0.75. New conversations can be started via setting the new_conversation option to True

/rollback [amount] - Go back a set amount of conversation steps in your message history

ChatGPT Browserless - bot2.py

/chat (message) [conversationID (optional)] [parentID (optional)] [new_conversation (optional)]

Talk to chatGPT and get a response. ConversationID and parentID are optional parameters that allow you to continue a previous conversation if you'd like, keep in mind you must have both to continue a previous conversation. New conversations can be started via setting the new_conversation option to True

/rollback [amount] - Go back a set amount of conversation steps in your message history

/delete-conversation [conversationID] [delete_all (optional)] - Delete a conversation, set delete_all to true to delete all conversations

EdgeGPT Browserless - bot3.py

/chat (message) [new_conversation (optional)] Talk to EdgeGPT and get a response that has internet access - you will get references from where the answer gets the information. Set new_conversation to true if you want to start a new conversation.

Setup

Install required modules with pip

Install the associated bot.py requirements.txt file

pip install -r requirements.txt

Getting OpenAI API key

  1. Create account on OpenAI
  2. Go to https://platform.openai.com/account/api-keys
  3. Copy API key

Getting session token (Only required for Versions 0.0.4 and below)

You can get your session token manually from your browser:

  1. Go to https://chat.openai.com/api/auth/session
  2. Press F12 to open console
  3. Go to Application then Cookies
  4. Copy the session token value in __Secure-next-auth.session-token
  5. Paste it into config.json file

You can modify the code to use email and password if you'd like just follow the guide by acheong08 - chatGPT authentication

Creating a Discord bot

  1. Go to https://discord.com/developers/
  2. Create a new application and choose a name
  3. Go to the Bot tab and then click Add Bot
  4. Copy bot token and put it into the config.json file
  5. Make sure you turn on the required intents for the bot e.g. Message Intents
  6. Invite bot to your server using the OAuth2 URL Generator

Running the bot

  1. Run python3 bot.py to start the bot
  2. A browser will open up and you will need to press verify you are a human button
  3. Use the commands and have fun!

License

Released under the GNU GPL v3 license.

chatgpt-discordbot's People

Contributors

jasonind avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

xcloudx12345

chatgpt-discordbot's Issues

Bot Typing Effect i.e Stream ChatGPT response in real-time

Awesome work! Thank you for creating this. Is there a way to add the Bot Typing Effect i.e Stream ChatGPT response in real-time? I seem to recall revChatGPT had this.

[EDIT]

I guess the bot could send a message each time it detects an end of sentence. Something like:

prompt = "What is the most difficult Jimi Hendrix song to play on guitar?"
prev_text = ""
for data in chatbot.ask(
    prompt,
):
    message = data["message"][len(prev_text) :]
    if message and message.endswith(('.','?','!', '."',':')):
	    print(message.strip())
	    prev_text = data["message"]

Can't find parentid for older chats

How do I extract the parentid if I wanted to resume a previous conversation that is originally created on the website? I'm trying to return to an old chat I had on the site. I can see the conversation id on the link, but I can't seem to find the parentid one.

New Conversation

Is there a way to create a new conversation thread? It doesn't seem to create a new one unless if I restart the whole bot.

Question

Any way to save conversation history right now? i dont see it remembers what i said earlier

Online host

Is there a way to somehow integrate this into an independent host like Replit or Docker? Or is the manual verify of the captcha preventing this from doing so?

Error

The thing worked the first time, but now I'm getting this:
Traceback (most recent call last): File "/Users/mashooraiyaan/ChatGPT-DiscordBot/bot.py", line 3, in <module> from discord import app_commands File "/opt/homebrew/lib/python3.10/site-packages/discord/app_commands/__init__.py", line 12, in <module> from .commands import * File "/opt/homebrew/lib/python3.10/site-packages/discord/app_commands/commands.py", line 51, in <module> from ..enums import AppCommandOptionType, AppCommandType, ChannelType, Locale ImportError: cannot import name 'AppCommandOptionType' from 'discord.enums' (/opt/homebrew/lib/python3.10/site-packages/discord/enums.py)

New Conversation Feature

Why was new conversation feature got removed? I loved that feature and use it a lot. Would be cool if you could add it again.

Error

I get this error when I try to ask the bot:

That model does not exist

revChatGPT update

Hello, I just wanted to let you know that a new revChatGPT update has been released and it now utilizes the official ChatGPT API. It now also supports Async and has no ratelimits and it's completely free. It would be cool if you update the bot to that version. Thanks!

V1 support

Hello, I'm just wondering if you can also add revChatGPT V1 support for the bot since V2 is down right now. TYSM!

That model does not exist

At first it worked, then it stopped, I did not change anything in the code, with others everything works

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.