§
    ~Štjb	  ã                  ór   — d Z ddlmZ ddlZddlmZmZ  ej        e¦  «        Z	g d¢Z
dZdd„Zdd„Zdd„ZdS )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Ð  ÚobserveúCallable[[Any], None]Úeventr   ÚreturnÚNonec                óx   — 	  | |¦  «         dS # t           $ r  t                               dd¬¦  «         Y dS w xY w)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)r	   r   s     ú_/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langsmith/_internal/voice/helpers.pyr   r      sb   € ð
Øˆ�‰ŒˆˆˆøÝð 
ð 
ð 
Ý�ŠØDÈtð 	ñ 	
ô 	
ð 	
ð 	
ð 	
ð 	
ð
øøøs   ‚ �&9¸9Úobjc                óÀ  — t          | t          ¦  «        rdt          | ¦  «        › d�S t          | t          ¦  «        rEt          | ¦  «        t          k    r+| dt          …         dt          | ¦  «        t          z
  › d�z   S | S t          | t
          ¦  «        rd„ |                      ¦   «         D ¦   «         S t          | t          t          f¦  «        rd„ | D ¦   «         S | S )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>c                ó4   — i | ]\  }}|t          |¦  «        “ŒS © ©r   )Ú.0ÚkÚvs      r   ú
<dictcomp>zscrub.<locals>.<dictcomp>7   s$   € Ð4Ð4Ð4¡  1�•5˜‘8”8Ð4Ð4Ð4ó    c                ó,   — g | ]}t          |¦  «        ‘ŒS r   r   )r   r   s     r   ú
<listcomp>zscrub.<locals>.<listcomp>9   s   € Ð&Ð&Ð&˜Q•�a‘”Ð&Ð&Ð&r   )	Ú
isinstanceÚbytesÚlenÚstrÚMAX_STRÚdictÚitemsÚlistÚtuple)r   s    r   r   r   (   sÜ   € õ �#•uÑÔð %Ø$•3�s‘8”8Ð$Ð$Ð$Ð$Ý�#•sÑÔð Ýˆs‰8Œ8•gÒÐØ�x��x”=Ð#G­C°©H¬HµwÑ,>Ð#GÐ#GÐ#GÑGÐGØˆ
Ý�#•tÑÔð 5Ø4Ð4¨¯	ª	©¬Ð4Ñ4Ô4Ð4Ý�#��e�}Ñ%Ô%ð 'Ø&Ð& #Ð&Ñ&Ô&Ð&Ø€Jr   údict[str, Any]c                ó¼   — t          | d¦  «        r%	 |                      ¦   «         S # t          $ r Y nw xY wt          | t          ¦  «        r| S dt          | ¦  «        iS )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   =   ss   € åˆu�lÑ#Ô#ð ð	Ø×#Ò#Ñ%Ô%Ð%øÝð 	ð 	ð 	ØˆDð	øøøå�%�ÑÔð ØˆØ•D˜‘K”KÐ Ð s   ’& ¦
3²3)r	   r
   r   r   r   r   )r   r   r   r   )r   r   r   r*   )Ú__doc__Ú
__future__r   ÚloggingÚtypingr   r   Ú	getLoggerÚ__name__r   Ú__all__r%   r   r   r   r   r   r   ú<module>r6      s®   ðð	ð 	ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  à	ˆÔ	˜8Ñ	$Ô	$€à
3Ð
3Ð
3€ð €ð
ð 
ð 
ð 
ðð ð ð ð*	!ð 	!ð 	!ð 	!ð 	!ð 	!r   