
    dh                    ,   % S SK Jr  S SKrS SKrS SKrS SKrS SKJr  S SKJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJr  S SKrS SKJr  S SKJr  S SKJr  S SKJr  S S	K J!r!  \	(       a  S SK"r"\S
   r#\$" \" \#5      5      r%S\&S'   \S   r'\$" \" \'5      5      r(S\&S'   Sr)Sr*Sr+\+S-  r,/ SQr-/ SQr.SS0 /r/\R`                  " \15      r2S/S jr3S0S jr4S1S jr5S2S3S jjr6\" SSSS9 " S S \5      5       r7       S4                   S5S! jjr8         S6                       S7S" jjr9      S8S# jr:S$/ S4         S9S% jjr;S:S& jr<S;S' jr=S<S( jr>S=S) jr?        S>S* jr@S?S+ jrA  S@       SAS, jjrBSBS- jrCSCS. jrDg)D    )annotationsN)deepcopy)TYPE_CHECKINGAnyCallableDictIterableListLiteralOptionalSizedTupleTypeUnionget_args)
deprecated)Document)
Embeddings)VectorStore)maximal_marginal_relevance)L2IPzList[DISTANCE_METRICS]AVAILABLE_DISTANCE_METRICS)TileDBDenseTileDBSparse	FaissFlatFaissIVFFlatFlinngzList[ENGINES]AVAILABLE_ENGINES	langchain          )	_distanceidcontent)r$   r&   blobzMissing propertyc                    [        U [        5      (       a[  [        U[        5      (       aF  [        U 5      [        U5      :w  a.  [        U SU SU S[        U 5       SU S[        U5       35      eg)z
Check that sizes of two variables are the same

Args:
    x: Variable to compare
    y: Variable to compare
    x_name: Name for variable x
    y_name: Name for variable y
z and z% expected to be equal length but len(z)=z	 and len(N)
isinstancer   len
ValueError)xyx_namey_names       ]/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/vectorstores/vdms.py_len_check_if_sizedr1   ?   ss     !U
1e 4 4Q3q69IheF8 $("SVHIfXRAxA
 	
     c                L    [        U 5       VVs/ sH  u  pUPM	     snn$ s  snnf N)_results_to_docs_and_scores)resultsdoc_s      r0   _results_to_docsr9   Q   s#    9'BCBFCCBCCCs    c                   / n U S   u  p#[        U5      S:  a  SUS   ;   a  SUS   S   ;   a  US   S   S   nU Hv  n[        US   S5      nUS   n[         H  nX;   d  M
  XX	 M     UR                  5        V	V
s0 sH  u  pU
[        ;  d  M  X_M     nn	n
UR                  [        X{S9U45        Mx     U$ s  sn
n	f ! [         a#  n[        R                  SU 35         S nAU$ S nAff = f)	Nr   FindDescriptorentitiesr$   
   r&   )page_contentmetadataz2No results returned. Error while parsing results: )
r*   roundINVALID_DOC_METADATA_KEYSitemsINVALID_METADATA_VALUEappendr   	Exceptionloggerwarning)r6   	final_res	responsesblobsresult_entitiesentdistancetxt_contentspmkeymvalpropses                r0   r5   r5   U   s$   IQ"1:		NQ IaL0il+;<<'l+;<ZHO& [!126"9~2AxF 3
 '*iik&1
#99 DJ&1      lK  '(   QKA3OPPQs6   AB> #B> <B8B8!B> 8B> >
C+C&&C+c                     SSK nUR                   " 5       nUR                  X5        U$ ! [         a    [        S5      ef = f)zyVDMS client for the VDMS server.

Args:
    host: IP or hostname of VDMS server
    port: Port to connect to VDMS server
r   NzOCould not import vdms python package. Please install it with `pip install vdms.)vdmsImportErrorconnect)hostportrU   clients       r0   VDMS_Clientr[   w   sK    
 YY[F
NN4M  
8
 	

s	   * A z0.3.18z1.0.0zlangchain_vdms.VDMS)sinceremovalalternative_importc                     \ rS rSrSrS\SSSSS.               S5S jjr\S6S j5       rS7S	 jr	S8S
 jr
S9S jrS:S jrS;S jr\\S4           S<S jjr  S=           S>S jjr  S?       S@S jjr  S=       SAS jjr    SB           SCS jjr  SD       SES jjr/ S4       SFS jjr SG           SHS jjr        SIS jrSS\S4             SJS jjr     SK               SLS jjrSS\4           SMS jjrS\4             SNS jjr      SOS jrSPS jrSQS  jr    SR         SSS! jjr!   ST           SUS" jjr"\\SSSS4                 SVS# jjr#SWS$ jr$\%SS\\4               SXS% jj5       r&\%SSS\\4                 SYS& jj5       r'SSS/4         SZS' jjr(\\S(S4             S[S) jjr)\\S(S4             S\S* jjr*\\S(S4             S]S+ jjr+\\S(S4             S^S, jjr,SS\\SSS4                 S_S- jjr-\\S4           S`S. jjr.\\S4           SaS/ jjr/\\S4           SbS0 jjr0\\S4           ScS1 jjr1        SdS2 jr2        SeS3 jr3S4r4g)fVDMS   a  Intel Lab's VDMS for vector-store workloads.

To use, you should have both:
- the ``vdms`` python package installed
- a host (str) and port (int) associated with a deployed VDMS Server

Visit https://github.com/IntelLabs/vdms/wiki more information.

IT IS HIGHLY SUGGESTED TO NORMALIZE YOUR DATA.

Args:
    client: VDMS Client used to connect to VDMS server
    collection_name: Name of data collection [Default: langchain]
    distance_strategy: Method used to calculate distances. VDMS supports
        "L2" (euclidean distance) or "IP" (inner product) [Default: L2]
    engine: Underlying implementation for indexing and computing distances.
        VDMS supports TileDBDense, TileDBSparse, FaissFlat, FaissIVFFlat,
        and Flinng [Default: FaissFlat]
    embedding: Any embedding function implementing
        `langchain_core.embeddings.Embeddings` interface.
    relevance_score_fn: Function for obtaining relevance score

Example:
    .. code-block:: python

        from langchain_huggingface import HuggingFaceEmbeddings
        from langchain_community.vectorstores.vdms import VDMS, VDMS_Client

        model_name = "sentence-transformers/all-mpnet-base-v2"
        vectorstore = VDMS(
            client=VDMS_Client("localhost", 55555),
            embedding=HuggingFaceEmbeddings(model_name=model_name),
            collection_name="langchain-demo",
            distance_strategy="L2",
            engine="FaissFlat",
        )
Nr   r   )	embeddingcollection_namedistance_strategyenginerelevance_score_fnembedding_dimensionsc                   Xl         XPl        X@l        X l        U R	                  X75        X`l        U R                  UU R                  U R                  S9U l        g )Nre   metric)_clientsimilarity_search_enginerd   rb   _check_required_inputsoverride_relevance_score_fnadd_set_collection_name)selfrZ   rb   rc   rd   re   rf   rg   s           r0   __init__VDMS.__init__   s]     (.%!2"##OJ ,>( !%00)) !- !
r2   c                    U R                   $ r4   )rb   rq   s    r0   
embeddingsVDMS.embeddings   s    ~~r2   c                    [        U R                  [        5      (       a  U R                  R                  U5      $ SnUS-  n[	        U5      e)Nz*Must provide `embedding` which is expectedz to be an Embeddings object)r)   rb   r   embed_documentsr+   )rq   textsp_strs      r0   _embed_documentsVDMS._embed_documents   sC    dnnj11>>11%88@E22EU##r2   c                    U R                   b9  [        U R                   S5      (       a  U R                   R                  " SSU0UD6$ [        S5      e)Nembed_videopathsz:Must provide `embedding` which has attribute `embed_video` )rb   hasattrr   r+   )rq   r   kwargss      r0   _embed_videoVDMS._embed_video   sI    >>%'$..-*P*P>>--DEDVDDL r2   c                    U R                   b4  [        U R                   S5      (       a  U R                   R                  US9$ [        S5      e)Nembed_imageurisz:Must provide `embedding` which has attribute `embed_image`)rb   r   r   r+   )rq   r   s     r0   _embed_imageVDMS._embed_image   sD    >>%'$..-*P*P>>--4-88L r2   c                    [        U R                  [        5      (       a  U R                  R                  U5      $ [	        S5      e)NzEMust provide `embedding` which is expected to be an Embeddings object)r)   rb   r   embed_queryr+   )rq   texts     r0   _embed_queryVDMS._embed_query   s8    dnnj11>>--d33W r2   c                    U R                   b  U R                   $ U R                  R                  5       S;   a  S $ [        SU R                   S35      e)a   
The 'correct' relevance function
may differ depending on a few things, including:
- the distance / similarity metric used by the VectorStore
- the scale of your embeddings (OpenAI's are unit normed. Many others are not!)
- embedding dimensionality
- etc.
)ipl2c                    U $ r4   r   )r,   s    r0   <lambda>1VDMS._select_relevance_score_fn.<locals>.<lambda>  s    Qr2   z=No supported normalization function for distance_strategy of z;.Consider providing relevance_score_fn to VDMS constructor.)rn   rd   lowerr+   ru   s    r0   _select_relevance_score_fnVDMS._select_relevance_score_fn   sf     ++7333 !!'')\9--1-C-C,D EMM r2   c                    U R                   c  SUS'   U R                  " SUUUUS.UD6n/ nU HH  u  pU R                   c  UR                  X45        M&  UR                  UU R                  U	5      45        MJ     U$ )z?Return docs and their similarity scores on a scale from 0 to 1.Tnormalize_distance)querykfetch_kfilterr   )rn   similarity_search_with_scorerD   )
rq   r   r   r   r   r   docs_and_scoresdocs_and_rel_scoresr7   scores
             r0   (_similarity_search_with_relevance_scores-VDMS._similarity_search_with_relevance_scores
  s     ++3+/F'(;; 
	

 
 *,)JC//7#**C<8#**88?	 * #"r2   c           	        [        X#SS5        Ub  UOU Vs/ sH  nS PM     snn[        X$SS5        Ub  UO-U Vs/ sH!  n[        [        R                  " 5       5      PM#     snn[        X%SS5        / n/ n/ n	[	        XCX%5       HQ  u  ppU R                  XXUS9u  pUc  M  UR                  U5        UR                  U5        U	R                  U5        MS     U R                  Xx5      u  nnU	$ s  snf s  snf )Nrz   rv   	metadatasidsr?   rb   documentr%   )r1   struuiduuid4zip_VDMS__get_add_queryrD   _VDMS__run_vdms_query)rq   rc   rz   rv   r   r   r8   all_queries	all_blobsinserted_idsmetaembr7   r%   r   r'   responseresponse_arrays                     r0   addVDMS.add*  s    	EwE!*!6I5<Q5aT5<Q	Eg{C_ce*Le3tzz|+<e*LE7!#!	"$"%iU"HDs..#PR / KE ""5)  &##B' #I $(#8#8#P .+ =R +Ms
   C/'C4c                    [        SUU R                  [        USU5      [        USU5      S9nU R                  U/5      u  pVSUS   ;   a  [	        SU 35      eU$ )NAddDescriptorSetvalueri   FailedCommandr   zFailed to add collection )_add_descriptorsetembedding_dimensiongetattrr   r+   )rq   rc   re   rj   r   r   r8   s          r0   ro   VDMS.add_setK  sq     #$$67F367F3
 ++UG4hqk)88IJKKr2   c                *   / n/ nU R                  U5      nSU0nUc  SSS/0nOSS/US'   Ub
  SUS   /US'   [        SUSSSSSUUS	9	nUR                  U5        U R                  XE5      u  p[	        S
USS9nU R                  U/U5      u  pSU	S   ;   $ )z1
Deletes entire collection if id is not provided
listN	_deletion==   r   r%   r;   labelrefrR   linkk_neighborsconstraintsr6   FindDescriptorSetT)
storeIndex)_VDMS__get_properties_add_descriptorrD   r   r   )rq   rc   r   r   r   r   collection_propertiesr6   r   r   r   responseSetr8   s                r0   __deleteVDMS.__delete`  s     "$!	 $ 5 5o F01&q	2K(,ayK$?!%s1vK#

 	5!#'#8#8#P  #T
 ..w	B8A;..r2   r?   c                   Uc  0 nOwSU0n[        U R                  X5      u  pxU(       aT  US   S   R                  5        V	V
s0 sH
  u  pXS   _M     nn	n
SU S3nUS-  n[        U5        [        SU 35        US 4$ U(       a  UR	                  U5        US	;  a  XFS
'   UR                  5        H/  nXR                  ;  d  M  U R                  R                  U5        M1     [        SUS S US S S S S9	n[        U5      nUU4$ s  sn
n	f )Nr%   r;   r   z[!] Embedding with id (z) exists in DB;z#Therefore, skipped and not insertedz	Skipped values are: )N r&   AddDescriptorr   )
_check_descriptor_exists_by_idrk   rB   printupdatekeysr   rD   r   embedding2bytes)rq   rc   r?   rb   r   r%   rR   	id_existsr   prop_keyprop_valskipped_valuepstrr   r'   s                  r0   __get_add_queryVDMS.__get_add_query  sR    :$&E2JE=o I  /44D.E%/eg/!/* rl*/  ! 1OD==d.}o>?d{"LL":%')A222**11!4   

 y) 
 	
G!s   DFc                    [        XUS9nU R                  U/5      u  pV[        U5      S:  a  [        US   5      R	                  S5      nU$ [        [        5      nU$ )N)unique_entitydeletionr   ,)_find_property_entityr   r*   
_bytes2strsplitr   DEFAULT_PROPERTIES)rq   rc   r   r   
find_queryr   response_blobr   s           r0   __get_propertiesVDMS.__get_properties  sn     +8

 #'"7"7"E}!$.}Q/?$@$F$Fs$K! %$ %--?$@!$$r2   c                    U R                   R                  X5      u  pE[        X5      nU(       a  U R                   R                  5         XE4$ r4   )rk   r   _check_valid_responseprint_last_response)rq   r   r   r   r   r   r8   s          r0   __run_vdms_queryVDMS.__run_vdms_query  sA     $(<<#5#5k#M !+8LL,,.''r2   c                "   [        X#SS5        [        X$SS5        Ub  UOU Vs/ sH  nSPM     snn[        X%SS5        U R                  U5      n/ n[        XTX25       H  u  ppSU R                  0nSSS	/0nUb  SU/US
'   [	        SUSSSSSUUS9	nU R                  U/5      u  nnU R                  UU	U
UUS9u  nnUc  Me  U R                  U/U/5      u  nnUR                  U5        M     U R                  XU R                  5        gs  snf )zs
Updates (find, delete, add) a collection based on id.
If more than one collection returned with id, error occuers
r   	documentsrv   Nr   r   r   r   r   r%   r;   r   r   )	r1   r   r   r   r   r   r   rD   _VDMS__update_properties)rq   rc   r   r   rv   r   r8   
orig_propsupdated_idsr   r   r7   r%   r6   r   r   r   r   r'   s                      r0   __updateVDMS.__update  sZ    	CE;?CULA!*!6I3<O3aT3<O	CE;?**?;
!#"%iY"LDst99:G&q	2K~%)2JD!#  '
E (,'<'<eW'E$Hn.. / KE4 +/+@+@%4&+Q(.""2&? #MB 	  )C)C	
O =Ps   Dc                    UbT  [        U5      nU H  nXR;  d  M
  UR                  U5        M     X$:w  a"  [        USUS9u  pgU R                  Xg/5      u  pg g g )Nr   )command_typeall_properties)r   rD   _build_property_queryr   )
rq   rc   current_collection_propertiesnew_collection_propertiesold_collection_propertiespropr   blob_arrr   r8   s
             r0   __update_propertiesVDMS.__update_properties  su     %0(01N(O%1<188> 2 -I(=#!)#@)%
 #33KL! J 1r2   Tc           	        U Vs/ sH  opR                  US9PM     nnU(       a#  U(       a  [        U5       H  u  pXrU	   S'   M     O%U(       a  / nU H  nUR                  SU05        M     Ub  UO-U V
s/ sH!  n
[        [        R
                  " 5       5      PM#     sn
nU R                  US9nUc  U V
s/ sH  n
0 PM     nn
OU Vs/ sH  n[        U5      PM     nnU R                  " SUUUUUS.UD6  U$ s  snf s  sn
f s  sn
f s  snf )aA  Run more images through the embeddings and add to the vectorstore.

Images are added as embeddings (AddDescriptor) instead of separate
entity (AddImage) within VDMS to leverage similarity search capability

Args:
    uris: List of paths to the images to add to the vectorstore.
    metadatas: Optional list of metadatas associated with the images.
    ids: Optional list of unique IDs.
    batch_size (int): Number of concurrent requests to send to the server.
    add_path: Bool to add image path as metadata

Returns:
    List of ids from adding images into the vectorstore.
)
image_pathr	  r   rz   rv   r   r   
batch_sizer   )	encode_image	enumeraterD   r   r   r   r   _validate_vdms_propertiesadd_from)rq   r   r   r   r  add_pathr   uri	b64_textsmidxr8   rv   ms                r0   
add_imagesVDMS.add_images1  s#   2 CGG$3&&#&6$	G	&t_	03$- -I  ,!45  _cd*Kd3tzz|+<d*K &&D&1
%)*TTI*I?HIy!215yII 	
!!	
 	
 
; H +L +Is   C86'C=6DDc           	        Uc  U Vs/ sH  nSPM     nnU(       a#  U(       a  [        U5       H  u  pXU	   S'   M     O%U(       a  / nU H  n
UR                  SU
05        M     Ub  UO-U Vs/ sH!  n[        [        R                  " 5       5      PM#     snnU R
                  " SSU0UD6nUc  U Vs/ sH  n0 PM     nnU R                  " SUUUUUS.UD6  U$ s  snf s  snf s  snf )a~  Run videos through the embeddings and add to the vectorstore.

Videos are added as embeddings (AddDescriptor) instead of separate
entity (AddVideo) within VDMS to leverage similarity search capability

Args:
    paths: List of paths to the videos to add to the vectorstore.
    metadatas: Optional list of text associated with the videos.
    metadatas: Optional list of metadatas associated with the videos.
    ids: Optional list of unique IDs.
    batch_size (int): Number of concurrent requests to send to the server.
    add_path: Bool to add video path as metadata

Returns:
    List of ids from adding videos into the vectorstore.
r   
video_pathr   r
  r   )r  rD   r   r   r   r   r  )rq   r   rz   r   r   r  r  r   r8   r  pathrv   s               r0   
add_videosVDMS.add_videosi  s    4 =!&'ARE'	'.
04$- /I  ,!56  _ce*Le3tzz|+<e*L &&=U=f=
%*+UUI+ 	
!!	
 	
 
7 ( +M ,s   C-'C2C#c           	     J   [        U5      nUc-  U Vs/ sH!  n[        [        R                  " 5       5      PM#     nnU R	                  U5      nUc  U Vs/ sH  n0 PM     nnOU Vs/ sH  n[        U5      PM     nnU R                  " SUUUUUS.UD6n	U	$ s  snf s  snf s  snf )a{  Run more texts through the embeddings and add to the vectorstore.

Args:
    texts: List of strings to add to the vectorstore.
    metadatas: Optional list of metadatas associated with the texts.
    ids: Optional list of unique IDs.
    batch_size (int): Number of concurrent requests to send to the server.

Returns:
    List of ids from adding the texts into the vectorstore.
r
  r   )r   r   r   r   r|   r  r  )
rq   rz   r   r   r  r   r8   rv   r  r   s
             r0   	add_textsVDMS.add_texts  s    ( U;.34e3tzz|$eC4**51
%*+UUI+I?HIy!215yII}} 
!!
 
 # 5
 ,Is   'BB&B c           	     ~   U R                  U R                  5      n/ n[        S[        U5      U5       H_  n	[	        X-   [        U5      5      n
XU
 nX)U
 nX9U
 nU(       a  XIU
 nU R                  U R                  UUWUS9nUR                  U5        Ma     U R                  U R                  XpR                  5        U$ )Nr   )rv   rz   r   r   )	r   rp   ranger*   minr   extendr   r   )rq   rz   rv   r   r   r  r   r   r   	start_idxend_idxbatch_textsbatch_embedding_vectors	batch_idsbatch_metadatasresults                   r0   r  VDMS.add_from  s     **4+@+@A
"$q#e*j9I)0#e*=G'2K&07&C#g.I"+g">XX%%2!)  F '# :( 	  !!:/I/I	
 r2   c                   U R                   R                  5       (       d  [        S5      eU R                  [        ;  a  [        S5      eU R
                  [        ;  a  [        S5      eU R                  c  [        S5      eUb  X l        OU R                  b;  [        U R                  S5      (       a   [        U R                  S5      5      U l        OU R                  b  [        U R                  S5      (       d  [        U R                  S5      (       aW  [        U R                  S	5      (       a1   U R                  R                  R                  R                  U l        O[        S
5      eU R                  U5      n[        U S5      (       a  U R                   R#                  U5        g X0l        g ! [         a    [        S
5      ef = f)Nz_VDMS client must be connected to a VDMS server.Please use VDMS_Client to establish a connectionz-distance_strategy must be either 'L2' or 'IP'z]engine must be either 'TileDBDense', 'TileDBSparse', 'FaissFlat', 'FaissIVFFlat', or 'Flinng'Must provide embedding functionr   zThis is a sample sentence.r   r   modelz>Embedding dimension needed. Please define embedding_dimensionsr   )rk   is_connectedr+   rd   r   rl   r   rb   r   r   r*   r   r-  token_embeddingembedding_dimr   r   r"  )rq   rc   rg   current_propss       r0   rm   VDMS._check_required_inputs  s    ||((**E  !!)CCLMM ((0AA=  >>!>??+';$^^'GDNNM,R,R'*!!">?(D$ ^^'DNNM22t~~}55t~~w//,,<<JJ , !T 
 --o>4011&&--m<4A& " $X s   2/F2 2Gc                    / n/ nSS/S.n[        SUS S S S S S US9	nUR                  U5        U R                  X#5      u  pgUS   S   S   $ )Nr   r%   )countr   r;   r   r   returned)r   rD   r   )rq   rc   r   r   r6   r   r   r   s           r0   r4  
VDMS.count'  su    !#!	/

 	5!#'#8#8#P {+,Z88r2   c                .    [         R                  " U5      $ r4   )base64	b64decode)rq   base64_images     r0   decode_imageVDMS.decode_image=  s    --r2   c                D    Ub  UOU R                   nU R                  XQUS9$ )zDelete by ID. These are the IDs in the vectorstore.

Args:
    ids: List of ids to delete.

Returns:
    Optional[bool]: True if deletion is successful,
    False otherwise, None if not implemented.
)r   r   )rp   _VDMS__delete)rq   r   rc   r   r   names         r0   deleteVDMS.delete@  s)      #2"=4CXCX}}T}DDr2   c                    SnSn[        UUUUS9nU R                  U/U5      u  pU(       a  XyS   ;   a  U	S   U   S   S   S   nXU4$ )Nr   r;   )r   r6   r   r<   r   r$   )r   r   )rq   setnamer   r6   r   	normalizemax_distcommand_strr   r   r   s              r0   get_k_candidatesVDMS.get_k_candidatesS  sq     &	
 $(#8#8%)#L 3{;/
;B?LH11r2   c	                   / n	[        U5      n
U
b  U	R                  U
5        Uc  U R                  X#XiUS9u  pnGO<Uc  SS/0nO*SU;  a  S/US'   OSUS   ;  a  US   R                  S5        [        UUUUS9nU R	                  U/5      u  pXS   ;   a,  US   U   S   S:  a  US   U   S    Vs/ sH  oS   PM	     nnO/ / 4$ U R                  X$XiUS9u  pnXS   ;  d  XS   ;   a  US   U   S   S:X  a  / / 4$ / nUS   U   S    H.  nUS   U;   a  UR                  U5        [        U5      U:X  d  M.    O   UUS   U   S'   [        U5      US   U   S'   [        U5      U:  a  Sn[        U5        U(       aW  US[        R                  4;   a  S	OUn[        US   U   S   5       H%  u  nnUS
   U-  US
'   US
   US   U   S   U   S
'   M'     X4$ s  snf )N)rD  r   r%   r   r6   r   r5  r<   z4Returned items < k_neighbors; Try increasing fetch_kg      ?r$   )
r   rD   rG  r   r   r*   r   npinfr  )rq   rF  rC  r   r   r   r6   query_embeddingr   r   r'   r   r   rE  r   rL   ids_of_interestnew_entitiesr{   ent_idxs                       r0   get_descriptor_responseVDMS.get_descriptor_responsej  s     "	/T"151F1FgDV 2G 2.Hh !D6*w&#'&WV_,&&t, $'	E (,'<'<eW'E$Hqk)hqk+.Fz.RUV.V)1![)A*)M#)M#I)M   # 2v 261F1F'@R 2G 2.Hh 1+-{*x{;/G
/SWX/X2v (*L{;/
;t9/ '',|$3	 <
 4@HQK$Z036|3DHQK$Z0< ;.Ne&1bff+5s8H )(1+k*B:*N O#&{#3h#>K MPNK(4W=kJ !P ''I#s   2Gc                    [        US5       nUR                  5       n[        R                  " U5      R	                  S5      sS S S 5        $ ! , (       d  f       g = f)Nrbzutf-8)openreadr8  	b64encodedecode)rq   r	  fr'   s       r0   r  VDMS.encode_image  s>    *d#q668D##D)009 $##s   5A
Ac           
         US   nU R                  UU Vs/ sH  oR                  PM     snU Vs/ sH  oR                  PM     snUUUUS9$ s  snf s  snf )a  Create a VDMS vectorstore from a list of documents.

Args:
    collection_name (str): Name of the collection to create.
    documents (List[Document]): List of documents to add to vectorstore.
    embedding (Embeddings): Embedding function. Defaults to None.
    ids (Optional[List[str]]): List of document IDs. Defaults to None.
    batch_size (int): Number of concurrent requests to send to the server.

Returns:
    VDMS: VDMS vectorstore.
rZ   )rZ   rz   r   rb   r   r  rc   )
from_textsr>   r?   )	clsr   rb   r   r  rc   r   rZ   r7   s	            r0   from_documentsVDMS.from_documents  sc    , #8,~~/89y##y9/89y||y9!+  	
 		
99s
   A
Ac                    US   nU " UUUS9n	Uc-  U V
s/ sH!  n
[        [        R                  " 5       5      PM#     nn
U	R                  UUUUS9  U	$ s  sn
f )a  Create a VDMS vectorstore from a raw documents.

Args:
    texts (List[str]): List of texts to add to the collection.
    embedding (Embeddings): Embedding function. Defaults to None.
    metadatas (Optional[List[dict]]): List of metadatas. Defaults to None.
    ids (Optional[List[str]]): List of document IDs. Defaults to None.
    batch_size (int): Number of concurrent requests to send to the server.
    collection_name (str): Name of the collection to create.

Returns:
    VDMS: VDMS vectorstore.
rZ   )rc   rb   rZ   )rz   r   r   r  )r   r   r   r  )r]  rz   rb   r   r   r  rc   r   rZ   vdms_collectionr8   s              r0   r\  VDMS.from_texts  ss    0 #8,+
 ;.34e3tzz|$eC4!!!	 	" 	
  5s   'Ac                    / n/ nSS0nUb  X7S'   SU;   a  U R                  U5      nXS'   SU;   a  SUS	'   [        S
USUUS9n	UR                  U	5        U R                  XV5      u  pX4$ )a6  Gets the collection.
Get embeddings and their associated data from the data store.
If no constraints provided returns all embeddings up to limit.

Args:
    constraints: A dict used to filter results by.
           E.g. `{"color" : ["==", "red"], "price": [">", 4.00]}`. Optional.
    limit: The number of documents to return. Optional.
    include: A list of what to include in the results.
             Can contain `"embeddings"`, `"metadatas"`, `"documents"`.
             Ids are always included.
             Defaults to `["metadatas", "documents"]`. Optional.
r4  r   Nlimitr?   r   rv   Tr'   r;   )r   r   r6   )r   r   rD   r   )rq   rc   r   rd  includer   r   r6   r   r   r   r   s               r0   getVDMS.get  s    ( "$!	#*B-$G  $($9$9/$J!3FO 7""GFO#
 	5!#'#8#8#P ''r2   g      ?c                   U R                   c  [        S5      e[        R                  R	                  U5      (       d-  [        U R                   S5      (       a  U R                  U5      nO[        R                  R	                  U5      (       a/  [        U R                   S5      (       a  U R                  U/S9S   nOn[        R                  R	                  U5      (       a/  [        U R                   S5      (       a  U R                  U/S9S   nOSU S	3nUS
-  nUS-  n[        U5      eU R                  UUUUUS9n	U	$ a  Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.

Args:
    query (str): Query to look up. Text or path for image or video.
    k: Number of Documents to return. Defaults to 4.
    fetch_k: Number of Documents to fetch to pass to MMR algorithm.
    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.
    filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.

Returns:
    List of Documents selected by maximal marginal relevance.
zBFor MMR search, you must specify an embedding function oncreation.r   r   r   r   r   r   (Could not generate embedding for query ''.9If using path for image or video, verify embedding model 6has callable functions 'embed_image' or 'embed_video'.)lambda_multr   )
rb   r+   osr  isfiler   r   r   r   'max_marginal_relevance_search_by_vector)
rq   r   r   r   ro  r   r   embedding_vector	error_msgdocss
             r0   max_marginal_relevance_search"VDMS.max_marginal_relevance_search9  s*   4 >>!T  ww~~e$$)O)O#007WW^^E""wt~~}'M'M#00ug0>qAWW^^E""wt~~}'M'M#00w0?BB5'LITTIQQIY'';;# < 
 r2   c                   U R                  U/UU/ SQS9n[        US   S   5      S:X  a  / $ US   S    Vs/ sH  n[        [        U5      5      PM     n	n[	        [
        R                  " U[
        R                  S9U	UUS9n
[        U5      n[        U5       VVs/ sH  u  pX;   d  M  UPM     nnnU$ s  snf s  snnf a  Return docs selected using the maximal marginal relevance.
Maximal marginal relevance optimizes for similarity to query AND diversity
among selected documents.

Args:
    embedding: Embedding to look up documents similar to.
    k: Number of Documents to return. Defaults to 4.
    fetch_k: Number of Documents to fetch to pass to MMR algorithm.
    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.
    filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.

Returns:
    List of Documents selected by maximal marginal relevance.
)r   r   	distancesrv   )query_embeddings	n_resultsr   re  r   r   dtype)r   ro  )
query_collection_embeddingsr*   r   _bytes2embeddingr   rK  arrayfloat32r9   r  )rq   rb   r   r   ro  r   r   r6   r)  embedding_listmmr_selected
candidatesirselected_resultss                  r0   rr  ,VDMS.max_marginal_relevance_search_by_vectoro  s    4 22'[I	 3 
 wqz!}"I >EQZ]=J6%f-.]   6"**5'	L *'2J (
3 3daq7H3    $#! s   B5
B:*B:c                   U R                   c  [        S5      e[        R                  R	                  U5      (       d-  [        U R                   S5      (       a  U R                  U5      nO[        R                  R	                  U5      (       a/  [        U R                   S5      (       a  U R                  U/S9S   nOn[        R                  R	                  U5      (       a/  [        U R                   S5      (       a  U R                  U/S9S   nOSU S	3nUS
-  nUS-  n[        U5      eU R                  UUUUUS9n	U	$ ri  )
rb   r+   rp  r  rq  r   r   r   r   2max_marginal_relevance_search_with_score_by_vector)
rq   r   r   r   ro  r   r   rb   rt  ru  s
             r0   (max_marginal_relevance_search_with_score-VDMS.max_marginal_relevance_search_with_score  s(   4 >>!T  ww~~e$$)O)O))%0IWW^^E""wt~~}'M'M))w)7:IWW^^E""wt~~}'M'M)))8;IB5'LITTIQQIY''FF# G 
 r2   c                   U R                  U/UU/ SQS9n[        US   S   5      S:X  a  / $ US   S    Vs/ sH  n[        [        U5      5      PM     n	n[	        [
        R                  " U[
        R                  S9U	UUS9n
[        U5      n[        U5       VVVs/ sH  u  nu  pX;   d  M  X4PM     nnnnU$ s  snf s  snnnf ry  )
r  r*   r   r  r   rK  r  r  r5   r  )rq   rb   r   r   ro  r   r   r6   r)  r  r  r  r  r  sr  s                   r0   r  7VDMS.max_marginal_relevance_search_with_score_by_vector  s    4 22'[I	 3 
 wqz!}"I >EQZ]=J6%f-.]   6"**5'	L 5W=J )2*(= (=91fqAR(=    $#! s   B;C .C c                    / n	Uc  U R                   nUc  U	$ UR                  SS/5      n
Uc  SU
;   a  U R                  SU
;   S.nU H-  nU R                  SUUUUUUUS9u  pU	R	                  X/5        M/     U	$ )Nre  r   rv   )r   r'   r;   )r   r   r   r6   r   rM  )rp   rf  r   rQ  rD   )rq   r{  rc   r|  r   r   r6   r   r   all_responsesre  qembr   r   s                 r0   r   VDMS.query_collection_embeddings  s     $&""33O#  **Y6?{g522$/G
 %D'+'C'C %"#5 $ (D 	($H   (!;< % r2   c                f    U R                   " U4X#US.UD6nU VVs/ sH  u  pxUPM	     snn$ s  snnf )a  Run similarity search with VDMS.

Args:
    query (str): Query to look up. Text or path for image or video.
    k (int): Number of results to return. Defaults to 3.
    fetch_k (int): Number of candidates to fetch for knn (>= k).
    filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.

Returns:
    List[Document]: List of documents most similar to the query text.
)r   r   r   )r   )	rq   r   r   r   r   r   r   r7   r8   s	            r0   similarity_searchVDMS.similarity_search:  sE    & ;;

:@
 #22//222s   -c                H    U R                   " SU/UUUS.UD6n[        U5      $ )a  Return docs most similar to embedding vector.
Args:
    embedding (List[float]): Embedding to look up documents similar to.
    k (int): Number of Documents to return. Defaults to 3.
    fetch_k (int): Number of candidates to fetch for knn (>= k).
    filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.
Returns:
    List of Documents most similar to the query vector.
r{  r|  r   r   r   )r  r9   rq   rb   r   r   r   r   r6   s          r0   similarity_search_by_vector VDMS.similarity_search_by_vectorR  s>    " 22 
'[	

 
  ((r2   c                   U R                   c  [        S5      e[        R                  R	                  U5      (       d-  [        U R                   S5      (       a  U R                  U5      nO[        R                  R	                  U5      (       a/  [        U R                   S5      (       a  U R                  U/S9S   nOn[        R                  R	                  U5      (       a/  [        U R                   S5      (       a  U R                  U/S9S   nOSU S	3nUS
-  nUS-  n[        U5      eU R                  " SU/UUUS.UD6n[        U5      $ )a  Run similarity search with VDMS with distance.

Args:
    query (str): Query to look up. Text or path for image or video.
    k (int): Number of results to return. Defaults to 3.
    fetch_k (int): Number of candidates to fetch for knn (>= k).
    filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.

Returns:
    List[Tuple[Document, float]]: List of documents most similar to
    the query text and cosine distance in float for each.
    Lower score represents more similarity.
r,  r   r   r   r   r   rj  rk  rl  rm  rn  r  r   )rb   r+   rp  r  rq  r   r   r   r   r  r5   )	rq   r   r   r   r   r   rM  rt  r6   s	            r0   r   !VDMS.similarity_search_with_scorem  s1   * >>!>??77>>%((WT^^]-S-S/3/@/@/G&&74>>=+Q+Q"&"3"3%"3"A!"D&&74>>=+Q+Q"&"3"35'"3"B1"EFugRP	XX	UU	 ++66 "1!2	
 G +733r2   c                H    U R                   " SU/UUUS.UD6n[        U5      $ )a  
Return docs most similar to embedding vector and similarity score.

Args:
    embedding (List[float]): Embedding to look up documents similar to.
    k (int): Number of Documents to return. Defaults to 3.
    fetch_k (int): Number of candidates to fetch for knn (>= k).
    filter (Optional[Dict[str, str]]): Filter by metadata. Defaults to None.

Returns:
    List[Tuple[Document, float]]: List of documents most similar to
    the query text. Lower score represents more similarity.
r  r   )r  r5   r  s          r0   &similarity_search_with_score_by_vector+VDMS.similarity_search_with_score_by_vector  s>    0 22 
'[	

 
 +733r2   c                *    U R                  X/U/5      $ )zUpdate a document in the collection.

Args:
    document_id (str): ID of the document to update.
    document (Document): Document to update.
)update_documents)rq   rc   document_idr   s       r0   update_documentVDMS.update_document  s     $$_mhZPPr2   c                    U Vs/ sH  oDR                   PM     nnU Vs/ sH  n[        UR                  5      PM     nnU R                  U5      nU R	                  UUUUUS9  gs  snf s  snf )zUpdate a document in the collection.

Args:
    ids (List[str]): List of ids of the document to update.
    documents (List[Document]): List of documents to update.
)r   rv   r   N)r>   r  r?   r|   _VDMS__update)rq   rc   r   r   r   r   r?   rv   s           r0   r  VDMS.update_documents  s     7@@i(%%i@IR
IRX%h&7&78 	 
 **40
! 	 	
 A
s
   A$A))rk   rp   r   rd   rb   r   rn   rl   )rZ   	vdms.vdmsrb   Optional[Embeddings]rc   r   rd   DISTANCE_METRICSre   ENGINESrf   z"Optional[Callable[[float], float]]rg   Optional[int]returnNone)r  r  )rz   	List[str]r  List[List[float]])r   r  r   r   r  r  )r   r  r  r  )r   r   r  List[float])r  zCallable[[float], float])r   r   r   intr   r  r   Optional[Dict[str, Any]]r   r   r  List[Tuple[Document, float]])NN)rc   r   rz   r  rv   r  r   1Optional[Union[List[None], List[Dict[str, Any]]]]r   Optional[List[str]]r  r
   )r   r   )rc   r   re   r  rj   r  r  r   )rc   r   r   zUnion[None, List[str]]r   Union[None, Dict[str, Any]]r  bool)NNNN)rc   r   r?   Optional[Any]rb   Union[List[float], None]r   r  r%   Optional[str]r  z4Tuple[Dict[str, Dict[str, Any]], Union[bytes, None]]FF)rc   r   r   Optional[bool]r   r  r  r  )r   z
List[Dict]r   Optional[List]r   r  r  Tuple[Any, Any]r4   )rc   r   r   r  r   r  rv   r  r   r  r  r  )rc   r   r  r
   r  r  r  r  )r   r  r   Optional[List[dict]]r   r  r  r  r  r  r   r   r  r  )NNNr   T)r   r  rz   r  r   r  r   r  r  r  r  r  r   r   r  r  )rz   zIterable[str]r   r  r   r  r  r  r   r   r  r  )rz   r  rv   r  r   r  r   r  r  r  r   r   r  r  )rc   r   rg   zUnion[int, None]r  r  )rc   r   r  r  )r:  r   r  bytes)NNN)
