Skip to content

Commit b6e6ae5

Browse files
committed
Move dimensions into args
1 parent 4ac72c0 commit b6e6ae5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

libs/langchain-community/src/vectorstores/pgvector.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,16 @@ export class PGVectorStore extends VectorStore {
163163
* `connect` to return a new instance of `PGVectorStore`.
164164
*
165165
* @param embeddings - Embeddings instance.
166-
* @param fields - `PGVectorStoreArgs` instance.
167-
* @param dimensions Number of dimensions in your vector data type. For example, use 1536 for OpenAI's `text-embedding-3-small`. If not set, indexes like HNSW might not be used during query time.
166+
* @param fields - `PGVectorStoreArgs` instance
167+
* @param fields.dimensions Number of dimensions in your vector data type. For example, use 1536 for OpenAI's `text-embedding-3-small`. If not set, indexes like HNSW might not be used during query time.
168168
* @returns A new instance of `PGVectorStore`.
169169
*/
170170
static async initialize(
171171
embeddings: EmbeddingsInterface,
172-
config: PGVectorStoreArgs,
173-
dimensions?: number
172+
config: PGVectorStoreArgs & { dimensions?: number }
174173
): Promise<PGVectorStore> {
175-
const postgresqlVectorStore = new PGVectorStore(embeddings, config);
174+
const { dimensions, ...rest } = config;
175+
const postgresqlVectorStore = new PGVectorStore(embeddings, rest);
176176

177177
await postgresqlVectorStore._initializeClient();
178178
await postgresqlVectorStore.ensureTableInDatabase(dimensions);
@@ -638,7 +638,7 @@ export class PGVectorStore extends VectorStore {
638638
texts: string[],
639639
metadatas: object[] | object,
640640
embeddings: EmbeddingsInterface,
641-
dbConfig: PGVectorStoreArgs
641+
dbConfig: PGVectorStoreArgs & { dimensions?: number }
642642
): Promise<PGVectorStore> {
643643
const docs = [];
644644
for (let i = 0; i < texts.length; i += 1) {
@@ -665,7 +665,7 @@ export class PGVectorStore extends VectorStore {
665665
static async fromDocuments(
666666
docs: Document[],
667667
embeddings: EmbeddingsInterface,
668-
dbConfig: PGVectorStoreArgs
668+
dbConfig: PGVectorStoreArgs & { dimensions?: number }
669669
): Promise<PGVectorStore> {
670670
const instance = await PGVectorStore.initialize(embeddings, dbConfig);
671671
await instance.addDocuments(docs, { ids: dbConfig.ids });

0 commit comments

Comments
 (0)