§
    šŠtj0[  ã                  óÆ   — d dl mZ d dlZd dlmZmZmZ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 erd dlmZ  ed	d
d¬¦  «         G d„ de¦  «        ¦   «         ZdS )é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚDictÚIterableÚListÚOptionalÚTupleÚType)Ú
deprecated)ÚDocument)Ú
Embeddings)ÚVectorStore©ÚClusterz0.2.4z1.0z.langchain_couchbase.CouchbaseSearchVectorStore)ÚsinceÚremovalÚalternative_importc                  ó  — e Zd ZU dZdZded<   dZded<   dZded	<   d
Zded<   dDd„Z	dDd„Z
dDd„ZeeddœdEd„Z	 	 	 dFdGd,„ZdHdId.„ZedJd/„¦   «         ZdKd2„Zd3i fdLd9„Zd3i fdMd<„Zd3i fdNd=„Zd3i fdOd>„ZedPdA„¦   «         Ze	 dHdQdC„¦   «         Zd S )RÚCouchbaseVectorStoreah  `Couchbase Vector Store` vector store.

    To use it, you need
    - a recent installation of the `couchbase` library
    - a Couchbase database with a pre-defined Search index with support for
        vector fields

    Example:
        .. code-block:: python

            from langchain_community.vectorstores import CouchbaseVectorStore
            from langchain_openai import OpenAIEmbeddings

            from couchbase.cluster import Cluster
            from couchbase.auth import PasswordAuthenticator
            from couchbase.options import ClusterOptions
            from datetime import timedelta

            auth = PasswordAuthenticator(username, password)
            options = ClusterOptions(auth)
            connect_string = "couchbases://localhost"
            cluster = Cluster(connect_string, options)

            # Wait until the cluster is ready for use.
            cluster.wait_until_ready(timedelta(seconds=5))

            embeddings = OpenAIEmbeddings()

            vectorstore = CouchbaseVectorStore(
                cluster=cluster,
                bucket_name="",
                scope_name="",
                collection_name="",
                embedding=embeddings,
                index_name="vector-index",
            )

            vectorstore.add_texts(["hello", "world"])
            results = vectorstore.similarity_search("ola", k=1)
    éd   ÚintÚDEFAULT_BATCH_SIZEÚmetadataÚstrÚ_metadata_keyÚtextÚ_default_text_keyÚ	embeddingÚ_default_embedding_keyÚreturnÚboolc                ó�   — | j                              ¦   «         }	 |                     | j        ¦  «         dS # t          $ r Y dS w xY w)z:Check if the bucket exists in the linked Couchbase clusterTF)Ú_clusterÚbucketsÚ
get_bucketÚ_bucket_nameÚ	Exception)ÚselfÚbucket_managers     úh/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/vectorstores/couchbase.pyÚ_check_bucket_existsz)CouchbaseVectorStore._check_bucket_existsD   sX   € àœ×.Ò.Ñ0Ô0ˆð	Ø×%Ò% dÔ&7Ñ8Ô8Ð8Ø�4øÝð 	ð 	ð 	Ø�5�5ð	øøøs   ›7 ·
AÁAc                óÂ  — i }| j                              ¦   «                              ¦   «         D ];}g ||j        <   |j        D ]'}||j                                      |j        ¦  «         Œ(Œ<| j        |                     ¦   «         vrt          d| j        › d| j        › �¦  «        ‚| j	        || j                 vr't          d| j	        › d| j        › d| j        › �¦  «        ‚dS )zzCheck if the scope and collection exists in the linked Couchbase bucket
        Raises a ValueError if either is not foundzScope z not found in Couchbase bucket zCollection z not found in scope z in Couchbase bucket T)
