
    3fi-                        d dl mZ d dlmZmZmZmZmZ d dlm	Z	 d dl
mZ d dlmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZmZmZ  G d de      Zy)    )annotations)AnyCallableIterableOptionalSequence)Document)
Embeddings)VectorStore   )AsyncPGVectorStore)PGEngine)HybridSearchConfig)DEFAULT_DISTANCE_STRATEGY	BaseIndexDistanceStrategyQueryOptionsc                     e Zd ZdZ e       Zd7dZeddddddded	d
dddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d8d       Z	eddddddded	d
dddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d9d       Z
ed:d       Z	 	 d;	 	 	 	 	 	 	 	 	 	 	 d<dZ	 	 d;	 	 	 	 	 	 	 	 	 d=dZ	 d>	 	 	 	 	 	 	 d?dZ	 	 d;	 	 	 	 	 	 	 	 	 	 	 d<dZ	 	 d;	 	 	 	 	 	 	 	 	 d=dZ	 d>	 	 	 	 	 	 	 d?dZ	 d>	 	 	 	 	 d@dZ	 d>	 	 	 	 	 d@dZeddddddddded	d
dddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dAd       Zedddddddded	d
dddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dBd       Zeddddddddded	d
dddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dAd       Zedddddddded	d
dddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dBd       Z	 	 d;	 	 	 	 	 	 	 	 	 dCdZ	 	 d;	 	 	 	 	 	 	 	 	 dCdZdDdZ	 	 d;	 	 	 	 	 	 	 	 	 dEdZ	 	 d;	 	 	 	 	 	 	 	 	 dFdZ	 	 d;	 	 	 	 	 	 	 	 	 dGd Z	 	 	 	 dH	 	 	 	 	 	 	 	 	 	 	 	 	 dId!Z	 	 	 	 dH	 	 	 	 	 	 	 	 	 	 	 	 	 dJd"Z 	 	 	 	 dH	 	 	 	 	 	 	 	 	 	 	 	 	 dKd#Z!	 	 d;	 	 	 	 	 	 	 	 	 dEd$Z"	 	 d;	 	 	 	 	 	 	 	 	 dFd%Z#	 	 d;	 	 	 	 	 	 	 	 	 dGd&Z$	 	 	 	 dH	 	 	 	 	 	 	 	 	 	 	 	 	 dId'Z%	 	 	 	 dH	 	 	 	 	 	 	 	 	 	 	 	 	 dJd(Z&	 	 	 	 dH	 	 	 	 	 	 	 	 	 	 	 	 	 dKd)Z'	 dL	 	 	 dMd*Z(	 dL	 	 	 dMd+Z)	 	 dN	 	 	 	 	 	 	 dOd,Z*	 	 dN	 	 	 	 	 	 	 dOd-Z+d>dPd.Z,d>dPd/Z-	 d>	 	 	 dPd0Z.	 d>	 	 	 dPd1Z/	 d>	 	 	 dQd2Z0	 d>	 	 	 dQd3Z1dRd4Z2dRd5Z3dSd6Z4y)TPGVectorStorezPostgres Vector Store classc                \    |t         j                  k7  rt        d      || _        || _        y)af  PGVectorStore constructor.
        Args:
            key (object): Prevent direct constructor usage.
            engine (PGEngine): Connection pool engine for managing connections to Postgres database.
            vs (AsyncPGVectorStore): The async only VectorStore implementation


        Raises:
            Exception: If called directly by user.
        z<Only create class through 'create' or 'create_sync' methods!N)r   _PGVectorStore__create_key	Exception_engine_PGVectorStore__vs)selfkeyenginevss       `/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_postgres/v2/vectorstores.py__init__zPGVectorStore.__init__   s2     -,,,N  	    publiccontent	embeddingNlangchain_idlangchain_metadata      g      ?c                   K   t        j                  |||||||||
|	||||||      }|j                  |       d{   } | | j                  ||      S 7 w)a  Create an PGVectorStore instance.

        Args:
            engine (PGEngine): Connection pool engine for managing connections to postgres database.
            embedding_service (Embeddings): Text embedding model to use.
            table_name (str): Name of an existing table.
            schema_name (str, optional): Name of the database schema. Defaults to "public".
            content_column (str): Column that represent a Document's page_content. Defaults to "content".
            embedding_column (str): Column for embedding vectors. The embedding is generated from the document value. Defaults to "embedding".
            metadata_columns (list[str]): Column(s) that represent a document's metadata.
            ignore_metadata_columns (list[str]): Column(s) to ignore in pre-existing tables for a document's metadata. Can not be used with metadata_columns. Defaults to None.
            id_column (str): Column that represents the Document's id. Defaults to "langchain_id".
            metadata_json_column (str): Column to store metadata as JSON. Defaults to "langchain_metadata".
            distance_strategy (DistanceStrategy): Distance strategy to use for vector similarity search. Defaults to COSINE_DISTANCE.
            k (int): Number of Documents to return from search. Defaults to 4.
            fetch_k (int): Number of Documents to fetch to pass to MMR algorithm.
            lambda_mult (float): Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5.
            index_query_options (QueryOptions): Index query option.
            hybrid_search_config (HybridSearchConfig): Hybrid search configuration. Defaults to None.

        Returns:
            PGVectorStore
        schema_namecontent_columnembedding_columnmetadata_columnsignore_metadata_columnsmetadata_json_column	id_columndistance_strategykfetch_klambda_multindex_query_optionshybrid_search_configN)r   create_run_as_asyncr   clsr   embedding_service
table_namer+   r,   r-   r.   r/   r1   r0   r2   r3   r4   r5   r6   r7   coror   s                      r   r8   zPGVectorStore.create-   sx     V "((#)--$;!5/# 3!5!
$ ''--3##VR00 .s   :AAAc                    t        j                  |||||||||
|	||||||      }|j                  |      } | | j                  ||      S )a  Create an PGVectorStore instance.

        Args:
            key (object): Prevent direct constructor usage.
            engine (PGEngine): Connection pool engine for managing connections to postgres database.
            embedding_service (Embeddings): Text embedding model to use.
            table_name (str): Name of an existing table.
            schema_name (str, optional): Name of the database schema. Defaults to "public".
            content_column (str, optional): Column that represent a Document's page_content. Defaults to "content".
            embedding_column (str, optional): Column for embedding vectors. The embedding is generated from the document value. Defaults to "embedding".
            metadata_columns (list[str], optional): Column(s) that represent a document's metadata. Defaults to None.
            ignore_metadata_columns (Optional[list[str]]): Column(s) to ignore in pre-existing tables for a document's metadata. Can not be used with metadata_columns. Defaults to None.
            id_column (str, optional): Column that represents the Document's id. Defaults to "langchain_id".
            metadata_json_column (str, optional): Column to store metadata as JSON. Defaults to "langchain_metadata".
            distance_strategy (DistanceStrategy, optional): Distance strategy to use for vector similarity search. Defaults to COSINE_DISTANCE.
            k (int, optional): Number of Documents to return from search. Defaults to 4.
            fetch_k (int, optional): Number of Documents to fetch to pass to MMR algorithm. Defaults to 20.
            lambda_mult (float, optional): Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5.
            index_query_options (Optional[QueryOptions], optional): Index query option. Defaults to None.
            hybrid_search_config (HybridSearchConfig): Hybrid search configuration. Defaults to None.

        Returns:
            PGVectorStore
        r*   )r   r8   _run_as_syncr   r:   s                      r   create_synczPGVectorStore.create_syncm   sl    X "((#)--$;!5/# 3!5!
$   &3##VR00r!   c                .    | j                   j                  S N)r   r<   r   s    r   
embeddingszPGVectorStore.embeddings   s    yy***r!   c                   K   | j                   j                   | j                  j                  ||||fi |       d{   S 7 w),Add data along with embeddings to the table.N)r   r9   r   aadd_embeddingsr   textsrE   	metadatasidskwargss         r   rH   zPGVectorStore.aadd_embeddings   sH      \\//%DII%%eZCR6R
 
 	
 
s   =AA Ac                   K   | j                   j                   | j                  j                  |||fi |       d{   S 7 w)Embed texts and add to the table.

        Raises:
            :class:`InvalidTextRepresentationError <asyncpg.exceptions.InvalidTextRepresentationError>`: if the `ids` data type does not match that of the `id_column`.
        N)r   r9   r   
aadd_textsr   rJ   rK   rL   rM   s        r   rP   zPGVectorStore.aadd_texts   sF      \\// DII  	3A&A
 
 	
 
   <AAAc                   K   | j                   j                   | j                  j                  ||fi |       d{   S 7 w)Embed documents and add to the table.

        Raises:
            :class:`InvalidTextRepresentationError <asyncpg.exceptions.InvalidTextRepresentationError>`: if the `ids` data type does not match that of the `id_column`.
        N)r   r9   r   aadd_documentsr   	documentsrL   rM   s       r   rU   zPGVectorStore.aadd_documents   sD      \\//$DII$$Y>v>
 
 	
 
   ;AAAc                t    | j                   j                   | j                  j                  ||||fi |      S )rG   )r   r@   r   rH   rI   s         r   add_embeddingszPGVectorStore.add_embeddings   s:     ||((%DII%%eZCR6R
 	
r!   c                r    | j                   j                   | j                  j                  |||fi |      S )rO   )r   r@   r   rP   rQ   s        r   	add_textszPGVectorStore.add_texts   s8     ||(( DII  	3A&A
 	
r!   c                p    | j                   j                   | j                  j                  ||fi |      S )rT   )r   r@   r   rU   rV   s       r   add_documentszPGVectorStore.add_documents   s6     ||(($DII$$Y>v>
 	
r!   c                   K   | j                   j                   | j                  j                  |fi |       d{   S 7 w)Delete records from the table.

        Raises:
            :class:`InvalidTextRepresentationError <asyncpg.exceptions.InvalidTextRepresentationError>`: if the `ids` data type does not match that of the `id_column`.
        N)r   r9   r   adeleter   rL   rM   s      r   ra   zPGVectorStore.adelete
  s:      \\//0A		0A0A#0P0PQQQQs   :AAAc                n    | j                   j                   | j                  j                  |fi |      S )r`   )r   r@   r   ra   rb   s      r   deletezPGVectorStore.delete  s0     ||(():):):3)I&)IJJr!   c                   K   | j                  ||||||	|
