Skip to content

Commit fb90d68

Browse files
committed
feat: update data type of values from STRING to JSON
The bump in lowerbound for google-cloud-spanner is to capture the fix in googleapis/python-spanner#1236.
1 parent ba13efc commit fb90d68

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies = [
1212
"langchain-core>=0.1.25, <1.0.0",
1313
"langchain-community>=0.0.18, <1.0.0",
1414
"langgraph-checkpoint>=2.0.2, <3.0.0",
15-
"google-cloud-spanner>=3.41.0, <4.0.0",
15+
"google-cloud-spanner>=3.50.1, <4.0.0",
1616
]
1717
classifiers = [
1818
"Intended Audience :: Developers",

src/langchain_google_spanner/langgraph_checkpoint.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from typing import Any, Dict, Iterator, Optional, Sequence, Tuple, TypedDict
1919

2020
from google.cloud.spanner_dbapi import Cursor # type: ignore[import-untyped]
21-
from langchain_core.load.dump import dumps
21+
from google.cloud.spanner_v1 import JsonObject
22+
from langchain_core.load.dump import dumpd
2223
from langchain_core.runnables import RunnableConfig
2324
from langgraph.checkpoint.base import (
2425
WRITES_IDX_MAP,
@@ -135,8 +136,8 @@ def __init__(
135136
checkpoint_ns STRING(1024) NOT NULL DEFAULT (''),
136137
checkpoint_id STRING(1024) NOT NULL,
137138
parent_checkpoint_id STRING(1024),
138-
checkpoint STRING(MAX) NOT NULL,
139-
metadata STRING(MAX) NOT NULL DEFAULT ('{}'),
139+
checkpoint JSON NOT NULL,
140+
metadata JSON NOT NULL DEFAULT (JSON '{}'),
140141
) PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)
141142
"""
142143
)
@@ -149,7 +150,7 @@ def __init__(
149150
task_id STRING(1024) NOT NULL,
150151
idx INT64 NOT NULL,
151152
channel STRING(1024) NOT NULL,
152-
value STRING(MAX) NOT NULL,
153+
value JSON NOT NULL,
153154
) PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id, task_id, idx)
154155
"""
155156
)
@@ -368,8 +369,8 @@ def put(
368369
checkpoint_ns,
369370
checkpoint["id"],
370371
config["configurable"].get("checkpoint_id"),
371-
dumps(checkpoint),
372-
dumps(metadata),
372+
JsonObject(dumpd(checkpoint)),
373+
JsonObject(dumpd(metadata)),
373374
),
374375
)
375376
return _config(thread_id, checkpoint_ns, checkpoint["id"])
@@ -405,7 +406,7 @@ def put_writes(
405406
task_id,
406407
WRITES_IDX_MAP.get(channel, idx),
407408
channel,
408-
dumps(value),
409+
JsonObject(dumpd(value)),
409410
)
410411
for idx, (channel, value) in enumerate(writes)
411412
],

0 commit comments

Comments
 (0)