Ú_bucketÚcollectionsÚget_all_scopesÚnameÚappendÚ_scope_nameÚkeysÚ
ValueErrorr'   Ú_collection_name)r)   Úscope_collection_mapÚscopeÚ
collections       r+   Ú"_check_scope_and_collection_existsz7CouchbaseVectorStore._check_scope_and_collection_existsM   s@  € ð 02Ðð ”\×-Ò-Ñ/Ô/×>Ò>Ñ@Ô@ð 	Ið 	IˆEØ/1Ð  ¤Ñ,ð $Ô/ð Ið I�
Ø$ U¤ZÔ0×7Ò7¸
¼ÑHÔHÐHÐHðIð ÔÐ#7×#<Ò#<Ñ#>Ô#>Ð>Ð>Ýð.˜Ô)ð .ð .ØÔ+ð.ð .ñô ð ð Ô Ð(<¸TÔ=MÔ(NÐNÐNÝðN˜dÔ3ð Nð NØÔ#ðNð NØ:>Ô:KðNð Nñô ð ð
 ˆtó    c                ón  — | j         rWd„ | j                             ¦   «                              ¦   «         D ¦   «         }| j        |vrt          d| j        › d�¦  «        ‚nVd„ | j                             ¦   «                              ¦   «         D ¦   «         }| j        |vrt          d| j        › d�¦  «        ‚dS )zxCheck if the Search index exists in the linked Couchbase cluster
        Raises a ValueError if the index does not existc                ó   — g | ]	}|j         ‘Œ