|||||||||       d{   }|j                  |||       d{    |S 7 "7 w)aA	  Create an PGVectorStore instance from texts.

        Args:
            texts (list[str]): Texts to add to the vector store.
            embedding (Embeddings): Text embedding model to use.
            engine (PGEngine): Connection pool engine for managing connections to postgres database.
            table_name (str): Name of an existing table.
            schema_name (str, optional): Name of the database schema. Defaults to "public".
            metadatas (Optional[list[dict]], optional): List of metadatas to add to table records. Defaults to None.
            ids: (Optional[list]): List of IDs to add to table records. Defaults to None.
            content_column (str, optional): Column that represent a Document's page_content. Defaults to "content".
            embedding_column (str, optional): Column for embedding vectors. The embedding is generated from the document value. Defaults to "embedding".
            metadata_columns (list[str], optional): Column(s) that represent a document's metadata. Defaults to an empty list.
            ignore_metadata_columns (Optional[list[str]], optional): Column(s) to ignore in pre-existing tables for a document's metadata. Can not be used with metadata_columns. Defaults to None.
            id_column (str, optional): Column that represents the Document's id. Defaults to "langchain_id".
            metadata_json_column (str, optional): Column to store metadata as JSON. Defaults to "langchain_metadata".
            distance_strategy (DistanceStrategy): Distance strategy to use for vector similarity search. Defaults to COSINE_DISTANCE.
            k (int): Number of Documents to return from search. Defaults to 4.
            fetch_k (int): Number of Documents to fetch to pass to MMR algorithm.
            lambda_mult (float): Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5.
            index_query_options (QueryOptions): Index query option.
            hybrid_search_config (HybridSearchConfig): Hybrid search configuration. Defaults to None.

        Raises:
            :class:`InvalidTextRepresentationError <asyncpg.exceptions.InvalidTextRepresentationError>`: if the `ids` data type does not match that of the `id_column`.

        Returns:
            PGVectorStore
        r*   NrK   rL   )r8   rP   r;   rJ   r$   r   r=   r+   rK   rL   r,   r-   r.   r/   r1   r0   r2   r3   r4   r5   r6   r7   rM   r   s                         r   afrom_textszPGVectorStore.afrom_texts"  s|     j ::#)--$;!5/# 3!5!  
 
