Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update, delete and insert messages on Langchain SDK #339

Open
matisidler opened this issue Apr 25, 2024 · 1 comment
Open

Update, delete and insert messages on Langchain SDK #339

matisidler opened this issue Apr 25, 2024 · 1 comment

Comments

@matisidler
Copy link

matisidler commented Apr 25, 2024

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)

@danielchalef
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants