§
    šŠtjQ¥  ã                  ó  — 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
 d dlmZ d dl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 erd d
lmZ  ej        e¦  «        ZddddddœZ eddd¬¦  «         G d„ de¦  «        ¦   «         ZdS )é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚIterableÚListÚOptionalÚTupleÚUnion)Úuuid4)Ú
deprecated)ÚDocument)Ú
Embeddings)ÚVectorStore)Úmaximal_marginal_relevance)ÚMutationResultÚ	localhostÚ19530Ú F)ÚhostÚportÚuserÚpasswordÚsecurez0.2.0z1.0z"langchain_milvus.MilvusVectorStore)ÚsinceÚremovalÚalternative_importc                  ó–  — e Zd ZdZ	 	 	 	 	 	 	 	 	 diddd	dddd
dddœ	djd*„Zedkd,„¦   «         Zdld.„Z	 	 	 	 	 dmdnd3„Z	 dodpd5„Z	dqd6„Z
drd7„Zdqd8„Zdqd9„Z	 	 	 dsdtd:„Z	 	 	 dudd<œdvdF„Z	 	 	 	 dwdxdM„Z	 	 	 	 dwdydP„Z	 	 	 	 dwdzdR„Z	 	 	 	 dwd{dS„Z	 	 	 	 	 	 d|d}dY„Z	 	 	 	 	 	 d|d~d[„Z	 dd€d]„Zeddeddddfdd<œd�d_„¦   «         Zd‚db„Zdƒdd„Z	 	 dd„dh„ZdS )…ÚMilvusa  `Milvus` vector store. DO NOT USE. KEPT FOR BACKWARDS COMPATIBILITY.

    You need to install `pymilvus` and run Milvus.

    See the following documentation for how to run a Milvus instance:
    https://milvus.io/docs/install_standalone-docker.md

    If looking for a hosted Milvus, take a look at this documentation:
    https://zilliz.com/cloud and make use of the Zilliz vectorstore found in
    this project.

    IF USING L2/IP metric, IT IS HIGHLY SUGGESTED TO NORMALIZE YOUR DATA.

    Args:
        embedding_function (Embeddings): Function used to embed the text.
        collection_name (str): Which Milvus collection to use. Defaults to
            "LangChainCollection".
        collection_description (str): The description of the collection. Defaults to
            "".
        collection_properties (Optional[dict[str, any]]): The collection properties.
            Defaults to None.
            If set, will override collection existing properties.
            For example: {"collection.ttl.seconds": 60}.
        connection_args (Optional[dict[str, any]]): The connection args used for
            this class comes in the form of a dict.
        consistency_level (str): The consistency level to use for a collection.
            Defaults to "Session".
        index_params (Optional[dict]): Which index params to use. Defaults to
            HNSW/AUTOINDEX depending on service.
        search_params (Optional[dict]): Which search params to use. Defaults to
            default of index.
        drop_old (Optional[bool]): Whether to drop the current collection. Defaults
            to False.
        auto_id (bool): Whether to enable auto id for primary key. Defaults to False.
            If False, you needs to provide text ids (string less than 65535 bytes).
            If True, Milvus will generate unique integers as primary keys.
        primary_field (str): Name of the primary key field. Defaults to "pk".
        text_field (str): Name of the text field. Defaults to "text".
        vector_field (str): Name of the vector field. Defaults to "vector".
        metadata_field (str): Name of the metadata field. Defaults to None.
            When metadata_field is specified,
            the document's metadata will store as json.

    The connection args used for this class comes in the form of a dict,
    here are a few of the options:
        address (str): The actual address of Milvus
            instance. Example address: "localhost:19530"
        uri (str): The uri of Milvus instance. Example uri:
            "http://randomwebsite:19530",
            "tcp:foobarsite:19530",
            "https://ok.s3.south.com:19530".
        host (str): The host of Milvus instance. Default at "localhost",
            PyMilvus will fill in the default host if only port is provided.
        port (str/int): The port of Milvus instance. Default at 19530, PyMilvus
            will fill in the default port if only host is provided.
        user (str): Use which user to connect to Milvus instance. If user and
            password are provided, we will add related header in every RPC call.
        password (str): Required when user is provided. The password
            corresponding to the user.
        secure (bool): Default is false. If set to true, tls will be enabled.
        client_key_path (str): If use tls two-way authentication, need to
            write the client.key path.
        client_pem_path (str): If use tls two-way authentication, need to
            write the client.pem path.
        ca_pem_path (str): If use tls two-way authentication, need to write
            the ca.pem path.
        server_pem_path (str): If use tls one-way authentication, need to
            write the server.pem path.
        server_name (str): If use tls, need to write the common name.

    Example:
        .. code-block:: python

        from langchain_community.vectorstores import Milvus
        from langchain_community.embeddings import OpenAIEmbeddings

        embedding = OpenAIEmbeddings()
        # Connect to a milvus instance on localhost
        milvus_store = Milvus(
            embedding_function = Embeddings,
            collection_name = "LangChainCollection",
            drop_old = True,
            auto_id = True
        )

    Raises:
        ValueError: If the pymilvus python package is not installed.
    ÚLangChainCollectionr   NÚSessionFÚpkÚtextÚvectoré   )	Úprimary_fieldÚ
text_fieldÚvector_fieldÚmetadata_fieldÚpartition_key_fieldÚpartition_namesÚreplica_numberÚtimeoutÚ
num_shardsÚembedding_functionr   Úcollection_nameÚstrÚcollection_descriptionÚcollection_propertiesúOptional[dict[str, Any]]Úconnection_argsÚconsistency_levelÚindex_paramsúOptional[dict]Úsearch_paramsÚdrop_oldúOptional[bool]Úauto_idÚboolr%   r&   r'   r(   úOptional[str]r)   r*   úOptional[list]r+   Úintr,   úOptional[float]r-   úOptional[int]c       	        óÆ  — 	 ddl m}m} n# t          $ r t          d¦  «        ‚w xY wdddidœdddidœdddidœdddidœdddidœdddidœdddidœdddd	œdœdd
didœdd
didœdi dœdddddddœdœdddidœdddidœdœ| _        || _        || _        || _        || _        || _	        || _
        || _        |
| _        || _        || _        || _        || _        || _        g | _        || _        || _        || _        || _        |€t.          }|                      |¦  «        | _        d| _        |                     | j        | j        ¬¦  «        rB || j        | j        ¬¦  «        | _        | j        �| j                             | j        ¦  «         |	r5t;          | j        |¦  «        r | j                             ¦   «          d| _        |                      |||¬¦  «         dS )z#Initialize the Milvus vector store.r   ©Ú
CollectionÚutilityzXCould not import pymilvus python package. Please install it with `pip install pymilvus`.ÚL2Únprobeé
   )Úmetric_typeÚparamsÚef)rG   rK   Úsearch_ké€   é   )Ú
