
    <iD                        S SK r S SKJr  S SKJrJrJrJr  S SKJ	r	  S SK
rS SKJr  S SKJr  S SKJrJ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  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'J(r(  S SK&J)r)J*r*J+r+J,r,   " S S\5      r-g)    N)tee)AnyIterableSequenceget_args)deepcopy)	BaseModel)grpc)show_warningshow_warning_once)
QdrantBase)Embedder)ModelEmbedder)models)common_types)
GrpcToRest)INFERENCE_OBJECT_TYPES)ModelSchemaParser)reciprocal_rank_fusion)FastEmbedMiscOnnxProvider)QueryResponseTextEmbeddingSparseTextEmbeddingIDF_EMBEDDING_MODELSc                   L	  ^  \ rS rSr% SrSr\\S'   S\S\S\	S-  4U 4S	 jjr
\S
\\	\\\R                   4   4   4S j5       r\S
\\	\\\R                   4   4   4S j5       r\S
\\	\\\R                   4   4   4S j5       r\S
\\	\\\R                   4   4   4S j5       r\S
\\	\\	\4   4   4S j5       r\S
\	4S j5       r\S
\	S-  4S j5       r       SQS\	S\S-  S\	S-  S\S-  S\S   S-  S\S\\   S-  S\S\S
S4S jjr      SRS\	S-  S\	S-  S\S-  S\S   S-  S\S\\   S-  S\S\S
S4S jjr\S\	S
\\\R                   4   4S j5       r    SSS\	S\	S-  S\S-  S\S   S-  S \S\S
S!4S" jjr    SSS\	S\	S-  S\S-  S\S   S-  S \S\S
S#4S$ jjr \SS%S4S&\!\	   S\	S'\S(\	S)\S-  S
\!\\	\\"   4      4S* jjr#\SS4S&\!\	   S\	S'\S)\S-  S
\!\$RJ                     4
S+ jjr&S
\	4S, jr'S
\	S-  4S- jr(S.\\$RR                     S
\\*   4S/ jr+ STS0\!\RX                     S-  S1\!\\	\4      S-  S2\!\\	\\"   4      S3\S4\!\$RJ                     S-  S
\!\RZ                     4S5 jjr.S6\R^                  S
S4S7 jr0 STS\	S-  S
\4S8 jjr1   SUS9\S-  S:\Rd                  S-  S;\Rf                  S-  S
\\	\Rh                  4   4S< jjr5  SVS9\S-  S=\Rl                  S-  S
\\	\Rn                  4   S-  4S> jjr8    SWS?\	S&\!\	   S1\!\\	\4      S-  S0\!\RX                     S-  S'\S)\S-  S\S
\\	\-     4S@ jjr9  SXS?\	SA\	SB\Rt                  S-  SC\S\S
\\*   4SD jjr;  SXS?\	SE\\	   SB\Rt                  S-  SC\S\S
\\\*      4SF jjr<\SG\$Rz                  \\"   -  \\\"      -  \$RJ                  -  \$R|                  -  \$R~                  -  \R                  -  \R                  -  \R                  -  S-  S
\R|                  S-  4SH j5       rCSG\R                  S
\R                  4SI jrESJ\\R                     S
\\R                     4SK jrF  SYSL\G\!\G   -  SM\S'\S-  S
\!\G   4SN jjrH  SVSL\!\\	\G4   \G-     S'\S-  S)\S-  S
\!\G   4SO jjrISPrJU =rK$ )ZQdrantFastembedMixin    zBAAI/bge-small-en   _FASTEMBED_INSTALLEDparseris_local_modeserver_versionNc                    > [         R                  " 5       U R                  l        S U l        S U l        [        XUS9U l        [        TU ]%  5         g )N)r!   r"   r#   )
r   is_installed	__class__r    _embedding_model_name_sparse_embedding_model_namer   _model_embeddersuper__init__)selfr!   r"   r#   r&   s       X/home/james-whalen/.local/lib/python3.13/site-packages/qdrant_client/qdrant_fastembed.pyr+   QdrantFastembedMixin.__init__%   sG    .;.H.H.J+15"8<),~ 
 	    returnc                 ,    [         R                  " 5       $ )zLists the supported dense text models.

Returns:
    dict[str, tuple[int, models.Distance]]: A dict of model names, their dimensions and distance metrics.
)r   list_text_modelsclss    r-   r2   %QdrantFastembedMixin.list_text_models/   s     --//r/   c                 ,    [         R                  " 5       $ )zLists the supported image dense models.

Returns:
    dict[str, tuple[int, models.Distance]]: A dict of model names, their dimensions and distance metrics.
)r   list_image_modelsr3   s    r-   r7   &QdrantFastembedMixin.list_image_models8   s     ..00r/   c                 ,    [         R                  " 5       $ )zLists the supported late interaction text models.

Returns:
    dict[str, tuple[int, models.Distance]]: A dict of model names, their dimensions and distance metrics.
)r   !list_late_interaction_text_modelsr3   s    r-   r:   6QdrantFastembedMixin.list_late_interaction_text_modelsA   s     >>@@r/   c                 ,    [         R                  " 5       $ )zLists the supported late interaction multimodal models.

Returns:
    dict[str, tuple[int, models.Distance]]: A dict of model names, their dimensions and distance metrics.
)r   'list_late_interaction_multimodal_modelsr3   s    r-   r=   <QdrantFastembedMixin.list_late_interaction_multimodal_modelsJ   s     DDFFr/   c                 ,    [         R                  " 5       $ )zLists the supported sparse text models.

Returns:
    dict[str, dict[str, Any]]: A dict of model names and their descriptions.
)r   list_sparse_modelsr3   s    r-   r@   'QdrantFastembedMixin.list_sparse_modelsS   s     //11r/   c                 V    U R                   c  U R                  U l         U R                   $ N)r'   DEFAULT_EMBEDDING_MODELr,   s    r-   embedding_model_name)QdrantFastembedMixin.embedding_model_name\   s(    %%-)-)E)ED&)))r/   c                     U R                   $ rC   )r(   rE   s    r-   sparse_embedding_model_name0QdrantFastembedMixin.sparse_embedding_model_nameb   s    000r/   rF   
max_length	cache_dirthreads	providersr   cuda
device_ids	lazy_loadkwargsc	                 j    Ub  [        S[        SS9  U R                  " SUUUUUUUSS.U	D6  Xl        g)a  
Set embedding model to use for encoding documents and queries.

Args:
    embedding_model_name: One of the supported embedding models. See `SUPPORTED_EMBEDDING_MODELS` for details.
    max_length (int, optional): Deprecated. Defaults to None.
    cache_dir (str, optional): The path to the cache directory.
        Can be set using the `FASTEMBED_CACHE_PATH` env variable.
        Defaults to `fastembed_cache` in the system's temp directory.
    threads (int, optional): The number of threads single onnxruntime session can use. Defaults to None.
    providers: The list of onnx providers (with or without options) to use. Defaults to None.
        Example configuration:
        https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#configuration-options
    cuda (bool, optional): Whether to use cuda for inference. Mutually exclusive with `providers`
        Defaults to False.
    device_ids (Optional[list[int]], optional): The list of device ids to use for data parallel processing in
        workers. Should be used with `cuda=True`, mutually exclusive with `providers`. Defaults to None.
    lazy_load (bool, optional): Whether to load the model during class initialization or on demand.
        Should be set to True when using multiple-gpu and parallel encoding. Defaults to False.
Raises:
    ValueError: If embedding model is not supported.
    ImportError: If fastembed is not installed.

Returns:
    None
Nzhmax_length parameter is deprecated and will be removed in the future. It's not used by fastembed models.   )messagecategory
stacklevelT
model_namerL   rM   rN   rO   rP   rQ   
deprecated )r   DeprecationWarning_get_or_init_modelr'   )
r,   rF   rK   rL   rM   rN   rO   rP   rQ   rR   s
             r-   	set_modelQdrantFastembedMixin.set_modelf   s]    N !5+	 	 
	
+!
	
 
	
 &:"r/   c                 L    Ub  U R                   " SUUUUUUUSS.UD6  Xl        g)a	  
Set sparse embedding model to use for hybrid search over documents in combination with dense embeddings.

Args:
    embedding_model_name: One of the supported sparse embedding models. See `SUPPORTED_SPARSE_EMBEDDING_MODELS` for details.
                If None, sparse embeddings will not be used.
    cache_dir (str, optional): The path to the cache directory.
                               Can be set using the `FASTEMBED_CACHE_PATH` env variable.
                               Defaults to `fastembed_cache` in the system's temp directory.
    threads (int, optional): The number of threads single onnxruntime session can use. Defaults to None.
    providers: The list of onnx providers (with or without options) to use. Defaults to None.
        Example configuration:
        https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#configuration-options
    cuda (bool, optional): Whether to use cuda for inference. Mutually exclusive with `providers`
        Defaults to False.
    device_ids (Optional[list[int]], optional): The list of device ids to use for data parallel processing in
        workers. Should be used with `cuda=True`, mutually exclusive with `providers`. Defaults to None.
    lazy_load (bool, optional): Whether to load the model during class initialization or on demand.
        Should be set to True when using multiple-gpu and parallel encoding. Defaults to False.
Raises:
    ValueError: If embedding model is not supported.
    ImportError: If fastembed is not installed.

Returns:
    None
NTrX   r[   )_get_or_init_sparse_modelr(   )	r,   rF   rL   rM   rN   rO   rP   rQ   rR   s	            r-   set_sparse_model%QdrantFastembedMixin.set_sparse_model   sI    J  +** 
/##%#
 
 -A)r/   rY   c                 z   [         R                  " 5         [         R                  " 5       [         R                  " 5       [         R                  " 5       [         R
                  " 5       4 H  nUR                  U5      =n(       d  M  Us  $    U[         R                  " 5       ;   a  [        S5      e[        SU 35      e)NzFSparse embeddings do not return fixed embedding size and distance typezUnsupported embedding model: )	r   import_fastembedr2   r7   r:   r=   getr@   
ValueError)r4   rY   descriptionsparamss       r-   _get_model_params&QdrantFastembedMixin._get_model_params   s    &&( **,++-;;=AAC	
L &))*55v5
 99;;X  8EFFr/   rZ   r   c           	          [         R                  " 5         [        U R                  R                  [
        5      (       d   eU R                  R                  R                  " SUUUUUS.UD6$ N)rY   rL   rM   rN   rZ   r[   )r   re   
isinstancer)   embedderr   get_or_init_modelr,   rY   rL   rM   rN   rZ   rR   s          r-   r]   'QdrantFastembedMixin._get_or_init_model   sl     	&&($..77BBBB##,,>> 
!!
 
 	
r/   r   c           	          [         R                  " 5         [        U R                  R                  [
        5      (       d   eU R                  R                  R                  " SUUUUUS.UD6$ rm   )r   re   rn   r)   ro   r   get_or_init_sparse_modelrq   s          r-   ra   .QdrantFastembedMixin._get_or_init_sparse_model   sl     	&&($..77BBBB##,,EE 
!!
 
 	
r/   default	documents
batch_size
embed_typeparallelc              #   6  ^#    U R                  USS9m[        US5      u  pgUS:X  a  TR                  XcUS9nO8US:X  a  U4S jU 5       nO%US:X  a  TR                  XcUS9nO[	        S	U 35      e[        X5       H  u  pXR                  5       4v   M     g 7f)
NTrY   rZ      passagerx   rz   queryc              3   Z   >#    U  H   n[        TR                  US 95      S   v   M"     g7f)r   r   N)listquery_embed).0r   embedding_models     r-   	<genexpr>8QdrantFastembedMixin._embed_documents.<locals>.<genexpr>!  s,      OZe_00u0=>qA{s   (+rv   zUnknown embed type: )r]   r   passage_embedembedrg   ziptolist)r,   rw   rF   rx   ry   rz   documents_adocuments_bvectors_itervectordocr   s              @r-   _embed_documents%QdrantFastembedMixin._embed_documents  s      11=Q^b1c#&y!#4 "*88X 9 L 7"OZL 9$*00X 1 L 3J<@AA|9KF}}&& :s   BBc              #      #    U R                  USS9nUR                  XUS9nU HJ  n[        R                  " UR                  R                  5       UR                  R                  5       S9v   ML     g 7f)NTr|   r   indicesvalues)ra   r   typesSparseVectorr   r   r   )r,   rw   rF   rx   rz   sparse_embedding_modelr   sparse_vectors           r-   _sparse_embed_documents,QdrantFastembedMixin._sparse_embed_documents.  s      "&!?!?+ "@ "
 .33x 4 
 *M$$%--446$++224  *s   A2A4c                 d    U R                   R                  S5      S   R                  5       nSU 3$ )
Returns name of the vector field in qdrant collection, used by current fastembed model.
Returns:
    Name of the vector field.
/zfast-)rF   splitlowerr,   rY   s     r-   get_vector_field_name*QdrantFastembedMixin.get_vector_field_nameC  s5     ..44S9"=CCE
zl##r/   c                     U R                   b1  U R                   R                  S5      S   R                  5       nSU 3$ g)r   Nr   r   zfast-sparse-)rI   r   r   r   s     r-   get_sparse_vector_field_name1QdrantFastembedMixin.get_sparse_vector_field_nameL  sD     ++799??DRHNNPJ!*..r/   scored_pointsc                    / nU R                  5       nU R                  5       nU H  n[        UR                  [        5      (       a  UR                  R                  US 5      OS nS nUb=  [        UR                  [        5      (       a  UR                  R                  US 5      OS nUR                  [        UR                  UUUR                  UR                  R                  SS5      UR                  S95        M     U$ )Ndocument )id	embeddingsparse_embeddingmetadatar   score)r   r   rn   r   dictrf   appendr   r   payloadr   )r,   r   responsevector_field_namesparse_vector_field_namescored_pointr   r   s           r-   !_scored_points_to_query_responses6QdrantFastembedMixin._scored_points_to_query_responsesW  s      668#'#D#D#F )L l11488 ##''(94@ 
  $'3 ","5"5t<< !''++,DdK ! OO#'%5)11)1155j"E&,,	 *0 r/   idsr   encoded_docsids_accumulatorsparse_vectorsc              #   T  #    Uc  [        S S 5      nUc  [        S S 5      nUc  [        S S5      nU R                  5       nU R                  5       n[        XX55       HD  u  pu  pnUR	                  U5        SU
0U	EnXk0nUb  Ub  XU'   [
        R                  " XUS9v   MF     g 7f)Nc                  @    [         R                  " 5       R                  $ rC   )uuiduuid4hexr[   r/   r-   <lambda>7QdrantFastembedMixin._points_iterator.<locals>.<lambda>  s    tzz|//r/   c                      0 $ rC   r[   r[   r/   r-   r   r     s    Br/   c                      g rC   r[   r[   r/   r-   r   r     s    $r/   Tr   )r   r   r   )iterr   r   r   r   r   PointStruct)r,   r   r   r   r   r   vector_namesparse_vector_nameidxmetar   r   r   r   point_vectors                  r-   _points_iterator%QdrantFastembedMixin._points_iteratory  s      ;/6CJ-H!!,5N002!>>@7:<8
3C}m ""3'!3/$/G6A5JL!--2K3@/0$$\RR8
s   B&B(collection_infoc                 4   U R                  U R                  S9u  p#U R                  5       n[        UR                  R
                  R                  [        5      (       d(   SUR                  R
                  R                   35       eXAR                  R
                  R                  ;   d+   SUR                  R
                  R                   SU 35       eUR                  R
                  R                  U   nX%R                  :X  d   SU SUR                   35       eX5R                  :X  d   SU SUR                   35       eU R                  5       nUb  XaR                  R
                  R                  ;   d(   SUR                  R
                  R                   35       eU R                  [        ;   ab  UR                  R
                  R                  U   R                  nU[        R                   R"                  :X  d   U R                   SU 35       eg g g )NrY   z,Collection have incompatible vector params: z, expected zEmbedding size mismatch: z != zDistance mismatch: z, requires modifier IDF, current modifier is )rj   rF   r   rn   configri   vectorsr   sizedistancer   r   rI   r   modifierr   ModifierIDF)r,   r   embeddings_sizer   r   vector_paramsr   r   s           r-   _validate_collection_info.QdrantFastembedMixin._validate_collection_info  s/   $($:$:dF_F_$:$`! 668 ""))114
 
 	b9/:P:P:W:W:_:_9`a	b 

 !7!7!>!>!F!FF	@9/:P:P:W:W:_:_9``kl}k~	@F (..55==>OP 111	Q&&7tM<N<N;OP	Q1 ...	H 
$}/E/E.FG	H. $(#D#D#F #/(,B,B,I,I,X,XXf=o>T>T>[>[>c>c=defX//3GG*1188GG,(   3 33o6677cdlcmno3 H	 0r/   c                 R    U=(       d    U R                   nU R                  US9u  p#U$ )as  Get the size of the embeddings produced by the specified model.

Args:
    model_name: optional, the name of the model to get the embedding size for. If None, the default model will
        be used.

Returns:
    int: the size of the embeddings produced by the model.

Raises:
    ValueError: If sparse model name is passed or model is not found in the supported models.
r   )rF   rj   )r,   rY   r   _s       r-   get_embedding_size'QdrantFastembedMixin.get_embedding_size  s0       <4#<#<
!33z3Jr/   on_diskquantization_confighnsw_configc           	          U R                  5       nU R                  U R                  S9u  pVU[        R                  " UUUUUS90$ )a  
Generates vector configuration, compatible with fastembed models.

Args:
    on_disk: if True, vectors will be stored on disk. If None, default value will be used.
    quantization_config: Quantization configuration. If None, quantization will be disabled.
    hnsw_config: HNSW configuration. If None, default configuration will be used.

Returns:
    Configuration for `vectors_config` argument in `create_collection` method.
r   )r   r   r   r   r   )r   rj   rF   r   VectorParams)r,   r   r   r   r   r   r   s          r-   get_fastembed_vector_params0QdrantFastembedMixin.get_fastembed_vector_params  sX    " !668$($:$:dF_F_$:$`!v22$!$7' 
 	
r/   r   c                     U R                  5       nU R                  [        ;   a  Uc  [        R                  R
                  OUnUc  gU[        R                  " [        R                  " US9US90$ )al  
Generates vector configuration, compatible with fastembed sparse models.

Args:
    on_disk: if True, vectors will be stored on disk. If None, default value will be used.
    modifier: Sparse vector queries modifier. E.g. Modifier.IDF for idf-based rescoring. Default: None.
Returns:
    Configuration for `vectors_config` argument in `create_collection` method.
N)r   )indexr   )r   rI   r   r   r   r   SparseVectorParamsSparseIndexParams)r,   r   r   r   s       r-   "get_fastembed_sparse_vector_params7QdrantFastembedMixin.get_fastembed_sparse_vector_params  ss     !==?++/CC.6.>v**HH$ v88..# "	 
 	
r/   collection_namec           	         [        S5        U R                  UU R                  USUS9nSn	U R                  b  U R	                  UU R                  UUS9n	 U R                  US9n
U R                  U
5        / nU R                  UUUUU	S9nU R                  " SUUS	U=(       d    S
US.UD6  U$ ! [         a?    U R                  UU R                  5       U R                  5       S9  U R                  US9n
 Nf = f)a  
Adds text documents into qdrant collection.
If collection does not exist, it will be created with default parameters.
Metadata in combination with documents will be added as payload.
Documents will be embedded using the specified embedding model.

If you want to use your own vectors, use `upsert` method instead.

Args:
    collection_name (str):
        Name of the collection to add documents to.
    documents (Iterable[str]):
        List of documents to embed and add to the collection.
    metadata (Iterable[dict[str, Any]], optional):
        List of metadata dicts. Defaults to None.
    ids (Iterable[models.ExtendedPointId], optional):
        List of ids to assign to documents.
        If not specified, UUIDs will be generated. Defaults to None.
    batch_size (int, optional):
        How many documents to embed and upload in single request. Defaults to 32.
    parallel (Optional[int], optional):
        How many parallel workers to use for embedding. Defaults to None.
        If number is specified, data-parallel process will be used.

Raises:
    ImportError: If fastembed is not installed.

Returns:
    List of IDs of added documents. If no ids provided, UUIDs will be randomly generated on client side.

z`add` method has been deprecated and will be removed in 1.17. Instead, inference can be done internally within regular methods like `upsert` by wrapping data into `models.Document` or `models.Image`.r~   )rw   rF   rx   ry   rz   N)rw   rF   rx   rz   )r   )r   vectors_configsparse_vectors_config)r   r   r   r   r   T   )r   pointswaitrz   rx   r[   )r   r   rF   rI   r   get_collection	Exceptioncreate_collectionr   r   r   r   upload_points)r,   r   rw   r   r   rx   rz   rR   r   encoded_sparse_docsr   inserted_idsr   s                r-   addQdrantFastembedMixin.add
  s\   R 	=	
 ,,!%!:!:!  - 
 #++7"&">">#%)%E%E%!	 #? #	S"11/1RO 	&&7&&%(. ' 
 	 	
+]!	
 	
 ;  	S"" /#??A&*&M&M&O # 
 #11/1RO	Ss   B- -AC65C6
query_textquery_filterlimitc                 \   [        S5        U R                  U R                  SS9n[        UR	                  US95      nUS   R                  5       nU R                  c@  U R                  U R                  " SUUU R                  5       UUSS.UD6R                  5      $ U R                  U R                  SS9n	[        U	R	                  US95      S   n
[        R                  " U
R                  R                  5       U
R                  R                  5       S9n[        R                   " SUU R                  5       UUSS.UD6n[        R                   " SUU R#                  5       UUSS.UD6nU R%                  XU/S	9u  pU R                  ['        UR                  UR                  /US
95      $ )a  
Search for documents in a collection.
This method automatically embeds the query text using the specified embedding model.
If you want to use your own query vector, use `search` method instead.

Args:
    collection_name: Collection to search in
    query_text:
        Text to search for. This text will be embedded using the specified embedding model.
        And then used as a query vector.
    query_filter:
        - Exclude vectors which doesn't fit given conditions.
        - If `None` - search among all vectors
    limit: How many results return
    **kwargs: Additional search parameters. See `qdrant_client.models.QueryRequest` for details.

Returns:
    list[types.ScoredPoint]: List of scored points.

z`query` method has been deprecated and will be removed in 1.17. Instead, inference can be done internally within regular methods like `query_points` by wrapping data into `models.Document` or `models.Image`.Tr|   r   r   )r   r   usingr  r  with_payloadr   r   r  filterr  r  r   requestsr  r[   )r   r]   rF   r   r   r   rI   r   query_pointsr   r   ra   r   r   r   r   QueryRequestr   query_batch_pointsr   )r,   r   r   r  r  rR   embedding_model_inst
embeddingsquery_vectorsparse_embedding_model_instr   sparse_query_vectordense_requestsparse_requestdense_request_responsesparse_request_responses                   r-   r   QdrantFastembedMixin.querym  s   8 	=	

  $6600T  7  
 .:::LM
