Node Details

  • Name: Postgres_VectorStores

  • Type: Postgres

  • Version: 6.0

  • Category: Vector Stores

Base Classes

  • Postgres

  • VectorStoreRetriever

  • BaseRetriever

Credential

  • Type: PostgresApi

  • Required Fields:

    • User

    • Password

Input Parameters

  1. Document (optional, list)

    • Type: Document

    • Description: List of documents to be stored in the vector store

  2. Embeddings

    • Type: Embeddings

    • Description: Embedding model to use for vectorizing documents

  3. Record Manager (optional)

    • Type: RecordManager

    • Description: Keeps track of records to prevent duplication

  4. Host

    • Type: string

    • Description: PostgreSQL server host

  5. Database

    • Type: string

    • Description: Name of the PostgreSQL database

  6. Port (optional)

    • Type: number

    • Default: 6432

    • Description: PostgreSQL server port

  7. Table Name (optional)

    • Type: string

    • Default: “documents”

    • Description: Name of the table to store vectors

  8. File Upload (optional)

    • Type: boolean

    • Description: Enables file upload functionality in the chat

  9. Additional Configuration (optional)

    • Type: JSON

    • Description: Additional PostgreSQL connection options

  10. Top K (optional)

    • Type: number

    • Default: 4

    • Description: Number of top results to fetch in similarity search

  11. Postgres Metadata Filter (optional)

    • Type: JSON

    • Description: Filter to apply on metadata during similarity search

Outputs

  1. Postgres Retriever

    • Type: VectorStoreRetriever

    • Description: A retriever object for similarity search operations

  2. Postgres Vector Store

    • Type: TypeORMVectorStore

    • Description: The vector store object for direct interactions

Functionality

Initialization

  • Establishes a connection to the PostgreSQL database

  • Sets up the vector store with the specified table and embeddings

  • Configures similarity search function to use pg pool for better performance

Upsert Method

  • Allows adding new documents to the vector store

  • Handles file upload scenarios by adding chat ID to metadata

  • Supports using a record manager to prevent duplicates

Delete Method

  • Enables deletion of documents from the vector store

  • Supports deletion using record manager or direct ID-based deletion

  • Performs similarity search on stored vectors

  • Applies metadata filters if specified

  • Returns top K results based on cosine similarity

Use Cases

  • Document storage and retrieval in AI-powered applications

  • Semantic search functionality in large document collections

  • Building knowledge bases for question-answering systems

Notes

  • Requires PostgreSQL with pgvector extension installed

  • Optimized for performance with connection pooling

  • Supports additional configuration for fine-tuning PostgreSQL connection

  • Integrates with file upload functionality for chat-based document ingestion