+
    iHàj•  ã                  ór   € R 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 R lt ! R	 R
4      tR# )uù  Relay-side accumulator for the chat_completions streaming wire.

Relay invokes its collector for every post-intercept chunk and then its finalizer as soon
as the provider stream ends â€” concurrently with Hermes' consumer thread, which may not have
read the last chunk yet. The finalizer therefore builds Relay's recorded response from
collector-observed state only, never from the consumer loop's closures. Sibling of
``relay_llm.AnthropicStreamAccumulator``; Bedrock and Codex follow the same contract.
)Úannotations)ÚSimpleNamespace)ÚAny)Ú_ToolCallAccumulator)Úflatten_message_text)Úseparate_glued_reasoning_blocksc               ó    € V ^8„  d   QhRRRR/# )é   Útc_deltar   Úreturn© )Úformats   "ÚH/home/ubuntu/.hermes/hermes-agent/agent/chat_completion_helpers_relay.pyÚ__annotate__r      s   € ÷ ^ñ ^ Cð ^¨Cñ ^ó    c                ó¸   € \        V \        4      '       g   V # V P                  R4      p\        R/ / V CR\        V\        4      '       d   \        R/ VB MT/CB # )zýAttribute view of a JSON tool-call delta for ``_ToolCallAccumulator.feed`` (written
against SDK objects). Only ``function`` is wrapped: ``feed`` passes ``extra_content``
(a dict) straight through ``_dump_if_model``, so a recursive view would corrupt it.Úfunctionr   )Ú
isinstanceÚdictÚgetr   )r
   r   s   & r   Ú_tool_call_delta_viewr      si   € ô �h¤×%Ò%ØˆØ�|‰|˜JÓ'€HÜñ ^ð ] ð ]Ø´:¸hÌ×3MÒ3M”OÑ/ hÒ/ÐS[ñ]ñ ^ð ^r   c                  ó>   € ] tR t^tRtR R ltR R ltR R ltRtR	# )
ÚRelayChatAccumulatorzBRebuild a chat.completion from Relay's post-intercept chunk dicts.c               ó   € V ^8„  d   QhRR/# )r	   r   ÚNoner   )r   s   "r   r   Ú!RelayChatAccumulator.__annotate__"   s   € ÷ !ñ !˜$ñ !r   c                	ó”   € . V n         . V n        . V n        . V n        \	        4       V n        R ;V n        ;V n        V n        RV n	        R # )NÚ	assistant)
Ú_contentÚ
_reasoningÚ_refusalÚ_reasoning_detailsr   Ú_tool_callsÚ_modelÚ_usageÚ_finish_reasonÚ_role)Úselfs   &r   Ú__init__ÚRelayChatAccumulator.__init__"   sG   € Ø#%ˆŒØ%'ˆŒØ#%ˆŒØ-/ˆÔÜ/Ó1ˆÔØ:>Ð>ˆŒÐ>�d”k DÔ$7Ø ˆŽ
r   c               ó    € V ^8„  d   QhRRRR/# )r	   Úchunkr   r   r   r   )r   s   "r   r   r   +   s   € ÷ Cñ C˜Sð C Tñ Cr   c                	óN  € \        V\        4      '       g   R # VP                  R4      ;'       g    V P                  V n        VP                  R4      '       d   VR,          V n        VP                  R4      ;'       g    . pV'       d
   V^ ,          MR p\        V\        4      '       g   R # VP                  R4      ;'       g    V P
                  V n        VP                  R4      p\        V\        4      '       g   R # VP                  R4      '       d   VR,          V n        \        VP                  R4      RR	7      pV'       d   V P                  P                  V4       V P                  P                  VP                  R
