Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to specify custom table schema #138

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

anupkg1985
Copy link

@anupkg1985 anupkg1985 commented Nov 10, 2024

Current LangChain-Postgres framework, the database table name is hardcoded and defaults to the public schema due to the absence of a specified schema name. This limitation affects the flexibility of the PGVector connector, restricting its ability to dynamically configure during runtime. This poses significant challenges in multi-tenant architectures, where it's essential for different clients or projects to operate within separate schemas to ensure data isolation and management efficiency. Addressing this issue would involve enabling schema specification, thereby enhancing the connector's versatility and making it more suitable for diverse deployment scenarios.

Proposed solution -

  • Introduced new argument/ parameter table_schema to `PGVector' class
  • This new parameter is optional and defaulted to public schema

Discussions related to issue -
langchain-ai/langchain#20877
langchain-ai/langchain#18883

Example usage -

Default publicschema -

connection = "postgresql+psycopg://langchain:langchain@localhost:6024/langchain" 
collection_name = "my_docs"
embeddings = CohereEmbeddings()

vectorstore = PGVector(
    embeddings=embeddings,
    collection_name=collection_name,
    connection=connection,
    use_jsonb=True,
)

Specify custom table-schema -

connection = "postgresql+psycopg://langchain:langchain@localhost:6024/langchain" 
collection_name = "my_docs"
embeddings = CohereEmbeddings()

vectorstore = PGVector(
    embeddings=embeddings,
    collection_name=collection_name,
    connection=connection,
    use_jsonb=True,
    table_schema="custom"
)

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.

1 participant