ó
    ³ü¡j„  ã                  óÚ   • S r SSKJr  SSKJrJrJrJrJr  SSK	J
r
JrJr  SSKJr  SSKJrJrJrJr  SSKJr  \S   rSS	 jrSS
 jr  S         SS jjr  S         SS jjrg)u¤  Answering to a stated expectation rather than an inferred one.

The union in `shapes` lets the model decide whether a question wants a figure
or an explanation, and it decides well â€” but "well" is not "predictably", and a
caller that wanted prose and got a figure has no recourse except to rephrase.
So the expectation is something the caller states:

    auto   the model chooses the payload from the union
    value  a figure, whatever the question looked like
    text   an explanation, whatever the question looked like

Every path returns the same `Answer`, so stating an expectation changes which
shape comes back and nothing else about the contract. `value` and `text` go
through `declared` â€” the caller-supplied-schema path â€” which is exactly what
stating an expectation means.

A forced shape can still fail honestly: asking for a figure where the context
holds none returns `unanswerable` rather than inventing one.
é    )Úannotations)ÚAsyncIteratorÚListÚLiteralÚOptionalÚTuple)ÚdeclaredÚfixedÚ	streaming)ÚDocumentIdentity)ÚAnswerÚProseÚScalarÚUnanswerable)ÚRetrievedChunk)ÚautoÚvalueÚtextc                óä   • U R                   (       a%  [        [        U R                   S9U R                  S9$ [        [	        U R
                  U R                  U R                  S9U R                  S9$ )N©Úreason©ÚpayloadÚ	cited_ids)r   ÚunitÚperiod)Ú	not_foundr   r   r   r   r   r   r   ©Úresults    ÚB/home/mande/repo/quber/src/quber/playground/answers/expectation.pyÚscalar_answerr!   !   sW   € Ø××Üœl°&×2BÑ2BÑCÈv×O_ÑO_Ñ`Ð`ÜÜ˜VŸ\™\°·±ÀFÇMÁMÑRØ×"Ñ"ñð ó    c                óÚ   • U R                   (       a6  U R                  (       d%  [        [        U R                   S9U R                  S9$ [        [        U R                  S9U R                  S9$ )Nr   r   )r   )r   r   r   r   r   r   r   s    r    Úprose_answerr$   *   sK   € Ø×× §§Üœl°&×2BÑ2BÑCÈv×O_ÑO_Ñ`Ð`Üœ% V§[¡[Ñ1¸V×=MÑ=MÑNÐNr"   Nc              ƒ  óH  #   • US:X  a7  [        [        R                  " X[        R                  U5      I S h  v•N 5      $ US:X  a7  [	        [        R                  " X[        R
                  U5      I S h  v•N 5      $ [        R                  " XU5      I S h  v•N $  Nd N) N7f)Nr   r   )r!   r	   ÚanswerÚDeclaredScalarr$   ÚDeclaredProser
   )ÚquestionÚchunksÚwantÚdocuments       r    r&   r&   0   sy   é € ð ˆwƒÜ¤8§?¢?°8ÄX×E\ÑE\Ð^fÓ#g×gÓhÐhØˆvƒ~Ü¤(§/¢/°(ÄH×DZÑDZÐ\dÓ"e×eÓfÐfÜ—’˜h°Ó9×9Ð9ñ háeÙ9ùs3   ‚5B"·B¸<B"Á4BÁ5"B"ÂB ÂB"ÂB"Â B"c               ó¦  #   • US:X  as  [         R                  " X[         R                  SU5        Sh  v•N u  pEUS:X  a  XE47v •  M  [        U[         R                  5      (       d   eS[	        U5      47v •  ML  US:X  a  S[        XSU5      I Sh  v•N 47v •  g[        R                  " XU5        Sh  v•N u  pEXE47v •  M   N’
 g N7 N
 g7f)zHYield ("delta", text) while readable text grows, then ("final", Answer).r   NÚdeltaÚfinalr   )r	   Úanswer_streamr(   Ú
isinstancer$   r&   r   )r)   r*   r+   r,   Úkindr   s         r    r0   r0   =   sÏ   é € ð ˆvƒ~Ü#+×#9Ò#9Øœh×4Ñ4°f¸hô$
÷ 	5‘-�$ð �w‹Ø�mÕ#ä! '¬8×+AÑ+A×BÑBÐBÐBØœ|¨GÓ4Ð4Õ4àˆwƒð œV H°g¸xÓH×HÐHÓHØÜ(×6Ò6°xÈÔR÷ ‰mˆdØˆmÕñ	5ð $
ð 	ñ IñÑRùsV   ‚.C°C	´CµC	¸ACÂCÂ CÂ4CÂ8CÂ9CÂ<CÃC	Ã	CÃCÃC)r   zdeclared.DeclaredScalarÚreturnr   )r   zdeclared.DeclaredProser3   r   )r   N)
r)   Ústrr*   úList[RetrievedChunk]r+   ÚWantr,   úOptional[DocumentIdentity]r3   r   )
r)   r4   r*   r5   r+   r6   r,   r7   r3   z!AsyncIterator[Tuple[str, object]])Ú__doc__Ú
__future__r   Útypingr   r   r   r   r   Úquber.playground.answersr	   r
   r   Ú!quber.playground.answers.documentr   Úquber.playground.answers.shapesr   r   r   r   Úquber.playground.retrievalr   r6   r!   r$   r&   r0   © r"   r    Ú<module>r@      s³   ðñõ( #ç @Õ @ç ?Ñ ?Ý >ß OÓ OÝ 5àÐ&Ñ'€ôôOð Ø+/ð	
:Øð
:à ð
:ð ð
:ð )ð	
:ð
 õ
:ð  Ø+/ð	Øðà ðð ðð )ð	ð
 'ör"   