跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

Vectors

Vector store constructors now require an id property, and vector store methods have been renamed to follow consistent naming conventions.

Changed
Changed的直接链接

Required id property for vector store instances
required-id-property-for-vector-store-instances的直接链接

Vector store instances now require an id property. This unique identifier is used for tracking and managing vector store instances within Mastra. The id should be a descriptive, unique string for each vector store in your application.

To migrate, add an id field to your vector store constructor.

const vectorStore = new PgVector({
+ id: 'main-vector-store',
connectionString: process.env.POSTGRES_CONNECTION_STRING,
});

const chromaStore = new ChromaVector({
+ id: 'chroma-embeddings',
url: process.env.CHROMA_URL,
});

const pineconeStore = new PineconeVector({
+ id: 'pinecone-production',
apiKey: process.env.PINECONE_API_KEY,
});

getVectors to listVectors
getvectors-to-listvectors的直接链接

The getVectors() method has been renamed to listVectors(). This change aligns with the naming convention used across the API where plural getter methods use the list prefix.

To migrate, replace all calls to getVectors() with listVectors().

const vectorStore = new VectorStore({ ... });

- const vectors = await vectorStore.getVectors({ ... });
+ const vectors = await vectorStore.listVectors({ ... });

LibSQLVector: connectionUrl to url
libsqlvector-connectionurl-to-url的直接链接

The connectionUrl parameter has been renamed to url to align with the @libsql/client API and match LibSQLStorage.

const vectorStore = new LibSQLVector({
id: 'my-vector',
- connectionUrl: 'file:./db.sqlite',
+ url: 'file:./db.sqlite',
});

OpenSearchVector: url to node
opensearchvector-url-to-node的直接链接

The url parameter has been renamed to node to match the OpenSearch ClientOptions API. The constructor now accepts all OpenSearch client options including authentication, SSL, and compression.

const vectorStore = new OpenSearchVector({
id: 'my-vector',
- url: 'http://localhost:9200',
+ node: 'http://localhost:9200',
});

PineconeVector: environment removed
pineconevector-environment-removed的直接链接

The environment parameter has been removed. Use controllerHostUrl instead if you need to specify a custom controller host. The constructor now accepts all Pinecone configuration options.

const vectorStore = new PineconeVector({
id: 'my-vector',
apiKey: process.env.PINECONE_API_KEY,
- environment: process.env.PINECONE_ENVIRONMENT,
});

If you need a custom controller host:

const vectorStore = new PineconeVector({
id: 'my-vector',
apiKey: process.env.PINECONE_API_KEY,
controllerHostUrl: 'https://api.pinecone.io',
})