UNPKG

@langchain/community

Version:
1 lines • 2.57 kB
{"version":3,"file":"tensorflow.d.cts","names":["load","Embeddings","EmbeddingsParams","TensorFlowEmbeddingsParams","TensorFlowEmbeddings","ReturnType","Promise"],"sources":["../../src/embeddings/tensorflow.d.ts"],"sourcesContent":["import { load } from \"@tensorflow-models/universal-sentence-encoder\";\nimport { Embeddings, type EmbeddingsParams } from \"@langchain/core/embeddings\";\n/**\n * Interface that extends EmbeddingsParams and defines additional\n * parameters specific to the TensorFlowEmbeddings class.\n */\nexport interface TensorFlowEmbeddingsParams extends EmbeddingsParams {\n}\n/**\n * Class that extends the Embeddings class and provides methods for\n * generating embeddings using the Universal Sentence Encoder model from\n * TensorFlow.js.\n * @example\n * ```typescript\n * const embeddings = new TensorFlowEmbeddings();\n * const store = new MemoryVectorStore(embeddings);\n *\n * const documents = [\n * \"A document\",\n * \"Some other piece of text\",\n * \"One more\",\n * \"And another\",\n * ];\n *\n * await store.addDocuments(\n * documents.map((pageContent) => new Document({ pageContent }))\n * );\n * ```\n */\nexport declare class TensorFlowEmbeddings extends Embeddings {\n constructor(fields?: TensorFlowEmbeddingsParams);\n _cached: ReturnType<typeof load>;\n private load;\n private _embed;\n /**\n * Method that takes a document as input and returns a promise that\n * resolves to an embedding for the document. It calls the _embed method\n * with the document as the input and processes the result to return a\n * single embedding.\n * @param document Document to generate an embedding for.\n * @returns Promise that resolves to an embedding for the input document.\n */\n embedQuery(document: string): Promise<number[]>;\n /**\n * Method that takes an array of documents as input and returns a promise\n * that resolves to a 2D array of embeddings for each document. It calls\n * the _embed method with the documents as the input and processes the\n * result to return the embeddings.\n * @param documents Array of documents to generate embeddings for.\n * @returns Promise that resolves to a 2D array of embeddings for each input document.\n */\n embedDocuments(documents: string[]): Promise<number[][]>;\n}\n//# sourceMappingURL=tensorflow.d.ts.map"],"mappings":";;;;;;;AAMA;AAuBA;AACyBG,UAxBRA,0BAAAA,SAAmCD,gBAwB3BC,CAAAA;;;;;AADmC;;;;;;;;;;;;;;;;;cAAvCC,oBAAAA,SAA6BH,UAAAA;uBACzBE;WACZE,kBAAkBL;;;;;;;;;;;gCAWGM;;;;;;;;;uCASOA"}