4      ;'       g    . 4       VP                  R4      ;'       g    VP                  R4      pV'       dK   V P                  P                  \        V P                  '       d   V P                  R,          MRV4      4       VP                  R4      p\        V\        4      '       d$   V'       d   V P                  P                  V4       VP                  R4      ;'       g    .  F'  pV P                   P#                  \%        V4      4       K)  	  R # )NÚmodelÚusageÚchoicesÚfinish_reasonÚdeltaÚroleÚcontentÚ )ÚsepÚreasoning_detailsÚreasoning_contentÚ	reasoningÚrefusalÚ
tool_callséÿÿÿÿ)r   r   r   r#   r$   r%   r&   r   r   Úappendr!   Úextendr   r   Ústrr    r"   Úfeedr   )	r'   r+   r/   Úchoicer1   Útextr8   r9   r
   s	   &&       r   ÚobserveÚRelayChatAccumulator.observe+   sà  € Ü˜%¤×&Ò&ÙØ—i‘i Ó(×7Ð7¨D¯K©KˆŒØ�9‰9�W×ÒØ �.ˆDŒKØ—)‘)˜IÓ&×,Ð,¨"ˆß&�˜–¨DˆÜ˜&¤$×'Ò'ÙØ$Ÿj™j¨Ó9×PÐP¸T×=PÑ=PˆÔØ—
‘
˜7Ó#ˆÜ˜%¤×&Ò&ÙØ�9‰9�V×ÒØ˜v�ˆDŒJÜ# E§I¡I¨iÓ$8¸bÔAˆßØ�M‰M× Ñ  Ô&Ø×Ñ×&Ñ& u§y¡yÐ1DÓ'E×'KÐ'KÈÔLØ—I‘IÐ1Ó2×LÐL°e·i±iÀÓ6Lˆ	ßØ�O‰O×"Ñ"Ô#BØ'+§§ �—‘ Ö#¸BÀ	ó$Kô Là—)‘)˜IÓ&ˆÜ�gœs×#Ò#¯Ø�M‰M× Ñ  Ô)ØŸ	™	 ,Ó/×5Ð5°2Ò5ˆHØ×Ñ×!Ñ!Ô"7¸Ó"AÖBó 6r   c               ó   € V ^8„  d   QhRR/# )r	   r   zdict[str, Any]r   )r   s   "r   r   r   I   s   € ÷ 	_ñ 	_˜.ñ 	_r   c                	ó&  € V P                   P                  4       pR V P                  RRP                  V P                  4      ;'       g    RRRP                  V P
                  4      ;'       g    RRRP                  V P                  4      ;'       g    RRV P                  ;'       g    RR\        V4       Uu. uF  q!V,          NK  	  up;'       g    R/pRV P                  R	V P                  R
RTRV P                  ;'       g    R/./# u upi )r2   r3   r4   Nr7   r9   r6   r:   r-   r.   r/   Úmessager0   Ústop)r"   Úmaterializer&   Újoinr   r   r    r!   Úsortedr#   r$   r%   )r'   ÚaccÚirF   s   &   r   ÚfinalizeÚRelayChatAccumulator.finalizeI   sï   € Ø×Ñ×*Ñ*Ó,ˆØ˜4Ÿ:™: y°"·'±'¸$¿-¹-Ó2H×2PÐ2PÈDØ §¡¨¯©Ó!9×!AÐ!A¸TØ�r—w‘w˜tŸ}™}Ó-×5Ð5°Ø ×!8Ñ!8×!@Ð!@¸DØ¬6°#¬;Ó7©; a˜qŸ6˜6©;Ñ7×?Ð?¸4ð	Aˆð ˜Ÿ™ g¨t¯{©{Ø˜ G¨_¸d×>QÑ>Q×>[Ð>[ÐU[Ð\Ð]ð_ð 	_ùò 8s   Â:D)	r   r%   r#   r   r!   r    r&   r"   r$   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r(   rB   rM   Ú__static_attributes__r   r   r   r   r      s   † ÙLõ!õC÷<	_ñ 	_r   r   N)rS   Ú
__future__r   Útypesr   Útypingr   Ú(agent.chat_completion_helpers_tool_callsr   Úagent.message_contentr   Úagent.reasoning_summariesr   r   r   r   r   r   Ú<module>r[      s0   ðñõ #å !Ý å IÝ 6Ý Eõ^÷3_ó 3_r   