+
    i6                    H  a  0 t $ ^ RIHt ^ RIt^ RIHt ^ RIt^ RIHtHtH	t	H
t
Ht ^ RIHt ^ RIHu Ht ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt Rt]P@                  PB                  t!]	]"]#]!3,          t$/ ]!PJ                  ]!PJ                  b^ ]!PJ                  bR]!PJ                  bR]!PJ                  b]!PL                  ]!PL                  b^]!PL                  bR]!PL                  bR]!PL                  b]!PN                  ]!PN                  b^]!PN                  bR]!PN                  bR]!PN                  b]!PP                  ]!PP                  b^]!PP                  bR]!PP                  bR]!PP                  bt)R]*R&   R R lt+]	]PX                  ]-]#]P\                  3,          ]P\                  3,          3t/]	]P`                  ]]/,          ]
]#]P\                  3,          3,          t1R R lt2]	]#]Pf                  ]Pf                  ]Ph                  ]Ph                  3,          t5 ! R R]4      t6]	]5]6]Pn                  3,          t8R R  lt9R! R" lt:R#]R$RR%RR&RR'RR(R/R) R* llt;R#]R$RR%RR&RR'RR(RR+RR,R/R- R. llt<R#]R$RR%RR&RR'RR(RR+RR,R/R/ R0 llt=R# )1    )annotationsN)Iterable)Anyr   UnionMappingOptional)	TypedDict)protos)get_default_generative_client#get_default_generative_async_client)model_types)helper_types)safety_types)content_types)retriever_types)MetadataFilterz
models/aqaanswer_style_unspecifiedunspecifiedanswer_style_abstractiveabstractiveanswer_style_extractive
extractiveanswer_style_verboseverbosez%dict[AnswerStyleOptions, AnswerStyle]_ANSWER_STYLESc                    V ^8  d   QhRRRR/# )   xAnswerStyleOptionsreturnAnswerStyle )formats   "m/Users/igloo/.openclaw/workspace/scratch/fb_ad_env/lib/python3.14/site-packages/google/generativeai/answer.py__annotate__r%   ?   s      ) k     c                h    \        V \        4      '       d   V P                  4       p \        V ,          # N)
isinstancestrlowerr   )r   s   &r$   to_answer_styler,   ?   s%    !SGGI!r&   c                    V ^8  d   QhRRRR/# )r   sourceGroundingPassagesOptionsr    zprotos.GroundingPassagesr"   )r#   s   "r$   r%   r%   R   s      7  7%=  7BZ  7r&   c           	        \        V \        P                  4      '       d   V # \        V \        4      '       g#   \	        R\        V 4      P                   R24      h. p\        V \        4      '       d   V P                  4       p \        V 4       F  w  r#\        V\        P                  4      '       d   VP                  V4       K8  \        V\        4      '       d0   Vw  rEVP                  RVR\        P                  ! V4      /4       K}  VP                  R\        V4      R\        P                  ! V4      /4       K  	  \        P                  ! VR7      # )a  
Converts the `source` into a `protos.GroundingPassage`. A `GroundingPassages` contains a list of
`protos.GroundingPassage` objects, which each contain a `protos.Content` and a string `id`.

Args:
    source: `Content` or a `GroundingPassagesOptions` that will be converted to protos.GroundingPassages.

Return:
    `protos.GroundingPassages` to be passed into `protos.GenerateAnswer`.
zdInvalid input: The 'source' argument must be an instance of 'GroundingPassagesOptions'. Received a 'z' object instead.idcontent)passages)r)   r
   GroundingPassagesr   	TypeErrortype__name__r   items	enumerateGroundingPassageappendtupler   