$ mmEYCm@@@	'
$ 	As!   %AA
AAAAc                   K   | j                  |||||||	|
||||||||       d{   }|j                  ||       d{    |S 7 !7 w)  Create an PGVectorStore instance from documents.

        Args:
            documents (list[Document]): Documents to add to the vector store.
            embedding (Embeddings): Text embedding model to use.
            engine (PGEngine): Connection pool engine for managing connections to postgres database.
            table_name (str): Name of an existing table.
            schema_name (str, optional): Name of the database schema. Defaults to "public".
            ids: (Optional[list]): List of IDs to add to table records. Defaults to None.
            content_column (str, optional): Column that represent a Document's page_content. Defaults to "content".
            embedding_column (str, optional): Column for embedding vectors. The embedding is generated from the document value. Defaults to "embedding".
            metadata_columns (list[str], optional): Column(s) that represent a document's metadata. Defaults to an empty list.
            ignore_metadata_columns (Optional[list[str]], optional): Column(s) to ignore in pre-existing tables for a document's metadata. Can not be used with metadata_columns. Defaults to None.
            id_column (str, optional): Column that represents the Document's id. Defaults to "langchain_id".
            metadata_json_column (str, optional): Column to store metadata as JSON. Defaults to "langchain_metadata".
            distance_strategy (DistanceStrategy): Distance strategy to use for vector similarity search. Defaults to COSINE_DISTANCE.
            k (int): Number of Documents to return from search. Defaults to 4.
            fetch_k (int): Number of Documents to fetch to pass to MMR algorithm.
            lambda_mult (float): Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5.
            index_query_options (QueryOptions): Index query option.
            hybrid_search_config (HybridSearchConfig): Hybrid search configuration. Defaults to None.

        Raises:
            :class:`InvalidTextRepresentationError <asyncpg.exceptions.InvalidTextRepresentationError>`: if the `ids` data type does not match that of the `id_column`.

        Returns:
            PGVectorStore
        r*   NrL   )r8   rU   r;   rW   r$   r   r=   r+   rL   r,   r-   r.   r/   r1   r0   r2   r3   r4   r5   r6   r7   rM   r   s                        r   afrom_documentszPGVectorStore.afrom_documentsl  s|     h ::#)--$;!5/# 3!5!  
 
