§
    ~Štjy  ã                  ó®   — d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	 ddl
mZ ddlmZ dd	lmZ  ej        e¦  «        Zg d
¢Zedddddœdd„¦   «         ZdS )z)LangSmith integration for LiveKit Agents.é    )ÚannotationsN)ÚPath)ÚAnyÚCallableÚOptional)Ú	warn_beta)Úset_thread_idé   )ÚLiveKitLangSmithSpanProcessor)r   Úconfigure_livekitr	   ©Úaudio_path_providerÚapi_keyÚprojectÚendpointr   ú&Optional[Callable[[], Optional[Path]]]r   úOptional[str]r   r   Úkwargsr   Úreturnú'Optional[LiveKitLangSmithSpanProcessor]c                óH  — 	 ddl m} ddlm} ddlm} n3# t          $ r&}t                               d|¦  «         Y d}~dS d}~ww xY wt          d| |||dœ|¤Ž}	 |¦   «         }
|
 
                    |	¦  «         |                     |
¦  «         |                     |
¦  «         |	S )	um  Enable LangSmith tracing for a LiveKit Agents worker.

    Builds a ``TracerProvider`` with a :class:`LiveKitLangSmithSpanProcessor`
    (which rewrites LiveKit's ``lk.*`` spans for LangSmith and exports them to
    LangSmith's OTLP endpoint) and registers it as both LiveKit's tracer provider
    and the OTel global. Call before starting the worker.

    To manage your own ``TracerProvider`` instead, skip this function: construct
    :class:`LiveKitLangSmithSpanProcessor` directly, add it to your provider, and
    register that provider with LiveKit via
    ``livekit.agents.telemetry.set_tracer_provider(...)`` â€” LiveKit only emits
    spans through the provider its tracer is bound to.

    To group a conversation's spans into a LangSmith thread, call
    :func:`set_thread_id` once per conversation (inside that conversation's
    asyncio task). The processor captures it as the conversation's spans start
    and applies it to every span in the trace â€” so it holds even for spans
    finished on a background task, and concurrent conversations stay separated.

    For a realtime (speech-to-speech) model, also call
    :meth:`LiveKitLangSmithSpanProcessor.instrument_session` on the returned
    processor: the user transcript arrives as a session event rather than on a
    span, so without it the trace shows only the agent's turns.

    Args:
        audio_path_provider: zero-arg callable returning a local recording path
            whose bytes are embedded in the root span (console/dev only). For
            production, attach a LiveKit Egress recording via the returned
            processor's ``expect_recording`` / ``complete_recording`` methods.
        api_key / project / endpoint: LangSmith exporter config; default to the
            standard ``LANGSMITH_*`` resolution.

    Returns:
        The processor, or ``None`` if LiveKit / OpenTelemetry aren't installed.
    r   )Útrace)ÚTracerProvider)Ú	telemetryz*Missing dependency for LiveKit tracing: %sNr   © )Úopentelemetryr   Úopentelemetry.sdk.tracer   Úlivekit.agentsr   ÚImportErrorÚloggerÚwarningr   Úadd_span_processorÚset_tracer_provider)r   r   r   r   r   Ú
otel_tracer   r   ÚeÚ	processorÚproviders              úe/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langsmith/integrations/livekit/__init__.pyr   r      s  € ðXØ5Ð5Ð5Ð5Ð5Ð5Ø:Ð:Ð:Ð:Ð:Ð:à,Ð,Ð,Ð,Ð,Ð,Ð,øÝð ð ð Ý�ŠÐCÀQÑGÔGÐGØˆtˆtˆtˆtˆtøøøøðøøøõ .ð Ø/ØØØð	ð ð
 ðð €Ið ˆ~ÑÔ€HØ×Ò 	Ñ*Ô*Ð*Ø×!Ò! (Ñ+Ô+Ð+Ø×"Ò" 8Ñ,Ô,Ð,ØÐs   ‚ •
AŸA Á A)r   r   r   r   r   r   r   r   r   r   r   r   )Ú__doc__Ú
__future__r   ÚloggingÚpathlibr   Útypingr   r   r   Ú#langsmith._internal._beta_decoratorr   Úlangsmith._internal.voicer	   r&   r   Ú	getLoggerÚ__name__r    Ú__all__r   r   ó    r(   ú<module>r4      só   ðØ /Ð /à "Ð "Ð "Ð "Ð "Ð "à €€€Ø Ð Ð Ð Ð Ð Ø *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ð *Ð *à 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3à 4Ð 4Ð 4Ð 4Ð 4Ð 4à	ˆÔ	˜8Ñ	$Ô	$€ðð ð €ð ð CGØ!Ø!Ø"ð?ð ?ð ?ð ?ð ?ñ „ð?ð ?ð ?r3   