!!}++-++399!! $3&446!-!%  &
 
 '+&D&D77D 'E '
# 8DD:DVWXYZ$11!))002 ''..0

 ++ 
,,.
 
  ,, 
%335
 
 ;?:Q:Q+n6U ;R ;
7 55"'..0G0N0NOW\
 	
r/   query_textsc           
      v   [        S5        U R                  U R                  SS9n[        UR	                  US95      n/ nU HL  n	[
        R                  " SU	R                  5       U R                  5       UUSS.UD6n
UR                  U
5        MN     U R                  c;  U R                  UUS9nU Vs/ s H  oR                  UR                  5      PM     sn$ U R                  U R                  SS9nUR                  US9 Vs/ s HH  n[
        R                   " UR"                  R                  5       UR$                  R                  5       S	9PMJ     nnU H>  n[
        R                  " SU R'                  5       UUUSS
.UD6n
UR                  U
5        M@     U R                  UUS9nUS[)        U5       nU[)        U5      S n[+        UU5       VVs/ s H&  u  nn[-        UR                  UR                  /US9PM(     nnnU Vs/ s H  oR                  U5      PM     sn$ s  snf s  snf s  snnf s  snf )a  
Search for documents in a collection with batched query.
This method automatically embeds the query text using the specified embedding model.

Args:
    collection_name: Collection to search in
    query_texts:
        A list of texts to search for. Each text will be embedded using the specified embedding model.
        And then used as a query vector for a separate search requests.
    query_filter:
        - Exclude vectors which doesn't fit given conditions.
        - If `None` - search among all vectors
        This filter will be applied to all search requests.
    limit: How many results return
    **kwargs: Additional search parameters. See `qdrant_client.models.QueryRequest` for details.

Returns:
    list[list[QueryResponse]]: List of lists of responses for each query text.

z`query_batch` method has been deprecated and will be removed in 1.17. Instead, inference can be done internally within regular methods like `query_batch_points` by wrapping data into `models.Document` or `models.Image`.Tr|   r   r  Nr  )rw   r   )r  r   r  r  r  r
  r[   )r   r]   rF   r   r   r   r  r   r   r   rI   r  r   r   ra   r   r   r   r   r   lenr   r   )r,   r   r  r  r  rR   r  query_vectorsr	  r   request	responsesr   r  r   sparse_query_vectorsdense_responsessparse_responsesdense_responsesparse_responses                       r-   query_batch QdrantFastembedMixin.query_batch  s   8 	=	

  $6600T  7  
 1==K=PQ#F)) mmo002#! G OOG$ $ ++3// /! 0 I
 YbXaH66xGXa  '+&D&D77D 'E '
# "=!B!B[!B!Y 

 "Z	 %--446$++224 "Z 	  
 2M)) 779##! G OOG$ 2 +++ , 
	
 $$6c+&67$S%5%78 47HX3Y
3Y/ #N$9$9?;Q;Q#RZ_`3Y 	 

 R[[QZX66x@QZ[[M 
4

 \s   3$H&AH+-H0	H6r   c                    [        U[        [        R                  5      5      (       a  U$ [        U[        R                  5      (       a  [
        R                  " US9$ [        U[        R                  5      (       a"  [
        R                  " UR                  5       S9$ [        U[        5      (       a  [
        R                  " US9$ [        U[        [        R                  5      5      (       aK  [        U[        R                  5      (       a  [        R                  " U5      OUn[
        R                  " US9$ [        U[        [        5      5      (       a  [
        R                  " US9$ Uc  g[!        S[#        U5       35      e)a+  Resolves query interface into a models.Query object

Args:
    query: models.QueryInterface - query as a model or a plain structure like list[float]

Returns:
    Optional[models.Query]: query as it was, models.Query(nearest=query) or None

Raises:
    ValueError: if query is not of supported type
)nearestNzUnsupported query type: )rn   r   r   Queryr   r   NearestQuerynpndarrayr   r   PointIdr
   r   convert_point_idr   rg   type)r4   r   s     r-   _resolve_query#QdrantFastembedMixin._resolve_query#  s   2 eXekk233LeU//00&&u55eRZZ((&&u||~>>eT""&&u55eXemm4556@6U6U
++E2[`  &&u55eX&<=>>&&u55=3DK=ABBr/   c                 \    [        U5      nU R                  UR                  5      Ul        U$ )zResolve QueryRequest query field

Args:
    query: models.QueryRequest - query request to resolve

Returns:
    models.QueryRequest: A deepcopy of the query request with resolved query field
)r   r.  r   )r,   r   s     r-   _resolve_query_request+QdrantFastembedMixin._resolve_query_requestU  s(     ))%++6r/   r	  c                 N    U Vs/ s H  o R                  U5      PM     sn$ s  snf )zResolve query field for each query request in a batch

Args:
    requests: Sequence[models.QueryRequest] - query requests to resolve

Returns:
    Sequence[models.QueryRequest]: A list of deep copied query requests with resolved query fields
)r1  )r,   r	  r   s      r-   _resolve_query_batch_request1QdrantFastembedMixin._resolve_query_batch_requestb  s'     AIIu++E2IIIs   "
raw_modelsis_queryc              #   |   #    U R                   R                  UUU=(       d    U R                  S9 S h  vN   g  N7f)N)r6  r7  rx   )r)   embed_modelsDEFAULT_BATCH_SIZE)r,   r6  r7  rx   s       r-   _embed_models"QdrantFastembedMixin._embed_modelso  s>      ''44!!<T%<%< 5 
 	
 	
   2<:<c              #   |   #    U R                   R                  UU=(       d    U R                  US9 S h  vN   g  N7f)N)r6  rx   rz   )r)   embed_models_strictr:  )r,   r6  rx   rz   s       r-   _embed_models_strict)QdrantFastembedMixin._embed_models_strict{  s>      '';;!!<T%<%< < 
 	
 	
r=  )r'   r)   r(   )NNNNFNF)NNNFNF)NNNFrC   )NNN)NN)NNr   N)N
   )FN)L__name__
__module____qualname____firstlineno__rD   r:  bool__annotations__r   strr+   classmethodr   tupleintr   Distancer2   r7   r:   r=   r   r@   propertyrF   rI   r   r   r^   rb   rj   r]   ra   r   floatr   r   r   r   r   r   ScoredPointr   r   ExtendedPointIdr   r   CollectionInfor   r   QuantizationConfigHnswConfigDiffr   r   r   r   r   r   Filterr   r#  r+  r'  
NumpyArrayDocumentImageInferenceObjectr.  r  r1  r4  r	   r;  r@  __static_attributes____classcell__)r&   s   @r-   r   r       s?	   10  WZ]aWa  0c5foo1E+F&F!G 0 0 1$sE#v2F,G'G"H 1 1 A$sE#vBV<W7W2X A A GS%V__H\B]=]8^ G G 24T#s(^(;#< 2 2 *c * *
 1S4Z 1 1 "& $"59'+::!:: $J:: :	::
 t:: N+d2:: :: I$:: :: :: 
::~ !%"59'+1A!Dj1A :1A t	1A
 N+d21A 1A I$1A 1A 1A 
1Af G3 G5foo9M3N G G, !%"59 

 :
 t	

 N+d2
 
 
 

0 !%"59 

 :
 t	

 N+d2
 
 
 

. %<##'C=' "' 	'
 ' *' 
%T%[()	*'> %<#C= " 	
 * 
%$$	%*$s $	cDj 	 E--.  
m	 P ?CSf,,-4S 4S>*T1S uS$u+%567	S
 S !!3!34t;S 
&$$	%S<"o9N9N "oSW "oL "&$J 
,  $@D48	

 $66=
 **T1	

 
c6&&&	'
>  $+/

 //D(
 
c6,,,	-	4	
D 597;#aa C=a 4S>*T1	a
 f,,-4a a *a a 
cCiaN .2U
U
 U
 mmd*	U

 U
 U
 
m	U
v .2]\]\ #Y]\ mmd*	]\
 ]\ ]\ 
d=!	"]\~ /C}}
u+
tE{
 

 ++	
 

 // ,, 
 
 ! 	/C 
	/C /CbF,?,? FDWDW J !4!45J	&%%	&J  !%	

 33

 

 $J	


 
)	

 "&#	

T#y.1I=>

 $J

 *	


 
)	

 

r/   r   ).r   	itertoolsr   typingr   r   r   r   copyr   numpyr)  pydanticr	   qdrant_clientr
   $qdrant_client.common.client_warningsr   r   qdrant_client.client_baser   qdrant_client.embed.embedderr   "qdrant_client.embed.model_embedderr   qdrant_client.httpr   qdrant_client.conversionsr   r   $qdrant_client.conversions.conversionr   qdrant_client.embed.commonr   !qdrant_client.embed.schema_parserr   qdrant_client.hybrid.fusionr   qdrant_client.fastembed_commonr   r   r   r   r   r   r   r[   r/   r-   <module>rm     sV      4 4     P 0 1 < % ; ; = ? > F e
: e
r/   