$ 	s333	'
$ 	4s!   %AA	AAAAc                t     | j                   |||f|||	|
|||||||||d|}|j                  |||       |S )a>	  Create an PGVectorStore instance from texts.

        Args:
            texts (list[str]): Texts to add to the vector store.
            embedding (Embeddings): Text embedding model to use.
            engine (PGEngine): Connection pool engine for managing connections to postgres database.
            table_name (str): Name of an existing table.
            schema_name (str, optional): Name of the database schema. Defaults to "public".
            metadatas (Optional[list[dict]], optional): List of metadatas to add to table records. Defaults to None.
            ids: (Optional[list]): List of IDs to add to table records. Defaults to None.
            content_column (str, optional): Column that represent a Document's page_content. Defaults to "content".
            embedding_column (str, optional): Column for embedding vectors. The embedding is generated from the document value. Defaults to "embedding".
            metadata_columns (list[str], optional): Column(s) that represent a document's metadata. Defaults to empty list.
            ignore_metadata_columns (Optional[list[str]], optional): Column(s) to ignore in pre-existing tables for a document's metadata. Can not be used with metadata_columns. Defaults to None.
            id_column (str, optional): Column that represents the Document's id. Defaults to "langchain_id".
            metadata_json_column (str, optional): Column to store metadata as JSON. Defaults to "langchain_metadata".
            distance_strategy (DistanceStrategy): Distance strategy to use for vector similarity search. Defaults to COSINE_DISTANCE.
            k (int): Number of Documents to return from search. Defaults to 4.
            fetch_k (int): Number of Documents to fetch to pass to MMR algorithm.
            lambda_mult (float): Number between 0 and 1 that determines the degree of diversity among the results with 0 corresponding to maximum diversity and 1 to minimum diversity. Defaults to 0.5.
            index_query_options (QueryOptions): Index query option.
            hybrid_search_config (HybridSearchConfig): Hybrid search configuration. Defaults to None.

        Raises:
            :class:`InvalidTextRepresentationError <asyncpg.exceptions.InvalidTextRepresentationError>`: if the `ids` data type does not match that of the `id_column`.

        Returns:
            PGVectorStore
        r*   rf   )rA   r\   rg   s                         r   
from_textszPGVectorStore.from_texts  so    j S__
 $)--$;!5/# 3!5!
" #
& 	UiS9	r!   c                r     | j                   |||f||||	|
||||||||d|}|j                  ||       |S )rj   r*   rk   )rA   r^   rl   s                        r   from_documentszPGVectorStore.from_documents   sp    f S__
 $)--$;!5/# 3!5!
" #
& 	,	r!   c                r    | j                   j                   | j                  j                  |||fi |      S )3Return docs selected by similarity search on query.)r   r@   r   asimilarity_searchr   queryr3   filterrM   s        r   similarity_searchzPGVectorStore.similarity_searchI  s8     ||(((DII((6DVD
 	
r!   c                   K   | j                   j                   | j                  j                  |||fi |       d{   S 7 w)rs   N)r   r9   r   rt   ru   s        r   rt   z PGVectorStore.asimilarity_searchU  sF      \\//(DII((6DVD
 
 	
 
rR   c                6   | j                   j                  t        j                  k(  r| j                  S | j                   j                  t        j
                  k(  r| j                  S | j                   j                  t        j                  k(  r| j                  S y)z7Select a relevance function based on distance strategy.N)	r   r2   r   COSINE_DISTANCE_cosine_relevance_score_fnINNER_PRODUCT%_max_inner_product_relevance_score_fn	EUCLIDEAN_euclidean_relevance_score_fnrD   s    r   _select_relevance_score_fnz(PGVectorStore._select_relevance_score_fnb  sy     99&&*:*J*JJ22299&&*:*H*HH===YY((,<,F,FF555 Gr!   c                   K   | j                   j                   | j                  j                  |||fi |       d{   S 7 w)GReturn docs and distance scores selected by similarity search on query.N)r   r9   r   asimilarity_search_with_scoreru   s        r   r   z+PGVectorStore.asimilarity_search_with_scorel  sF      \\//3DII33E1fOO
 
 	
 
rR   c                   K   | j                   j                   | j                  j                  |||fi |       d{   S 7 w)1Return docs selected by vector similarity search.N)r   r9   r   asimilarity_search_by_vectorr   r$   r3   rw   rM   s        r   r   z*PGVectorStore.asimilarity_search_by_vectorx  sF      \\//2DII229aR6R
 
 	
 
rR   c                   K   | j                   j                   | j                  j                  |||fi |       d{   S 7 w)zEReturn docs and distance scores selected by vector similarity search.N)r   r9   r   'asimilarity_search_with_score_by_vectorr   s        r   r   z5PGVectorStore.asimilarity_search_with_score_by_vector  sL      \\//=DII==1f(.
 
 	
 
rR   c           	        K   | j                   j                   | j                  j                  |||||fi |       d{   S 7 w:Return docs selected using the maximal marginal relevance.N)r   r9   r   amax_marginal_relevance_searchr   rv   r3   r4   r5   rw   rM   s          r   r   z,PGVectorStore.amax_marginal_relevance_search  sP      \\//4DII44q';:@
 
 	
 
   >A AAc           	        K   | j                   j                   | j                  j                  |||||fi |       d{   S 7 wr   )r   r9   r   (amax_marginal_relevance_search_by_vectorr   r$   r3   r4   r5   rw   rM   s          r   r   z6PGVectorStore.amax_marginal_relevance_search_by_vector  sP      \\//>DII>>1g{F>D
 
 	
 
r   c           	        K   | j                   j                   | j                  j                  |||||fi |       d{   S 7 w)NReturn docs and distance scores selected using the maximal marginal relevance.N)r   r9   r   3amax_marginal_relevance_search_with_score_by_vectorr   s          r   r   zAPGVectorStore.amax_marginal_relevance_search_with_score_by_vector  sP      \\//IDIIII1g{F>D
 
 	
 
r   c                r    | j                   j                   | j                  j                  |||fi |      S )r   )r   r@   r   r   ru   s        r   similarity_search_with_scorez*PGVectorStore.similarity_search_with_score  s8     ||((3DII33E1fOO
 	
r!   c                r    | j                   j                   | j                  j                  |||fi |      S )r   )r   r@   r   r   r   s        r   similarity_search_by_vectorz)PGVectorStore.similarity_search_by_vector  s8     ||((2DII229aR6R
 	
r!   c                r    | j                   j                   | j                  j                  |||fi |      S )zHReturn docs and distance scores selected by similarity search on vector.)r   r@   r   r   r   s        r   &similarity_search_with_score_by_vectorz4PGVectorStore.similarity_search_with_score_by_vector  s>     ||((=DII==1f(.
 	
r!   c           	     v    | j                   j                   | j                  j                  |||||fi |      S r   )r   r@   r   r   r   s          r   max_marginal_relevance_searchz+PGVectorStore.max_marginal_relevance_search  sB     ||((4DII44q';:@
 	
r!   c           	     v    | j                   j                   | j                  j                  |||||fi |      S r   )r   r@   r   r   r   s          r   'max_marginal_relevance_search_by_vectorz5PGVectorStore.max_marginal_relevance_search_by_vector  sB     ||((>DII>>1g{F>D
 	
r!   c           	     v    | j                   j                   | j                  j                  |||||fi |      S )r   )r   r@   r   r   r   s          r   2max_marginal_relevance_search_with_score_by_vectorz@PGVectorStore.max_marginal_relevance_search_with_score_by_vector  sB     ||((IDIIII1g{F>D
 	
r!   c                   K   | j                   j                  | j                  j                  |             d{   S 7 w):Creates a TSV index in the vector store table if possible.concurrentlyN)r   r9   r   aapply_hybrid_search_indexr   r   s     r   r   z(PGVectorStore.aapply_hybrid_search_index  s>     
 \\//II00l0K
 
 	
 
   9AA Ac                l    | j                   j                  | j                  j                  |            S )r   r   )r   r@   r   r   r   s     r   apply_hybrid_search_indexz'PGVectorStore.apply_hybrid_search_index!  s0    
 ||((II00l0K
 	
r!   c                   K   | j                   j                  | j                  j                  |||             d{   S 7 w)*Create an index on the vector store table.r   N)r   r9   r   aapply_vector_indexr   indexnamer   s       r   r   z!PGVectorStore.aapply_vector_index*  sB      \\//II))%L)Q
 
 	
 
rX   c                p    | j                   j                  | j                  j                  |||            S )r   r   )r   r@   r   r   r   s       r   apply_vector_indexz PGVectorStore.apply_vector_index5  s4     ||((II))%L)Q
 	
r!   c                   K   | j                   j                  | j                  j                  |             d{   S 7 w) Re-index the vector store table.N)r   r9   r   areindexr   
index_names     r   r   zPGVectorStore.areindex@  s0     \\//		0B0B:0NOOOO   8A?Ac                j    | j                   j                  | j                  j                  |            S )r   )r   r@   r   r   r   s     r   reindexzPGVectorStore.reindexD  s&    ||((););J)GHHr!   c                   K   | j                   j                  | j                  j                  |             d{   S 7 w)Drop the vector index.N)r   r9   r   adrop_vector_indexr   s     r   r   z PGVectorStore.adrop_vector_indexH  s;     
 \\//II((4
 
 	
 
r   c                j    | j                   j                  | j                  j                  |            S )r   )r   r@   r   r   r   s     r   drop_vector_indexzPGVectorStore.drop_vector_indexQ  s(    
 ||(()E)Ej)QRRr!   c                   K   | j                   j                  | j                  j                  |             d{   S 7 w)#Check if index exists in the table.N)r   r9   r   is_valid_indexr   s     r   ais_valid_indexzPGVectorStore.ais_valid_indexX  s2     
 \\//		0H0H0TUUUUr   c                j    | j                   j                  | j                  j                  |            S )r   )r   r@   r   r   r   s     r   r   zPGVectorStore.is_valid_index_  s(    
 ||(()A)A*)MNNr!   c                   K   | j                   j                  | j                  j                  |             d{   S 7 w)Get documents by ids.rk   N)r   r9   r   aget_by_idsr   rL   s     r   r   zPGVectorStore.aget_by_idsf  s3     \\//		0E0E#0E0NOOOOr   c                l    | j                   j                  | j                  j                  |            S )r   rk   )r   r@   r   r   r   s     r   
get_by_idszPGVectorStore.get_by_idsj  s)    ||(()>)>3)>)GHHr!   c                .    | j                   j                  S rC   )r   r=   rD   s    r   get_table_namezPGVectorStore.get_table_namen  s    yy###r!   )r   objectr   r   r   r   )$r;   type[PGVectorStore]r   r   r<   r
   r=   strr+   r   r,   r   r-   r   r.   Optional[list[str]]r/   r   r1   r   r0   Optional[str]r2   r   r3   intr4   r   r5   floatr6   Optional[QueryOptions]r7   Optional[HybridSearchConfig]returnr   )"r   r   r<   r
   r=   r   r+   r   r,   r   r-   r   r.   r   r/   r   r1   r   r0   r   r2   r   r3   r   r4   r   r5   r   r6   r   r7   r   r   r   )r   r
   )NN)rJ   Iterable[str]rE   zlist[list[float]]rK   Optional[list[dict]]rL   r   rM   r   r   	list[str])
rJ   r   rK   r   rL   Optional[list]rM   r   r   r   rC   )rW   list[Document]rL   r   rM   r   r   r   )rL   r   rM   r   r   zOptional[bool]),r;   r   rJ   r   r$   r
   r   r   r=   r   r+   r   rK   r   rL   r   r,   r   r-   r   r.   r   r/   r   r1   r   r0   r   r2   r   r3   r   r4   r   r5   r   r6   r   r7   r   rM   r   r   r   )*r;   r   rW   r   r$   r
   r   r   r=   r   r+   r   rL   r   r,   r   r-   r   r.   r   r/   r   r1   r   r0   r   r2   r   r3   r   r4   r   r5   r   r6   r   r7   r   rM   r   r   r   )
rv   r   r3   Optional[int]rw   Optional[dict]rM   r   r   r   )r   zCallable[[float], float])
rv   r   r3   r   rw   r   rM   r   r   list[tuple[Document, float]])
r$   list[float]r3   r   rw   r   rM   r   r   r   )
r$   r   r3   r   rw   r   rM   r   r   r   )NNNN)rv   r   r3   r   r4   r   r5   Optional[float]rw   r   rM   r   r   r   )r$   r   r3   r   r4   r   r5   r   rw   r   rM   r   r   r   )r$   r   r3   r   r4   r   r5   r   rw   r   rM   r   r   r   )F)r   boolr   None)NF)r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   )rL   zSequence[str]r   r   )r   r   )5__name__
__module____qualname____doc__r   r   r    classmethodr   r8   rA   propertyrE   rH   rP   rU   rZ   r\   r^   ra   rd   rh   rm   ro   rq   rx   rt   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r   r   r      s   %8L&  $' +047;'.B.G 6:=A#=1 =1=1 &=1 	=1
 =1 =1 =1 .=1 "5=1 =1 ,=1 ,=1 =1 =1 =1  4!=1" ;#=1$ 
%=1 =1~  $' +047;'$8.G 6:=A#>1>1 &>1 	>1
 >1 >1 >1 .>1 "5>1 >1 ">1 ,>1 >1 >1 >1  4!>1" ;#>1$ 