S © ©r1   ©Ú.0Úindexs     r+   ú
<listcomp>z<CouchbaseVectorStore._check_index_exists.<locals>.<listcomp>n   ó'   € ð ð ð Ø$�”
ðð ð r;   zIndex z; does not exist.  Please create the index before searching.c                ó   — g | ]	}|j         ‘Œ
S r>   r?   r@   s     r+   rC   z<CouchbaseVectorStore._check_index_exists.<locals>.<listcomp>w   rD   r;   T)Ú_scoped_indexÚ_scopeÚsearch_indexesÚget_all_indexesÚ_index_namer5   r$   )r)   Úall_indexess     r+   Ú_check_index_existsz(CouchbaseVectorStore._check_index_existsj   s	  € ð Ôð 	ðð Ø(,¬×(BÒ(BÑ(DÔ(D×(TÒ(TÑ(VÔ(Vðñ ô ˆKð Ô {Ð2Ð2Ý ðA˜TÔ-ð Að Að Añô ð ð 3ðð Ø(,¬×(DÒ(DÑ(FÔ(F×(VÒ(VÑ(XÔ(Xðñ ô ˆKð Ô {Ð2Ð2Ý ðA˜TÔ-ð Að Að Añô ð ð
 ˆtr;   T)Útext_keyÚembedding_keyÚscoped_indexÚclusterr   Úbucket_nameÚ
scope_nameÚcollection_namer   Ú
index_namerM   úOptional[str]rN   rO   ÚNonec               óþ  — 	 ddl m}
 n"# t          $ r}t          d¦  «        |‚d}~ww xY wt          ||
¦  «        st	          dt          |¦  «        › �¦  «        ‚|| _        |st	          d¦  «        ‚|st	          d¦  «        ‚|st	          d¦  «        ‚|st	          d	¦  «        ‚|st	          d
¦  «        ‚|| _        || _        || _	        || _
        || _        || _        || _        |	| _        |                      ¦   «         st	          d| j        › d�¦  «        ‚	 | j                             | j        ¦  «        | _        | j                             | j        ¦  «        | _        | j                             | j	        ¦  «        | _        n"# t,          $ r}t	          d¦  «        |‚d}~ww xY w	 |                      ¦   «          n# t,          $ r}|‚d}~ww xY w	 |                      ¦   «          dS # t,          $ r}|‚d}~ww xY w)av  
        Initialize the Couchbase Vector Store.

        Args:

            cluster (Cluster): couchbase cluster object with active connection.
            bucket_name (str): name of bucket to store documents in.
            scope_name (str): name of scope in the bucket to store documents in.
            collection_name (str): name of collection in the scope to store documents in
            embedding (Embeddings): embedding function to use.
            index_name (str): name of the Search index to use.
            text_key (optional[str]): key in document to use as text.
                Set to text by default.
            embedding_key (optional[str]): key in document to use for the embeddings.
                Set to embedding by default.
            scoped_index (optional[bool]): specify whether the index is a scoped index.
                Set to True by default.
        r   r   zfCould not import couchbase python package. Please install couchbase SDK  with `pip install couchbase`.Nz8cluster should be an instance of couchbase.Cluster, got z%Embeddings instance must be provided.zbucket_name must be provided.zscope_name must be provided.z!collection_name must be provided.zindex_name must be provided.zBucket z< does not exist.  Please create the bucket before searching.zKError connecting to couchbase. Please check the connection and credentials.)Úcouchbase.clusterr   ÚImportErrorÚ
isinstancer5   Útyper$   r'   r3   r6   Ú_embedding_functionÚ	_text_keyÚ_embedding_keyrJ   rF   r,   Úbucketr.   r8   rG   r9   Ú_collectionr(   r:   rL   )r)   rP   rQ   rR   rS   r   rT   rM   rN   rO   r   Úes               r+   Ú__init__zCouchbaseVectorStore.__init__‚   s¥  € ð>	Ø1Ð1Ð1Ð1Ð1Ð1Ð1øÝð 	ð 	ð 	ÝðNñô ð ðøøøøð	øøøõ ˜' 7Ñ+Ô+ð 	Ýð'Ý˜G‘}”}ð'ð 'ñô ð ð
  ˆŒàð 	FÝÐDÑEÔEÐEàð 	>ÝÐ<Ñ=Ô=Ð=àð 	=ÝÐ;Ñ<Ô<Ð<àð 	BÝÐ@ÑAÔAÐAàð 	=ÝÐ;Ñ<Ô<Ð<à'ˆÔØ%ˆÔØ /ˆÔØ#,ˆÔ Ø!ˆŒØ+ˆÔØ%ˆÔØ)ˆÔð ×(Ò(Ñ*Ô*ð 	Ýð>˜$Ô+ð >ð >ð >ñô ð ð
	Øœ=×/Ò/°Ô0AÑBÔBˆDŒLØœ,×,Ò,¨TÔ-=Ñ>Ô>ˆDŒKØ#œ{×5Ò5°dÔ6KÑLÔLˆDÔÐøÝð 	ð 	ð 	Ýð?ñô ð ðøøøøð	øøøð	Ø×3Ò3Ñ5Ô5Ð5Ð5øÝð 	ð 	ð 	ØˆGøøøøð	øøøð	Ø×$Ò$Ñ&Ô&Ð&Ð&Ð&øÝð 	ð 	ð 	ØˆGøøøøð	øøøsY   ‚	 ‰
(“#£(ÄA,F Æ
F'ÆF"Æ"F'Æ+G  Ç 
GÇ
GÇGÇG+ Ç+
G<Ç5G7Ç7G<NÚtextsúIterable[str]Ú	metadatasúOptional[List[Dict[str, Any]]]ÚidsúOptional[List[str]]Ú
batch_sizeúOptional[int]Úkwargsr   ú	List[str]c                ó2  ‡ — ddl m} |s‰ j        }g }|€d„ |D ¦   «         }|€d„ |D ¦   «         }‰ j                             t          |¦  «        ¦  «        }ˆ fd„t          ||||¦  «        D ¦   «         g}	t          dt          |	¦  «        |¦  «        D ]ƒ}
|	|
|
|z   …         }	 ‰ j	         
                    |d         ¦  «        }|j        r-|                     |d                              ¦   «         ¦  «         Œe# |$ r}t          d|› �¦  «        ‚d}~ww xY w|S )aK  Run texts through the embeddings and persist in vectorstore.

        If the document IDs are passed, the existing documents (if any) will be
        overwritten with the new ones.

        Args:
            texts (Iterable[str]): Iterable of strings to add to the vectorstore.
            metadatas (Optional[List[Dict]]): Optional list of metadatas associated
                with the texts.
            ids (Optional[List[str]]): Optional list of ids associated with the texts.
                IDs have to be unique strings across the collection.
                If it is not specified uuids are generated and used as ids.
            batch_size (Optional[int]): Optional batch size for bulk insertions.
                Default is 100.

        Returns:
            List[str]:List of ids from adding the texts into the vectorstore.
        r   )ÚDocumentExistsExceptionNc                ó>   — g | ]}t          j        ¦   «         j        ‘ŒS r>   )ÚuuidÚuuid4Úhex©rA   Ú_s     r+   rC   z2CouchbaseVectorStore.add_texts.<locals>.<listcomp>  s!   € Ð3Ð3Ð3¨•4”:‘<”<Ô#Ð3Ð3Ð3r;   c                ó   — g | ]}i ‘ŒS r>   r>   rs   s     r+   rC   z2CouchbaseVectorStore.add_texts.<locals>.<listcomp>
  s   € Ð+Ð+Ð+ ˜Ð+Ð+Ð+r;   c           	     óJ   •— i | ]\  }}}}|‰j         |‰j        |‰j        |i“Œ S r>   )r]   r^   r   )rA   Úidr   Úvectorr   r)   s        €r+   ú
