Skip to content

Register PGVector class in the TypeScript SDK's VectorStoreFactory to enable pgvector support.#3801

Closed
zaiddkhan wants to merge 1 commit intomem0ai:mainfrom
zaiddkhan:fix/registered-pgvector-in-the-factory
Closed

Register PGVector class in the TypeScript SDK's VectorStoreFactory to enable pgvector support.#3801
zaiddkhan wants to merge 1 commit intomem0ai:mainfrom
zaiddkhan:fix/registered-pgvector-in-the-factory

Conversation

@zaiddkhan
Copy link
Copy Markdown

Description

Fixes #3782
Register PGVector class in the TypeScript SDK's VectorStoreFactory to enable pgvector support.

The PGVector class was already fully implemented in mem0-ts/src/oss/src/vector_stores/pgvector.ts but was never registered in the factory (mem0-ts/src/oss/src/utils/factory.ts), making it unusable despite being
documented.

Changes:

  • Added import for PGVector from ../vector_stores/pgvector
  • Added case "pgvector" in VectorStoreFactory.create() switch statement

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit Test
import { Memory } from "mem0ai/oss";

const memory = new Memory({
  vectorStore: {
    provider: "pgvector",
    config: {
      user: "postgres",
      password: "password",
      host: "localhost",
      port: 5432,
      embeddingModelDims: 1536,
    }
  },
  // ... other config
});

// Previously threw: Error: Unsupported vector store provider: pgvector
// Now initializes correctly

Checklist:

- My code follows the style guidelines of this project
- I have performed a self-review of my own code
- I have commented my code, particularly in hard-to-understand areas
- I have made corresponding changes to the documentation
- My changes generate no new warnings
- I have added tests that prove my fix is effective or that my feature works
- New and existing unit tests pass locally with my changes
- Any dependent changes have been merged and published in downstream modules
- I have checked my code and corrected any misspellings

Maintainer Checklist

- closes #xxxx (Replace xxxx with the GitHub issue number)
- Made sure Checks passed

@colinrgodsey
Copy link
Copy Markdown

seems PGVector also doesn't initialize itself 😅

diff --git a/mem0-ts/src/oss/src/vector_stores/pgvector.ts b/mem0-ts/src/oss/src/vector_stores/pgvector.ts
index 9c1b0034..96846d00 100644
--- a/mem0-ts/src/oss/src/vector_stores/pgvector.ts
+++ b/mem0-ts/src/oss/src/vector_stores/pgvector.ts
@@ -35,6 +35,11 @@ export class PGVector implements VectorStore {
       host: config.host,
       port: config.port,
     });
+
+    this.initialize().catch((err) => {
+      console.error("Failed to initialize PGVector:", err);
+      throw err;
+    });
   }
 
   async initialize(): Promise<void> {

@utkarsh240799
Copy link
Copy Markdown
Contributor

Closing in favor of #3997 which has been merged and includes the additional self-initialization fix. Thanks for the contribution @zaiddkhan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pgvector nor working for mem0ai/oss

3 participants