snowby666 / poe-api-wrapper

👾 A Python API wrapper for Poe.com. With this, you will have free access to GPT-4, Claude, Llama, Gemini, Mistral and more! 🚀
https://pypi.org/project/poe-api-wrapper/
GNU General Public License v3.0
687 stars 82 forks source link

chat_break not clearing context #90

Closed Luke-in-the-sky closed 6 months ago

Luke-in-the-sky commented 6 months ago

I can send messages and read them back, but I can't clear the context. I am using bot and chatCode to identify the chat I wan to clear, just like in the readme example

# 1. Using chatCode
client.chat_break(bot, chatCode="....")

but then I can tell the context is NOT cleared, both by the type of answers I get to new messages and by opening up the chat thread in poe.com and seeing that there is no "Context cleared" event in the chain of messages

Luke-in-the-sky commented 6 months ago

The issue seems to be with https://github.com/snowby666/poe-api-wrapper/blob/d124147fb93df20b32b89f040f8c22b1ff7d702d/poe_api_wrapper/api.py#L916C48-L916C48

    def chat_break(self, bot: str, chatId: int=None, chatCode: str=None):
        bot = bot_map(bot)
        chatdata = self.get_threadData(bot, chatCode, chatId)
        chatId = chatdata['chatId']
        variables = {'chatId': chatId, 'clientNonce': generate_nonce()}
        self.send_request('gql_POST', 'SendChatBreakMutation', variables)  <=====

SendChatBreakMutation is not helping. Tried with ChatHelpers_addMessageBreakEdgeMutation_Mutation instead, and it seems to work:

  1. I can now see the Context cleared message in the Poe UI, and
  2. if I prompt the LLM with "what did we discuss so far?" I get "I'm afraid I don't have any record of a previous discussion we had"
snowby666 commented 6 months ago

Thanks for your fix. I've merged the PR.