mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-10 11:47:51 +02:00
Add delete_thread method to Checkpointer class (#4328)
- Deletes all data associated with a thread_id - Implemented in InMemory, Sqlite and Postgres checkpointers Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
co-authored by
Eugene Yurtsev
parent
83bf004ad7
commit
18a9ae45f3
@@ -464,6 +464,25 @@ class SqliteSaver(BaseCheckpointSaver[str]):
|
||||
],
|
||||
)
|
||||
|
||||
def delete_thread(self, thread_id: str) -> None:
|
||||
"""Delete all checkpoints and writes associated with a thread ID.
|
||||
|
||||
Args:
|
||||
thread_id (str): The thread ID to delete.
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
with self.cursor() as cur:
|
||||
cur.execute(
|
||||
"DELETE FROM checkpoints WHERE thread_id = ?",
|
||||
(str(thread_id),),
|
||||
)
|
||||
cur.execute(
|
||||
"DELETE FROM writes WHERE thread_id = ?",
|
||||
(str(thread_id),),
|
||||
)
|
||||
|
||||
async def aget_tuple(self, config: RunnableConfig) -> Optional[CheckpointTuple]:
|
||||
"""Get a checkpoint tuple from the database asynchronously.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user