ó
    üÞ jb	  ã                  óz   • S r SSKJr  SSKrSSKJrJr  \R                  " \5      r	/ SQr
SrS
S jrSS jrSS	 jrg)u  Shared helpers for the voice integration adapters.

* ``dump_event`` â€” best-effort conversion of an event object to a plain dict
  (Pydantic ``model_dump`` â†’ ``dict`` â†’ ``repr`` fallback).
* ``scrub`` â€” replace raw audio ``bytes`` with a ``<N bytes>`` placeholder and
  truncate long strings, recursing through dicts and sequences, so a span never
  carries megabytes of audio or un-serializable junk.
* ``observe_safely`` â€” run an adapter's per-event ``observe`` so a tracing error
  never escapes into the caller's live loop.
é    )ÚannotationsN)ÚAnyÚCallable)Ú
dump_eventÚscrubÚobserve_safelyiÐ  c                ó^   •  U " U5        g! [          a    [        R                  SSS9   gf = f)zÍRun an adapter's ``observe`` over one event, swallowing any error.

Tracing must never break the live voice loop, so a failure building the
trace is logged and dropped and the caller still gets its event.
z6voice tracing: failed to observe an event; skipping itT)Úexc_infoN)Ú	ExceptionÚloggerÚwarning)ÚobserveÚevents     Ú[/var/www/html/gaurav/venv/lib/python3.13/site-packages/langsmith/_internal/voice/helpers.pyr   r      s3   € ð
Ù��øÜó 
Ü�‰ØDÈtð 	ó 	
ð
ús   ‚ ‹,«,c                óê  • [        U [        5      (       a  S[        U 5       S3$ [        U [        5      (       a5  [        U 5      [        :”  a   U S[         S[        U 5      [        -
   S3-   $ U $ [        U [
        5      (       a.  U R                  5        VVs0 sH  u  pU[        U5      _M     snn$ [        U [        [        45      (       a  U  Vs/ sH  n[        U5      PM     sn$ U $ s  snnf s  snf )a  Make an event payload safe and compact for a span.

Replaces raw ``bytes`` (audio / base64 blobs) with a ``<N bytes>``
placeholder and truncates very long strings, recursing through dicts and
sequences, so a span never ships megabytes of payload or breaks JSON
serialization.
Ú<z bytes>Nz... <+z chars>)
Ú
isinstanceÚbytesÚlenÚstrÚMAX_STRÚdictÚitemsr   ÚlistÚtuple)ÚobjÚkÚvs      r   r   r   (   sÏ   € ô �#”u×ÑØ”3�s“8�*˜GÐ$Ð$Ü�#”s×ÑÜˆs‹8”gÓØ�xœ�= V¬C°«H´wÑ,>Ð+?¸wÐ#GÑGÐGØˆ
Ü�#”t×ÑØ(+¯	©	¬Ô4©¡ �”5˜“8’©Ò4Ð4Ü�#œœe�}×%Ñ%Ù"%Ó&¡#˜Q”�a–¡#Ñ&Ð&Ø€Jùó 5ùâ&s   ÂC*ÃC0c                ó®   • [        U S5      (       a   U R                  5       $ [        U [        5      (       a  U $ S[        U 5      0$ ! [         a     N0f = f)z:Best-effort conversion of an event object to a plain dict.Ú
model_dumpÚrepr)Úhasattrr    r   r   r   r!   )r   s    r   r   r   =   sZ   € äˆu�l×#Ñ#ð	Ø×#Ñ#Ó%Ð%ô �%œ×ÑØˆØ”D˜“KÐ Ð øô	 ó 	Ùð	ús   “A Á
AÁA)r   zCallable[[Any], None]r   r   ÚreturnÚNone)r   r   r#   r   )r   r   r#   zdict[str, Any])Ú__doc__Ú
__future__r   ÚloggingÚtypingr   r   Ú	getLoggerÚ__name__r   Ú__all__r   r   r   r   © ó    r   Ú<module>r.      s@   ðñ	õ #ã ß  à	×	Ò	˜8Ó	$€â
3€ð €ô
ôõ*	!r-   