-;iF/UddlmZddlZddlmZmZmZmZmZm Z ddl m cm Z ddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZd Zd ZejZeeeefZiejejdejd ejdejej ej dej dej dej ej!ej!dej!dej!dej!ej"ej"dej"dej"dej"ej#ej#dej#dej#ej$ej$dej$dej$dej%dej%dej%ej%ej%dej&d ej&d!ej&ej&ej&i Z'd"e(d#<dLd(Z) ej*Z+n#e,$red)Z-dMd/Z+YnwxYwe dNdOd?Z.e dNdPdBZ. dNdQdFZ.e dNdRdHZ/e dNdSdIZ/ dNdTdKZ/dS)U) annotationsN)AnyIterableoverloadTypeVarUnionMapping)protos)get_default_generative_client)#get_default_generative_async_client) helper_types) model_types) text_types) content_typeszmodels/embedding-001dtask_type_unspecified unspecifiedretrieval_queryqueryretrieval_documentdocumentsemantic_similarity similarityclassification clusteringquestion_answeringqafact_verification verificationz1dict[EmbeddingTaskTypeOptions, EmbeddingTaskType]_EMBEDDING_TASK_TYPExEmbeddingTaskTypeOptionsreturnEmbeddingTaskTypecnt|tr|}t|SN) isinstancestrlowerr')r(s QC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\google/generativeai/embedding.py to_task_typer2Hs,!S GGII  ""Titerable Iterable[T]nintIterable[list[T]]c#K|dkrtd|dg}|D]0}||t||kr|Vg}1|r|VdSdS)NrzKInvalid input: The batch size 'n' must be a positive integer. You entered: z'. Please enter a number greater than 0.) ValueErrorappendlen)r5r7batchitems r1_batchedr@Ts q55I^_III   D LL   5zzQ   KKKKK  r3model model_types.BaseModelNameOptionscontentcontent_types.ContentType task_typeEmbeddingTaskTypeOptions | Nonetitle str | Noneoutput_dimensionality int | Noneclient"glm.GenerativeServiceClient | Nonerequest_options&helper_types.RequestOptionsType | Nonetext_types.EmbeddingDictcdSr-rArCrErGrIrKrMs r1 embed_contentrSds  #sr3#Iterable[content_types.ContentType]text_types.BatchEmbeddingDictcdSr-rQrRs r1rSrSps %(Cr3?content_types.ContentType | Iterable[content_types.ContentType]glm.GenerativeServiceClient8text_types.EmbeddingDict | text_types.BatchEmbeddingDictctj|i}|t}r1ttjurt dddrdkrt ddrtt|trt|ttfsdgi}fd|D}t|tD]s} tj| } |j| fi|} t!| | } |dd | d Dt|Stjt)j| } |j| fi|} t!| | } | dd | d<| S)aCalls 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. NsInvalid task type: When a title is specified, the task must be of a 'retrieval document' type. Received task type: and title: .rQInvalid value: `output_dimensionality` must be a non-negative integer. Received: embeddingc3nK|]/}tjtj|V0dSrArCrErGrINr EmbedContentRequestr to_content.0crArIrErGs r1 z embed_content..e     &%033#&;           r3rArequestsc3&K|] }|dV dSvaluesNrQrges r1riz embed_content..&&Y&Yqq{&Y&Y&Y&Y&Y&Yr3 embeddingsrbro)rmake_model_namer r2r+RETRIEVAL_DOCUMENTr;r.rr/r r@EMBEDDING_MAX_BATCH_SIZEr BatchEmbedContentsRequestbatch_embed_contentstypeto_dictextendrdrrerS rArCrErGrIrKrMresultrlr>embedding_requestembedding_responseembedding_dicts ` ``` r1rSrS|sN  ' . .E ~.00  i((0A0TTT bCL b bZ_ b b b    !6!:!: x`u x x x   , ++ '8$$#Z#w-P-P#r"            h(@AA Z ZE & @uW\ ] ] ] !<!<!""!"" ""455==>PQQN ;  & &&Y&YN<.rjr3rkc3&K|] }|dV dSrnrQrps r1riz&embed_content_async..(rrr3rsrbro)rrtr r2r+rur;r.rr/r r@rvr rwrxryrzr{rdrrerSr|s ` ``` r1rrs  ' . .E ~466  i((0A0TTT bCL b bZ_ b b b    !6!:!: x`u x x x   , ++ '8$$#Z#w-P-P#r"            h(@AA Z ZE & @uW\ ] ] ] 'Bv'B!((!(("""""" ""455==>PQQN ;  & &&Y&YN<rs#""""""CCCCCCCCCCCCCCCC*********&&&&&&DDDDDDJJJJJJ222222111111000000333333*O c+-TK.K.DK$: K %'8'H K ( K(8K  .K(*;*NK+K+>K!4K)+<+PK,K,@K #7!K"$&7&F#K$''6 "3">##.++>  .(*;*N**<%7'):)L=KKD####  HH A      & 26(,15>B#### # 26(,15>B(((( (26(,*.>B_____D 26(,6:>B#### # 26(,6:>B(((( (26(,/3>BBBBBBBBs>FFF