Vector_store

This module contains functionality related to the the vector_store module for embedding.vector_stores.pgvector.

Vector_store

PGVectorStoreFactory

Bases: SingletonFactory

Factory for creating configured PostgreSQL vector store clients.

This factory creates and manages a singleton instance of PGVectorStore for vector similarity search using the pgvector extension.

Source code in src/embedding/vector_stores/pgvector/vector_store.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class PGVectorStoreFactory(SingletonFactory):
    """Factory for creating configured PostgreSQL vector store clients.

    This factory creates and manages a singleton instance of PGVectorStore
    for vector similarity search using the pgvector extension.
    """

    _configuration_class: Type = PGVectorStoreConfiguration

    @classmethod
    def _create_instance(
        cls, configuration: PGVectorStoreConfiguration
    ) -> PGVectorStore:
        """Creates a PostgreSQL vector store client based on provided configuration.

        Args:
            configuration: PostgreSQL vector store connection configuration.

        Returns:
            PGVectorStore: Configured PostgreSQL vector store instance.
        """
        return PGVectorStore.from_params(
            database=configuration.database_name,
            host=configuration.host,
            password=configuration.secrets.password.get_secret_value(),
            port=configuration.port,
            user=configuration.secrets.username.get_secret_value(),
            table_name=configuration.collection_name,
            embed_dim=configuration.embed_dim,
        )