Skip to main content

upsertFromStorage

Inserts or updates vectors from a Storage Element.

upsertFromStorage(
storage: BabelStorage,
options?: {
keys?: string[]
metadata?: Record<string, any>
textSplitter?: SplitterParams
}
): Promise<string[]>

Reference

import { myVectorStore, myStorage } from "#elements";
export default async function () {
const count = await myVectorStore.upsertFromStorage(myStorage, {
keys: ["key1", "key2"],
});
console.log(`${count} vectors upserted`);
}

Parameters

  • storage: The Storage Element to extract content from.
  • options: Optional configuration parameters, including:
    • keys: (optional) An array of keys of the items to upsert. If not provided, all items in the storage will be upserted.
    • metadata: (optional) The metadata to associate with the vectors.
    • textSplitter: (optional) The text splitter employed to divide the content into multiple vectors. In the absence of a provided splitter, the token splitter is used by default.

Returns

Promise of an array of IDs of the upserted vectors.

Caveats

  • This method will insert a new vector if the key does not exist in the VectorStore, or update the existing vector if the key exists.
  • This method will only upsert items that are text files.
  • This method will only upsert items that are file size less than 128MB.
  • You can query all the results by filtering the metadata field storage to storage.