xtekky / gpt4free-discord

Gpt4Free basic disord bot, streamed responses, gpt-4 and more
GNU General Public License v3.0
176 stars 27 forks source link

The script does not remember the context of the conversation #3

Open GregFedy opened 1 year ago

GregFedy commented 1 year ago

Is there some way to save the conversation so that GPT understands the context of the conversation?

The script does not allow for retaining conversation context. Each prompt/result pair is independent of each other. As a result, GPT cannot continue its response if it was not fully generated, and it will not understand what was asked in the prompt in previous interactions. For example, I ask gpt to remember my name, and in the next message I ask him to say my name. As a result, he doesn't know. image

a13xlol commented 1 year ago

This is due to a random token being picked from text file, only way to bypass this is make json file and code it so it associates your username with certain Poe token

GregFedy commented 1 year ago

This is due to a random token being picked from text file, only way to bypass this is make json file and code it so it associates your username with certain Poe token

Will there be any restriction because of this? Let's say a limited number of requests per day, as an example. Can you help me with that? I don't quite understand how to make a json file with my account and a certain token so that the context of the conversation is preserved. Do I understand correctly what I need in the file tokens.txt leave only one? Then the token and client variables will always store the same value?

token = random.choice(open('/root/gpt4free-discord/tokens.txt', 'r').read().splitlines())
client = poe.Client(token.split(':')[0])
GregFedy commented 1 year ago

No, I was wrong about the reasoning above. Even if you leave one token in tokens.txt , anyway, the bot does not remember the context of the conversation.

Bohaska commented 1 year ago

Is there some way to save the conversation so that GPT understands the context of the conversation?

The script does not allow for retaining conversation context. Each prompt/result pair is independent of each other. As a result, GPT cannot continue its response if it was not fully generated, and it will not understand what was asked in the prompt in previous interactions. For example, I ask gpt to remember my name, and in the next message I ask him to say my name. As a result, he doesn't know. image

The bot is designed so that its conversation context is cleared after every message it sends. When the bot sends a message, with_chat_break is set to True, which means that the conversation context is cleared. If you don't want that to happen, simply go to https://github.com/xtekky/gpt4free-discord/blob/7f266029f52422380c5a630f20cff381a53a38ac/main.py#L67 and change True to False for it to never reset conversation history. Also, use your own poe account for that or else your messages will be mixed with other strangers.

GregFedy commented 1 year ago

The bot is designed so that its conversation context is cleared after every message it sends. When the bot sends a message, with_chat_break is set to True, which means that the conversation context is cleared. If you don't want that to happen, simply go to

https://github.com/xtekky/gpt4free-discord/blob/7f266029f52422380c5a630f20cff381a53a38ac/main.py#L67

and change True to False for it to never reset conversation history. Also, use your own poe account for that or else your messages will be mixed with other strangers.

I changed the parameter value from True to False, but now I get responses to other users' requests. How do I use my poe account? How to link it? In the settings of the profile on the site there are no apis, identifiers and other things that would allow me to be identified. And where to specify it in the code? And do I understand correctly that if I use my account, then I will have a restriction on GPT-4 and other models as on the site?

GregFedy commented 1 year ago

Ok, i got it. The token is just a cookie value. And if I set mine, I get the Error

2023-06-11 17:41:57 ERROR    discord.app_commands.tree Ignoring exception in command 'create'
Traceback (most recent call last):
  File "/root/gpt4free-discord/main.py", line 69, in say
    for token in completion:
  File "/usr/local/lib/python3.10/dist-packages/poe.py", line 483, in send_message
    raise RuntimeError(f"Daily limit reached for {chatbot}.")
**RuntimeError: Daily limit reached for beaver.**

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 842, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "/root/gpt4free-discord/main.py", line 76, in say
    await interaction.response.send_message(f'an error occured: {e}')
  File "/usr/local/lib/python3.10/dist-packages/discord/interactions.py", line 751, in send_message
    raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/tree.py", line 1248, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 867, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 860, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'create' raised an exception: InteractionResponded: This interaction has already been responded to before
ERROR:discord.app_commands.tree:Ignoring exception in command 'create'
Traceback (most recent call last):
  File "/root/gpt4free-discord/main.py", line 69, in say
    for token in completion:
  File "/usr/local/lib/python3.10/dist-packages/poe.py", line 483, in send_message
    raise RuntimeError(f"Daily limit reached for {chatbot}.")
**RuntimeError: Daily limit reached for beaver.**

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 842, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "/root/gpt4free-discord/main.py", line 76, in say
    await interaction.response.send_message(f'an error occured: {e}')
  File "/usr/local/lib/python3.10/dist-packages/discord/interactions.py", line 751, in send_message
    raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/tree.py", line 1248, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 867, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 860, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'create' raised an exception: InteractionResponded: This interaction has already been responded to before

Thus, it is impossible to use your account without restrictions?

Bohaska commented 1 year ago

Ok, i got it. The token is just a cookie value. And if I set mine, I get the Error

2023-06-11 17:41:57 ERROR    discord.app_commands.tree Ignoring exception in command 'create'
Traceback (most recent call last):
  File "/root/gpt4free-discord/main.py", line 69, in say
    for token in completion:
  File "/usr/local/lib/python3.10/dist-packages/poe.py", line 483, in send_message
    raise RuntimeError(f"Daily limit reached for {chatbot}.")
**RuntimeError: Daily limit reached for beaver.**

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 842, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "/root/gpt4free-discord/main.py", line 76, in say
    await interaction.response.send_message(f'an error occured: {e}')
  File "/usr/local/lib/python3.10/dist-packages/discord/interactions.py", line 751, in send_message
    raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/tree.py", line 1248, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 867, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 860, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'create' raised an exception: InteractionResponded: This interaction has already been responded to before
ERROR:discord.app_commands.tree:Ignoring exception in command 'create'
Traceback (most recent call last):
  File "/root/gpt4free-discord/main.py", line 69, in say
    for token in completion:
  File "/usr/local/lib/python3.10/dist-packages/poe.py", line 483, in send_message
    raise RuntimeError(f"Daily limit reached for {chatbot}.")
**RuntimeError: Daily limit reached for beaver.**

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 842, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "/root/gpt4free-discord/main.py", line 76, in say
    await interaction.response.send_message(f'an error occured: {e}')
  File "/usr/local/lib/python3.10/dist-packages/discord/interactions.py", line 751, in send_message
    raise InteractionResponded(self._parent)
discord.errors.InteractionResponded: This interaction has already been responded to before

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/tree.py", line 1248, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 867, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/usr/local/lib/python3.10/dist-packages/discord/app_commands/commands.py", line 860, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'create' raised an exception: InteractionResponded: This interaction has already been responded to before

Thus, it is impossible to use your account without restrictions?

@GregFedy Without paying, no, your account will have restrictions. The tokens sent in the Discord server are all premium accounts, so you can use unlimited GPT-4 with them, but your account is a free account, so you can't use GPT-4 with them. If you buy poe.com's premium option, then you can use your account without restrictions.

TheLime1 commented 1 year ago

can't fix this because each time you message the bot, a random token is chosen to login to a premium poe.com account so the bot can answer you.

And if everyone stays with the same token, overload will happen, and maybe there is a risk of a ban (so we lose that token).