class TensorFlowEmbeddingsClass that extends the Embeddings class and provides methods for generating embeddings using the Universal Sentence Encoder model from TensorFlow.js.
The async caller should be used by subclasses to make any async calls, which will thus benefit from the concurrency and retry logic.
Method to generate embeddings for an array of documents. Splits the documents into batches and makes requests to the AlibabaTongyi API to generate embeddings.
Method to generate an embedding for a single document. Calls the embeddingWithRetry method with the document as the input.
const embeddings = new TensorFlowEmbeddings();
const store = new MemoryVectorStore(embeddings);
const documents = [
"A document",
"Some other piece of text",
"One more",
"And another",
];
await store.addDocuments(
documents.map((pageContent) => new Document({ pageContent }))
);