r   r  rc   r  r   Optional[Dict]r   r   r  r  )NNF)rC  r   r   r  r6   r  r   r  rD  r  r  z(Tuple[List[Dict[str, Any]], List, float])rF  r   rC  r   r   r  r   r  r   Optional[dict]r6   r  rM  zOptional[List[float]]r   r  r  z!Tuple[List[Dict[str, Any]], List])r	  r   r  r   )r]  
Type[VDMS]r   List[Document]rb   r  r   r  r  r  rc   r   r   r   r  r`   )r]  r  rz   r  rb   r  r   r  r   r  r  r  rc   r   r   r   r  r`   )
rc   r   r   r  rd  r  re  r  r  r  )r   r   r   r  r   r  ro  floatr   Optional[Dict[str, List]]r   r   r  r  )rb   r  r   r  r   r  ro  r  r   r  r   r   r  r  )r   r   r   r  r   r  ro  r  r   r  r   r   r  r  )rb   r  r   r  r   r  ro  r  r   r  r   r   r  r  )r{  zOptional[List[List[float]]]rc   r  r|  r  r   r  r   r  r6   r  r   r  r   r   r  z!List[Tuple[Dict[str, Any], List]])r   r   r   r  r   r  r   r  r   r   r  r  )rb   r  r   r  r   r  r   r  r   r   r  r  )r   r   r   r  r   r  r   r  r   r   r  r  )rb   r  r   r  r   r  r   r  r   r   r  r  )rc   r   r  r   r   r   r  r  )rc   r   r   r  r   r  r  r  )5__name__
__module____qualname____firstlineno____doc__DEFAULT_COLLECTION_NAMErr   propertyrv   r|   r   r   r   r   	DEFAULT_KDEFAULT_FETCH_Kr   r   ro   r>  r   r   r   r  r   DEFAULT_INSERT_BATCH_SIZEr  r  r  r  rm   r4  r;  r@  rG  rQ  r  classmethodr^  r\  rf  rv  rr  r  r  r  r  r  r   r  r  r  __static_attributes__r   r2   r0   r`   r`      s	   $T +/6.2%AE.2

 (	

 
 ,
 
 ?
 ,
 

8  $4 &+/## # 	#
 )# # 
&#J HL#'  &	
 E ! 
H &#'	  !	
 
0 '+37	+/+/ $+/ 1	+/
 
+/` #'.2"& 6
6
  6
 ,	6

  6
 6
 
>6
v ).#(	%% &% !	%
 
%& %'.3	(( "( ,	(
 
(& HL9
9
 9
 	9

 &9
 E9
 
9
vMM (,M $2	M
 
M. +/#'3#'66 (6 !	6
 6 !6 6 
6v &**.#'#'66 #6 (	6
 !6 6 !6 6 
6v +/#'3'' (' !	'
 ' ' 
'\ +/3## &# 	#
 (# # # 
#J6B"6B:J6B	6Bp9,.
 $()-&*	E E 'E $	E
 E 
E. -1$($)22 2 *	2
 "2 "2 
226 %&&*,015#(J(J( J( 	J(
 J( $J( *J( /J( !J( 
+J(X:
  +/#'36 
 
! 
 ( 
 !	 

  
  
  
 
 
  
D  +/*.#'36&&& (& (	&
 !& & & & 
& &V '+#(\0(0( $0( 	0(
 0( 
0(j & ,044 4 	4
 4 *4 4 
4r & ,05$5$ 5$ 	5$
 5$ *5$ 5$ 
5$t & ,022 2 	2
 2 *2 2 
&2n & ,05$5$ 5$ 	5$
 5$ *5$ 5$ 
&5$r 9=)-"&.2/3#('5' '' 	'
 ' ,' -' !' ' 
+'X &,033 3 	3
 *3 3 
36 &,0)) ) 	)
 *) ) 
)< &,0,4,4 ,4 	,4
 *,4 ,4 
&,4b &,044 4 	4
 *4 4 
&4B	Q"	Q14	Q@H	Q		Q
"
)2
?M
	
r2   r`   c	                    SU0n	SU ;   a  U(       a  X)S'   Ub  X9S'   U[         ;  a  XIS'   SU ;   a  Ub  XYS'   SU ;   a  Ub  [        U5      U	S'   SU ;   a  U[         ;  a  XyS	'   SU ;   a  U[         ;  a  XS
'   X	0n
U
$ )NsetAddr   _ref
propertiesr   Findr   r   r6   )rC   r  )rF  rC  r   r   rR   r   r   r   r6   entityr   s              r0   r   r     s     $W-Fw
v**$| 0v!8 #K 0}4J!J +}0F!F#y!ELr2   c                   U S:X  aF  [        S X4 5       5      (       a.  UUS.nUb  X;S'   Ub  XKS'   Ub  X[S'   US 0 4;  a  XkS'   Ub  X{S'   O7U S	:X  a#  S
U0nU(       a  XS'   U	S 0 4;  a  XS'   U
b  XS'   O[        SU  35      eX0nU$ )Nr   c              3  &   #    U H  oS Lv   M
     g 7fr4   r   ).0vars     r0   	<genexpr>%_add_descriptorset.<locals>.<genexpr>  s      1#3C4#3s   )r?  
dimensionsre   rj   r  r  r   r   r  r   r   r6   zUnknown command: )allr+   )rF  r?  num_dimsre   rj   r   rR   r   r   r   r6   r  r   s                r0   r   r     s     ((S 1$(#31 . . ""

 %8%8? 6Nr
"#(< !6N	+	+#-< tRj($/=! '9 ,[M:;;!ELr2   c                    [        U5      S:  a  SR                  U5      OSnSn0 nSUS'   SUS'   S	U 0nS
US'   X%S'   XTS'   [        U5      n0 nXGU'   Xv4$ )Nr   r   r   	AddEntityr  classTr'   r?  zqueryable propertiestyper&   )r*   join
_str2bytes)rc   r   all_properties_str	querytyper  rR   	byte_datar   s           r0   _add_entity_with_blobr  ?  s     695H15L.1RTIF"F7OF6N#_5E*E&M)) <-.IE)r2   findc                >   / n/ n/ SQnUR                  5       U;  a)  [        SR                  SR                  U5      5      5      eUR                  5       S:X  a  [	        U SS9nUR                  U5        XE4$ UR                  5       S:X  a2  [        X5      u  pxUR                  U5        UR                  U5        XE4$ UR                  5       S:X  aJ  [	        U SS	9nUR                  U5        [        X5      u  pxUR                  U5        UR                  U5        XE4$ )
N)r  r   r   z"[!] Invalid type. Choices are : {}r   r  T)r   r   r   )r   )r   r+   formatr  r   rD   r  )	rc   r   r   r   r   r  choicesr   r  s	            r0   r   r   U  s     KH'G7*=DDSXXgEVWXXv%%oTJ5!"    
				&0Q5!	"    
				)%oE5! 1Q5!	"  r2   c                0    [         R                  " U SS9nU$ )Nr  r}  )rK  
frombuffer)r'   r   s     r0   r  r  x  s    
--I
.CJr2   c                "    U R                  5       $ r4   )rX  )in_bytess    r0   r   r   }  s    ??r2   c           
         [        [        U  VVs/ sH  oR                  5        H  o"PM     M     snn5      5      $ s  snnf r4   )r   r  r   )r   qr   s      r0   _get_cmds_from_queryr    s0    >1VVXQXQ>?@@>s    <c                v   ^ [        U 5      n[        T[        5      =(       a    [        U4S jU 5       5      nU$ )Nc              3     >#    U H4  nUTS    ;   =(       a     STS    U   ;   =(       a    TS    U   S   S :  v   M6     g7f)r   r5  Nr   )r  cmdr   s     r0   r  (_check_valid_response.<locals>.<genexpr>  s[      3 C 	x{ 	-(1+c**	-QKZ(1,	- s   ;>)r  r)   r   any)r   r   cmd_list	valid_ress    `  r0   r   r     s<    #K0H8T* s 3 	3 0I r2   c                v    SSU/0n[        SUUS/SS.S9nU/nU R                  U5      u  pg[        XV5      nX4$ )Nr%   r   r;   r   )r   r4  rJ  )r   r   r   )	rZ   rC  r%   r   findDescriptorr   resr8   r  s	            r0   r   r     s\    
 $$K$"-	N ""K\\+&FC%k7I$$r2   c                Z    SnU b%  [         R                  " U SS9nUR                  5       nU$ )zConvert embedding to bytes.Nr  r}  )rK  r  tobytes)rb   r'   r   s      r0   r   r     s/     Dhhy	2{{}Kr2   c                    Sn0 nSUS'   U(       a  XS'   0 nSUS'   SUS'   S	/US
'   XTS'   0 nU(       a  SS/US'   SU /US'   XdS'   0 nXGU'   U$ )N
FindEntityr  r  uniqueTr'   r   r4  r&   r   r6   r   r   r   r?  r   r   )rc   r   r   r  r  r6   r   r   s           r0   r   r     s    
 IF"F7O(x GGFOGG kGFO9"$K$(!9K 1K'=E)Lr2   c                ,    [         R                  U 5      $ r4   )r   encode)in_strs    r0   r  r    s    ::fr2   c                    0 nU R                  5        H)  u  p#[        U[        5      (       a  M  X1[        U5      '   M+     U$ r4   )rB   r)   r   r   )r?   new_metadatakeyr   s       r0   r  r    s;    #%Lnn&
