Coder Social home page Coder Social logo

chatgpt-discord-bot's Introduction

ChatGPT Discord Bot

Build your own Discord bot using ChatGPT


Important

Major Update (2024/03):

  • Due to instability issues with GPT-4 model, we have defaulted back to GPT-3.5-turbo
  • Gemini-Pro and GPT-4 now supported for free
  • See README for details and dependency updates.

Chat

image

Setup

Prerequisites

  • Python 3.9 or later
  • Rename the file .env.example to .env
  • Running pip3 install -r requirements.txt to install the required dependencies
  • Google Chrome for Image Generation

Step 1: Create a Discord bot

  1. Go to https://discord.com/developers/applications create an application

  2. Build a Discord bot under the application

  3. Get the token from bot setting

    image

  4. Store the token to .env under the DISCORD_BOT_TOKEN

    image
  5. Turn MESSAGE CONTENT INTENT ON

    image

  6. Invite your bot to your server via OAuth2 URL Generator

    image

Optional: OPENAI ACCESS (gpt-4 & DALL-E-3 supported)

If you possess an OpenAI Plus account, utilizing the OpenAI provider is recommended for a smoother experience.

  1. Navigate to https://chat.openai.com/ and log in with your account credentials.

  2. Launch the Developer Tools in your browser.

  3. In the Developer Tools, navigate to the Network tab.

  4. Refresh the page to record the network activity.

  5. Chat whth the bot one time.

  6. In the Network tab, right-click on any item in the list of network activities and choose Save all as HAR with content. Save the file with the name a.har.

  7. place the a.har file in the ./hardir directory.

  • You can change MODEL in .env to gpt-4 also

Caution

Ensure that your a.har file is stored securely, as it may contain sensitive information.

This is not OpenAI API. For API access, refer Optional: Configuring OpenAI API

Step 2: Run the bot on the desktop

  1. Open a terminal or command prompt

  2. Navigate to the directory where you installed the ChatGPT Discord bot

  3. Run python3 main.py or python main.py to run the bot


Step 2: Run the bot with Docker

  1. Build the Docker image & run the Docker container with docker compose up -d

  2. Inspect whether the bot works well docker logs -t chatgpt-discord-bot

    Stop the bot:

    • docker ps to see the list of running services
    • docker stop <BOT CONTAINER ID> to stop the running bot

Have a good chat!


Image Generation

image

OpenAI DALLE3 Image Generation (Requires a GPT Plus account)

  1. Log into your openai account

  2. Go to https://chat.openai.com/api/auth/session

  3. Copy the value for access_token and paste it into .env under OPENAI_TOKEN

Microsoft Bing Image Generation

  1. Go to https://www.bing.com/chat and log in

  2. Open console with F12

  3. Open Application tab > Cookies

  4. Copy the value for _U from cookies and paste it into .env under BING_COOKIE

Google Gemini Image Generation

  1. Go to https://gemini.google.com/app and log in

  2. Open console with F12

  3. Open Application tab > Cookies

  4. Copy the value for __Secure-1PSID from cookies and paste it into .env under GOOGLE_PSID

Optional: Configuring OpenAI API

To use the OpenAI API features, follow these steps:

  1. Obtain your API key by visiting https://platform.openai.com/api-keys
  2. Paste the API key under OPENAI_KEY in .env
  3. Set OPENAI_ENABLED to True in .env

Note

GPT-4 API is subject to certain restrictions.

For more details, please visit https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4

Optional: Setup system prompt

  • A system prompt would be invoked when the bot is first started or reset

  • You can set it up by modifying the content in system_prompt.txt

  • All the text in the file will be fired as a prompt to the bot

  • Get the first message from ChatGPT in your discord channel!

  • Go Discord setting turn developer mode on

    1. Right-click the channel you want to recieve the message, Copy ID

      channel-id

    2. paste it into .env under DISCORD_CHANNEL_ID

Optional: Disable logging

  • Set the value of LOGGING in the .env to False

中文設置教學


