translation/translated/documents/course/03-agent-memory/13-vector-store-configurati...

30 lines
926 B
Markdown
Raw Permalink Normal View History

# 向量存储配置
除了记忆存储适配器外Mastra 还提供向量存储适配器,用于存储和检索向量嵌入。其中之一是 `LibSQLVector` 适配器,它为在 LibSQL 向量数据库中存储和检索向量嵌入提供简单的接口。
```typescript
import { Memory } from "@mastra/memory";
import { LibSQLStore, LibSQLVector } from "@mastra/libsql";
const memory = new Memory({
storage: new LibSQLStore({
id: "learning-memory-storage",
url: "file:../../memory.db", // 相对于 `.mastra/output` 目录的相对路径
}),
vector: new LibSQLVector({
id: "learning-memory-vector",
connectionUrl: "file:../../vector.db", // 相对于 `.mastra/output` 目录的相对路径
}),
});
```
Mastra 支持多种向量存储选项,包括:
- LibSQL
- Chroma
- Pinecone
- Qdrant
- Postgres使用 pgvector
向量存储负责存储和检索用于语义搜索的向量嵌入。