Zero6992 / chatGPT-discord-bot

Integrate ChatGPT into your own discord bot
GNU General Public License v2.0
2.6k stars 699 forks source link

Regenerate respone #436

Closed arash-ashra closed 3 months ago

arash-ashra commented 12 months ago

Hii, Thank you so much for this project. Is it possible to regenerate the response using a command similar to the ChatGPT's interface here? image Cheers, Arash

arash-ashra commented 11 months ago

As it is quite useful for my application, I'll give $100 to the person who implements this feature first ;) What I have in mind is an emoji on the response in Discord that when clicked would regenerate and replace the previous response. @Zero6992 @aW3ikun @shinysocks @jacky-chay

shinysocks commented 11 months ago

@arashash, I implemented the feature on my fork and made a pull request https://github.com/Zero6992/chatGPT-discord-bot/pull/438. If you like the work that I did, please support me on Paypal or Ko-fi!

arash-ashra commented 11 months ago

Awesome! I'll check it out later today. Thank you 🙏

arash-ashra commented 11 months ago

I checked it out in Windows. I see two issues. One is that it doesn't work with /draw. The other one is that the counter. After clicking the emoji the counter goes from 1 to 2 then back to 1. I think it'd be cool to have it count how many it has generated so far similar to OpenAI interface. Thank you for rising to the challenge, I'm sure many users will appreciate this feature as well.

P.S. I made the payment here. Cheers, Arash

arash-ashra commented 11 months ago

Ooh there is a big issue. It is not removing the previous output from the context memory. We can see in this example that each time it's generating it is incrementing, but it should not! image

This is really important for the feature since allows us to sample the same thing multiple times. Looking forward to the patch!

shinysocks commented 11 months ago

Alright,

shinysocks commented 11 months ago

out of curiosity, what are you building? is the source published yet? It seems really neat!

arash-ashra commented 11 months ago

I'm using it to tutor my students in Disocrd (so it helps as a TA). We can't reset the memory in a channel since the bot needs to know the context so we can refer to previous points. The problem I'm trying to solve is to remove the output from the context when the bot is giving a wrong or vague response. We just want to replace the last output. this is exactly how the chatGPT interface works, each time you get an output, you get the chance to replace it at that point (but not later when the next output is generated). As this is the default in ChatGPT I think it makes sense to have it as default here as well. And you could prioritize this to the other issues since currently it's not solving the problem as it's still keeping the wrong outputs in the memory.

arash-ashra commented 11 months ago

another issue, the regenerate button is keep appearing within different lines of the same output. I think doing it with the slash command would have been more robust. image

shinysocks commented 11 months ago

Hello, I'm going to try and attach a regenerate button to only the latest interaction to solve this issue. Otherwise, I could also use a slash command to do the same thing but a button would look really nice.

arash-ashra commented 11 months ago

Right I agree, but until bugs fixed and become a general-purpose button like openAI interface, it may be better to have a /slash command that only users who know what they are doing be able to use it.

shinysocks commented 11 months ago

alright, sounds good

shinysocks commented 11 months ago

I moved the regeneration into a slash command, it does not work for images as of right now.

shinysocks commented 11 months ago

I wanted to get a reaction based counter on the message to show the number of regenerations but I cannot figure out how discord.Interaction works with reactions. But let me know if this is what you were looking for

arash-ashra commented 11 months ago

No worries about that, it's not really useful for my application anyway. The priority should be to remove the previous generation from context memory since currently it's not regenerating, but rather redoing given previous attempts. But I need a sampling function that can reattempt without memory of the previous attempts. Since when it keeps the previous attempts in memory, the new attempts look very similar so it quickly gets stuck in the same frame of mind, but having the ability to regenerate from scratch gives much more brainstorming power

shinysocks commented 11 months ago

I finally understand what you're saying! I'll take a look at the OpenAI API docs and figure how to do this correctly. Sorry for the confusion

arash-ashra commented 11 months ago

Thaanks. Sorry for the misunderstanding

shinysocks commented 11 months ago

I don't think what you want is possible due to limitations in OpenAI API: api reference

arash-ashra commented 11 months ago

Looks like possible if you use chatCompletion API which allows you to store and edit the entire conversation, basically it makes the API memoryless https://platform.openai.com/docs/guides/gpt/chat-completions-api

arash-ashra commented 11 months ago

also, it allows you to edit any part of the conversation in the past which would be a pretty cool feature to have as well

shinysocks commented 11 months ago

oh, awesome!

arash-ashra commented 10 months ago

Hey @shinysocks, any update or plan on this?

shinysocks commented 10 months ago

I haven't yet taken a look at rewriting the API requests. I'll check it out sometime this upcoming week hopefully

arash-ashra commented 10 months ago

Awesome. Looking forward to it

shinysocks commented 10 months ago

Where did you find information in the API to regenerate? I can't seem to find it.

arash-ashra commented 10 months ago

image Here Once you run the bot with this method (ChatCompletion), then regenerating is only a matter of replacing the last item in the messages array and calling again.

shinysocks commented 10 months ago

@Zero6992 Does this bot even use the official openai api?

arash-ashra commented 10 months ago

@shinysocks it's using this https://github.com/acheong08/ChatGPT, which inside is using the official openai api

shinysocks commented 10 months ago

Looking that this api's documentation, it doesn't look like they include a regeneration. If you want to utilize this specific feature you may need to open a pull request on that api.

arash-ashra commented 10 months ago

Yea looks like using that API was a mistake, as the project is dead. I found a better discord chatGPT, which also has the regenerate button. I'll give it a try: https://github.com/Kav-K/GPTDiscord.

shinysocks commented 10 months ago

Awesome, that one looks great.