<dictcomp>z2CouchbaseVectorStore.add_texts.<locals>.<dictcomp>  sO   ø€ ð 	ð 	ð 	ñ /�B˜˜f hð Ø”N DØÔ'¨ØÔ&¨ðð	ð 	ð 	r;   zDocument already exists: )Úcouchbase.exceptionsrn   r   r\   Úembed_documentsÚlistÚzipÚrangeÚlenr`   Úupsert_multiÚall_okÚextendr4   r5   )r)   rc   re   rg   ri   rk   rn   Údoc_idsÚembedded_textsÚdocuments_to_insertÚiÚbatchÚresultra   s   `             r+   Ú	add_textszCouchbaseVectorStore.add_textsæ   s‚  ø€ ð4 	AÐ@Ð@Ð@Ð@Ð@àð 	1ØÔ0ˆJØˆàˆ;Ø3Ð3¨UÐ3Ñ3Ô3ˆCàÐØ+Ð+ UÐ+Ñ+Ô+ˆIàÔ1×AÒAÅ$ÀuÁ+Ä+ÑNÔNˆð	ð 	ð 	ð 	õ 36Ø˜ °	ñ3ô 3ð	ñ 	ô 	ð
Ðõ �q�#Ð1Ñ2Ô2°JÑ?Ô?ð 	Bð 	BˆAØ'¨¨A°
©NÐ(:Ô;ˆEðBØÔ)×6Ò6°u¸Q´xÑ@Ô@�Ø”=ð 4Ø—N’N 5¨¤8§=¢=¡?¤?Ñ3Ô3Ð3øøØ*ð Bð Bð BÝ Ð!@¸QÐ!@Ð!@ÑAÔAÐAøøøøðBøøøð ˆs   Â#AC8Ã8DÃ=DÄDúOptional[bool]c                óX  — ddl m} |€t          d¦  «        ‚|                     d| j        ¦  «        }d}t          dt          |¦  «        |¦  «        D ]V}||||z   …         }	 | j                             |¦  «        }n!# |$ r}	d}t          d|	› �¦  «        ‚d}	~	ww xY w||j	        z  }ŒW|S )	aF  Delete documents from the vector store by ids.

        Args:
            ids (List[str]): List of IDs of the documents to delete.
            batch_size (Optional[int]): Optional batch size for bulk deletions.

        Returns:
            bool: True if all the documents were deleted successfully, False otherwise.

        r   )ÚDocumentNotFoundExceptionNz#No document ids provided to delete.ri   TFzDocument not found: )