%&&%*S" ' r2   )
r,   r   r-   r   r.   r   r/   r   r  r  )r6   r   r  r  )r6   r   r  r  )	localhosti  )rX   r   rY   r  r  r  )NNNNNNN)rF  r   rC  r   r   r  r   r  rR   r  r   r  r   r  r   r  r6   r  r  Dict[str, Dict[str, Any]])	NNNNNNFNN)rF  r   r?  r   r  r  re   r  rj   r  r   r  rR   r  r   r  r   r  r   r  r6   r  r  Dict[str, Any])rc   r   r   r
   r  zTuple[Dict[str, Any], bytes])
rc   r   r   r   r   r
   r   r  r  r  )r'   r  r  r   )r  r  r  r   )r   r   r  r  )r   z
List[dict]r   r   r  r  )rZ   r  rC  r   r%   r   r  zTuple[bool, Any])rb   r  r  zUnion[bytes, None]r  )rc   r   r   r  r   r  r  r  )r  r   r  r  )r?   r  r  r   )E
__future__r   r8  loggingrp  r   copyr   typingr   r   r   r   r	   r
   r   r   r   r   r   r   r   numpyrK  langchain_core._api.deprecationr   langchain_core.documentsr   langchain_core.embeddingsr   langchain_core.vectorstoresr   &langchain_community.vectorstores.utilsr   rU   r  r   r   __annotations__r  r   r  r  r  r  r   rA   rC   	getLoggerr  rF   r1   r9   r5   r[   r`   r   r   r  r   r  r   r  r   r   r   r   r  r  r   r2   r0   <module>r     s	   "   	        6 - 0 3 M 
  6:(CS:T5U 2 U
 $((9#: = :%  	a-3 < ,dB7  
		8	$$DD( (G@UVP
; P
 WP
r*   !%"&"### # 
	#
 # # #  # # #R #   "&"44
4 4 	4
 4 
4 4 4 4  4 4 4n*.!0 	 ! ! !  ! 
	 !
  !F
A%%% 	% 	%& %*$!  	8r2   