ó
    ³ü¡jb
  ã                  ó´   • S 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
Jr  SSKJr  SSKJrJrJr  SSKJr  SS	KJr  SS
KJrJr  SS jr S       SS jjrg)uƒ  Streaming a typed answer.

The playground streams today because a prose answer is worth watching arrive.
A figure is not â€” by the time a scalar validates there is nothing to animate â€”
but the question is not whether streaming is useful for a scalar, it is
whether adding a shape breaks the streaming path that prose still needs.

So the stream yields the same two events as before. `delta` carries whatever
text is readable so far, which is the prose payload's text while it grows and
nothing at all for a scalar; `final` carries the validated `Answer`. A caller
that only wants the value ignores the deltas and waits for the final event.
é    )Úannotations)ÚAsyncIteratorÚListÚOptionalÚTuple)Úusage_metadata_from)ÚDEFAULT_MODEL)ÚDocumentIdentity)Úbuild_agentÚ
prompt_forÚtrace_inputs)ÚAnswer)ÚRetrievedChunk)Úrun_metadataÚtracerc                ót   • [        U SS5      nUc  g[        USS5      S:w  a  g[        USS5      =(       d    S$ )z¿The text worth showing from a partially built answer, if any.

Only the prose payload has text that grows. A partial whose payload is not
yet determined, or is a figure, has nothing to show.
ÚpayloadNÚ ÚkindÚproseÚtext)Úgetattr)Úpartialr   s     Ú@/home/mande/repo/quber/src/quber/playground/answers/streaming.pyÚreadabler      sB   € ô �g˜y¨$Ó/€GØ�ØÜˆw˜ Ó%¨Ó0ØÜ�7˜F BÓ'×-¨2Ð-ó    Nc               ó²  #   • [        XU5      n[        5       R                  S[        X15      [        [        5       S9 ISh  v•N n[        5       R                  U5       ISh  v•N nSnUR                  SS9  Sh  v•N n[        U5      nU(       d  M  X†:w  d  M$  UnSU47v •  M/   Nf NF N.
 UR                  5       I Sh  v•N  n	SU	R                  5       S	./[        UR                  5      S
.Ul        SSS5      ISh  v•N    O! , ISh  v•N  (       d  f       O= fSW	47v •  SSS5      ISh  v•N    g! , ISh  v•N  (       d  f       g= f7f)zCYield ("delta", text) as prose accumulates, then ("final", Answer).Úanswer_fixed)ÚmodelÚextra_metadataNr   gš™™™™™©?)Údebounce_byÚdeltaÚ	assistant)ÚroleÚcontent)ÚmessagesÚusage_metadataÚfinal)r   r   Úllm_runr   r	   r   r   Ú
run_streamÚstream_outputr   Ú
get_outputÚmodel_dump_jsonr   ÚusageÚoutputs)
ÚquestionÚchunksÚdocumentÚpromptÚrunÚresultÚlastr   r   r(   s
             r   Úanswer_streamr7   )   s&  é € ô ˜¨(Ó3€FÜ‹x×ÑØœ VÓ4¼MÔZfÓZhð  ÷ ñ à	Ü“=×+Ñ+¨F×3Ô3°vØˆDØ!'×!5Ñ!5À$Ð!5Ñ!G÷ (�gÜ Ó(�ß�4˜D�LØ�DØ! 4˜-Õ'ññ 4ñ(Ð!Gð
 #)×"3Ñ"3Ó"5×5Ð5ˆEà&1¸e×>SÑ>SÓ>UÑVÐWÜ"5°f·l±lÓ"CñˆCŒK÷ 4×3×3×3×3Ð3úð �uˆnÓ÷÷ ÷ ÷ ÷ ð üsÆ   ‚A EÁB)ÁEÁD=Á$B+Á%D=Á(D
Á:B/Á>B-
Á?B/ÂD
ÂD
ÂD
Â)EÂ+D=Â-B/Â/D
ÃCÃ4D
Ã8D=ÄDÄD=Ä
D!	ÄDÄD!	ÄD=Ä+EÄ6D9Ä7EÄ=EÅEÅEÅE)r   ÚobjectÚreturnÚstr)N)r0   r:   r1   zList[RetrievedChunk]r2   zOptional[DocumentIdentity]r9   z!AsyncIterator[Tuple[str, object]])Ú__doc__Ú
__future__r   Útypingr   r   r   r   Úquber.agents.langsmith_tracerr   Úquber.playground.agentr	   Ú!quber.playground.answers.documentr
   Úquber.playground.answers.fixedr   r   r   Úquber.playground.answers.shapesr   Úquber.playground.retrievalr   Úquber.playground.tracingr   r   r   r7   © r   r   Ú<module>rF      s^   ðñõ #ç 7Ó 7å =Ý 0Ý >ß PÑ PÝ 2Ý 5ß 9ô.ð Y]ðØðØ/ðØ;Uðà&ör   