to_contentr*   )r.   r3   ndatar1   r2   s   &     r$   _make_grounding_passagesr@   R   s    &&2233fh''rswx~s  tI  tI  sJ  J[  \
 	
 H&'""V$dF3344OOD!e$$KBOOT2y-2J2J72STUOOT3q69m6N6Nt6TUV % ##X66r&   c                  J    ] tR t^zt$ R]R&   R]R&   R]R&   R]R&   R	]R
&   RtR# )SemanticRetrieverConfigDictSourceNameTyper.   content_types.ContentsTypequeryz"Optional[Iterable[MetadataFilter]]metadata_filterzOptional[int]max_chunks_countzOptional[float]minimum_relevance_scorer"   N)r7   
__module____qualname____firstlineno____annotations____static_attributes__r"   r&   r$   rB   rB   z   s     %%77##,,r&   rB   c                   V ^8  d   QhRR/# )r   r    z
str | Noner"   )r#   s   "r$   r%   r%      s      j r&   c                    \        V \        4      '       d   V # \        V \        P                  \        P                  \        P
                  \        P
                  34      '       d   V P                  # R # r(   )r)   r*   r   Corpusr
   Documentname)r.   s   &r$   _maybe_get_source_namerS      sU    &#	''8P8PRXRaRab
 
 {{r&   c               $    V ^8  d   QhRRRRRR/# )r   r.   SemanticRetrieverConfigOptionsrE   rD   r    zprotos.SemanticRetrieverConfigr"   )r#   s   "r$   r%   r%      s&     2 2*2%2 $2r&   c                   \        V \        P                  4      '       d   V # \        V 4      pVe   RV/p MP\        V \        4      '       d   \        V R,          4      V R&   M$\        R\        V 4      P                   RV  24      hV R,          f   WR&   M=\        V R,          \        4      '       d!   \        P                  ! V R,          4      V R&   \        P                  ! V 4      # )Nr.   zlInvalid input: Failed to create a 'protos.SemanticRetrieverConfig' from the provided source. Received type: z, Received value: rE   )r)   r
   SemanticRetrieverConfigrS   dictr5   r6   r7   r*   r   r=   )r.   rE   rR   s   && r$   _make_semantic_retriever_configrY      s     &&8899!&)DD!	FD	!	!1&2BCx"6l334 5%h(
 	
 gw	F7OS	)	)'226'?Cw))&11r&   modelinline_passagessemantic_retrieveranswer_stylesafety_settingstemperaturec               8    V ^8  d   QhRRRRRRRRR	R
RRRRRR/# )r   rZ   model_types.AnyModelNameOptionscontentsrD   r[   GroundingPassagesOptions | Noner\   %SemanticRetrieverConfigOptions | Noner]   AnswerStyle | Noner^   (safety_types.SafetySettingOptions | Noner_   float | Noner    zprotos.GenerateAnswerRequestr"   )r#   s   "r$   r%   r%      sZ     ? ?*? )? 5	?
 >? %? >? ? "?r&   c           
        \         P                  ! V 4      p \        P                  ! V4      pV'       d   \        P
                  ! V4      pVe   Ve   \        RV RV R24      hVe   \        V4      pM)Ve   \        W1R,          4      pM\        RV RV R24      hV'       d   \        V4      p\        P                  ! V VVVVVVR7      # )a  
constructs a protos.GenerateAnswerRequest object by organizing the input parameters for the API call to generate a grounded answer from the model.

Args:
    model: Name of the model used to generate the grounded response.
    contents: Content of the current conversation with the model. For single-turn query, this is a
        single question to answer. For multi-turn queries, this is a repeated field that contains
        conversation history and the last `Content` in the list containing the question.
    inline_passages: Grounding passages (a list of `Content`-like objects or `(id, content)` pairs,
        or a `protos.GroundingPassages`) to send inline with the request. Exclusive with `semantic_retriever`,
        one must be set, but not both.
    semantic_retriever: A Corpus, Document, or `protos.SemanticRetrieverConfig` to use for grounding. Exclusive with
         `inline_passages`, one must be set, but not both.
    answer_style: Style for grounded answers.
    safety_settings: Safety settings for generated output.
    temperature: The temperature for randomness in the output.

Returns:
    Call for protos.GenerateAnswerRequest().
