ó
    üÞ j&  ã                  ó¾   • S r SSKJr  SSKrSSKJrJr  SSKJr  SSK	J
r
Jr  SSKJr  \R                  " \5      r/ SQr\S	SSSS
S.             SS jj5       rg)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_namec                óX  •  SSK Jn  SSKJn  SSKJn  UR                  USSS9  [        SU UUUS	.UD6n
UR                  5       n[        X·5      (       a  UR                  U
5        U
$ [        R                  S
5        U
$ ! [         a   n	[        R                  SU	5         Sn	A	gSn	A	ff = f)ul  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   Úkwargsr   r   r   ÚeÚ	processorÚproviders               Úa/var/www/html/gaurav/venv/lib/python3.13/site-packages/langsmith/integrations/pipecat/__init__.pyr
   r
      s¿   € ðXÝ'Ý:å/ð 
×Ñ \¸DÐQVÐÑWä-ð Ø#ØØØñ	ð
 ñ€Ið ×(Ñ(Ó*€HÜ�(×+Ñ+Ø×#Ñ# IÔ.ð Ðô	 	�‰ð@ô	
ð Ðøô/ ó Ü�‰ÐCÀQÔGÜûðús   ‚A? Á?
B)Â	B$Â$B))r   Ústrr   úOptional[str]r   r)   r   r)   r   r(   r#   r   Úreturnz'Optional[PipecatLangSmithSpanProcessor])Ú__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>r6      s£   ðÙ (å "ã ß  å 9ß KÝ Rà	×	Ò	˜8Ó	$€ò€ð ð Ø!Ø!Ø"Ø!ñGàðGð ðGð ð	Gð
 ðGð ðGð ðGð -ôGó ñGr5   