抽象类
抽象方法
batch在单个批次中执行多个操作。这比单独执行操作更有效率。
要执行的操作数组
Promise 解析为与操作匹配的结果
列出和过滤存储中的命名空间。用于探索数据组织和导航命名空间层次结构。
可选
options: { 列出命名空间的选项
可选
limit?: number可选
max可选
offset?: number可选
prefix?: string[]可选
suffix?: string[]Promise 解析为命名空间路径列表
// List all namespaces under "documents"
await store.listNamespaces({
prefix: ["documents"],
maxDepth: 2
});
// List namespaces ending with "v1"
await store.listNamespaces({
suffix: ["v1"],
limit: 50
});
存储或更新一个项目。
项目的分层路径
命名空间内的唯一标识符
包含项目数据的对象
可选
index: false | string[]可选的索引配置
// Simple storage
await store.put(["docs"], "report", { title: "Annual Report" });
// With specific field indexing
await store.put(
["docs"],
"report",
{
title: "Q4 Report",
chapters: [{ content: "..." }, { content: "..." }]
},
["title", "chapters[*].content"]
);
在命名空间前缀内搜索项目。支持元数据过滤和向量相似度搜索。
要在其中搜索的分层路径前缀
可选
options: { 可选
options: { 用于过滤和分页的搜索选项
可选
filter?: Record<string, any>可选
limit?: number可选
offset?: number可选
query?: stringPromise 解析为带有相关性分数的匹配项目列表
// Search with filters
await store.search(["documents"], {
filter: { type: "report", status: "active" },
limit: 5,
offset: 10
});
// Vector similarity search
await store.search(["users", "content"], {
query: "technical documentation about APIs",
limit: 20
});
持久键值存储的抽象基类。
存储支持持久性和内存,这些持久性和内存可以在线程之间共享,并限定于用户 ID、助手 ID 或其他任意命名空间。
功能