itopk_sizeÚsearch_widthÚmin_iterationsÚmax_iterationsÚ	team_size)ÚIVF_FLATÚIVF_SQ8ÚIVF_PQÚHNSWÚ
RHNSW_FLATÚRHNSW_SQÚRHNSW_PQÚIVF_HNSWÚANNOYÚSCANNÚ	AUTOINDEXÚ	GPU_CAGRAÚGPU_IVF_FLATÚ
GPU_IVF_PQN©Úusing©r*   r+   r,   ) ÚpymilvusrD   rE   ÚImportErrorÚdefault_search_paramsÚembedding_funcr/   r1   r2   r6   r8   r5   r;   Ú_primary_fieldÚ_text_fieldÚ_vector_fieldÚ_metadata_fieldÚ_partition_key_fieldÚfieldsr*   r+   r,   r-   ÚDEFAULT_MILVUS_CONNECTIONÚ_create_connection_aliasÚaliasÚcolÚhas_collectionÚset_propertiesÚ
isinstanceÚdropÚ_init)Úselfr.   r/   r1   r2   r4   r5   r6   r8   r9   r;   r%   r&   r'   r(   r)   r*   r+   r,   r-   rD   rE   s                         úe/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langchain_community/vectorstores/milvus.pyÚ__init__zMilvus.__init__|   s×  € ð0	Ø4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ð4øÝð 	ð 	ð 	ÝðAñô ð ð	øøøð )-¸À2¸ÐGÐGØ'+¸À"°~ÐFÐFØ&*°xÀ°nÐEÐEØ$(°T¸2°JÐ?Ð?Ø*.¸4À¸*ÐEÐEØ(,¸¸r¸
ÐCÐCØ(,¸¸r¸
ÐCÐCØ(,À2ÈRÐ8PÐ8PÐQÐQØ%)°jÀ"Ð5EÐFÐFØ%)°jÀ"Ð5EÐFÐFØ)-¸Ð<Ð<à#à"%Ø$%Ø&'Ø&'Ø!"ðð ð	ð 	ð -1¸XÀr¸NÐKÐKØ*.¸8ÀR¸.ÐIÐIð/&
ð &
ˆÔ"ð4 1ˆÔØ.ˆÔØ&<ˆÔ#Ø%:ˆÔ"Ø(ˆÔØ*ˆÔØ!2ˆÔØˆŒð ,ˆÔà%ˆÔà)ˆÔØ-ˆÔØ$7ˆÔ!Ø!#ˆŒØ.ˆÔØ,ˆÔØˆŒØ$ˆŒð Ð"Ý7ˆOØ×2Ò2°?ÑCÔCˆŒ
Ø)-ˆŒð ×!Ò! $Ô"6¸d¼jÐ!ÑIÔIð 	DØ!�zØÔ$Ø”jðñ ô ˆDŒHð Ô)Ð5Ø”×'Ò'¨Ô(BÑCÔCÐCàð 	�
 4¤8¨ZÑ8Ô8ð 	ØŒH�MŠM‰OŒOˆOØˆDŒHð 	�
Š
Ø+Ø)Øð 	ñ 	
ô 	
ð 	
ð 	
ð 	
s   ‚ ‹%Úreturnc                ó   — | j         S ©N)rh   )rx   s    ry   Ú
embeddingszMilvus.embeddingsè   s   € àÔ"Ð"ó    Údictc                óŒ  — ddl m}m} |                     dd¦  «        }|                     dd¦  «        }|                     dd¦  «        }|                     dd¦  «        }|                     dd¦  «        }|�%|�#t	          |¦  «        d	z   t	          |¦  «        z   }	n°|��|                     d
¦  «        r|                     d
¦  «        d         }	n}|                     d¦  «        r|                     d¦  «        d         }	nLt                               d|¦  «         t          d|¦  «        ‚|�|}	nd}	t           
                    d¦  «         |�|}
nd}
|	�…|                     ¦   «         D ]p}|                     |d         ¦  «        }|d         rKd|v rG|d         |	k    r;d|v r7|d         |
k    r+t           
                    d|d         ¦  «         |d         c S Œqt          ¦   «         j        }	  |j        dd|i|¤Ž t           
                    d|¦  «         |S # |$ r"}t                               d|¦  «         |‚d}~ww xY w)z+Create the connection to the Milvus server.r   )ÚMilvusExceptionÚconnectionsr   Nr   ÚaddressÚurir   ú:zhttps://r$   zhttp://zInvalid Milvus URI: %sz/Missing standard address type for reuse attemptr   zUsing previous connection: %srq   z Created new connection using: %sz)Failed to create new connection using: %s© )re   r‚   rƒ   Úgetr0   Ú
startswithÚsplitÚloggerÚerrorÚ
ValueErrorÚdebugÚlist_connectionsÚget_connection_addrr   ÚhexÚconnect)rx   r4   r‚   rƒ   r   r   r„   r…   r   Úgiven_addressÚtmp_userÚconÚaddrrq   Úes                  ry   rp   zMilvus._create_connection_aliasì   sŽ  € à9Ð9Ð9Ð9Ð9Ð9Ð9Ð9ð .×1Ò1°&¸$Ñ?Ô?ˆØ*9×*=Ò*=¸fÀdÑ*KÔ*KˆØ!0×!4Ò!4°YÀÑ!EÔ!EˆØ,×0Ò0°¸Ñ=Ô=ˆØ×"Ò" 6¨4Ñ0Ô0ˆð Ð Ð 0Ý ™IœI¨™O­c°$©i¬iÑ7ˆMˆMØˆ_Ø�~Š~˜jÑ)Ô)ð @Ø #§	¢	¨*Ñ 5Ô 5°aÔ 8��Ø—’ 	Ñ*Ô*ð @Ø #§	¢	¨)Ñ 4Ô 4°QÔ 7��å—’Ð5°sÑ;Ô;Ð;Ý Ð!9¸3Ñ?Ô?Ð?ØÐ Ø#ˆMˆMà ˆMÝ�LŠLÐJÑKÔKÐKð ÐØˆHˆHàˆHð Ð$Ø"×3Ò3Ñ5Ô5ð 
"ð 
"�Ø"×6Ò6°s¸1´vÑ>Ô>�à˜”Fð"à" dÐ*Ð*Ø˜iœ¨MÒ9Ð9Ø 4˜˜Ø˜fœ¨Ò1Ð1å—L’LÐ!@À#ÀaÄ&ÑIÔIÐIØ˜qœ6�M�M�Møõ ‘””ˆð	ØˆKÔÐ?Ð? eÐ?¨Ð?Ð?Ð?Ý�LŠLÐ;¸UÑCÔCÐCØˆLøØð 	ð 	ð 	Ý�LŠLÐDÀeÑLÔLÐLØˆGøøøøð	øøøs   Ç0+H ÈIÈ!H>È>Ir~   Ú	metadatasúOptional[list[dict]]ÚNonec                óÞ   — |�|                       ||¦  «         |                      ¦   «          |                      ¦   «          |                      ¦   «          |                      |||¬¦  «         d S )Nrd   )Ú_create_collectionÚ_extract_fieldsÚ_create_indexÚ_create_search_paramsÚ_load)rx   r~   r˜   r*   r+   r,   s         ry   rw   zMilvus._init&  s„   € ð Ð!Ø×#Ò# J°	Ñ:Ô:Ð:Ø×ÒÑÔÐØ×ÒÑÔÐØ×"Ò"Ñ$Ô$Ð$Ø�
Š
Ø+Ø)Øð 	ñ 	
ô 	
ð 	
ð 	
ð 	
r   Úlistc           	     óN  — ddl m}m}m}m}m} ddlm} t          |d         ¦  «        }	g }
| j	        �*|
 
                     || j	        |j        ¦  «        ¦  «         nÂ|rÀ|d                              ¦   «         D ]¥\  }} ||¦  «        }||j        k    s||j        k    r.t                               d|¦  «         t#          d|› d�¦  «        ‚||j        k    r'|
 
                     |||j        d¬¦  «        ¦  «         Œ†|
 
                     |||¦  «        ¦  «         Œ¦|
 
                     || j        |j        d¬¦  «        ¦  «         | j        r-|
 
                     || j        |j        d	d	¬
