zep icon indicating copy to clipboard operation
zep copied to clipboard

Update, delete and insert messages on Langchain SDK

Open matisidler opened this issue 1 year ago • 1 comments

Hey! Is it possible to update, delete, and insert messages on Langchain SDK?

I have two LLMs that format inputs and outputs, and I need them to be aware of the actual conversation, but I also need to remove the old input/output from the conversation and only keep the formatted ones.

At the moment, I have something like this:

        current_messages = zep_chat_history._get_memory()
        last_message = current_messages.messages[-1]
        # Here I change the role of the last message, from AI to "human"
        last_message.role = "human"
        current_messages.messages[-1] = last_message
        # Here I want to remove the last user's message
        current_messages.messages.pop(-2)
        # Now I need a method to update the session's messages with these changes

Is there any workaround to achieve this?

I could also use the Python SDK if needed (out of Langchain)

matisidler avatar Apr 25 '24 23:04 matisidler

We don't currently support update or deletion of messages as this requires recalculating artifacts such as summaries and embeddings. We're considering how to do this, but haven't yet settled on an elegant solution.

danielchalef avatar Apr 26 '24 00:04 danielchalef