AstraDBByteStore
这将帮助你开始使用 Astra DB 键值存储。有关 AstraDBByteStore 所有功能和配置的详细文档,请前往 API 参考。
概述
DataStax Astra DB 是一个无服务器的、 面向 AI 的数据库,它构建在
Apache Cassandra®之上,并通过易于使用的 JSON API 方便地提供服务。
集成详情
| 类 | 包 | 本地 | JS 支持 | 包下载量 | 最新包 |
|---|---|---|---|---|---|
| AstraDBByteStore | langchain_astradb | ❌ | ❌ |
设置
要创建 AstraDBByteStore 字节存储,你需要创建一个 DataStax 账户。
凭据
注册后,设置以下凭据:
from getpass import getpass
ASTRA_DB_API_ENDPOINT = getpass("ASTRA_DB_API_ENDPOINT = ")
ASTRA_DB_APPLICATION_TOKEN = getpass("ASTRA_DB_APPLICATION_TOKEN = ")
安装
LangChain AstraDB 集成位于 langchain_astradb 包中:
%pip install -qU langchain_astradb
实例化
现在我们可以实例化我们的字节存储桶:
from langchain_astradb import AstraDBByteStore
kv_store = AstraDBByteStore(
api_endpoint=ASTRA_DB_API_ENDPOINT,
token=ASTRA_DB_APPLICATION_TOKEN,
collection_name="my_store",
)
API Reference:AstraDBByteStore
用法
你可以使用 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]
你可以将 AstraDBByteStore 用在任何你可以使用其他 ByteStores 的地方,包括作为 embeddings 的缓存。
API 参考
有关 AstraDBByteStore 所有功能和配置的详细文档,请访问 API 参考:https://python.langchain.com/api_reference/astradb/storage/langchain_astradb.storage.AstraDBByteStore.html
Related
- Key-value store conceptual guide