feat(runtime): añade build_checkpointer wrapper sobre SqliteSaver
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
"""Wrapper sobre SqliteSaver de LangGraph. Centraliza el path y el ciclo de vida."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import sqlite3
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from langgraph.checkpoint.sqlite import SqliteSaver
|
||||||
|
|
||||||
|
|
||||||
|
def build_checkpointer(data_dir: Path) -> SqliteSaver:
|
||||||
|
"""Devuelve un SqliteSaver apuntando a ``data_dir/checkpoints.sqlite``.
|
||||||
|
|
||||||
|
La base se crea si no existe. La conexión usa ``check_same_thread=False``
|
||||||
|
porque LangGraph ejecuta nodos en hilos del executor.
|
||||||
|
"""
|
||||||
|
data_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
db_path = data_dir / "checkpoints.sqlite"
|
||||||
|
conn = sqlite3.connect(str(db_path), check_same_thread=False)
|
||||||
|
return SqliteSaver(conn)
|
||||||
Reference in New Issue
Block a user