§
    ~Štj&  ã                  ó¤   — d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
mZ ddlmZ  ej        e¦  «        Zg d¢Zed	dddd
dœdd„¦   «         ZdS )z"LangSmith integration for Pipecat.é    )ÚannotationsN)ÚAnyÚOptional)Ú	warn_beta)Úset_thread_idÚthread_id_from_context)ÚPipecatLangSmithSpanProcessor)r	   Úconfigure_pipecatr   r   ÚllmÚpipecat)Úllm_span_kindÚapi_keyÚprojectÚendpointÚservice_namer   Ústrr   úOptional[str]r   r   r   Úkwargsr   Úreturnú'Optional[PipecatLangSmithSpanProcessor]c                óŽ  — 	 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| 	                    |dd¬¦  «         t          d| |||d	œ|¤Ž}
|                     ¦   «         }t          ||¦  «        r|                     |
¦  «         nt                               d
¦  «         |
S )uØ  Enable LangSmith tracing for a Pipecat pipeline.

    Installs Pipecat's OTel ``TracerProvider`` (via ``setup_tracing``) and
    registers a :class:`PipecatLangSmithSpanProcessor` that rewrites Pipecat's
    spans for LangSmith and exports them to LangSmith's OTLP endpoint. Enable
    tracing on the pipeline itself with
    ``PipelineTask(..., enable_tracing=True, enable_turn_tracking=True,
    params=PipelineParams(enable_metrics=True))``.

    To manage your own ``TracerProvider`` instead, skip this function and add
    ``PipecatLangSmithSpanProcessor(...)`` to your provider directly.

    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) service, also call
    :meth:`PipecatLangSmithSpanProcessor.instrument_user_aggregator` on the
    returned processor. Pipecat delivers finalized user text through the user
    context aggregator rather than an OTel span.

    Args:
        llm_span_kind: LangSmith run kind for Pipecat's ``llm`` span; see the
            :mod:`~langsmith.integrations.pipecat.processor` module docstring.
        api_key / project / endpoint: LangSmith exporter config; default to the
            standard ``LANGSMITH_*`` resolution.
        service_name: OTel service name for the provider.

    Returns:
        The registered processor (so callers can e.g. ``attach_audio_buffer``),
        or ``None`` if Pipecat / OpenTelemetry aren't installed.
    r   )Útrace)ÚTracerProvider)Úsetupz*Missing dependency for Pipecat tracing: %sNF)r   ÚexporterÚconsole_export)r   r   r   r   zjActive OTel TracerProvider is not an SDK TracerProvider; PipecatLangSmithSpanProcessor was not registered.© )Úopentelemetryr   Úopentelemetry.sdk.tracer   Úpipecat.utils.tracingr   ÚImportErrorÚloggerÚwarningÚsetup_tracingr	   Úget_tracer_providerÚ
isinstanceÚadd_span_processor)r   r   r   r   r   r   r   r   r   ÚeÚ	processorÚproviders               úe/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langsmith/integrations/pipecat/__init__.pyr
   r
      s/  € ðXØ'Ð'Ð'Ð'Ð'Ð'Ø:Ð:Ð:Ð:Ð:Ð:à/Ð/Ð/Ð/Ð/Ð/Ð/øÝð ð ð Ý�ŠÐCÀQÑGÔGÐGØˆtˆtˆtˆtˆtøøøøðøøøð 
×Ò \¸DÐQVÐÑWÔWÐWå-ð Ø#ØØØð	ð ð
 ðð €Ið ×(Ò(Ñ*Ô*€HÝ�(˜NÑ+Ô+ð 
Ø×#Ò# IÑ.Ô.Ð.Ð.å�Šð@ñ	
ô 	
ð 	
ð Ðs   ‚ •
AŸA Á A)r   r   r   r   r   r   r   r   r   r   r   r   r   r   )Ú__doc__Ú
__future__r   ÚloggingÚtypingr   r   Ú#langsmith._internal._beta_decoratorr   Úlangsmith._internal.voicer   r   Ú(langsmith.integrations.pipecat.processorr	   Ú	getLoggerÚ__name__r"   Ú__all__r
   r   ó    r+   ú<module>r7      sê   ðØ (Ð (à "Ð "Ð "Ð "Ð "Ð "à €€€Ø  Ð  Ð  Ð  Ð  Ð  Ð  Ð  à 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø KÐ KÐ KÐ KÐ KÐ KÐ KÐ KØ RÐ RÐ RÐ RÐ RÐ Rà	ˆÔ	˜8Ñ	$Ô	$€ðð ð €ð ð Ø!Ø!Ø"Ø!ðGð Gð Gð Gð Gñ „ðGð Gð Gr6   