rz   rŒ   r5   Úgetr   r~   r   r`   Úremove_multir�   )
r)   rg   rk   rŒ   ri   Údeletion_statusr†   r‡   rˆ   ra   s
             r+   ÚdeletezCouchbaseVectorStore.delete'  sê   € ð 	CÐBÐBÐBÐBÐBàˆ;ÝÐBÑCÔCÐCà—Z’Z ¨dÔ.EÑFÔFˆ
Øˆõ �q�#˜c™(œ( JÑ/Ô/ð 	-ð 	-ˆAØ˜˜A 
™NÐ*Ô+ˆEð=ØÔ)×6Ò6°uÑ=Ô=��øØ,ð =ð =ð =Ø"'�Ý Ð!;¸Ð!;Ð!;Ñ<Ô<Ð<øøøøð=øøøð ˜vœ}Ñ,ˆOˆOàÐs   Á#A>Á>BÂBÂBc                ó   — | j         S )z"Return the query embedding object.)r\   )r)   s    r+   Ú
embeddingszCouchbaseVectorStore.embeddingsG  s   € ð Ô'Ð'r;   Ú
row_fieldsúDict[str, Any]c                óÎ   — i }|                      ¦   «         D ]M\  }}|                     | j        ¦  «        r)|                     | j        dz   ¦  «        d         }|||<   ŒH|||<   ŒN|S )zßHelper method to format the metadata from the Couchbase Search API.
        Args:
            row_fields (Dict[str, Any]): The fields to format.

        Returns:
            Dict[str, Any]: The formatted metadata.
        ú.éÿÿÿÿ)ÚitemsÚ
startswithr   Úsplit)r)   r“   r   ÚkeyÚvalueÚnew_keys         r+   Ú_format_metadataz%CouchbaseVectorStore._format_metadataL  s|   € ð ˆØ$×*Ò*Ñ,Ô,ð 	&ð 	&‰JˆC�ð �~Š~˜dÔ0Ñ1Ô1ð &ØŸ)š) DÔ$6¸Ñ$<Ñ=Ô=¸bÔA�Ø$)�˜Ñ!Ð!à %�˜‘�àˆr;   é   úList[float]ÚkÚsearch_optionsúOptional[Dict[str, Any]]úList[Tuple[Document, float]]c           	     ó@  — ddl m} ddlm} ddlm}m} |                     ddg¦  «        }	|	dgk    r#| j        |	vr|	 	                    | j        ¦  «         |j
                             |                      || j        ||¦  «        ¦  «        ¦  «        }
	 | j        r.| j                             | j        |
 |||	|¬¦  «        ¦  «        }n.| j                             | j        |
 |||	|¬¦  «        ¬¦  «        }g }|                     ¦   «         D ]k}|j                             | j        d	¦  «        }|                      |j        ¦  «        }|j        }t/          ||¬
¦  «        }| 	                    ||f¦  «         Œln$# t0          $ r}t3          d|› �¦  «        ‚d}~ww xY w|S )a  Return docs most similar to embedding vector with their scores.

        Args:
            embedding (List[float]): Embedding vector to look up documents similar to.
            k (int): Number of Documents to return.
                Defaults to 4.
            search_options (Optional[Dict[str, Any]]): Optional search options that are
                passed to Couchbase search.
                Defaults to empty dictionary.
            fields (Optional[List[str]]): Optional list of fields to include in the
                metadata of results. Note that these need to be stored in the index.
                If nothing is specified, defaults to all the fields stored in the index.

        Returns:
            List of (Document, score) that are the most similar to the query vector.
        r   N)ÚSearchOptions)ÚVectorQueryÚVectorSearchÚfieldsÚ*)Úlimitr©   Úraw)rB   ÚrequestÚoptionsÚ )Úpage_contentr   zSearch failed with error: )Úcouchbase.searchÚsearchÚcouchbase.optionsr¦   Úcouchbase.vector_searchr§   r¨   r�   r]   r2   ÚSearchRequestÚcreateÚfrom_vector_queryr^   rF   rG   rJ   r$   Úrowsr©   Úpoprž   Úscorer   r(   r5   )r)   r   r¡   r¢   rk   r²   r¦   r§   r¨   r©   Ú
search_reqÚsearch_iterÚdocs_with_scoreÚrowr   r   rº   Údocra   s                      r+   Ú&similarity_search_with_score_by_vectorz;CouchbaseVectorStore.similarity_search_with_score_by_vector`  s  € ð. 	*Ð)Ð)Ð)Ð)Ð)Ø3Ð3Ð3Ð3Ð3Ð3ØEÐEÐEÐEÐEÐEÐEÐEà—’˜H s eÑ,Ô,ˆð �c�UŠ?ˆ?˜tœ~°VÐ;Ð;Ø�MŠM˜$œ.Ñ)Ô)Ð)àÔ)×0Ò0Ø×*Ò*Ø�ØÔ'ØØñô ñô ñ
ô 
ˆ
ð!	?ØÔ!ð Ø"œk×0Ò0ØÔ$ØØ!�MØØ%Ø*ðñ ô ñô ��ð #œm×2Ò2ØÔ*Ø&Ø)˜M°¸&ÀnÐUÑUÔUð 3ñ ô �ð !ˆOð #×'Ò'Ñ)Ô)ð 5ð 5�Ø”z—~’~ d¤n°bÑ9Ô9�ð  ×0Ò0°´Ñ<Ô<�àœ	�Ý¨D¸8ÐDÑDÔD�Ø×&Ò&¨¨U |Ñ4Ô4Ð4Ð4ð5øõ ð 	?ð 	?ð 	?ÝÐ=¸!Ð=Ð=Ñ>Ô>Ð>øøøøð	?øøøð Ðs   ÂC%E: Å:
FÆFÆFÚqueryúList[Document]c                ón   — | j                              |¦  «        } | j        |||fi |¤Ž}d„ |D ¦   «         S )aí  Return documents most similar to embedding vector with their scores.

        Args:
            query (str): Query to look up for similar documents
            k (int): Number of Documents to return.
                Defaults to 4.
            search_options (Optional[Dict[str, Any]]): Optional search options that are
                passed to Couchbase search.
                Defaults to empty dictionary
            fields (Optional[List[str]]): Optional list of fields to include in the
                metadata of results. Note that these need to be stored in the index.
                If nothing is specified, defaults to all the fields stored in the index.

        Returns:
            List of Documents most similar to the query.
        c                ó   — g | ]\  }}|‘ŒS r>   r>   ©rA   r¿   rt   s      r+   rC   z:CouchbaseVectorStore.similarity_search.<locals>.<listcomp>Ê  s   € Ð3Ð3Ð3™˜˜Q�Ð3Ð3Ð3r;   ©r’   Úembed_queryrÀ   )r)   rÁ   r¡   r¢   rk   Úquery_embeddingÚdocs_with_scoress          r+   Úsimilarity_searchz&CouchbaseVectorStore.similarity_search¯  sY   € ð. œ/×5Ò5°eÑ<Ô<ˆØF˜4ÔFØ˜Q ð