¦  «        ¦  «         n-|
 
                     || j        |j        d	dd¬¦  «        ¦  «         |
 
                     || j         ||d         ¦  «        |	¬¦  «        ¦  «          ||
| j        | j        ¬¦  «        }	 | j        �* || j        || j        | j        | j        ¬¦  «        | _        n# || j        || j        | j        ¬¦  «        | _        | j        �!| j                              | j        ¦  «         d S d S # |$ r(}t                               d| j        |¦  «         |‚d }~ww xY w)Nr   )rD   ÚCollectionSchemaÚDataTypeÚFieldSchemar‚   )Úinfer_dtype_bydataz<Failure to create collection, unrecognized dtype for key: %szUnrecognized datatype for ú.éÿÿ  )Ú
max_lengthT)Ú
is_primaryr;   F)rª   r;   r©   )Údim)Údescriptionr)   )ÚnameÚschemar5   rc   r-   )r­   r®   r5   rc   z)Failed to create collection: %s error: %s)!re   rD   r£   r¤   r¥   r‚   Úpymilvus.orm.typesr¦   Úlenrl   ÚappendÚJSONÚitemsÚUNKNOWNÚNONEr‹   rŒ   r�   ÚVARCHARrj   r;   ri   ÚINT64rk   r1   rm   r-   r/   r5   rq   rr   r2   rt   )rx   r~   r˜   rD   r£   r¤   r¥   r‚   r¦   r«   rn   ÚkeyÚvalueÚdtyper®   r—   s                   ry   rœ   zMilvus._create_collection9  s¨  € ð	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	:Ð9Ð9Ð9Ð9Ð9õ �*˜Q”-Ñ Ô ˆØˆØÔÐ+Ø�MŠM˜+˜+ dÔ&:¸H¼MÑJÔJÑKÔKÐKÐKð ð ?à"+¨A¤,×"4Ò"4Ñ"6Ô"6ð ?ð ?‘J�C˜à.Ð.¨uÑ5Ô5�Eà Ô 0Ò0Ð0°E¸X¼]Ò4JÐ4JÝŸšð!Að  ñô ð õ )Ð)LÀcÐ)LÐ)LÐ)LÑMÔMÐMà (Ô"2Ò2Ð2ØŸšØ'˜K¨¨XÔ-=È&ÐQÑQÔQñô ð ð ð Ÿš k k°#°uÑ&=Ô&=Ñ>Ô>Ð>Ð>ð 	�ŠØˆK˜Ô(¨(Ô*:ÀvÐNÑNÔNñ	
ô 	
ð 	
ð Œ<ð 	Ø�MŠMØ�ØÔ'¨¬ÀDÐRVðñ ô ñô ð ð ð �MŠMØ�ØÔ'ØÔ$Ø#Ø!Ø%ðñ ô ñô ð ð 	�ŠØˆK˜Ô*Ð,>Ð,>¸zÈ!¼}Ñ,MÔ,MÐSVÐWÑWÔWñ	
ô 	
ð 	
ð
 "Ð!ØØÔ3Ø $Ô 9ð
ñ 
ô 
ˆð	ØŒÐ*ð &˜:ØÔ-Ø!Ø&*Ô&<Øœ*Ø#œðñ ô �”�ð &˜:ØÔ-Ø!Ø&*Ô&<Øœ*ð	ñ ô �”ð Ô)Ð5Ø”×'Ò'¨Ô(BÑCÔCÐCÐCÐCð 6Ð5øàð 	ð 	ð 	Ý�LŠLØ;¸TÔ=QÐSTñô ð ð ˆGøøøøð		øøøs   Ç9A:I7 É7J$É<#JÊJ$c                óª   — ddl m} t          | j        |¦  «        r5| j        j        }|j        D ]#}| j                             |j        ¦  «         Œ"dS dS )z,Grab the existing fields from the Collectionr   ©rD   N)re   rD   ru   rr   r®   rn   r±   r­   )rx   rD   r®   Úxs       ry   r�   zMilvus._extract_fields   sq   € à'Ð'Ð'Ð'Ð'Ð'å�d”h 
Ñ+Ô+ð 	+Ø”X”_ˆFØ”]ð +ð +�Ø”×"Ò" 1¤6Ñ*Ô*Ð*Ð*ð	+ð 	+ð+ð +r   c                ó¦   — ddl m} t          | j        |¦  «        r5| j        j        D ](}|j        | j        k    r|                     ¦   «         c S Œ)dS )z0Return the vector index information if it existsr   r¼   N)re   rD   ru   rr   ÚindexesÚ
field_namerk   Úto_dict)rx   rD   r½   s      ry   Ú
_get_indexzMilvus._get_index©  sj   € à'Ð'Ð'Ð'Ð'Ð'å�d”h 
Ñ+Ô+ð 	'Ø”XÔ%ð 'ð '�Ø”< 4Ô#5Ò5Ð5ØŸ9š9™;œ;Ð&Ð&Ð&ð 6àˆtr   c                ó  — ddl m}m} t          | j        |¦  «        rë|                      ¦   «         €Ù	 | j        €dddddœd	œ| _        	 | j                             | j        | j        | j	        ¬
¦  «         nB# |$ r: ddi d	œ| _        | j                             | j        | j        | j	        ¬
¦  «         Y nw xY wt                               d| j        ¦  «         dS # |$ r'}t                               d| j        ¦  «         |‚d}~ww xY wdS dS )z Create a index on the collectionr   ©rD   r‚   NrF   rW   é   é@   )ÚMÚefConstruction)rI   Ú
index_typerJ   )r6   rc   r^   z/Successfully created an index on collection: %sz+Failed to create an index on collection: %s)re   rD   r‚   ru   rr   rÂ   r6   Úcreate_indexrk   rq   r‹   rŽ   r/   rŒ   )rx   rD   r‚   r—   s       ry   rž   zMilvus._create_index³  sš  € à8Ð8Ð8Ð8Ð8Ð8Ð8Ð8å�d”h 
Ñ+Ô+ð '	°·²Ñ0AÔ0AÐ0Ið&àÔ$Ð,à'+Ø&,Ø()¸RÐ"@Ð"@ð)ð )�DÔ%ðØ”H×)Ò)ØÔ*Ø%)Ô%6Ø"œjð *ñ ô ð ð øð 'ð ð ð ð (,Ø&1Ø"$ð)ð )�DÔ%ð
 ”H×)Ò)ØÔ*Ø%)Ô%6Ø"œjð *ñ ô ð ð ð ðøøøõ —’ØEØÔ(ñô ð ð ð øð
 #ð ð ð Ý—’ØAÀ4ÔCWñô ð ð �øøøøð	øøøðG'	ð '	Ð0IÐ0Is;   ³C Á	,A6 Á5C Á6<B5Â2C Â4B5Â5#C ÃDÃ"DÄDc                óò   — ddl m} t          | j        |¦  «        rW| j        €R|                      ¦   «         }|�>|d         d         }|d         d         }| j        |         | _        || j        d<   dS dS dS dS )z6Generate search params based on the current index typer   r¼   NÚindex_paramrÉ   rI   )re   rD   ru   rr   r8   rÂ   rg   )rx   rD   ÚindexrÉ   rI   s        ry   rŸ   zMilvus._create_search_paramsà  sŸ   € à'Ð'Ð'Ð'Ð'Ð'å�d”h 
