§
    šŠtj»  ã                   óv   — d dl Z d dlmZmZmZ d dlmZ d dlmZ  e j	        e
¦  «        Z G d„ de¦  «        ZdS )é    N)ÚIteratorÚListÚOptional)ÚDocument)Ú
BaseLoaderc                   ó†   — e Zd ZdZdddœdededededeee                  d	eee                  d
dfd„Zd
ee	         fd„Z
dS )ÚCouchbaseLoaderaU  Load documents from `Couchbase`.

    Each document represents one row of the result. The `page_content_fields` are
    written into the `page_content`of the document. The `metadata_fields` are written
    into the `metadata` of the document. By default, all columns are written into
    the `page_content` and none into the `metadata`.
    N)Úpage_content_fieldsÚmetadata_fieldsÚconnection_stringÚdb_usernameÚdb_passwordÚqueryr
   r   Úreturnc                óN  — 	 ddl m} ddlm} ddlm}	 n"# t          $ r}
t          d¦  «        |
‚d}
~
ww xY w|st          d¦  «        ‚|st          d¦  «        ‚|st          d	¦  «        ‚ |||¦  «        } || |	|¦  «        ¦  «        | _        || _	        || _
        || _        dS )
aÐ  Initialize Couchbase document loader.

        Args:
            connection_string (str): The connection string to the Couchbase cluster.
            db_username (str): The username to connect to the Couchbase cluster.
            db_password (str): The password to connect to the Couchbase cluster.
            query (str): The SQL++ query to execute.
            page_content_fields (Optional[List[str]]): The columns to write into the
                `page_content` field of the document. By default, all columns are
                written.
            metadata_fields (Optional[List[str]]): The columns to write into the
                `metadata` field of the document. By default, no columns are written.
        r   )ÚPasswordAuthenticator)ÚCluster)ÚClusterOptionsz]Could not import couchbase package.Please install couchbase SDK with `pip install couchbase`.Nz#connection_string must be provided.zdb_username must be provided.zdb_password must be provided.)Úcouchbase.authr   Úcouchbase.clusterr   Úcouchbase.optionsr   ÚImportErrorÚ
ValueErrorÚclusterr   r
   r   )Úselfr   r   r   r   r
   r   r   r   r   ÚeÚauths               úl/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/document_loaders/couchbase.pyÚ__init__zCouchbaseLoader.__init__   s  € ð.	Ø<Ð<Ð<Ð<Ð<Ð<Ø1Ð1Ð1Ð1Ð1Ð1Ø8Ð8Ð8Ð8Ð8Ð8Ð8øÝð 	ð 	ð 	ÝðMñô ð ðøøøøð	øøøð
 !ð 	DÝÐBÑCÔCÐCàð 	>ÝÐ<Ñ=Ô=Ð=àð 	>ÝÐ<Ñ=Ô=Ð=à$Ð$ØØñ
ô 
ˆð
 !( Ð(9¸>¸>È$Ñ;OÔ;OÑ PÔ PˆŒØˆŒ
Ø#6ˆÔ Ø.ˆÔÐÐs   ‚ •
4Ÿ/¯4c              #   ó¼  ‡‡K  — ddl m} | j                              |d¬¦  «        ¦  «         | j                             | j        ¦  «        }|D ]‹Š| j        }| j        Š‰s!t          ‰                     ¦   «         ¦  «        Š|sg }ˆfd„|D ¦   «         }d 	                    ˆfd„‰ 
                    ¦   «         D ¦   «         ¦  «        }t          ||¬¦  «        V — ŒŒd	S )
z1Load Couchbase data into Document objects lazily.r   )Ú	timedeltaé   )Úsecondsc                 ó"   •— i | ]}|‰|         “ŒS © r%   )Ú.0ÚfieldÚrows     €r   ú
<dictcomp>z-CouchbaseLoader.lazy_load.<locals>.<dictcomp>Z   s   ø€ ÐGÐGÐG¨e˜˜s 5œzÐGÐGÐGó    ú
c              3   ó4   •K  — | ]\  }}|‰v ¯	|› d |› �V — ŒdS )z: Nr%   )r&   ÚkÚvr
   s      €r   ú	<genexpr>z,CouchbaseLoader.lazy_load.<locals>.<genexpr>\   sE   øè è € ð !ð !Ù $  1°qÐ<OÐ7OÐ7O�1��˜��Ð7OÐ7OÐ7OÐ7Oð!ð !r*   )Úpage_contentÚmetadataN)Údatetimer!   r   Úwait_until_readyr   r   r
   ÚlistÚkeysÚjoinÚitemsr   )r   r!   Úresultr   r1   Údocumentr
   r(   s         @@r   Ú	lazy_loadzCouchbaseLoader.lazy_loadG   s)  øøè è € à&Ð&Ð&Ð&Ð&Ð&ð 	Œ×%Ò% i i¸Ð&:Ñ&:Ô&:Ñ;Ô;Ð;ð ”×#Ò# D¤JÑ/Ô/ˆØð 	Gð 	GˆCØ"Ô2ˆOØ"&Ô":Ðà&ð 7Ý&*¨3¯8ª8©:¬:Ñ&6Ô&6Ð#à"ð %Ø"$�àGÐGÐGÐG°ÐGÑGÔGˆHà—y’yð !ð !ð !ð !Ø(+¯	ª	©¬ð!ñ !ô !ñ ô ˆHõ ¨¸HÐEÑEÔEÐFÐFÐFÐFð!	Gð 	Gr*   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   r   r   r   r   r:   r%   r*   r   r	   r	      sÂ   € € € € € ðð ð 48Ø/3ð1/ð 1/ð 1/àð1/ð ð1/ð ð	1/ð
 ð1/ð & d¨3¤iÔ0ð1/ð " $ s¤)Ô,ð1/ð 
ð1/ð 1/ð 1/ð 1/ðfG˜8 HÔ-ð Gð Gð Gð Gð Gð Gr*   r	   )ÚloggingÚtypingr   r   r   Úlangchain_core.documentsr   Ú)langchain_community.document_loaders.baser   Ú	getLoggerr;   Úloggerr	   r%   r*   r   ú<module>rF      sª   ðØ €€€Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ð +à -Ð -Ð -Ð -Ð -Ð -à @Ð @Ð @Ð @Ð @Ð @à	ˆÔ	˜8Ñ	$Ô	$€ðUGð UGð UGð UGð UG�jñ UGô UGð UGð UGð UGr*   