ð 
Ø28ð
ð 
Ðð 4Ð3Ð"2Ð3Ñ3Ô3Ð3r;   c                óZ   — | j                              |¦  «        } | j        |||fi |¤Ž}|S )a÷  Return documents that are most similar to the query with their scores.

        Args:
            query (str): Query to look up for similar documents
            k (int): Number of Documents to return.
                Defaults to 4.
            search_options (Optional[Dict[str, Any]]): Optional search options that are
                passed to Couchbase search.
                Defaults to empty dictionary.
            fields (Optional[List[str]]): Optional list of fields to include in the
                metadata of results. Note that these need to be stored in the index.
                If nothing is specified, defaults to text and metadata fields.

        Returns:
            List of (Document, score) that are most similar to the query.
        rÆ   )r)   rÁ   r¡   r¢   rk   rÈ   r½   s          r+   Úsimilarity_search_with_scorez1CouchbaseVectorStore.similarity_search_with_scoreÌ  sI   € ð. œ/×5Ò5°eÑ<Ô<ˆØE˜$ÔEØ˜Q ð
ð 
Ø28ð
ð 
ˆð Ðr;   c                ó:   —  | j         |||fi |¤Ž}d„ |D ¦   «         S )aø  Return documents that are most similar to the vector embedding.

        Args:
            embedding (List[float]): Embedding to look up documents similar to.
            k (int): Number of Documents to return.
                Defaults to 4.
            search_options (Optional[Dict[str, Any]]): Optional search options that are
                passed to Couchbase search.
                Defaults to empty dictionary.
            fields (Optional[List[str]]): Optional list of fields to include in the
                metadata of results. Note that these need to be stored in the index.
                If nothing is specified, defaults to document text and metadata fields.

        Returns:
            List of Documents most similar to the query.
        c                ó   — g | ]\  }}|‘ŒS r>   r>   rÅ   s      r+   rC   zDCouchbaseVectorStore.similarity_search_by_vector.<locals>.<listcomp>  s   € Ð2Ð2Ð2™˜˜Q�Ð2Ð2Ð2r;   )rÀ   )r)   r   r¡   r¢   rk   r½   s         r+   Úsimilarity_search_by_vectorz0CouchbaseVectorStore.similarity_search_by_vectoré  sC   € ð. F˜$ÔEØ�q˜.ð