%>1 >1@ + + +/#'

 &
 (	

 !
 
 

  +/"	

 (
 	

 
 

& #
!
 
 	

 

& +/#'

 &
 (	

 !
 
 

  +/"	

 (
 	

 
 

& #
!
 
 	

 

" #
R
R 
R 
	
R #
K
K 
K 
	
K  $*."' +047;'$8.G 6:=A)G GG G 	G
 G G (G G G G .G "5G G "G ,G  !G" #G$ %G& 4'G( ;)G* +G, 
-G GR  $"' +047;'$8.G 6:=A'F F!F F 	F
 F F F F F .F "5F F "F ,F F  !F" #F$ 4%F& ;'F( )F* 
+F FP  $*."' +047;'$8.G 6:=A)H HH H 	H
 H H (H H H H .H "5H H "H ,H  !H" #H$ %H& 4'H( ;)H* +H, 
-H HT  $"' +047;'$8.G 6:=A'F F!F F 	F
 F F F F F .F "5F F "F ,F F  !F" #F$ 4%F& ;'F( )F* 
+F FV  !%	



 

 	


 

 


  !%	



 

 	


 

 


6  !%	



 

 	


 

 
&

  !%	



 

 	


 

 


  !%	

 
 	

 
 
&
"  !%'+!%

 
 	

 %
 
 
 

&  !%'+!%

 
 	

 %
 
 
 

&  !%'+!%

 
 	

 %
 
 
 
&
&  !%	



 

 	


 

 
&

  !%	



 

 	


 

 


  !%	

 
 	

 
 
&
"  !%'+!%

 
 	

 %
 
 
 

&  !%'+!%

 
 	

 %
 
 
 

&  !%'+!%

 
 	

 %
 
 
 
&
$ #

 

 #

 

 #"		
	
 	
 		

 
	
 #"		
	
 	
 		

 
	
PI %)
!
 

 %)S!S 
S %)V!V 
V %)O!O 
OPI$r!   r   N)
__future__r   typingr   r   r   r   r   langchain_core.documentsr	   langchain_core.embeddingsr
   langchain_core.vectorstoresr   async_vectorstorer   r   r   r7   r   indexesr   r   r   r   r   r   r!   r   <module>r      s8    " > > - 0 3 1  4 Z$K Z$r!   