Commands

  • /chat [message] Chat with ChatGPT/Gemeni

  • /draw [prompt] Generate an image with Gemini/OpenAI/Bing

  • /switchpersona [persona] Switch between optional chatGPT jailbreaks

    • random: Picks a random persona
    • standard: Standard chatGPT mode
    • dan: DAN 13.5 (Latest Working ChatGPT Jailbreak prompt)
    • Smart mode: AIM (Always Intelligent and Machiavellian)
    • Developer Mode: software developer who specializes in the AI's area
  • /private ChatGPT switch to private mode

  • /public ChatGPT switch to public mode

  • /replyall ChatGPT switch between replyAll mode and default mode

  • /reset Clear ChatGPT conversation history

  • /chat-model Switch different chat model

    • gpt-4: GPT-4 model
    • Gemini: Google Gemini Model

Special Features

Switch Persona

Warning

Certain personas may generate vulgar or disturbing content. Use at your own risk.

image

Mode

  • public mode (default) the bot directly reply on the channel

    image

  • private mode the bot's reply can only be seen by the person who used the command

    image

  • replyall mode the bot will reply to all messages in the channel without using slash commands (/chat will also be unavailable)

    Warning The bot will easily be triggered in replyall mode, which could cause program failures


chatgpt-discord-bot's People

Stargazers

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

Watchers

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

chatgpt-discord-bot's Issues

i got an error AttributeError: 'NoneType' object has no attribute 'info'

Traceback (most recent call last):
File "f:\Project\Python\1ntrovert Bot Remake\packages\bot.py", line 78, in send_start_prompt
logger.info(f"Send starting prompt with size {len(prompt)}")
AttributeError: 'NoneType' object has no attribute 'info'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\gamer\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "f:\Project\Python\1ntrovert Bot Remake\packages\bot.py", line 95, in on_ready
await send_start_prompt(client)
File "f:\Project\Python\1ntrovert Bot Remake\packages\bot.py", line 87, in send_start_prompt
logger.exception(f"Error while sending starting prompt: {e}")
AttributeError: 'NoneType' object has no attribute 'exception'

tls-client-amd64.so not found

Hi, I am trying to get this bot running on my M1 Mac. I have debian amd64 running inside UTM for Mac but I get the following error when I start the bot:

Traceback (most recent call last):
  File "/opt/chatGPT-discord-bot/main.py", line 1, in <module>
    from src import bot
  File "/opt/chatGPT-discord-bot/src/bot.py", line 5, in <module>
    from src import responses
  File "/opt/chatGPT-discord-bot/src/responses.py", line 1, in <module>
    from asyncChatGPT.asyncChatGPT import Chatbot
  File "/usr/local/lib/python3.9/dist-packages/asyncChatGPT/asyncChatGPT.py", line 10, in <module>
    from OpenAIAuth.OpenAIAuth import OpenAIAuth, Debugger
  File "/usr/local/lib/python3.9/dist-packages/OpenAIAuth/OpenAIAuth.py", line 5, in <module>
    import tls_client
  File "/usr/local/lib/python3.9/dist-packages/tls_client/__init__.py", line 15, in <module>
    from .sessions import Session
  File "/usr/local/lib/python3.9/dist-packages/tls_client/sessions.py", line 1, in <module>
    from .cffi import request
  File "/usr/local/lib/python3.9/dist-packages/tls_client/cffi.py", line 15, in <module>
    library = ctypes.cdll.LoadLibrary(f'{root_dir}/dependencies/tls-client{file_ext}')
  File "/usr/lib/python3.9/ctypes/__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/local/lib/python3.9/dist-packages/tls_client/dependencies/tls-client-amd64.so: cannot open shared object file: No such file or directory

I checked out v0.1.2 if that matters.
Any help appreciated

"OSError: Error relocating" on linux docker container

When running the bot I get this error on a Linux docker container. Its using an ARM chip instead of an AMD one, is there any way to resolve this for my specific machine?

