Skip to main content
Open In Colab在 GitHub 上打开

InMemoryByteStore 中

本指南将帮助您开始使用内存中的键值存储。有关所有InMemoryByteStore功能和配置可参考 API 参考

概述

InMemoryByteStoreByteStore将所有内容存储在 Python 字典中。它适用于演示和不需要在 Python 进程生命周期之后保持持久性的情况。

集成详细信息

本地化JS 支持软件包下载最新包装
InMemoryByteStorelangchain_corePyPI - DownloadsPyPI - Version

安装

The LangChainInMemoryByteStore集成位于langchain_core包:

%pip install -qU langchain_core

实例

现在你可以实例化你的字节存储了:

from langchain_core.stores import InMemoryByteStore

kv_store = InMemoryByteStore()
API 参考:InMemoryByteStore

用法

您可以使用mset方法:

kv_store.mset(
[
["key1", b"value1"],
["key2", b"value2"],
]
)

kv_store.mget(
[
"key1",
"key2",
]
)
[b'value1', b'value2']

您可以使用mdelete方法:

kv_store.mdelete(
[
"key1",
"key2",
]
)

kv_store.mget(
[
"key1",
"key2",
]
)
[None, None]

API 参考

有关所有InMemoryByteStore功能和配置,请前往 API 参考:https://python.langchain.com/api_reference/core/stores/langchain_core.stores.InMemoryByteStore.html