Ñ+Ô+ð 	@°Ô0BÐ0JØ—O’OÑ%Ô%ˆEØÐ Ø"'¨Ô"6°|Ô"D�
Ø#(¨Ô#7¸Ô#F�Ø%)Ô%?À
Ô%K�Ô"Ø4?�Ô" =Ñ1Ð1Ð1ð	@ð 	@Ð0JÐ0Jà Ð r   c                ó   — ddl m}m} ddlm} | j        p|}t          | j        |¦  «        r]|                      ¦   «         �K| 	                    | j
        | j        ¬¦  «        |j        k    r#| j                             |||¬¦  «         dS dS dS dS )z!Load the collection if available.r   rC   )Ú	LoadStateNrb   rd   )re   rD   rE   Úpymilvus.client.typesrÏ   r,   ru   rr   rÂ   Ú
load_stater/   rq   ÚNotLoadÚload)rx   r*   r+   r,   rD   rE   rÏ   s          ry   r    zMilvus._loadì  sÕ   € ð 	1Ð0Ð0Ð0Ð0Ð0Ð0Ð0Ø3Ð3Ð3Ð3Ð3Ð3à”,Ð) 'ˆå�t”x Ñ,Ô,ð
	à—’Ñ!Ô!Ð-Ø×"Ò" 4Ô#7¸t¼zÐ"ÑJÔJØÔ ò!ð !ð ŒH�MŠMØ /Ø-Øð ñ ô ð ð ð ð
	ð 
	à-Ð-ð!ð !r   éè  ©ÚidsÚtextsúIterable[str]úOptional[List[dict]]Ú
batch_sizerÖ   úOptional[List[str]]Úkwargsr   ú	List[str]c               ó  ‡ ‡‡‡— ddl m}m} t          |¦  «        }‰ j        syt          |t          ¦  «        s
J d¦   «         ‚t          t          |¦  «        ¦  «        t          |¦  «        k    s
J d¦   «         ‚t          d„ |D ¦   «         ¦  «        s
J d¦   «         ‚	 ‰ j	         
                    |¦  «        }	n# t          $ r ˆ fd„|D ¦   «         }	Y nw xY wt          |	¦  «        dk    rt                               d¦  «         g S t          ‰ j        |¦  «        sE|	|d	œ}‰ j        r