2022-12-08T19:19:37.481280314Z   File "/usr/local/lib/python3.9/site-packages/tls_client/cffi.py", line 15, in <module>
2022-12-08T19:19:37.481283354Z     library = ctypes.cdll.LoadLibrary(f'{root_dir}/dependencies/tls-client{file_ext}')
2022-12-08T19:19:37.481285994Z   File "/usr/local/lib/python3.9/ctypes/__init__.py", line 452, in LoadLibrary
2022-12-08T19:19:37.481366514Z     return self._dlltype(name)
2022-12-08T19:19:37.481370594Z   File "/usr/local/lib/python3.9/ctypes/__init__.py", line 374, in __init__
2022-12-08T19:19:37.481541554Z     self._handle = _dlopen(self._name, mode)
2022-12-08T19:19:37.481547074Z OSError: Error relocating /usr/local/lib/python3.9/site-packages/tls_client/dependencies/tls-client-amd64.so: unsupported relocation type 7

Formatting issue with seperate messages

Hi,
I've integrated chatgpt into my discord using your bot (really nice work by the way) but I noticed a small bug in your code. Specifically within the message splitting if the response from chatgpt is >1900 characters.

src > bot.py
image

This works fine with any message, but there are specific examples where this causes a slight formatting issue (pictured below) where because of the message splitting, this makes the code appear in two separate messages with no codeblock (although the ``` is there it must be within the same message to nest the text into a codeblock and discord can't format within 2 separate messages for a code block.

image

I don't anticipate this to be a major issue to solve as chatgpt api's has specific conditions to check if the response contains a codeblock and I'd like to work on this issue if that's okay with you guys.

Bot is no longer seeing any messages after update.

After a recent update, the bot is now not seeing any message. Before, messages would show up in the console when users typed in a discord channel that the bot had access to. But now, nothing is popping up in console as people send messages, and the bot is not responding to anything.

Problems Running the bot

I've been able to run the bot in my windows system naturally. Using the user-agent that my web browser uses.

However as I tried to upload the bot to a host, the bot simply refuses to work, and as far as I've analysed the problem is related to the User-Agent.

So I wonder how I'd be able to upload this bot to a hosting service... and still be able to make it run

Running on windows:
image

Running on Hosting service with the exact same files:
image

I'm quite new to User-agent related stuff, so I don't really know what I can do about this.

Bug: auth error

#134

If you encounter the problem mentioned above, please try using the session token method for authentication

Intents object has no attribute 'message_content'

[root@VM-4-11-centos chatGPT-discord-bot]# python3 main.py

Traceback (most recent call last):
File "main.py", line 1, in
import bot
File "/root/chatGPT-discord-bot/bot.py", line 19, in
intents.message_content = True
AttributeError: 'Intents' object has no attribute 'message_content'

I checked the application and bot, the MESSAGE CONTENT INTENT is on.

ImportError: cannot import name 'AppCommandOptionType' from 'discord.enums'

When I run it, I get the following error and it does not work

File "/opt/chatgpt/main.py", line 1, in <module> from src import bot File "/opt/chatgpt/src/bot.py", line 2, in <module> from discord import app_commands File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/__init__.py", line 12, in <module> from .commands import * File "/usr/local/lib/python3.10/dist-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' (/root/.local/lib/python3.10/site-packages/discord/enums.py)

Bots often don’t answer questions well

Hi, I have tried to run the bot and chat with it. However, it is not able to generate python code, etc., and often cannot answer questions well, even questions that can be answered in the web version. Is this a specification? Or is it a bug?

discord.app_commands.tree Ignoring exception in command

Hi there, I got a error message pop up every time when I send a command to the bot, the log is like this:

2022-12-08 07:50:35 ERROR    discord.app_commands.tree Ignoring exception in command 'chat'
Traceback (most recent call last):
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 862, in _do_call                           
    return await self._callback(interaction, **params)  # type: ignore 
  File "/home/tsunamori/L/chatGPT-discord-bot/src/bot.py", line 47, in chat                                                                   
    await interaction.response.defer(ephemeral = is_private)           
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/interactions.py", line 636, in defer                                       
    await adapter.create_interaction_response(                         
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/webhook/async_.py", line 218, in request                                   
    raise NotFound(response, data)                                     
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction                                                               
                                                                       
The above exception was the direct cause of the following exception:   
                                                                       
Traceback (most recent call last):                                     
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1242, in _call                                 
    await command._invoke_with_namespace(interaction, namespace)       
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 887, in _invoke_with_namespace             
    return await self._do_call(interaction, transformed_values)        
  File "/home/tsunamori/.local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 880, in _do_call                           
    raise CommandInvokeError(self, e) from e                           
discord.app_commands.errors.CommandInvokeError: Command 'chat' raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction 

The code is up-to-date, using the security session to connect the chatGPT. Is there any settings I need to change ?

Suggestion: Add ChannelID limit

Please add discord channelID to config to limit bot to a certain channel(s)
I thought /public /private might handle this but I have no idea what this even does.

Spelling error

When an error happens the text shows: Error: There are something went wrong. Please try again later!

A correct message would be Error: Something went wrong. Please try again later! or Error: There is something wrong. Please try again later!

Docker: Response.py is looking for config.json but only config.dev.json exists

In Docker
Response.py is looking for config.json but only config.dev.json exists

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from src import bot
  File "/DiscordBot/src/bot.py", line 3, in <module>
    from src import responses
  File "/DiscordBot/src/responses.py", line 26, in <module>
    data = get_config()
  File "/DiscordBot/src/responses.py", line 20, in get_config
    with open(config_path, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/DiscordBot/config.json'

Blocked connection

I was able to use the bot yesterday but today I'm faced with a 'The request is blocked' response after authorizing correctly. Any idea what could be happening

docker environment, compiled last night works fine, this morning I can't send the message, pulling the new code reports an error

Traceback (most recent call last):
File "main.py", line 1, in
from src import bot
File "/DiscordBot/src/bot.py", line 3, in
from src import responses
File "/DiscordBot/src/responses.py", line 32, in
chatbot = Chatbot(config, conversation_id=None)
File "/usr/local/lib/python3.8/dist-packages/revChatGPT/revChatGPT.py", line 116, in init
self.refresh_session()
File "/usr/local/lib/python3.8/dist-packages/revChatGPT/revChatGPT.py", line 295, in refresh_session
asyncio.run(self.get_cf_cookies())
File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/usr/local/lib/python3.8/dist-packages/revChatGPT/revChatGPT.py", line 390, in get_cf_cookies
raise Exception("cf challenge fail")
Exception: cf challenge fail

Bug: FileNotFoundError: [Errno 2] No such file or directory: 'config.json'

When I tried to run main.py using the full path, I encountered the following errors.

root@linux:~/chatGPTBot# pyython3 chatGPT-discord-bot/main.py 
-bash: pyython3: command not found
root@linux:~/chatGPTBot# python3 chatGPT-discord-bot/main.py 
Traceback (most recent call last):
  File "/root/chatGPTBot/chatGPT-discord-bot/main.py", line 1, in <module>
    from src import bot
  File "/root/chatGPTBot/chatGPT-discord-bot/src/bot.py", line 5, in <module>
    from src import responses
  File "/root/chatGPTBot/chatGPT-discord-bot/src/responses.py", line 5, in <module>
    with open('config.json', 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'config.json'

I will fix the bugs.

Error: I think there are something went wrong. Please try again later!

I keep getting the discord bot saying this error when I ask it a question:

Error: I think there are something went wrong. Please try again later!

Other error:
('Response is not in the correct format', "Service unavailable: Our services aren't available right now We're working to restore all services as soon as possible. Please check back soon.")

error message

image_2022-12-07_194407145
when I try to run the code I get this error message

The redundant log message.

@aW3ikun ➜ /workspaces/chatGPT-discord-bot (main ✗) $ xvfb-run python3 main.py
2022-12-14 05:49:51 ERROR    __main__ -> revChatGPT version 0.0.44 is installed but does not match the requirements.
NoneType: None

NoneType: None is a redundan message.
When using logger. exception() to print notice, the exception info is added to the logging message. However, it's just a reminder to users, it does not cause an exception, and the output is always NoneType: None.
Reference: https://docs.python.org/3/library/logging.html#logging.Logger.exception

As a result, logger.error() replaces logger.exception().

I will fix it next PR.

Wrong response code

Bot just stopped working. I stopped it, upgraded to v0.1.6 and also logged out and in with my browser and copied a new session_token into config.json.

Still when I start I get the same error as I got when it was failing before I quit the bot:

% python3 main.py
Traceback (most recent call last):
  File "/Users/ap/Projects/chatGPT-discord-bot/main.py", line 1, in <module>
    from src import bot
  File "/Users/ap/Projects/chatGPT-discord-bot/src/bot.py", line 3, in <module>
    from src import responses
  File "/Users/ap/Projects/chatGPT-discord-bot/src/responses.py", line 36, in <module>
    chatbot = Chatbot(config, conversation_id=None)
  File "/opt/homebrew/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 89, in __init__
    self.refresh_session()
  File "/opt/homebrew/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 285, in refresh_session
    raise Exception("Wrong response code")
Exception: Wrong response code

better discord implementation

instead of /chat how about ping the bot.
and make if able to be on the members list/to be able to chat with it without discord Server.

Add an option to remove boilerplate text from the result

ChatGPT answers are just too long for effective usage in a discord channel. And OpenAI has added lots of gatekeeping so the result often contains the same phrases about what it is and why it can’t browse the internet, regardless how one tries to force the AI to not repeat it.

So a more manual filtering on the bot level could solve this if it is made configurable.

BTW: excellent work!

Exception: Incorrect response from OpenAI API

Traceback (most recent call last):
File "/home/jbx2050/.local/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 215, in __get_chat_text
response = response.text.splitlines()[-4]
IndexError: list index out of range

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/jbx2050/chatGPT-discord-bot/src/bot.py", line 31, in send_message
response += await responses.handle_response(user_message)
File "/home/jbx2050/chatGPT-discord-bot/src/responses.py", line 7, in handle_response
response = await chatbot.get_chat_response(prompt, output="text")
File "/home/jbx2050/.local/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 269, in get_chat_response
return await self.__get_chat_text(data)
File "/home/jbx2050/.local/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 219, in __get_chat_text
raise Exception("Incorrect response from OpenAI API") from exc
Exception: Incorrect response from OpenAI API

Entering a multi-line message

When using the bot to type a message, it is not possible to send a message with line breaks. Do you have any plans to resolve this?

Thank you in advance.

Permissions and Roles Issues

How can I activate this bot into just one channel. I have tried to filter the bot into only one channel a number of ways.

  1. I attempted to set server and category and channel settings to revoke all accesses using roles.

  2. I attempted to use the new integrations function, and limit the bot and its / functions to only the relevant channel

In the discord developer page I only have "OAuth2 > scopes (BOT) > Bot Permissions (send message)" enabled. However I do not have REQUIRES OAUTH2 CODE GRANT checked. Do I need to check this, and then Generate an invite link for my application, and integrate this into the code?

Am I missing something, did I grant the bot admin access somewhere else?

Any thoughts or help would be greatly appreciated, new to discord integrations.

thank you.

known issue: httpx.RemoteProtocolError

httpx.RemoteProtocolError: peer closed connection without sending complete message body

It's a bug related to OpenAI

ChatGPT no longer outputs long-form content. If you hit the limit, it will throw a network error on their website too

Bot doesn't answer anymore to rquests.

Yesterday I tested this bot on my windows machine and it worked great. I could ask it stuff via my Discord server and it answered. Today I started the bot again and the bot went online as normal, but when I make any request I just get an Error like this:

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta content='text/html; charset=utf-8' http-equiv='content-type'/><style type='text/css'>body { font-family:Arial; margin-left:40px; }img  { border:0 none; }#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p  { font-size: 13px; color: #000000; margin: 7px 0px 0px 0px }#errorref { font-size: 11px; color: #737373; margin-top: 41px }</style><title>Microsoft</title></head><body><div id='content'><div id='message'><h2>The request is blocked.</h2></div><div id='errorref'><span>0F3GPYwAAAACjgYonb1DSSb9JK4m/9DtqRFVTMzBFREdFMDYxNwBlNjZiOGIwMy0wNzkzLTQ0MDktOTc3My0yZTYxMmU3MWExZTM=</span></div></div></body></html>
'ValueError' object is not subscriptable

What's going on?

Exception: cf challenge fail

Firstly, I ran xvfb-run python3 -m revChatGPT --debug, which works.
But when I ran main.py, which raised Exception: cf challenge fail.
How to resolve it?

root at linux in ~/chatGPT-discord-bot (main●) (venv) 
$ xvfb-run python3 -m revChatGPT --debug

        ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
        Repo: github.com/acheong08/ChatGPT
        Run with --debug to enable debugging
        
Type '!help' to show commands
Press enter twice to submit your question.

Debugging enabled.
Logging in...
Debugger enabled on OpenAIAuth
Jg5jNxuyekaUYaRgmFz9dJrJSqt2BDsUGWW3PtAx0Gw-1671071986-0-1-8cc334c5.f08c3a00.d1bb330a-160
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

You:
Hi

Chatbot: 
Hello! How can I help you today? Is there something on your mind that you want
to talk about or ask about? I'm here to assist with any questions or concerns
you may have. Let me know if there's anything I can do to help.

You:
^C
Goodbye!


root at linux in ~/chatGPT-discord-bot (main●) (venv) 
$ xvfb-run python3 main.py              
Traceback (most recent call last):
  File "/root/chatGPT-discord-bot/main.py", line 1, in <module>
    from src import bot
  File "/root/chatGPT-discord-bot/src/bot.py", line 3, in <module>
    from src import responses
  File "/root/chatGPT-discord-bot/src/responses.py", line 32, in <module>
    chatbot = Chatbot(config, conversation_id=None)
  File "/root/chatGPT-discord-bot/venv/lib/python3.9/site-packages/revChatGPT/revChatGPT.py", line 116, in __init__
    self.refresh_session()
  File "/root/chatGPT-discord-bot/venv/lib/python3.9/site-packages/revChatGPT/revChatGPT.py", line 295, in refresh_session
    asyncio.run(self.get_cf_cookies())
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/root/chatGPT-discord-bot/venv/lib/python3.9/site-packages/revChatGPT/revChatGPT.py", line 390, in get_cf_cookies
    raise Exception("cf challenge fail")
Exception: cf challenge fail

Answers cut off after first message

When the bot gives a long answer, the answer doesn't roll over to a second message. I've only seen it happen once where the bot sends a 2nd message to finish the answer. Is there any way to fix this?

cf_clearance

C:\Users\Desktop\DiscordChatGPT>python main.py
Traceback (most recent call last):
File "C:\Users\Desktop\DiscordChatGPT\main.py", line 1, in
from src import bot
File "C:\Users\Desktop\DiscordChatGPT\src\bot.py", line 3, in
from src import responses
File "C:\Users\Desktop\DiscordChatGPT\src\responses.py", line 29, in
"cf_clearance": data['cf_clearance'],
KeyError: 'cf_clearance'

Issue when trying to use /chat for anything

I am getting this issue whent trying to use /chat for anything in the latest version 0.2.5, also another issue which I am facing is after 3-4 hours the cookie expires and I have to manually add another new cookie, can anything be done about that to ensure 24/7 uptime of this bot.

2022-12-15 10:23:07 ERROR    src.bot -> Error while sending message: Incorrect response from OpenAI API
Traceback (most recent call last):
  File "C:\Users\ishan\AppData\Local\Programs\Python\Python310\lib\site-packages\revChatGPT\revChatGPT.py", line 215, in __get_chat_text
    response = response.text.splitlines()[-4]
IndexError: list index out of range

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\ishan\Downloads\chatGPT-discord-bot-0.2.5\src\bot.py", line 31, in send_message
    response += await responses.handle_response(user_message)
  File "C:\Users\ishan\Downloads\chatGPT-discord-bot-0.2.5\src\responses.py", line 7, in handle_response
    response = await chatbot.get_chat_response(prompt, output="text")
  File "C:\Users\ishan\AppData\Local\Programs\Python\Python310\lib\site-packages\revChatGPT\revChatGPT.py", line 269, in get_chat_response
    return await self.__get_chat_text(data)
  File "C:\Users\ishan\AppData\Local\Programs\Python\Python310\lib\site-packages\revChatGPT\revChatGPT.py", line 219, in __get_chat_text
    raise Exception("Incorrect response from OpenAI API") from exc
Exception: Incorrect response from OpenAI API

Errors with Remote Desktop

I ran the latest version and got the following error.
Probably due to the use of Xrdp

playwright._impl._api_types.Error: ╔════════════════════════════════════════════════════════════════════════════════════════════════╗ ║ Looks like you launched a headed browser without having a XServer running. ║ ║ Set either 'headless: true' or use 'xvfb-run <your-playwright-app>' before running Playwright. ║ ║ ║ ║ <3 Playwright Team ║ ╚════════════════════════════════════════════════════════════════════════════════════════════════╝ =========================== logs =========================== <launching> /root/.cache/ms-playwright/chromium-1033/chrome-linux/chrome --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-u1LdIB --remote-debugging-pipe --no-startup-window <launched> pid=9917 [pid=9917][err] [9917:9917:1213/235312.524155:ERROR:ozone_platform_x11.cc(238)] Missing X server or $DISPLAY [pid=9917][err] [9917:9917:1213/235312.524839:ERROR:env.cc(255)] The platform failed to initialize. Exiting.

"This command is outdated"

This error shows up after inputting "/chat" command in discord. I waited at least 15 mins and the problem still occurs.

image

asyncio.run() cannot be called from a running event loop

After the bot runs for awhile, I start getting this error and the bot is not able to send messages.

2022-12-14 16:58:34 ERROR    src.bot -> Error while sending message: asyncio.run() cannot be called from a running event loop
Traceback (most recent call last):
  File "/home/ubuntu/chatGPT-discord-bot/src/bot.py", line 18, in send_message
    response += await responses.handle_response(user_message)
  File "/home/ubuntu/chatGPT-discord-bot/src/responses.py", line 6, in handle_response
    chatbot.refresh_session()
  File "/home/ubuntu/.local/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 311, in refresh_session
    asyncio.run(self.get_cf_cookies())
  File "/usr/lib/python3.10/asyncio/runners.py", line 33, in run
    raise RuntimeError(
RuntimeError: asyncio.run() cannot be called from a running event loop
/home/ubuntu/chatGPT-discord-bot/src/bot.py:57: RuntimeWarning: coroutine 'AsyncChatbot.get_cf_cookies' was never awaited
  logger.exception(f"Error while sending message: {e}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

known issue: Not a JSON response

As the number of messages in the conversation increases, around 10 to 20, it will keep throwing errors Not a JSON response

The temporary fix is use /reset

about session

This is always returned for each request, and the robot will not respond, but it is online

<style type='text/css'>body { font-family:Arial; margin-left:40px; }img { border:0 none; }#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p { font-size: 13px; color: #000000; margin: 7px 0px 0px 0px }#errorref { font-size: 11px; color: #737373; margin-top: 41px }</style><title>Microsoft</title>

The request is blocked.

0zumOYwAAAAA8SfCJukZOQoFDTOlq+G28SEtHMzBFREdFMDYxNQBlNjZiOGIwMy0wNzkzLTQ0MDktOTc3My0yZTYxMmU3MWExZTM=

'ValueError' object is not subscriptable

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.