zInvalid configuration: Please set either 'inline_passages' or 'semantic_retriever_config', but not both. Received for inline_passages: z, and for semantic_retriever: .zInvalid configuration: Either 'inline_passages' or 'semantic_retriever_config' must be provided, but currently both are 'None'. Received for inline_passages: rZ   rb   r[   r\   r^   r_   r]   )r   make_model_namer   to_contentsr   normalize_safety_settings
ValueErrorr@   rY   r5   r,   r
   GenerateAnswerRequest)rZ   rb   r[   r\   r]   r^   r_   s   $$$$$$$r$   _make_generate_answer_requestrq      s    < ''.E((2H&@@Q"'9'E--<,==[\n[oopr
 	
 
	$2?C		'<=OZ\Q]^--<,==[\n[oopr
 	

 &|4'''-'! r&   clientrequest_optionsc               <    V ^8  d   QhRRRRRRRRR	R
RRRRRRRR/	# r   rZ   ra   rb   rD   r[   rc   r\   rd   r]   re   r^   rf   r_   rg   rr   z"glm.GenerativeServiceClient | Noners   z&helper_types.RequestOptionsType | Noner"   )r#   s   "r$   r%   r%      so     E E*E )E 5	E
 >E %E >E E /E <Er&   c        	   
     x    Vf   / pVf   \        4       p\        V VVVVVVR7      p	VP                  ! V	3/ VB p
V
# )aC  Calls the GenerateAnswer API and returns a `types.Answer` containing the response.

You can pass a literal list of text chunks:

>>> from google.generativeai import answer
>>> answer.generate_answer(
...     content=question,
...     inline_passages=splitter.split(document)
... )

Or pass a reference to a retreiver Document or Corpus:

>>> from google.generativeai import answer
>>> from google.generativeai import retriever
>>> my_corpus = retriever.get_corpus('my_corpus')
>>> genai.generate_answer(
...     content=question,
...     semantic_retriever=my_corpus
... )


Args:
    model: Which model to call, as a string or a `types.Model`.
    contents: The question to be answered by the model, grounded in the
            provided source.
    inline_passages: Grounding passages (a list of `Content`-like objects or (id, content) pairs,
        or a `protos.GroundingPassages`) to send inline with the request. Exclusive with `semantic_retriever`,
        one must be set, but not both.
    semantic_retriever: A Corpus, Document, or `protos.SemanticRetrieverConfig` to use for grounding. Exclusive with
         `inline_passages`, one must be set, but not both.
    answer_style: Style in which the grounded answer should be returned.
    safety_settings: Safety settings for generated output. Defaults to None.
    temperature: Controls the randomness of the output.
    client: If you're not relying on a default client, you pass a `glm.GenerativeServiceClient` instead.
    request_options: Options for the request.

Returns:
    A `types.Answer` containing the model's text answer response.
rj   )r   rq   generate_answerrZ   rb   r[   r\   r]   r^   r_   rr   rs   requestresponses   $$$$$$$$$  r$   rw   rw      sX    f ~.0+'-'!G %%gAAHOr&   c               <    V ^8  d   QhRRRRRRRRR	R
RRRRRRRR/	# ru   r"   )r#   s   "r$   r%   r%   9  sd     2 2*2 )2 5	2
 >2 %2 >2 2 /2 <2r&   c        	   
        "   Vf   / pVf   \        4       p\        V VVVVVVR7      p	VP                  ! V	3/ VB G Rj  xL
 p
V
#  L5i)a  
Calls the API and returns a `types.Answer` containing the answer.

Args:
    model: Which model to call, as a string or a `types.Model`.
    contents: The question to be answered by the model, grounded in the
            provided source.
    inline_passages: Grounding passages (a list of `Content`-like objects or (id, content) pairs,
        or a `protos.GroundingPassages`) to send inline with the request. Exclusive with `semantic_retriever`,
        one must be set, but not both.
    semantic_retriever: A Corpus, Document, or `protos.SemanticRetrieverConfig` to use for grounding. Exclusive with
         `inline_passages`, one must be set, but not both.
    answer_style: Style in which the grounded answer should be returned.
    safety_settings: Safety settings for generated output. Defaults to None.
    temperature: Controls the randomness of the output.
    client: If you're not relying on a default client, you pass a `glm.GenerativeServiceClient` instead.

Returns:
    A `types.Answer` containing the model's text answer response.
Nrj   )r   rq   rw   rx   s   $$$$$$$$$  r$   generate_answer_asyncr}   9  sd     @ ~46+'-'!G ++GGGGHO Hs   =AA A)>__conditional_annotations__
__future__r   dataclassescollections.abcr   	itertoolstypingr   r   r   r   typing_extensionsr	   google.ai.generativelanguageaigenerativelanguageglmgoogle.generativeair
   google.generativeai.clientr   r   google.generativeai.typesr   r   r   r   r   )google.generativeai.types.retriever_typesr   DEFAULT_ANSWER_MODELrp   r!   intr*   r   ANSWER_STYLE_UNSPECIFIEDABSTRACTIVE
EXTRACTIVEVERBOSEr   rL   r,   r:   r<   ContentTypeGroundingPassageOptionsr4   r/   r@   rP   rQ   rC   rB   rW   rU   rS   rY   rq   rw   r}   )r~   s   @r$   <module>r      s   # "  $  : : ' * * & 2 2 2 3 5 D# **663[01 9((+*N*N9{++9  D D9 ;77	9
 [449 {9  7 79 ;**9 K229 {9 {559 +((9 ,,9 {9 K//9  {""!95 ( 
sM,E,E'E!FHaHaa  !
$%C***+-  7F 		0H0H&//Y
-) - "'
""$" 26?-A? 8<	?
 AE? (,? AE? !%?DE-AE 8<	E
 AEE (,E AEE !%E 26E ?CEP2-A2 8<	2
 AE2 (,2 AE2 !%2 262 ?C2 2r&   