存储¶
持久化键值存储库的基类和类型。
存储库支持持久化和内存共享,可以在线程之间共享,也可以作用于用户 ID、助手 ID 或其他任意命名空间。
Item
¶
表示带元数据的存储项。
参数
-
value
(
) –dict [str ,Any ]以字典形式存储的数据。键是可过滤的。
-
key
(
) –str 命名空间内的唯一标识符。
-
namespace
(
) –tuple [str , ...]定义此文档所在集合的层次路径。以字符串元组表示,允许嵌套分类。例如:("documents", 'user123')
-
created_at
(
) –datetime 项目创建的时间戳。
-
updated_at
(
) –datetime 最后更新的时间戳。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
GetOp
¶
Bases:
通过命名空间和键检索项目的运算。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
SearchOp
¶
Bases:
在命名空间前缀内搜索项目的运算。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
PutOp
¶
Bases:
用于存储、更新或删除项目的运算。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
MatchCondition
¶
ListNamespacesOp
¶
Bases:
用于列出命名空间的运算,支持可选匹配条件。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
match_conditions: Optional[tuple[MatchCondition, ...]] = None
class-attribute
instance-attribute
¶
要应用于命名空间的匹配条件元组。
max_depth: Optional[int] = None
class-attribute
instance-attribute
¶
返回层次结构中不超过此深度的命名空间。
limit: int = 100
class-attribute
instance-attribute
¶
要返回的最大命名空间数。
offset: int = 0
class-attribute
instance-attribute
¶
在返回结果之前要跳过的命名空间数。
InvalidNamespaceError
¶
BaseStore
¶
基础:
键值存储的抽象基类。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
|
batch(ops: Iterable[Op]) -> list[Result]
abstractmethod
¶
在单个批次中同步执行多个操作。
参数
-
ops
(
) –Iterable [Op ]要执行的操作的迭代器。
返回值
-
–list [Result ]结果列表,其中每个结果对应于输入中的一个操作。
-
–list [Result ]结果的顺序与输入操作的顺序一致。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
abatch(ops: Iterable[Op]) -> list[Result]
abstractmethod
async
¶
在单个批次中异步执行多个操作。
参数
-
ops
(
) –Iterable [Op ]要执行的操作的迭代器。
返回值
-
–list [Result ]结果列表,其中每个结果对应于输入中的一个操作。
-
–list [Result ]结果的顺序与输入操作的顺序一致。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
get(namespace: tuple[str, ...], key: str) -> Optional[Item]
¶
检索单个项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
返回值
-
–Optional [Item ]检索到的项目,如果未找到,则为 None。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
search(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
¶
在命名空间前缀内搜索项目。
参数
-
namespace_prefix
(
) –tuple [str , ...]要搜索的层次路径前缀。
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –用于过滤结果的键值对。
-
limit
(
, default:int 10
) –要返回的最大项目数。
-
offset
(
, default:int 0
) –在返回结果之前要跳过的项目数。
返回值
-
–list [Item ]与搜索条件匹配的项目列表。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
put(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
¶
存储或更新项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
-
value
(
) –dict [str ,Any ]包含项目数据的字典。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
delete(namespace: tuple[str, ...], key: str) -> None
¶
删除项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
list_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
¶
列出并过滤存储中的命名空间。
用于探索数据组织方式、查找特定集合或导航命名空间层次结构。
参数
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径开头的命名空间。
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径结尾的命名空间。
-
max_depth
(
, default:Optional [int ]None
) –返回层次结构中不超过此深度的命名空间。比此级别更深的命名空间将被截断到此深度。
-
limit
(
, default:int 100
) –要返回的最大命名空间数量(默认值为 100)。
-
offset
(
, default:int 0
) –要跳过的命名空间数量,用于分页(默认值为 0)。
返回值
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: 与条件匹配的命名空间元组列表。
-
–list [tuple [str , ...]]每个元组表示一个完整的命名空间路径,直到
max_depth
。
示例
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
store.list_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
aget(namespace: tuple[str, ...], key: str) -> Optional[Item]
async
¶
异步检索单个项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
返回值
-
–Optional [Item ]检索到的项目,如果未找到,则为 None。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
asearch(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
async
¶
异步在命名空间前缀内搜索项目。
参数
-
namespace_prefix
(
) –tuple [str , ...]要搜索的层次路径前缀。
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –用于过滤结果的键值对。
-
limit
(
, default:int 10
) –要返回的最大项目数。
-
offset
(
, default:int 0
) –在返回结果之前要跳过的项目数。
返回值
-
–list [Item ]与搜索条件匹配的项目列表。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
aput(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
async
¶
异步存储或更新项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
-
value
(
) –dict [str ,Any ]包含项目数据的字典。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
adelete(namespace: tuple[str, ...], key: str) -> None
async
¶
异步删除项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
alist_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
async
¶
异步列出并过滤存储中的命名空间。
用于探索数据组织方式、查找特定集合或导航命名空间层次结构。
参数
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径开头的命名空间。
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径结尾的命名空间。
-
max_depth
(
, default:Optional [int ]None
) –返回层次结构中不超过此深度的命名空间。比此级别更深的命名空间将被截断到此深度。
-
limit
(
, default:int 100
) –要返回的最大命名空间数量(默认值为 100)。
-
offset
(
, default:int 0
) –要跳过的命名空间数量,用于分页(默认值为 0)。
返回值
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: 与条件匹配的命名空间元组列表。
-
–list [tuple [str , ...]]每个元组表示一个完整的命名空间路径,直到
max_depth
。
示例
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
await store.alist_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
AsyncPostgresStore
¶
基础:
源代码位于 libs/checkpoint-postgres/langgraph/store/postgres/aio.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
get(namespace: tuple[str, ...], key: str) -> Optional[Item]
¶
检索单个项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
返回值
-
–Optional [Item ]检索到的项目,如果未找到,则为 None。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
search(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
¶
在命名空间前缀内搜索项目。
参数
-
namespace_prefix
(
) –tuple [str , ...]要搜索的层次路径前缀。
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –用于过滤结果的键值对。
-
limit
(
, default:int 10
) –要返回的最大项目数。
-
offset
(
, default:int 0
) –在返回结果之前要跳过的项目数。
返回值
-
–list [Item ]与搜索条件匹配的项目列表。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
put(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
¶
存储或更新项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
-
value
(
) –dict [str ,Any ]包含项目数据的字典。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
delete(namespace: tuple[str, ...], key: str) -> None
¶
删除项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
list_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
¶
列出并过滤存储中的命名空间。
用于探索数据组织方式、查找特定集合或导航命名空间层次结构。
参数
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径开头的命名空间。
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径结尾的命名空间。
-
max_depth
(
, default:Optional [int ]None
) –返回层次结构中不超过此深度的命名空间。比此级别更深的命名空间将被截断到此深度。
-
limit
(
, default:int 100
) –要返回的最大命名空间数量(默认值为 100)。
-
offset
(
, default:int 0
) –要跳过的命名空间数量,用于分页(默认值为 0)。
返回值
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: 与条件匹配的命名空间元组列表。
-
–list [tuple [str , ...]]每个元组表示一个完整的命名空间路径,直到
max_depth
。
示例
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
store.list_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
aget(namespace: tuple[str, ...], key: str) -> Optional[Item]
async
¶
异步检索单个项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
返回值
-
–Optional [Item ]检索到的项目,如果未找到,则为 None。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
asearch(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
async
¶
异步在命名空间前缀内搜索项目。
参数
-
namespace_prefix
(
) –tuple [str , ...]要搜索的层次路径前缀。
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –用于过滤结果的键值对。
-
limit
(
, default:int 10
) –要返回的最大项目数。
-
offset
(
, default:int 0
) –在返回结果之前要跳过的项目数。
返回值
-
–list [Item ]与搜索条件匹配的项目列表。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
aput(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
async
¶
异步存储或更新项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
-
value
(
) –dict [str ,Any ]包含项目数据的字典。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
adelete(namespace: tuple[str, ...], key: str) -> None
async
¶
异步删除项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
alist_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
async
¶
异步列出并过滤存储中的命名空间。
用于探索数据组织方式、查找特定集合或导航命名空间层次结构。
参数
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径开头的命名空间。
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径结尾的命名空间。
-
max_depth
(
, default:Optional [int ]None
) –返回层次结构中不超过此深度的命名空间。比此级别更深的命名空间将被截断到此深度。
-
limit
(
, default:int 100
) –要返回的最大命名空间数量(默认值为 100)。
-
offset
(
, default:int 0
) –要跳过的命名空间数量,用于分页(默认值为 0)。
返回值
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: 与条件匹配的命名空间元组列表。
-
–list [tuple [str , ...]]每个元组表示一个完整的命名空间路径,直到
max_depth
。
示例
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
await store.alist_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
from_conn_string(conn_string: str) -> AsyncIterator[AsyncPostgresStore]
async
classmethod
¶
从连接字符串创建一个新的 AsyncPostgresStore 实例。
参数
-
conn_string
(
) –str Postgres 连接信息字符串。
返回值
-
AsyncPostgresStore
(
) –AsyncIterator [AsyncPostgresStore ]一个新的 AsyncPostgresStore 实例。
源代码位于 libs/checkpoint-postgres/langgraph/store/postgres/aio.py
setup() -> None
async
¶
异步设置存储数据库。
此方法在 Postgres 数据库中创建必要的表(如果尚未存在)并运行数据库迁移。它必须由用户在首次使用存储时直接调用。
源代码位于 libs/checkpoint-postgres/langgraph/store/postgres/aio.py
PostgresStore
¶
基类:
源代码位于 libs/checkpoint-postgres/langgraph/store/postgres/base.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
get(namespace: tuple[str, ...], key: str) -> Optional[Item]
¶
检索单个项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
返回值
-
–Optional [Item ]检索到的项目,如果未找到,则为 None。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
search(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
¶
在命名空间前缀内搜索项目。
参数
-
namespace_prefix
(
) –tuple [str , ...]要搜索的层次路径前缀。
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –用于过滤结果的键值对。
-
limit
(
, default:int 10
) –要返回的最大项目数。
-
offset
(
, default:int 0
) –在返回结果之前要跳过的项目数。
返回值
-
–list [Item ]与搜索条件匹配的项目列表。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
put(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
¶
存储或更新项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
-
value
(
) –dict [str ,Any ]包含项目数据的字典。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
delete(namespace: tuple[str, ...], key: str) -> None
¶
删除项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
list_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
¶
列出并过滤存储中的命名空间。
用于探索数据组织方式、查找特定集合或导航命名空间层次结构。
参数
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径开头的命名空间。
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径结尾的命名空间。
-
max_depth
(
, default:Optional [int ]None
) –返回层次结构中不超过此深度的命名空间。比此级别更深的命名空间将被截断到此深度。
-
limit
(
, default:int 100
) –要返回的最大命名空间数量(默认值为 100)。
-
offset
(
, default:int 0
) –要跳过的命名空间数量,用于分页(默认值为 0)。
返回值
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: 与条件匹配的命名空间元组列表。
-
–list [tuple [str , ...]]每个元组表示一个完整的命名空间路径,直到
max_depth
。
示例
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
store.list_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
aget(namespace: tuple[str, ...], key: str) -> Optional[Item]
async
¶
异步检索单个项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
返回值
-
–Optional [Item ]检索到的项目,如果未找到,则为 None。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
asearch(namespace_prefix: tuple[str, ...], /, *, filter: Optional[dict[str, Any]] = None, limit: int = 10, offset: int = 0) -> list[Item]
async
¶
异步在命名空间前缀内搜索项目。
参数
-
namespace_prefix
(
) –tuple [str , ...]要搜索的层次路径前缀。
-
filter
(
, default:Optional [dict [str ,Any ]]None
) –用于过滤结果的键值对。
-
limit
(
, default:int 10
) –要返回的最大项目数。
-
offset
(
, default:int 0
) –在返回结果之前要跳过的项目数。
返回值
-
–list [Item ]与搜索条件匹配的项目列表。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
aput(namespace: tuple[str, ...], key: str, value: dict[str, Any]) -> None
async
¶
异步存储或更新项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
-
value
(
) –dict [str ,Any ]包含项目数据的字典。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
adelete(namespace: tuple[str, ...], key: str) -> None
async
¶
异步删除项目。
参数
-
namespace
(
) –tuple [str , ...]项目的层次路径。
-
key
(
) –str 命名空间内的唯一标识符。
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
alist_namespaces(*, prefix: Optional[NameSpacePath] = None, suffix: Optional[NameSpacePath] = None, max_depth: Optional[int] = None, limit: int = 100, offset: int = 0) -> list[tuple[str, ...]]
async
¶
异步列出并过滤存储中的命名空间。
用于探索数据组织方式、查找特定集合或导航命名空间层次结构。
参数
-
prefix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径开头的命名空间。
-
suffix
(
, default:Optional [Tuple [str , ...]]None
) –过滤以该路径结尾的命名空间。
-
max_depth
(
, default:Optional [int ]None
) –返回层次结构中不超过此深度的命名空间。比此级别更深的命名空间将被截断到此深度。
-
limit
(
, default:int 100
) –要返回的最大命名空间数量(默认值为 100)。
-
offset
(
, default:int 0
) –要跳过的命名空间数量,用于分页(默认值为 0)。
返回值
-
–list [tuple [str , ...]]List[Tuple[str, ...]]: 与条件匹配的命名空间元组列表。
-
–list [tuple [str , ...]]每个元组表示一个完整的命名空间路径,直到
max_depth
。
示例
Setting max_depth=3. Given the namespaces:
# ("a", "b", "c")
# ("a", "b", "d", "e")
# ("a", "b", "d", "i")
# ("a", "b", "f")
# ("a", "c", "f")
await store.alist_namespaces(prefix=("a", "b"), max_depth=3)
# [("a", "b", "c"), ("a", "b", "d"), ("a", "b", "f")]
源代码位于 libs/checkpoint/langgraph/store/base/__init__.py
from_conn_string(conn_string: str) -> Iterator[PostgresStore]
classmethod
¶
从连接字符串创建一个新的 BasePostgresStore 实例。
参数
-
conn_string
(
) –str Postgres 连接信息字符串。
返回值
-
BasePostgresStore
(
) –Iterator [PostgresStore ]一个新的 BasePostgresStore 实例。
源代码位于 libs/checkpoint-postgres/langgraph/store/postgres/base.py
setup() -> None
¶
设置存储数据库。
此方法在 Postgres 数据库中创建必要的表(如果尚未存在)并运行数据库迁移。它必须由用户在首次使用存储时直接调用。