ð 
Ø,2ð
ð 
ˆð 3Ð2 /Ð2Ñ2Ô2Ð2r;   ÚclsúType[CouchbaseVectorStore]c                ó&  — |                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      dd¦  «        }|                      d| j        ¦  «        }|                      d| j        ¦  «        }	|                      d	d
¦  «        }
|€t          d¦  «        ‚|€t          d¦  «        ‚|€t          d¦  «        ‚|€t          d¦  «        ‚ | ||||||||	|
¬¦	  «	        S )a4  Initialize the Couchbase vector store from keyword arguments for the
        vector store.

        Args:
            embedding: Embedding object to use to embed text.
            **kwargs: Keyword arguments to initialize the vector store with.
                Accepted arguments are:
                    - cluster
                    - bucket_name
                    - scope_name
                    - collection_name
                    - index_name
                    - text_key
                    - embedding_key
                    - scoped_index

        rP   NrQ   rR   rS   rT   rM   rN   rO   Tzbucket_name must be providedzscope_name must be providedz collection_name must be providedzindex_name must be provided)	r   rP   rQ   rR   rS   rT   rM   rN   rO   )r�   r   r    r5   )rÐ   r   rk   rP   rQ   rR   rS   rT   rM   rN   rO   s              r+   Ú_from_kwargsz!CouchbaseVectorStore._from_kwargs  s+  € ð. —*’*˜Y¨Ñ-Ô-ˆØ—j’j °Ñ5Ô5ˆØ—Z’Z ¨dÑ3Ô3ˆ
Ø Ÿ*š*Ð%6¸Ñ=Ô=ˆØ—Z’Z ¨dÑ3Ô3ˆ
Ø—:’:˜j¨#Ô*?Ñ@Ô@ˆØŸ
š
 ?°CÔ4NÑOÔOˆØ—z’z .°$Ñ7Ô7ˆàÐÝÐ;Ñ<Ô<Ð<ØÐÝÐ:Ñ;Ô;Ð;ØÐ"ÝÐ?Ñ@Ô@Ð@ØÐÝÐ:Ñ;Ô;Ð;àˆsØØØ#Ø!Ø+Ø!ØØ'Ø%ð

ñ 

ô 

ð 
	