‰ j        |d
<   ‰ j        r
‰ j        |d<   ‰ j        r
‰ j        |d<    ‰ j        di |¤Ž ‰ j        |‰ j        |	iŠ‰ j        s
|‰‰ j        <   ‰ j        �4|D ]0}
‰                     ‰ j        g ¦  «                             |
¦  «         Œ1ny|�w|D ]t}
|
                     ¦   «         D ]]\  }}‰ j        rˆ fd„‰ j        D ¦   «         nd„ ‰ j        D ¦   «         }||v r)‰                     |g ¦  «                             |¦  «         Œ^Œu‰‰ j                 }t          |¦  «        }g }t          ‰ j        |¦  «        sJ ‚t7          d||¦  «        D ]ŽŠt9          ‰|z   |¦  «        Šˆˆˆfd„‰ j        D ¦   «         }	 ‰ j        p|} ‰ j        j        |fd|i|¤Ž}|                     |j        ¦  «         Œd# |$ r#}t                                d‰|¦  «         |‚d}~ww xY w|S )aì  Insert text data into Milvus.

        Inserting data when the collection has not be made yet will result
        in creating a new Collection. The data of the first entity decides
        the schema of the new collection, the dim is extracted from the first
        embedding and the columns are decided by the first metadata dict.
        Metadata keys will need to be present for all inserted values. At
        the moment there is no None equivalent in Milvus.

        Args:
            texts (Iterable[str]): The texts to embed, it is assumed
                that they all fit in memory.
            metadatas (Optional[List[dict]]): Metadata dicts attached to each of
                the texts. Defaults to None.
            should be less than 65535 bytes. Required and work when auto_id is False.
            timeout (Optional[float]): Timeout for each batch insert. Defaults
                to None.
            batch_size (int, optional): Batch size to use for insertion.
                Defaults to 1000.
            ids (Optional[List[str]]): List of text ids. The length of each item

        Raises:
            MilvusException: Failure to add texts

        Returns:
            List[str]: The resulting keys for each inserted element.
        r   rÄ   z7A list of valid ids are required when auto_id is False.z7Different lengths of texts and unique ids are provided.c              3  ó`   K  — | ])}t          |                     ¦   «         ¦  «        d k    V — Œ*dS )r¨   N)r°   Úencode©Ú.0r½   s     ry   ú	<genexpr>z#Milvus.add_texts.<locals>.<genexpr>2  s5   è è € Ð>Ð>°Q•s˜1Ÿ8š8™:œ:‘”¨&Ò0Ð>Ð>Ð>Ð>Ð>Ð>r   z1Each id should be a string less than 65535 bytes.c                óD   •— g | ]}‰j                              |¦  «        ‘ŒS r‡   )rh   Úembed_query©râ   r½   rx   s     €ry   ú
<listcomp>z$Milvus.add_texts.<locals>.<listcomp>9  s*   ø€ ÐLÐLÐLÀ˜$Ô-×9Ò9¸!Ñ<Ô<ÐLÐLÐLr   zNothing to insert, skipping.)r~   r˜   r*   r+   r,   Nc                ó*   •— g | ]}|‰j         k    ¯|‘ŒS r‡   )ri   ræ   s     €ry   rç   z$Milvus.add_texts.<locals>.<listcomp>\  s&   ø€ ÐPÐPÐP 1°q¸DÔ<OÒ7OÐ7O˜QÐ7OÐ7OÐ7Or   c                ó   — g | ]}|‘ŒS r‡   r‡   rá   s     ry   rç   z$Milvus.add_texts.<locals>.<listcomp>^  s   € Ð!9Ð!9Ð!9¨ !Ð!9Ð!9Ð!9r   c                ó8   •— g | ]}|‰v ¯‰|         ‰‰…         ‘ŒS r‡   r‡   )râ   r½   ÚendÚiÚinsert_dicts     €€€ry   rç   z$Milvus.add_texts.<locals>.<listcomp>n  s7   ø€ ð ð ð Ø*+¸aÀ;Ð>NÐ>N�˜A”˜q ˜uÔ%Ð>NÐ>NÐ>Nr   z0Failed to insert batch starting at entity: %s/%sr‡   )!re   rD   r‚   r¡   r;   ru   r°   ÚsetÚallrh   Úembed_documentsÚNotImplementedErrorr‹   rŽ   rr   r*   r+   r,   rw   rj   rk   ri   rl   Ú
setdefaultr±   r³   rn   ÚrangeÚminÚinsertÚextendÚprimary_keysrŒ   )rx   r×   r˜   r,   rÚ   rÖ   rÜ   rD   r‚   r~   Údr¸   r¹   ÚkeysÚvectorsÚtotal_countÚpksÚinsert_listÚresr—   rë   rì   rí   s   `                   @@@ry   Ú	add_textszMilvus.add_texts  s   øøøø€ ðJ 	9Ð8Ð8Ð8Ð8Ð8Ð8Ð8å�U‘”ˆØŒ|ð 		Ý˜c¥4Ñ(Ô(ð ð ØIñô Ð(õ •s˜3‘x”x‘=”=¥C¨¡J¤JÒ.Ð.Ð.ØIñ /Ô.Ð.õ Ð>Ð>¸#Ð>Ñ>Ô>Ñ>Ô>ð ð ØCñô Ð>ð	MØÔ,×<Ò<¸UÑCÔCˆJˆJøÝ"ð 	Mð 	Mð 	MØLÐLÐLÐLÀeÐLÑLÔLˆJˆJˆJð	Møøøõ ˆz‰?Œ?˜aÒÐÝ�LŠLÐ7Ñ8Ô8Ð8ØˆIõ ˜$œ( JÑ/Ô/ð 	!Ø$.¸YÐGÐGˆFØÔ#ð AØ,0Ô,@�Ð(Ñ)ØÔ"ð ?Ø+/Ô+>�Ð'Ñ(ØŒ|ð 1Ø$(¤L��yÑ!ØˆDŒJÐ Ð ˜Ð Ð Ð ð Ô˜eØÔ 
ð(
ˆð
 Œ|ð 	3Ø/2ˆK˜Ô+Ñ,àÔÐ+Øð Kð K�Ø×&Ò& tÔ';¸RÑ@Ô@×GÒGÈÑJÔJÐJÐJðKð Ð$Ø"ð Jð J�AØ&'§g¢g¡i¤ið Jð J™
˜˜Uð  $œ|ð:ÐPÐPÐPÐP¨¬ÐPÑPÔPÐPà!9Ð!9¨T¬[Ð!9Ñ!9Ô!9ð ð
  $˜;˜;Ø'×2Ò2°3¸Ñ;Ô;×BÒBÀ5ÑIÔIÐIøðJð $ DÔ$6Ô7ˆÝ˜'‘l”lˆàˆå˜$œ( JÑ/Ô/Ð/Ð/Ð/Ý�q˜+ zÑ2Ô2ð 	ð 	ˆAå�a˜*‘n kÑ2Ô2ˆCðð ð ð ð ð Ø/3¬{ðñ ô ˆKð	àœ,Ð1¨'�Ø%�d”h”o kÐMÐM¸7ÐMÀfÐMÐM�Ø—
’
˜3Ô+Ñ,Ô,Ð,Ð,øØ"ð ð ð Ý—’ØFÈÈ;ñô ð ð �øøøøð	øøøð
 ˆ
s*   ÂB8 Â8CÃCÊ%8KËLË#LÌLrN   ÚqueryÚkÚparamÚexprúList[Document]c           	     ó˜   — | j         €t                               d¦  «         g S | j        p|} | j        d|||||dœ|¤Ž}d„ |D ¦   «         S )an  Perform a similarity search against the query string.

        Args:
            query (str): The text to search.
            k (int, optional): How many results to return. Defaults to 4.
            param (dict, optional): The search params for the index type.
                Defaults to None.
            expr (str, optional): Filtering expression. Defaults to None.
            timeout (int, optional): How long to wait before timeout error.
                Defaults to None.
            kwargs: Collection.search() keyword arguments.

        Returns:
            List[Document]: Document results for search.
        Nú!No existing collection to search.)r   r  r  r  r,   c                ó   — g | ]\  }}|‘ŒS r‡   r‡   ©râ   ÚdocÚ_s      ry   rç   z,Milvus.similarity_search.<locals>.<listcomp>�  ó   € Ð&Ð&Ð&™˜˜Q�Ð&Ð&Ð&r   r‡   )rr   r‹   rŽ   r,   Úsimilarity_search_with_score)rx   r   r  r  r  r,   rÜ   rþ   s           ry   Úsimilarity_searchzMilvus.similarity_search~  sw   € ð0 Œ8ÐÝ�LŠLÐ<Ñ=Ô=Ð=ØˆIØ”,Ð) 'ˆØ/ˆdÔ/ð 
Ø˜1 E°¸gð
ð 
ØIOð
ð 
ˆð 'Ð& #Ð&Ñ&Ô&Ð&r   Ú	embeddingúList[float]c           	     ó˜   — | j         €t                               d¦  «         g S | j        p|} | j        d|||||dœ|¤Ž}d„ |D ¦   «         S )a†  Perform a similarity search against the query string.

        Args:
            embedding (List[float]): The embedding vector to search.
            k (int, optional): How many results to return. Defaults to 4.
            param (dict, optional): The search params for the index type.
                Defaults to None.
            expr (str, optional): Filtering expression. Defaults to None.
            timeout (int, optional): How long to wait before timeout error.
                Defaults to None.
            kwargs: Collection.search() keyword arguments.

        Returns:
            List[Document]: Document results for search.
        Nr  ©r  r  r  r  r,   c                ó   — g | ]\  }}|‘ŒS r‡   r‡   r  s      ry   rç   z6Milvus.similarity_search_by_vector.<locals>.<listcomp>¾  r  r   r‡   )rr   r‹   rŽ   r,   Ú&similarity_search_with_score_by_vector)rx   r  r  r  r  r,   rÜ   rþ   s           ry   Úsimilarity_search_by_vectorz"Milvus.similarity_search_by_vectorŸ  sw   € ð0 Œ8ÐÝ�LŠLÐ<Ñ=Ô=Ð=ØˆIØ”,Ð) 'ˆØ9ˆdÔ9ð 
Ø 1¨E¸Àgð
ð 
ØQWð
ð 
ˆð 'Ð& #Ð&Ñ&Ô&Ð&r   úList[Tuple[Document, float]]c           	     ó¸   — | j         €t                               d¦  «         g S | j                             |¦  «        }| j        p|} | j        d|||||dœ|¤Ž}|S )aJ  Perform a search on a query string and return results with score.

        For more information about the search parameters, take a look at the pymilvus
        documentation found here:
        https://milvus.io/api-reference/pymilvus/v2.2.6/Collection/search().md

        Args:
            query (str): The text being searched.
            k (int, optional): The amount of results to return. Defaults to 4.
            param (dict): The search params for the specified index.
                Defaults to None.
            expr (str, optional): Filtering expression. Defaults to None.
            timeout (float, optional): How long to wait before timeout error.
                Defaults to None.
            kwargs: Collection.search() keyword arguments.

        Returns:
            List[float], List[Tuple[Document, any, any]]:
        Nr  r  r‡   )rr   r‹   rŽ   rh   rå   r,   r  )	rx   r   r  r  r  r,   rÜ   r  rþ   s	            ry   r  z#Milvus.similarity_search_with_scoreÀ  s€   € ð8 Œ8ÐÝ�LŠLÐ<Ñ=Ô=Ð=ØˆIð Ô'×3Ò3°EÑ:Ô:ˆ	Ø”,Ð) 'ˆØ9ˆdÔ9ð 
Ø 1¨E¸Àgð
ð 
ØQWð
ð 
ˆð ˆ
r   c                ó   ‡— | j         €t                               d¦  «         g S |€| j        }| j        dd…         }|                     | j        ¦  «         | j        p|} | j         j        d|g| j        |||||dœ|¤Ž}g }	|d         D ]CŠˆfd„|D ¦   «         }
|  	                    |
¦  «        }|‰j
        f}|	                     |¦  «         ŒD|	S )ah  Perform a search on a query string and return results with score.

        For more information about the search parameters, take a look at the pymilvus
        documentation found here:
        https://milvus.io/api-reference/pymilvus/v2.2.6/Collection/search().md

        Args:
            embedding (List[float]): The embedding vector being searched.
            k (int, optional): The amount of results to return. Defaults to 4.
            param (dict): The search params for the specified index.
                Defaults to None.
            expr (str, optional): Filtering expression. Defaults to None.
            timeout (float, optional): How long to wait before timeout error.
                Defaults to None.
            kwargs: Collection.search() keyword arguments.

        Returns:
            List[Tuple[Document, float]]: Result doc and score.
        Nr  ©ÚdataÚ
anns_fieldr  Úlimitr  Úoutput_fieldsr,   r   c                óF   •— i | ]}|‰j                              |¦  «        “ŒS r‡   ©Úentityrˆ   ©râ   r½   Úresults     €ry   ú
<dictcomp>zAMilvus.similarity_search_with_score_by_vector.<locals>.<dictcomp>  ó+   ø€ ÐCÐCÐC°�A�v”}×(Ò(¨Ñ+Ô+ÐCÐCÐCr   r‡   )rr   r‹   rŽ   r8   rn   Úremoverk   r,   ÚsearchÚ_parse_documentÚscorer±   )rx   r  r  r  r  r,   rÜ   r  rþ   Úretr  r	  Úpairr!  s                @ry   r  z-Milvus.similarity_search_with_score_by_vectorè  s  ø€ ð8 Œ8ÐÝ�LŠLÐ<Ñ=Ô=Ð=ØˆIàˆ=ØÔ&ˆEð œ A A AœˆØ×Ò˜TÔ/Ñ0Ô0Ð0Ø”,Ð) 'ˆàˆdŒhŒoð 	
Ø�ØÔ)ØØØØ'Øð	
ð 	
ð ð	
ð 	
ˆð ˆØ˜!”fð 	ð 	ˆFØCÐCÐCÐC°]ÐCÑCÔCˆDØ×&Ò& tÑ,Ô,ˆCØ˜œÐ&ˆDØ�JŠJ�tÑÔÐÐàˆ
r   é   ç      à?Úfetch_kÚlambda_multÚfloatc                ó¸   — | j         €t                               d¦  «         g S | j                             |¦  «        }	| j        p|} | j        d|	||||||dœ|¤ŽS )aï  Perform a search and return results that are reordered by MMR.

        Args:
            query (str): The text being searched.
            k (int, optional): How many results to give. Defaults to 4.
            fetch_k (int, optional): Total results to select k from.
                Defaults to 20.
            lambda_mult: 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
            param (dict, optional): The search params for the specified index.
                Defaults to None.
            expr (str, optional): Filtering expression. Defaults to None.
            timeout (float, optional): How long to wait before timeout error.
                Defaults to None.
            kwargs: Collection.search() keyword arguments.


        Returns:
            List[Document]: Document results for search.
        Nr  )r  r  r,  r-  r  r  r,   r‡   )rr   r‹   rŽ   rh   rå   r,   Ú'max_marginal_relevance_search_by_vector)
rx   r   r  r,  r-  r  r  r,   rÜ   r  s
             ry   Úmax_marginal_relevance_searchz$Milvus.max_marginal_relevance_search$  s‡   € ðB Œ8ÐÝ�LŠLÐ<Ñ=Ô=Ð=ØˆIàÔ'×3Ò3°EÑ:Ô:ˆ	Ø”,Ð) 'ˆØ;ˆtÔ;ð 	
ØØØØ#ØØØð	
ð 	
ð ð	
ð 	
ð 		
r   úlist[float]c                ó>  ‡ ‡‡— ‰ j         €t                               d¦  «         g S |€‰ j        }‰ j        dd…         }	|	                     ‰ j        ¦  «         ‰ j        p|} ‰ j         j        d|g‰ j        ||||	|dœ|¤Ž}
g }g }g }|
d         D ]nŠˆfd„|	D ¦   «         }‰  	                    |¦  «        }| 
                    |¦  «         | 
                    ‰j        ¦  «         | 
                    ‰j        ¦  «         Œo‰ j                              ‰ j        › d|› �‰ j        ‰ j        g|¬¦  «        Šˆ fd„‰D ¦   «         Šˆfd	„|D ¦   «         }t          t!          j        |¦  «        |||¬
¦  «        }g }|D ]%}|dk    r n| 
                    ||         ¦  «         Œ&|S )aþ  Perform a search and return results that are reordered by MMR.

        Args:
            embedding (str): The embedding vector being searched.
            k (int, optional): How many results to give. Defaults to 4.
            fetch_k (int, optional): Total results to select k from.
                Defaults to 20.
            lambda_mult: 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
            param (dict, optional): The search params for the specified index.
                Defaults to None.
            expr (str, optional): Filtering expression. Defaults to None.
            timeout (float, optional): How long to wait before timeout error.
                Defaults to None.
            kwargs: Collection.search() keyword arguments.

        Returns:
            List[Document]: Document results for search.
        Nr  r  r   c                óF   •— i | ]}|‰j                              |¦  «        “ŒS r‡   r  r   s     €ry   r"  zBMilvus.max_marginal_relevance_search_by_vector.<locals>.<dictcomp>‘  r#  r   ú in )r  r  r,   c                óB   •— i | ]}|‰j                  |‰j                 “ŒS r‡   )ri   rk   ræ   s     €ry   r"  zBMilvus.max_marginal_relevance_search_by_vector.<locals>.<dictcomp>�  s+   ø€ ÐRÐRÐRÀQ�1�TÔ(Ô)¨1¨TÔ-?Ô+@ÐRÐRÐRr   c                ó    •— g | ]
}‰|         ‘ŒS r‡   r‡   )râ   r½   rú   s     €ry   rç   zBMilvus.max_marginal_relevance_search_by_vector.<locals>.<listcomp>Ÿ  s   ø€ Ð$=Ð$=Ð$=°A W¨Q¤ZÐ$=Ð$=Ð$=r   )r  r-  éÿÿÿÿr‡   )rr   r‹   rŽ   r8   rn   r$  rk   r,   r%  r&  r±   r'  Úidr   ri   r   ÚnpÚarray)rx   r  r  r,  r-  r  r  r,   rÜ   r  rþ   rÖ   Ú	documentsÚscoresr  r	  Úordered_result_embeddingsÚnew_orderingr(  r½   r!  rú   s   `                   @@ry   r0  z.Milvus.max_marginal_relevance_search_by_vectorV  s  øøø€ ð@ Œ8ÐÝ�LŠLÐ<Ñ=Ô=Ð=ØˆIàˆ=ØÔ&ˆEð œ A A AœˆØ×Ò˜TÔ/Ñ0Ô0Ð0Ø”,Ð) 'ˆàˆdŒhŒoð 	
Ø�ØÔ)ØØØØ'Øð	
ð 	
ð ð	
ð 	
ˆð ˆØˆ	ØˆØ˜!”fð 	"ð 	"ˆFØCÐCÐCÐC°]ÐCÑCÔCˆDØ×&Ò& tÑ,Ô,ˆCØ×Ò˜SÑ!Ô!Ð!Ø�MŠM˜&œ,Ñ'Ô'Ð'Ø�JŠJ�v”yÑ!Ô!Ð!Ð!à”(—.’.ØÔ'Ð2Ð2¨SÐ2Ð2ØÔ.°Ô0BÐCØð !ñ 
ô 
ˆð SÐRÐRÐRÈ'ÐRÑRÔRˆà$=Ð$=Ð$=Ð$=¸Ð$=Ñ$=Ô$=Ð!õ 2ÝŒH�YÑÔÐ!:¸aÈ[ð
ñ 
ô 
ˆð
 ˆØð 	)ð 	)ˆAà�BŠwˆwØ�à—
’
˜9 Qœ<Ñ(Ô(Ð(Ð(Øˆ
r   r   c                ó
  — t          |t          ¦  «        r<t          |¦  «        dk    r)|�t                               d¦  «         | j        › d|› �}nt          |t          ¦  «        s
J d¦   «         ‚ | j        j        dd|i|¤ŽS )ao  Delete by vector ID or boolean expression.
        Refer to [Milvus documentation](https://milvus.io/docs/delete_data.md)
        for notes and examples of expressions.

        Args:
            ids: List of ids to delete.
            expr: Boolean expression that specifies the entities to delete.
            kwargs: Other parameters in Milvus delete api.
        r   Nz>Both ids and expr are provided. Ignore expr and delete by ids.r5  z0Either ids list or expr string must be provided.r  r‡   )	ru   r¡   r°   r‹   Úwarningri   r0   rr   Údelete)rx   rÖ   r  rÜ   s       ry   rB  zMilvus.delete°  s¥   € õ �c�4Ñ Ô ð 		¥S¨¡X¤X°¢\ \ØÐÝ—’ØTñô ð ð Ô)Ð4Ð4¨sÐ4Ð4ˆDˆDå˜d¥CÑ(Ô(ð ð ØBñô Ð(ð ˆtŒxŒÐ3Ð3 DÐ3¨FÐ3Ð3Ð3r   údict[str, Any]c
               ó²   — t          |
t          ¦  «        rt          |
¦  «        dk    rd}nd} | d|||||||	|dœ|¤Ž}|                     |||
¬¦  «         |S )a¡  Create a Milvus collection, indexes it with HNSW, and insert data.

        Args:
            texts (List[str]): Text data.
            embedding (Embeddings): Embedding function.
            metadatas (Optional[List[dict]]): Metadata for each text if it exists.
                Defaults to None.
            collection_name (str, optional): Collection name to use. Defaults to
                "LangChainCollection".
            connection_args (dict[str, Any], optional): Connection args to use. Defaults
                to DEFAULT_MILVUS_CONNECTION.
            consistency_level (str, optional): Which consistency level to use. Defaults
                to "Session".
            index_params (Optional[dict], optional): Which index_params to use. Defaults
                to None.
            search_params (Optional[dict], optional): Which search params to use.
                Defaults to None.
            drop_old (Optional[bool], optional): Whether to drop the collection with
                that name if it exists. Defaults to False.
            ids (Optional[List[str]]): List of text ids. Defaults to None.

        Returns:
            Milvus: Milvus Vector Store
        r   FT)r.   r/   r4   r5   r6   r8   r9   r;   )r×   r˜   rÖ   r‡   )ru   r¡   r°   rÿ   )Úclsr×   r  r˜   r/   r4   r5   r6   r8   r9   rÖ   rÜ   r;   Ú	vector_dbs                 ry   Ú
from_textszMilvus.from_textsÈ  s‘   € õP �c�4Ñ Ô ð 	¥S¨¡X¤X°¢\ \ØˆGˆGàˆGà�Cð 

Ø(Ø+Ø+Ø/Ø%Ø'ØØð

ð 

ð ð

ð 

ˆ	ð 	×Ò %°9À#ÐÑFÔFÐFØÐr   r  r   c                ó–   — t          |                     | j        ¦  «        | j        r|                     | j        ¦  «        n|¬¦  «        S )N)Úpage_contentÚmetadata)r   Úpoprj   rl   )rx   r  s     ry   r&  zMilvus._parse_document  sK   € ÝØŸš $Ô"2Ñ3Ô3Ø7;Ô7KÐU�T—X’X˜dÔ2Ñ3Ô3Ð3ÐQUð
ñ 
ô 
ð 	
r   úList[int] | Nonec                ó  ‡ — ddl m} ‰ j        €t                               d¦  «         dS 	 ‰ j                             |‰ j        g¬¦  «        }n0# |$ r(}t                               d‰ j        |¦  «         |‚d}~ww xY wˆ fd„|D ¦   «         }|S )zÇGet primary keys with expression

        Args:
            expr: Expression - E.g: "id in [1, 2]", or "title LIKE 'Abc%'"

        Returns:
            List[int]: List of IDs (Primary Keys)
        r   ©r‚   Nz!No existing collection to get pk.)r  r  zFailed to get ids: %s error: %sc                óD   •— g | ]}|                      ‰j        ¦  «        ‘ŒS r‡   )rˆ   ri   )râ   Úitemrx   s     €ry   rç   z"Milvus.get_pks.<locals>.<listcomp>   s(   ø€ ÐFÐFÐF°ˆt�xŠx˜Ô+Ñ,Ô,ÐFÐFÐFr   )	re   r‚   rr   r‹   rŽ   r   ri   rŒ   r/   )rx   r  rÜ   r‚   Úquery_resultÚexcrü   s   `      ry   Úget_pkszMilvus.get_pks	  sÅ   ø€ ð 	-Ð,Ð,Ð,Ð,Ð,àŒ8ÐÝ�LŠLÐ<Ñ=Ô=Ð=Ø�4ð	Øœ8Ÿ>š>Ø¨$Ô*=Ð)>ð *ñ ô ˆLˆLøð ð 	ð 	ð 	Ý�LŠLÐ:¸DÔ<PÐRUÑVÔVÐVØˆIøøøøð	øøøð GÐFÐFÐF¸ÐFÑFÔFˆØˆ
s   ¬"A ÁA<Á#A7Á7A<r<  úList[Document] | NoneúList[str] | Nonec                ób  — ddl m} |�t          |¦  «        dk    rt                               d¦  «         dS |�7t          |¦  «        r(||d<   	 |                      |¬¦  «         n# |$ r Y nw xY w	  | j        d	d|i|¤ŽS # |$ r(}t                               d| j        |¦  «         |‚d}~ww xY w)
a"  Update/Insert documents to the vectorstore.

        Args:
            ids: IDs to update - Let's call get_pks to get ids with expression 

            documents (List[Document]): Documents to add to the vectorstore.

        Returns:
            List[str]: IDs of the added texts.
        r   rN  NzNo documents to upsert.rÖ   rÕ   r<  z'Failed to upsert entities: %s error: %sr‡   )	re   r‚   r°   r‹   rŽ   rB  Úadd_documentsrŒ   r/   )rx   rÖ   r<  rÜ   r‚   rR  s         ry   ÚupsertzMilvus.upsert#  s  € ð  	-Ð,Ð,Ð,Ð,Ð,àÐ¥ I¡¤°!Ò 3Ð 3Ý�LŠLÐ2Ñ3Ô3Ð3Ø�4àˆ?�s 3™xœxˆ?ØˆF�5‰MðØ—’ �Ñ$Ô$Ð$Ð$øØ"ð ð ð Ø�ðøøøð	Ø%�4Ô%ÐDÐD°	ÐD¸VÐDÐDÐDøØð 	ð 	ð 	Ý�LŠLØ9¸4Ô;OÐQTñô ð ð ˆIøøøøð		øøøs*   ÁA& Á&A.Á-A.Á2B ÂB.Â#B)Â)B.)	r   r   NNr    NNFF)&r.   r   r/   r0   r1   r0   r2   r3   r4   r3   r5   r0   r6   r7   r8   r7   r9   r:   r;   r<   r%   r0   r&   r0   r'   r0   r(   r=   r)   r=   r*   r>   r+   r?   r,   r@   r-   rA   )r{   r   )r4   r€   r{   r0   )NNNr$   N)r~   r>   r˜   r™   r*   r>   r+   r?   r,   r@   r{   rš   r}   )r~   r¡   r˜   r™   r{   rš   )r{   rš   )r{   r3   )Nr$   N)r*   r>   r+   r?   r,   r@   r{   rš   )NNrÔ   )r×   rØ   r˜   rÙ   r,   r@   rÚ   r?   rÖ   rÛ   rÜ   r   r{   rÝ   )rN   NNN)r   r0   r  r?   r  r7   r  r=   r,   r@   rÜ   r   r{   r  )r  r  r  r?   r  r7   r  r=   r,   r@   rÜ   r   r{   r  )r   r0   r  r?   r  r7   r  r=   r,   r@   rÜ   r   r{   r  )r  r  r  r?   r  r7   r  r=   r,   r@   rÜ   r   r{   r  )rN   r*  r+  NNN)r   r0   r  r?   r,  r?   r-  r.  r  r7   r  r=   r,   r@   rÜ   r   r{   r  )r  r2  r  r?   r,  r?   r-  r.  r  r7   r  r=   r,   r@   rÜ   r   r{   r  )NN)rÖ   rÛ   r  r=   rÜ   r   r{   r   )r×   rÝ   r  r   r˜   rÙ   r/   r0   r4   rC  r5   r0   r6   r7   r8   r7   r9   r<   rÖ   rÛ   rÜ   r   r{   r   )r  r€   r{   r   )r  r0   rÜ   r   r{   rL  )rÖ   rÛ   r<  rT  rÜ   r   r{   rU  )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rz   Úpropertyr~   rp   rw   rœ   r�   rÂ   rž   rŸ   r    rÿ   r  r  r  r  r1  r0  rB  Úclassmethodro   rG  r&  rS  rX  r‡   r   ry   r   r      su  € € € € € ðWð Wðx  5Ø&(Ø:>Ø48Ø!*Ø'+Ø(,Ø#(Øðj
ð "Ø Ø$Ø(,Ø-1Ø*.ØØ#'Ø$(ð+j
ð j
ð j
ð j
ð j
ð j
ðX ð#ð #ð #ñ „Xð#ð8ð 8ð 8ð 8ðx &*Ø*.Ø*.ØØ#'ð
ð 
ð 
ð 
ð 
ð( CGðeð eð eð eð eðN+ð +ð +ð +ðð ð ð ð+ð +ð +ð +ðZ
@ð 
@ð 
@ð 
@ð +/ØØ#'ð	ð ð ð ð ð4 +/Ø#'Øðyð $(ðyð yð yð yð yð yð| Ø $Ø"Ø#'ð'ð 'ð 'ð 'ð 'ðH Ø $Ø"Ø#'ð'ð 'ð 'ð 'ð 'ðH Ø $Ø"Ø#'ð&ð &ð &ð &ð &ðV Ø $Ø"Ø#'ð:ð :ð :ð :ð :ð~ ØØ Ø $Ø"Ø#'ð0
ð 0
ð 0
ð 0
ð 0
ðj ØØ Ø $Ø"Ø#'ðXð Xð Xð Xð Xðv FJð4ð 4ð 4ð 4ð 4ð0 ð
 +/Ø4Ø*CØ!*Ø'+Ø(,Øð8ð $(ð8ð 8ð 8ð 8ð 8ñ „[ð8ðt
ð 
ð 
ð 
ðð ð ð ð8 $(Ø+/ð"ð "ð "ð "ð "ð "ð "r   r   ) Ú
__future__r   ÚloggingÚtypingr   r   r   r   r   r	   r
   Úuuidr   Únumpyr:  Úlangchain_core._api.deprecationr   Úlangchain_core.documentsr   Úlangchain_core.embeddingsr   Úlangchain_core.vectorstoresr   Ú&langchain_community.vectorstores.utilsr   Úpymilvus.orm.mutationr   Ú	getLoggerrY  r‹   ro   r   r‡   r   ry   ú<module>rk     s  ðØ "Ð "Ð "Ð "Ð "Ð "à €€€Ø MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MØ Ð Ð Ð Ð Ð à Ð Ð Ð Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø -Ð -Ð -Ð -Ð -Ð -Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3à MÐ MÐ MÐ MÐ MÐ Màð 5Ø4Ð4Ð4Ð4Ð4Ð4à	ˆÔ	˜8Ñ	$Ô	$€ð ØØØØðð Ð ð €Ø
ØØ;ðñ ô ð
cð cð cð cð cˆ[ñ cô cñô ð
cð cð cr   