getzep / zep

Zep: Long-Term Memory for ‍AI Assistants.

Home Page:https://docs.getzep.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update, delete and insert messages on Langchain SDK

matisidler opened this issue · 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)

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.