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

core: add RemoveMessage #23636

Merged
merged 11 commits into from
Jun 28, 2024
Merged

core: add RemoveMessage #23636

merged 11 commits into from
Jun 28, 2024

Conversation

vbarda
Copy link
Contributor

@vbarda vbarda commented Jun 28, 2024

This change adds a new message type RemoveMessage. This will enable langgraph users to manually modify graph state (or have the graph nodes modify the state) to remove messages by id

Examples:

  • allow users to delete messages from state by calling
graph.update_state(config, values=[RemoveMessage(id=state.values[-1].id)])
  • allow nodes to delete messages
graph.add_node("delete_messages", lambda state: [RemoveMessage(id=state[-1].id)])

Copy link

vercel bot commented Jun 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Jun 28, 2024 9:03pm

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 28, 2024
@dosubot dosubot bot added Ɑ: core Related to langchain-core 🤖:improvement Medium size change to existing code to handle new use-cases labels Jun 28, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 28, 2024
@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Jun 28, 2024
@nfcampos nfcampos merged commit e8d7700 into master Jun 28, 2024
134 checks passed
@nfcampos nfcampos deleted the vb/remove-message branch June 28, 2024 21:40
class RemoveMessage(BaseMessage):
"""Message responsible for deleting other messages."""

type: Literal["remove"] = "remove"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RemoveMessage better here for 1:1 correspondence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ɑ: core Related to langchain-core 🤖:improvement Medium size change to existing code to handle new use-cases lgtm PR looks good. Use to confirm that a PR is ready for merging. size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants