
    
!iF/                    6   % S SK Jr  S SKrS SKJrJrJrJrJrJ	r	  S SK
Js  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rSr\R4                  r\\\\4   r0 \R>                  \R>                  _S \R>                  _S\R>                  _S\R>                  _\R@                  \R@                  _S\R@                  _S\R@                  _S\R@                  _\RB                  \RB                  _S\RB                  _S\RB                  _S\RB                  _\RD                  \RD                  _S\RD                  _S\RD                  _S\RD                  _\RF                  \RF                  _S\RF                  S\RF                  \RH                  \RH                  S\RH                  S\RH                  S\RJ                  S\RJ                  S\RJ                  \RJ                  \RJ                  S\RL                  S \RL                  S!\RL                  \RL                  \RL                  0Er'S"\(S#'   S-S$ jr) \RT                  r+\     S/               S0S' jj5       r.\     S/               S1S( jj5       r.     S/               S2S) jjr.\     S/               S3S* jj5       r/\     S/               S4S+ jj5       r/     S/               S5S, jjr/g! \, a    \" S%5      r-S.S& jr+ Nf = f)6    )annotationsN)AnyIterableoverloadTypeVarUnionMapping)protos)get_default_generative_client)#get_default_generative_async_client)helper_types)model_types)
text_types)content_typeszmodels/embedding-001d   task_type_unspecifiedunspecified   retrieval_queryquery   retrieval_documentdocument   semantic_similarity
similarity   classification   
clustering   question_answeringqa   fact_verificationverificationz1dict[EmbeddingTaskTypeOptions, EmbeddingTaskType]_EMBEDDING_TASK_TYPEc                ^    [        U [        5      (       a  U R                  5       n [        U    $ N)
isinstancestrlowerr'   )xs    W/home/james-whalen/.local/lib/python3.13/site-packages/google/generativeai/embedding.pyto_task_typer/   H   s%    !SGGI""    Tc              #     #    US:  a  [        SU S35      e/ nU  H+  nUR                  U5        [        U5      U:X  d  M%  Uv   / nM-     U(       a  Uv   g g 7f)Nr   zKInvalid input: The batch size 'n' must be a positive integer. You entered: z'. Please enter a number greater than 0.)
ValueErrorappendlen)iterablenbatchitems       r.   _batchedr:   T   sp     q5]^_]`  aH  I  DLL5zQ	  K s   ;AAc                    g r)    modelcontent	task_typetitleoutput_dimensionalityclientrequest_optionss          r.   embed_contentrE   d   s      #r0   c                    g r)   r<   r=   s          r.   rE   rE   p   s     %(r0   c                d  ^ ^^^ [         R                  " T 5      m Uc  0 nUc
  [        5       nT(       a.  [        T5      [        R
                  La  [        ST ST S35      eT(       a  TS:  a  [        ST S35      eT(       a  [        T5      m[        U[        5      (       a  [        U[        [        45      (       d  S/ 0nU UUU4S jU 5       n[        U[        5       Hc  n	[        R                  " T U	S9n
UR                  " U
40 UD6n[!        U5      R#                  U5      nUS   R%                  S	 US
    5       5        Me     U$ [        R&                  " T [(        R*                  " U5      TTTS9n
UR,                  " U
40 UD6n[!        U5      R#                  U5      nUS   S   US'   U$ )aA  Calls the API to create embeddings for content passed in.

Args:
    model:
        Which [model](https://ai.google.dev/models/gemini#embedding) to
        call, as a string or a `types.Model`.

    content:
        Content to embed.

    task_type:
        Optional task type for which the embeddings will be used. Can only
        be set for `models/embedding-001`.

    title:
        An optional title for the text. Only applicable when task_type is
        `RETRIEVAL_DOCUMENT`.

    output_dimensionality:
        Optional reduced dimensionality for the output embeddings. If set,
        excessive values from the output embeddings will be truncated from
        the end.

    request_options:
        Options for the request.

Return:
    Dictionary containing the embedding (list of float values) for the
    input content.
sInvalid task type: When a title is specified, the task must be of a 'retrieval document' type. Received task type:  and title: .r   QInvalid value: `output_dimensionality` must be a non-negative integer. Received: 	embeddingc           	   3  |   >#    U  H1  n[         R                  " T[        R                  " U5      TTTS 9v   M3     g7fr>   r?   r@   rA   rB   Nr
   EmbedContentRequestr   
to_content.0cr>   rB   r@   rA   s     r.   	<genexpr> embed_content.<locals>.<genexpr>   A      	
  &&%003#&;    9<r>   requestsc              3  *   #    U  H	  oS    v   M     g7fvaluesNr<   rT   es     r.   rV   rW           &Y<Xq{<X   
embeddingsrO   r^   )r   make_model_namer   r/   EmbeddingTaskTypeRETRIEVAL_DOCUMENTr3   r*   r   r+   r	   r:   EMBEDDING_MAX_BATCH_SIZEr
   BatchEmbedContentsRequestbatch_embed_contentstypeto_dictextendrQ   r   rR   rE   r>   r?   r@   rA   rB   rC   rD   resultr[   r8   embedding_requestembedding_responseembedding_dicts   ` ```        r.   rE   rE   |   s   N ''.E~.0i(0A0T0TT B  CL  BM  MY  Z_  Y`  `a  b
 	
 !6!:_`u_vvwx
 	
  +	'8$$Z#w-P-Pr"	
 	
 h(@AE & @ @uW\ ]!'!<!<!"!" ""45==>PQN;&&&YN<<X&YY B "66!,,W5"7
 $11

 0199:LM&4[&A(&K{#r0   c                   #    g 7fr)   r<   r=   s          r.   embed_content_asyncrs      s
       #   c                   #    g 7fr)   r<   r=   s          r.   rs   rs      s
      %(rt   c                  ^ ^^^#    [         R                  " T 5      m Uc  0 nUc
  [        5       nT(       a.  [        T5      [        R
                  La  [        ST ST S35      eT(       a  TS:  a  [        ST S35      eT(       a  [        T5      m[        U[        5      (       a  [        U[        [        45      (       d  S/ 0nU UUU4S jU 5       n[        U[        5       Hk  n	[        R                  " T U	S	9n
UR                  " U
40 UD6I Sh  vN n[!        U5      R#                  U5      nUS   R%                  S
 US    5       5        Mm     U$ [        R&                  " T [(        R*                  " U5      TTTS9n
UR,                  " U
40 UD6I Sh  vN n[!        U5      R#                  U5      nUS   S   US'   U$  N N-7f)z?Calls the API to create async embeddings for content passed in.NrH   rI   rJ   r   rK   rL   c           	   3  |   >#    U  H1  n[         R                  " T[        R                  " U5      TTTS 9v   M3     g7frN   rP   rS   s     r.   rV   &embed_content_async.<locals>.<genexpr>  rX   rY   rZ   c              3  *   #    U  H	  oS    v   M     g7fr]   r<   r_   s     r.   rV   rx   (  ra   rb   rc   rO   r^   )r   rd   r   r/   re   rf   r3   r*   r   r+   r	   r:   rg   r
   rh   ri   rj   rk   rl   rQ   r   rR   rE   rm   s   ` ```        r.   rs   rs      s     ''.E~46i(0A0T0TT B  CL  BM  MY  Z_  Y`  `a  b
 	
 !6!:_`u_vvwx
 	
  +	'8$$Z#w-P-Pr"	
 	
 h(@AE & @ @uW\ ]'-'B'B!(!( " ""45==>PQN;&&&YN<<X&YY B "66!,,W5"7
 $*#7#7$
$
 
 0199:LM&4[&A(&K{#+"
s%   DGGBGG,GG)r-   EmbeddingTaskTypeOptionsreturnre   )r6   zIterable[T]r7   intr{   zIterable[list[T]])NNNNN)r>    model_types.BaseModelNameOptionsr?   content_types.ContentTyper@   EmbeddingTaskTypeOptions | NonerA   
str | NonerB   
int | NonerC   "glm.GenerativeServiceClient | NonerD   &helper_types.RequestOptionsType | Noner{   text_types.EmbeddingDict)r>   r}   r?   #Iterable[content_types.ContentType]r@   r   rA   r   rB   r   rC   r   rD   r   r{   text_types.BatchEmbeddingDict)r>   r}   r?   ?content_types.ContentType | Iterable[content_types.ContentType]r@   r   rA   r   rB   r   rC   zglm.GenerativeServiceClientrD   r   r{   8text_types.EmbeddingDict | text_types.BatchEmbeddingDict)r>   r}   r?   r~   r@   r   rA   r   rB   r   rC   'glm.GenerativeServiceAsyncClient | NonerD   r   r{   r   )r>   r}   r?   r   r@   r   rA   r   rB   r   rC   r   rD   r   r{   r   )r>   r}   r?   r   r@   r   rA   r   rB   r   rC   z glm.GenerativeServiceAsyncClientrD   r   r{   r   )0
__future__r   	itertoolstypingr   r   r   r   r   r	   google.ai.generativelanguageaigenerativelanguageglmgoogle.generativeair
   google.generativeai.clientr   r   google.generativeai.typesr   r   r   r   DEFAULT_EMB_MODELrg   TaskTypere   r|   r+   rz   TASK_TYPE_UNSPECIFIEDRETRIEVAL_QUERYrf   SEMANTIC_SIMILARITYCLASSIFICATION
CLUSTERINGQUESTION_ANSWERINGFACT_VERIFICATIONr'   __annotations__r/   batchedr:   AttributeErrorr1   rE   rs   r<   r0   r.   <module>r      s]   #  C C * * & D J 2 1 0 3*  OO  c+<!<= K++->-T-TK..K .DDK $::	K
 %%'8'H'HK ((K (88K ..K ((*;*N*NK ++K +>>K !44K ))+<+P+PK ,,K ,@@K  #77!K" $$&7&F&F#K$ '''66  "3">">###..+++>>

.
.((*;*N*N***<<%77''):)L)L=K G D#  H( 
 26(,15>B#+#&# /# 	#
 &# /# <# # 
# 
 26(,15>B(+(0( /( 	(
 &( /( <( #( 
( 26(,*.>B_+_L_ /_ 	_
 &_ (_ <_ >_D 
 26(,6:>B#+#&# /# 	#
 &# 4# <# # 
# 
 26(,6:>B(+(0( /( 	(
 &( 4( <( #( 
( 26(,/3>BB+BLB /B 	B
 &B -B <B >BK  As   ?L LL