Ë
    ³Œjb	  ã                  ót   — 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y)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                ób   — 	  | |«       y# t         $ r t        j                  dd¬«       Y y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)ÚobserveÚevents     úk/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langsmith/_internal/voice/helpers.pyr   r      s3   € ð
Ù��øÜò 
Ü�‰ØDÈtð 	ö 	
ð
ús   ‚ ‹ .­.c                óº  — t        | t        «      rdt        | «      › d�S t        | t        «      r4t        | «      t        kD  r | dt         dt        | «      t        z
  › d�z   S | S t        | t
        «      r-| j                  «       D ��ci c]  \  }}|t        |«      “Œ c}}S t        | t        t        f«      r| D �cg c]  }t        |«      ‘Œ c}S | S c c}}w c c}w )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©¡  1�”5˜“8‘¨Ò4Ð4Ü�#œœe�}Ô%Ù"%Ó&¡#˜Q”�a• #Ñ&Ð&Ø€Jùó 5ùâ&s   ÂCÂ;Cc                ó˜   — t        | d«      r	 | j                  «       S t        | t        «      r| S dt        | «      iS # t        $ r Y Œ*w xY w)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   =   sT   € äˆu�lÔ#ð	Ø×#Ñ#Ó%Ð%ô �%œÔØˆØ”D˜“KÐ Ð øô	 ò 	Ùð	ús   Ž= ½	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.      sB   ðñ	õ #ã ß  à	ˆ×	Ñ	˜8Ó	$€â
3€ð €ó
óô*	!r-   