r;   úOptional[List[Dict[Any, Any]]]c                ó¶   —  | j         |fi |¤Ž}|                     d|j        ¦  «        }|                     dd¦  «        }|                     ||||¬¦  «         |S )a®  Construct a Couchbase vector store from a list of texts.

        Example:
            .. code-block:: python

            from langchain_community.vectorstores import CouchbaseVectorStore
            from langchain_openai import OpenAIEmbeddings

            from couchbase.cluster import Cluster
            from couchbase.auth import PasswordAuthenticator
            from couchbase.options import ClusterOptions
            from datetime import timedelta

            auth = PasswordAuthenticator(username, password)
            options = ClusterOptions(auth)
            connect_string = "couchbases://localhost"
            cluster = Cluster(connect_string, options)

            # Wait until the cluster is ready for use.
            cluster.wait_until_ready(timedelta(seconds=5))

            embeddings = OpenAIEmbeddings()

            texts = ["hello", "world"]

            vectorstore = CouchbaseVectorStore.from_texts(
                texts,
                embedding=embeddings,
                cluster=cluster,
                bucket_name="",
                scope_name="",
                collection_name="",
                index_name="vector-index",
            )

        Args:
            texts (List[str]): list of texts to add to the vector store.
            embedding (Embeddings): embedding function to use.
            metadatas (optional[List[Dict]): list of metadatas to add to documents.
            **kwargs: Keyword arguments used to initialize the vector store with and/or
                passed to `add_texts` method. Check the constructor and/or `add_texts`
                for the list of accepted arguments.

        Returns:
            A Couchbase vector store.

        ri   rg   N)re   rg   ri   )rÓ   r�   r   r‰   )rÐ   rc   r   re   rk   Úvector_storeri   rg   s           r+   Ú
from_textszCouchbaseVectorStore.from_texts:  sv   € ðn (�sÔ'¨	Ð<Ð<°VÐ<Ð<ˆØ—Z’Z ¨lÔ.MÑNÔNˆ
Ø�jŠj˜ Ñ%Ô%ˆØ×ÒØ˜Y¨C¸Jð 	ñ 	
ô 	
ð 	
ð Ðr;   )r!   r"   )rP   r   rQ   r   rR   r   rS   r   r   r   rT   r   rM   rU   rN   rU   rO   r"   r!   rV   )NNN)rc   rd   re   rf   rg   rh   ri   rj   rk   r   r!   rl   )N)rg   rh   rk   r   r!   rŠ   )r!   r   )r“   r”   r!   r”   )
r   r    r¡   r   r¢   r£   rk   r   r!   r¤   )
rÁ   r   r¡   r   r¢   r£   rk   r   r!   rÂ   )
rÁ   r   r¡   r   r¢   r£   rk   r   r!   r¤   )
r   r    r¡   r   r¢   r£   rk   r   r!   rÂ   )rÐ   rÑ   r   r   rk   r   r!   r   )rÐ   rÑ   rc   rl   r   r   re   rÔ   rk   r   r!   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r   r    r,   r:   rL   rb   r‰   r�   Úpropertyr’   rž   rÀ   rÊ   rÌ   rÏ   ÚclassmethodrÓ   r×   r>   r;   r+   r   r      s!  € € € € € € ð'ð 'ðT "ÐÐ!Ð!Ð!Ñ!Ø#€MÐ#Ð#Ð#Ñ#Ø#ÐÐ#Ð#Ð#Ñ#Ø"-ÐÐ-Ð-Ð-Ñ-ðð ð ð ðð ð ð ð:ð ð ð ðB #4Ø'=Ø!ðbð bð bð bð bð bðN 59Ø#'Ø$(ð?ð ?ð ?ð ?ð ?ðBð ð ð ð ð@ ð(ð (ð (ñ „Xð(ðð ð ð ð. Ø35ð	Mð Mð Mð Mð Mðd Ø35ð	4ð 4ð 4ð 4ð 4ð@ Ø35ð	ð ð ð ð ð@ Ø35ð	3ð 3ð 3ð 3ð 3ð8 ð2
ð 2
ð 2
ñ „[ð2
ðh ð
 59ð	=ð =ð =ð =ñ „[ð=ð =ð =r;   r   )Ú
__future__r   rp   Útypingr   r   r   r   r   r	   r
   r   Úlangchain_core._api.deprecationr   Úlangchain_core.documentsr   Úlangchain_core.embeddingsr   Úlangchain_core.vectorstoresr   rX   r   r   r>   r;   r+   ú<module>rå      s%  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ Rà 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø -Ð -Ð -Ð -Ð -Ð -Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3àð *Ø)Ð)Ð)Ð)Ð)Ð)ð €Ø
ØØGðñ ô ð
d	ð d	ð d	ð d	ð d	˜;ñ d	ô d	ñô ð
d	ð d	ð d	r;   