dv-pipecat-ai 0.0.74.dev770__py3-none-any.whl → 0.0.82.dev776__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dv-pipecat-ai might be problematic. Click here for more details.
- {dv_pipecat_ai-0.0.74.dev770.dist-info → dv_pipecat_ai-0.0.82.dev776.dist-info}/METADATA +137 -93
- dv_pipecat_ai-0.0.82.dev776.dist-info/RECORD +340 -0
- pipecat/__init__.py +17 -0
- pipecat/adapters/base_llm_adapter.py +36 -1
- pipecat/adapters/schemas/direct_function.py +296 -0
- pipecat/adapters/schemas/function_schema.py +15 -6
- pipecat/adapters/schemas/tools_schema.py +55 -7
- pipecat/adapters/services/anthropic_adapter.py +22 -3
- pipecat/adapters/services/aws_nova_sonic_adapter.py +23 -3
- pipecat/adapters/services/bedrock_adapter.py +22 -3
- pipecat/adapters/services/gemini_adapter.py +16 -3
- pipecat/adapters/services/open_ai_adapter.py +17 -2
- pipecat/adapters/services/open_ai_realtime_adapter.py +23 -3
- pipecat/audio/filters/base_audio_filter.py +30 -6
- pipecat/audio/filters/koala_filter.py +37 -2
- pipecat/audio/filters/krisp_filter.py +59 -6
- pipecat/audio/filters/noisereduce_filter.py +37 -0
- pipecat/audio/interruptions/base_interruption_strategy.py +25 -5
- pipecat/audio/interruptions/min_words_interruption_strategy.py +21 -4
- pipecat/audio/mixers/base_audio_mixer.py +30 -7
- pipecat/audio/mixers/soundfile_mixer.py +53 -6
- pipecat/audio/resamplers/base_audio_resampler.py +17 -9
- pipecat/audio/resamplers/resampy_resampler.py +26 -1
- pipecat/audio/resamplers/soxr_resampler.py +32 -1
- pipecat/audio/resamplers/soxr_stream_resampler.py +101 -0
- pipecat/audio/utils.py +194 -1
- pipecat/audio/vad/silero.py +60 -3
- pipecat/audio/vad/vad_analyzer.py +114 -30
- pipecat/clocks/base_clock.py +19 -0
- pipecat/clocks/system_clock.py +25 -0
- pipecat/extensions/voicemail/__init__.py +0 -0
- pipecat/extensions/voicemail/voicemail_detector.py +707 -0
- pipecat/frames/frames.py +590 -156
- pipecat/metrics/metrics.py +64 -1
- pipecat/observers/base_observer.py +58 -19
- pipecat/observers/loggers/debug_log_observer.py +56 -64
- pipecat/observers/loggers/llm_log_observer.py +8 -1
- pipecat/observers/loggers/transcription_log_observer.py +19 -7
- pipecat/observers/loggers/user_bot_latency_log_observer.py +32 -5
- pipecat/observers/turn_tracking_observer.py +26 -1
- pipecat/pipeline/base_pipeline.py +5 -7
- pipecat/pipeline/base_task.py +52 -9
- pipecat/pipeline/parallel_pipeline.py +121 -177
- pipecat/pipeline/pipeline.py +129 -20
- pipecat/pipeline/runner.py +50 -1
- pipecat/pipeline/sync_parallel_pipeline.py +132 -32
- pipecat/pipeline/task.py +263 -280
- pipecat/pipeline/task_observer.py +85 -34
- pipecat/pipeline/to_be_updated/merge_pipeline.py +32 -2
- pipecat/processors/aggregators/dtmf_aggregator.py +29 -22
- pipecat/processors/aggregators/gated.py +25 -24
- pipecat/processors/aggregators/gated_openai_llm_context.py +22 -2
- pipecat/processors/aggregators/llm_response.py +398 -89
- pipecat/processors/aggregators/openai_llm_context.py +161 -13
- pipecat/processors/aggregators/sentence.py +25 -14
- pipecat/processors/aggregators/user_response.py +28 -3
- pipecat/processors/aggregators/vision_image_frame.py +24 -14
- pipecat/processors/async_generator.py +28 -0
- pipecat/processors/audio/audio_buffer_processor.py +78 -37
- pipecat/processors/consumer_processor.py +25 -6
- pipecat/processors/filters/frame_filter.py +23 -0
- pipecat/processors/filters/function_filter.py +30 -0
- pipecat/processors/filters/identity_filter.py +17 -2
- pipecat/processors/filters/null_filter.py +24 -1
- pipecat/processors/filters/stt_mute_filter.py +56 -21
- pipecat/processors/filters/wake_check_filter.py +46 -3
- pipecat/processors/filters/wake_notifier_filter.py +21 -3
- pipecat/processors/frame_processor.py +488 -131
- pipecat/processors/frameworks/langchain.py +38 -3
- pipecat/processors/frameworks/rtvi.py +719 -34
- pipecat/processors/gstreamer/pipeline_source.py +41 -0
- pipecat/processors/idle_frame_processor.py +26 -3
- pipecat/processors/logger.py +23 -0
- pipecat/processors/metrics/frame_processor_metrics.py +77 -4
- pipecat/processors/metrics/sentry.py +42 -4
- pipecat/processors/producer_processor.py +34 -14
- pipecat/processors/text_transformer.py +22 -10
- pipecat/processors/transcript_processor.py +48 -29
- pipecat/processors/user_idle_processor.py +31 -21
- pipecat/runner/__init__.py +1 -0
- pipecat/runner/daily.py +132 -0
- pipecat/runner/livekit.py +148 -0
- pipecat/runner/run.py +543 -0
- pipecat/runner/types.py +67 -0
- pipecat/runner/utils.py +515 -0
- pipecat/serializers/base_serializer.py +42 -0
- pipecat/serializers/exotel.py +17 -6
- pipecat/serializers/genesys.py +95 -0
- pipecat/serializers/livekit.py +33 -0
- pipecat/serializers/plivo.py +16 -15
- pipecat/serializers/protobuf.py +37 -1
- pipecat/serializers/telnyx.py +18 -17
- pipecat/serializers/twilio.py +32 -16
- pipecat/services/ai_service.py +5 -3
- pipecat/services/anthropic/llm.py +113 -43
- pipecat/services/assemblyai/models.py +63 -5
- pipecat/services/assemblyai/stt.py +64 -11
- pipecat/services/asyncai/__init__.py +0 -0
- pipecat/services/asyncai/tts.py +501 -0
- pipecat/services/aws/llm.py +185 -111
- pipecat/services/aws/stt.py +217 -23
- pipecat/services/aws/tts.py +118 -52
- pipecat/services/aws/utils.py +101 -5
- pipecat/services/aws_nova_sonic/aws.py +82 -64
- pipecat/services/aws_nova_sonic/context.py +15 -6
- pipecat/services/azure/common.py +10 -2
- pipecat/services/azure/image.py +32 -0
- pipecat/services/azure/llm.py +9 -7
- pipecat/services/azure/stt.py +65 -2
- pipecat/services/azure/tts.py +154 -23
- pipecat/services/cartesia/stt.py +125 -8
- pipecat/services/cartesia/tts.py +102 -38
- pipecat/services/cerebras/llm.py +15 -23
- pipecat/services/deepgram/stt.py +19 -11
- pipecat/services/deepgram/tts.py +36 -0
- pipecat/services/deepseek/llm.py +14 -23
- pipecat/services/elevenlabs/tts.py +330 -64
- pipecat/services/fal/image.py +43 -0
- pipecat/services/fal/stt.py +48 -10
- pipecat/services/fireworks/llm.py +14 -21
- pipecat/services/fish/tts.py +109 -9
- pipecat/services/gemini_multimodal_live/__init__.py +1 -0
- pipecat/services/gemini_multimodal_live/events.py +83 -2
- pipecat/services/gemini_multimodal_live/file_api.py +189 -0
- pipecat/services/gemini_multimodal_live/gemini.py +218 -21
- pipecat/services/gladia/config.py +17 -10
- pipecat/services/gladia/stt.py +82 -36
- pipecat/services/google/frames.py +40 -0
- pipecat/services/google/google.py +2 -0
- pipecat/services/google/image.py +39 -2
- pipecat/services/google/llm.py +176 -58
- pipecat/services/google/llm_openai.py +26 -4
- pipecat/services/google/llm_vertex.py +37 -15
- pipecat/services/google/rtvi.py +41 -0
- pipecat/services/google/stt.py +65 -17
- pipecat/services/google/test-google-chirp.py +45 -0
- pipecat/services/google/tts.py +390 -19
- pipecat/services/grok/llm.py +8 -6
- pipecat/services/groq/llm.py +8 -6
- pipecat/services/groq/stt.py +13 -9
- pipecat/services/groq/tts.py +40 -0
- pipecat/services/hamsa/__init__.py +9 -0
- pipecat/services/hamsa/stt.py +241 -0
- pipecat/services/heygen/__init__.py +5 -0
- pipecat/services/heygen/api.py +281 -0
- pipecat/services/heygen/client.py +620 -0
- pipecat/services/heygen/video.py +338 -0
- pipecat/services/image_service.py +5 -3
- pipecat/services/inworld/__init__.py +1 -0
- pipecat/services/inworld/tts.py +592 -0
- pipecat/services/llm_service.py +127 -45
- pipecat/services/lmnt/tts.py +80 -7
- pipecat/services/mcp_service.py +85 -44
- pipecat/services/mem0/memory.py +42 -13
- pipecat/services/minimax/tts.py +74 -15
- pipecat/services/mistral/__init__.py +0 -0
- pipecat/services/mistral/llm.py +185 -0
- pipecat/services/moondream/vision.py +55 -10
- pipecat/services/neuphonic/tts.py +275 -48
- pipecat/services/nim/llm.py +8 -6
- pipecat/services/ollama/llm.py +27 -7
- pipecat/services/openai/base_llm.py +54 -16
- pipecat/services/openai/image.py +30 -0
- pipecat/services/openai/llm.py +7 -5
- pipecat/services/openai/stt.py +13 -9
- pipecat/services/openai/tts.py +42 -10
- pipecat/services/openai_realtime_beta/azure.py +11 -9
- pipecat/services/openai_realtime_beta/context.py +7 -5
- pipecat/services/openai_realtime_beta/events.py +10 -7
- pipecat/services/openai_realtime_beta/openai.py +37 -18
- pipecat/services/openpipe/llm.py +30 -24
- pipecat/services/openrouter/llm.py +9 -7
- pipecat/services/perplexity/llm.py +15 -19
- pipecat/services/piper/tts.py +26 -12
- pipecat/services/playht/tts.py +227 -65
- pipecat/services/qwen/llm.py +8 -6
- pipecat/services/rime/tts.py +128 -17
- pipecat/services/riva/stt.py +160 -22
- pipecat/services/riva/tts.py +67 -2
- pipecat/services/sambanova/llm.py +19 -17
- pipecat/services/sambanova/stt.py +14 -8
- pipecat/services/sarvam/tts.py +60 -13
- pipecat/services/simli/video.py +82 -21
- pipecat/services/soniox/__init__.py +0 -0
- pipecat/services/soniox/stt.py +398 -0
- pipecat/services/speechmatics/stt.py +29 -17
- pipecat/services/stt_service.py +47 -11
- pipecat/services/tavus/video.py +94 -25
- pipecat/services/together/llm.py +8 -6
- pipecat/services/tts_service.py +77 -53
- pipecat/services/ultravox/stt.py +46 -43
- pipecat/services/vision_service.py +5 -3
- pipecat/services/websocket_service.py +12 -11
- pipecat/services/whisper/base_stt.py +58 -12
- pipecat/services/whisper/stt.py +69 -58
- pipecat/services/xtts/tts.py +59 -2
- pipecat/sync/base_notifier.py +19 -0
- pipecat/sync/event_notifier.py +24 -0
- pipecat/tests/utils.py +73 -5
- pipecat/transcriptions/language.py +24 -0
- pipecat/transports/base_input.py +112 -8
- pipecat/transports/base_output.py +235 -13
- pipecat/transports/base_transport.py +119 -0
- pipecat/transports/local/audio.py +76 -0
- pipecat/transports/local/tk.py +84 -0
- pipecat/transports/network/fastapi_websocket.py +174 -15
- pipecat/transports/network/small_webrtc.py +383 -39
- pipecat/transports/network/webrtc_connection.py +214 -8
- pipecat/transports/network/websocket_client.py +171 -1
- pipecat/transports/network/websocket_server.py +147 -9
- pipecat/transports/services/daily.py +792 -70
- pipecat/transports/services/helpers/daily_rest.py +122 -129
- pipecat/transports/services/livekit.py +339 -4
- pipecat/transports/services/tavus.py +273 -38
- pipecat/utils/asyncio/task_manager.py +92 -186
- pipecat/utils/base_object.py +83 -1
- pipecat/utils/network.py +2 -0
- pipecat/utils/string.py +114 -58
- pipecat/utils/text/base_text_aggregator.py +44 -13
- pipecat/utils/text/base_text_filter.py +46 -0
- pipecat/utils/text/markdown_text_filter.py +70 -14
- pipecat/utils/text/pattern_pair_aggregator.py +18 -14
- pipecat/utils/text/simple_text_aggregator.py +43 -2
- pipecat/utils/text/skip_tags_aggregator.py +21 -13
- pipecat/utils/time.py +36 -0
- pipecat/utils/tracing/class_decorators.py +32 -7
- pipecat/utils/tracing/conversation_context_provider.py +12 -2
- pipecat/utils/tracing/service_attributes.py +80 -64
- pipecat/utils/tracing/service_decorators.py +48 -21
- pipecat/utils/tracing/setup.py +13 -7
- pipecat/utils/tracing/turn_context_provider.py +12 -2
- pipecat/utils/tracing/turn_trace_observer.py +27 -0
- pipecat/utils/utils.py +14 -14
- dv_pipecat_ai-0.0.74.dev770.dist-info/RECORD +0 -319
- pipecat/examples/daily_runner.py +0 -64
- pipecat/examples/run.py +0 -265
- pipecat/utils/asyncio/watchdog_async_iterator.py +0 -72
- pipecat/utils/asyncio/watchdog_event.py +0 -42
- pipecat/utils/asyncio/watchdog_priority_queue.py +0 -48
- pipecat/utils/asyncio/watchdog_queue.py +0 -48
- {dv_pipecat_ai-0.0.74.dev770.dist-info → dv_pipecat_ai-0.0.82.dev776.dist-info}/WHEEL +0 -0
- {dv_pipecat_ai-0.0.74.dev770.dist-info → dv_pipecat_ai-0.0.82.dev776.dist-info}/licenses/LICENSE +0 -0
- {dv_pipecat_ai-0.0.74.dev770.dist-info → dv_pipecat_ai-0.0.82.dev776.dist-info}/top_level.txt +0 -0
- /pipecat/{examples → extensions}/__init__.py +0 -0
|
@@ -41,9 +41,15 @@ T = TypeVar("T")
|
|
|
41
41
|
R = TypeVar("R")
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
# Internal helper functions
|
|
45
44
|
def _noop_decorator(func):
|
|
46
|
-
"""No-op fallback decorator when tracing is unavailable.
|
|
45
|
+
"""No-op fallback decorator when tracing is unavailable.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
func: The function to pass through unchanged.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
The original function unchanged.
|
|
52
|
+
"""
|
|
47
53
|
return func
|
|
48
54
|
|
|
49
55
|
|
|
@@ -53,10 +59,10 @@ def _get_parent_service_context(self):
|
|
|
53
59
|
This looks for the service span that was created when the service was initialized.
|
|
54
60
|
|
|
55
61
|
Args:
|
|
56
|
-
self: The service instance
|
|
62
|
+
self: The service instance.
|
|
57
63
|
|
|
58
64
|
Returns:
|
|
59
|
-
|
|
65
|
+
The parent service context, or None if unavailable.
|
|
60
66
|
"""
|
|
61
67
|
if not is_tracing_available():
|
|
62
68
|
return None
|
|
@@ -73,8 +79,8 @@ def _add_token_usage_to_span(span, token_usage):
|
|
|
73
79
|
"""Add token usage metrics to a span (internal use only).
|
|
74
80
|
|
|
75
81
|
Args:
|
|
76
|
-
span: The span to add token metrics to
|
|
77
|
-
token_usage: Dictionary or object containing token usage information
|
|
82
|
+
span: The span to add token metrics to.
|
|
83
|
+
token_usage: Dictionary or object containing token usage information.
|
|
78
84
|
"""
|
|
79
85
|
if not is_tracing_available() or not token_usage:
|
|
80
86
|
return
|
|
@@ -93,9 +99,10 @@ def _add_token_usage_to_span(span, token_usage):
|
|
|
93
99
|
|
|
94
100
|
|
|
95
101
|
def traced_tts(func: Optional[Callable] = None, *, name: Optional[str] = None) -> Callable:
|
|
96
|
-
"""
|
|
102
|
+
"""Trace TTS service methods with TTS-specific attributes.
|
|
97
103
|
|
|
98
104
|
Automatically captures and records:
|
|
105
|
+
|
|
99
106
|
- Service name and model information
|
|
100
107
|
- Voice ID and settings
|
|
101
108
|
- Character count and text content
|
|
@@ -118,8 +125,17 @@ def traced_tts(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|
|
118
125
|
|
|
119
126
|
@contextlib.asynccontextmanager
|
|
120
127
|
async def tracing_context(self, text):
|
|
121
|
-
"""Async context manager for TTS tracing.
|
|
122
|
-
|
|
128
|
+
"""Async context manager for TTS tracing.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
self: The TTS service instance.
|
|
132
|
+
text: The text being synthesized.
|
|
133
|
+
|
|
134
|
+
Yields:
|
|
135
|
+
The active span for the TTS operation.
|
|
136
|
+
"""
|
|
137
|
+
# Check if tracing is enabled for this service instance
|
|
138
|
+
if not getattr(self, "_tracing_enabled", False):
|
|
123
139
|
yield None
|
|
124
140
|
return
|
|
125
141
|
|
|
@@ -163,7 +179,8 @@ def traced_tts(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|
|
163
179
|
@functools.wraps(f)
|
|
164
180
|
async def gen_wrapper(self, text, *args, **kwargs):
|
|
165
181
|
try:
|
|
166
|
-
if
|
|
182
|
+
# Check if tracing is enabled for this service instance
|
|
183
|
+
if not getattr(self, "_tracing_enabled", False):
|
|
167
184
|
async for item in f(self, text, *args, **kwargs):
|
|
168
185
|
yield item
|
|
169
186
|
return
|
|
@@ -183,7 +200,8 @@ def traced_tts(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|
|
183
200
|
@functools.wraps(f)
|
|
184
201
|
async def wrapper(self, text, *args, **kwargs):
|
|
185
202
|
try:
|
|
186
|
-
if
|
|
203
|
+
# Check if tracing is enabled for this service instance
|
|
204
|
+
if not getattr(self, "_tracing_enabled", False):
|
|
187
205
|
return await f(self, text, *args, **kwargs)
|
|
188
206
|
|
|
189
207
|
async with tracing_context(self, text):
|
|
@@ -201,9 +219,10 @@ def traced_tts(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|
|
201
219
|
|
|
202
220
|
|
|
203
221
|
def traced_stt(func: Optional[Callable] = None, *, name: Optional[str] = None) -> Callable:
|
|
204
|
-
"""
|
|
222
|
+
"""Trace STT service methods with transcription attributes.
|
|
205
223
|
|
|
206
224
|
Automatically captures and records:
|
|
225
|
+
|
|
207
226
|
- Service name and model information
|
|
208
227
|
- Transcription text and final status
|
|
209
228
|
- Language information
|
|
@@ -223,7 +242,8 @@ def traced_stt(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|
|
223
242
|
@functools.wraps(f)
|
|
224
243
|
async def wrapper(self, transcript, is_final, language=None):
|
|
225
244
|
try:
|
|
226
|
-
if
|
|
245
|
+
# Check if tracing is enabled for this service instance
|
|
246
|
+
if not getattr(self, "_tracing_enabled", False):
|
|
227
247
|
return await f(self, transcript, is_final, language)
|
|
228
248
|
|
|
229
249
|
service_class_name = self.__class__.__name__
|
|
@@ -254,6 +274,7 @@ def traced_stt(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|
|
254
274
|
transcript=transcript,
|
|
255
275
|
is_final=is_final,
|
|
256
276
|
language=str(language) if language else None,
|
|
277
|
+
user_id=getattr(self, "_user_id", None),
|
|
257
278
|
vad_enabled=getattr(self, "vad_enabled", False),
|
|
258
279
|
settings=settings,
|
|
259
280
|
ttfb=ttfb,
|
|
@@ -278,9 +299,10 @@ def traced_stt(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|
|
278
299
|
|
|
279
300
|
|
|
280
301
|
def traced_llm(func: Optional[Callable] = None, *, name: Optional[str] = None) -> Callable:
|
|
281
|
-
"""
|
|
302
|
+
"""Trace LLM service methods with LLM-specific attributes.
|
|
282
303
|
|
|
283
304
|
Automatically captures and records:
|
|
305
|
+
|
|
284
306
|
- Service name and model information
|
|
285
307
|
- Context content and messages
|
|
286
308
|
- Tool configurations
|
|
@@ -302,7 +324,8 @@ def traced_llm(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|
|
302
324
|
@functools.wraps(f)
|
|
303
325
|
async def wrapper(self, context, *args, **kwargs):
|
|
304
326
|
try:
|
|
305
|
-
if
|
|
327
|
+
# Check if tracing is enabled for this service instance
|
|
328
|
+
if not getattr(self, "_tracing_enabled", False):
|
|
306
329
|
return await f(self, context, *args, **kwargs)
|
|
307
330
|
|
|
308
331
|
service_class_name = self.__class__.__name__
|
|
@@ -482,16 +505,17 @@ def traced_llm(func: Optional[Callable] = None, *, name: Optional[str] = None) -
|
|
|
482
505
|
|
|
483
506
|
|
|
484
507
|
def traced_gemini_live(operation: str) -> Callable:
|
|
485
|
-
"""
|
|
508
|
+
"""Trace Gemini Live service methods with operation-specific attributes.
|
|
486
509
|
|
|
487
510
|
This decorator automatically captures relevant information based on the operation type:
|
|
511
|
+
|
|
488
512
|
- llm_setup: Configuration, tools definitions, and system instructions
|
|
489
513
|
- llm_tool_call: Function call information
|
|
490
514
|
- llm_tool_result: Function execution results
|
|
491
515
|
- llm_response: Complete LLM response with usage and output
|
|
492
516
|
|
|
493
517
|
Args:
|
|
494
|
-
operation: The operation name (matches the event type being handled)
|
|
518
|
+
operation: The operation name (matches the event type being handled).
|
|
495
519
|
|
|
496
520
|
Returns:
|
|
497
521
|
Wrapped method with Gemini Live specific tracing.
|
|
@@ -503,7 +527,8 @@ def traced_gemini_live(operation: str) -> Callable:
|
|
|
503
527
|
@functools.wraps(func)
|
|
504
528
|
async def wrapper(self, *args, **kwargs):
|
|
505
529
|
try:
|
|
506
|
-
if
|
|
530
|
+
# Check if tracing is enabled for this service instance
|
|
531
|
+
if not getattr(self, "_tracing_enabled", False):
|
|
507
532
|
return await func(self, *args, **kwargs)
|
|
508
533
|
|
|
509
534
|
service_class_name = self.__class__.__name__
|
|
@@ -786,15 +811,16 @@ def traced_gemini_live(operation: str) -> Callable:
|
|
|
786
811
|
|
|
787
812
|
|
|
788
813
|
def traced_openai_realtime(operation: str) -> Callable:
|
|
789
|
-
"""
|
|
814
|
+
"""Trace OpenAI Realtime service methods with operation-specific attributes.
|
|
790
815
|
|
|
791
816
|
This decorator automatically captures relevant information based on the operation type:
|
|
817
|
+
|
|
792
818
|
- llm_setup: Session configuration and tools
|
|
793
819
|
- llm_request: Context and input messages
|
|
794
820
|
- llm_response: Usage metadata, output, and function calls
|
|
795
821
|
|
|
796
822
|
Args:
|
|
797
|
-
operation: The operation name (matches the event type being handled)
|
|
823
|
+
operation: The operation name (matches the event type being handled).
|
|
798
824
|
|
|
799
825
|
Returns:
|
|
800
826
|
Wrapped method with OpenAI Realtime specific tracing.
|
|
@@ -806,7 +832,8 @@ def traced_openai_realtime(operation: str) -> Callable:
|
|
|
806
832
|
@functools.wraps(func)
|
|
807
833
|
async def wrapper(self, *args, **kwargs):
|
|
808
834
|
try:
|
|
809
|
-
if
|
|
835
|
+
# Check if tracing is enabled for this service instance
|
|
836
|
+
if not getattr(self, "_tracing_enabled", False):
|
|
810
837
|
return await func(self, *args, **kwargs)
|
|
811
838
|
|
|
812
839
|
service_class_name = self.__class__.__name__
|
pipecat/utils/tracing/setup.py
CHANGED
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
# SPDX-License-Identifier: BSD 2-Clause License
|
|
5
5
|
#
|
|
6
6
|
|
|
7
|
-
"""Core OpenTelemetry tracing utilities and setup for Pipecat.
|
|
7
|
+
"""Core OpenTelemetry tracing utilities and setup for Pipecat.
|
|
8
|
+
|
|
9
|
+
This module provides functions to check availability and configure OpenTelemetry
|
|
10
|
+
tracing for Pipecat applications. It handles the optional nature of OpenTelemetry
|
|
11
|
+
dependencies and provides a safe setup process.
|
|
12
|
+
"""
|
|
8
13
|
|
|
9
14
|
import os
|
|
10
15
|
|
|
@@ -21,10 +26,10 @@ except ImportError:
|
|
|
21
26
|
|
|
22
27
|
|
|
23
28
|
def is_tracing_available() -> bool:
|
|
24
|
-
"""
|
|
29
|
+
"""Check if OpenTelemetry tracing is available and configured.
|
|
25
30
|
|
|
26
31
|
Returns:
|
|
27
|
-
|
|
32
|
+
True if tracing is available, False otherwise.
|
|
28
33
|
"""
|
|
29
34
|
return OPENTELEMETRY_AVAILABLE
|
|
30
35
|
|
|
@@ -37,15 +42,16 @@ def setup_tracing(
|
|
|
37
42
|
"""Set up OpenTelemetry tracing with a user-provided exporter.
|
|
38
43
|
|
|
39
44
|
Args:
|
|
40
|
-
service_name: The name of the service for traces
|
|
45
|
+
service_name: The name of the service for traces.
|
|
41
46
|
exporter: A pre-configured OpenTelemetry span exporter instance.
|
|
42
47
|
If None, only console export will be available if enabled.
|
|
43
|
-
console_export: Whether to also export traces to console (useful for debugging)
|
|
48
|
+
console_export: Whether to also export traces to console (useful for debugging).
|
|
44
49
|
|
|
45
50
|
Returns:
|
|
46
|
-
|
|
51
|
+
True if setup was successful, False otherwise.
|
|
52
|
+
|
|
53
|
+
Example::
|
|
47
54
|
|
|
48
|
-
Example:
|
|
49
55
|
# With OTLP exporter
|
|
50
56
|
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
|
|
51
57
|
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
# SPDX-License-Identifier: BSD 2-Clause License
|
|
5
5
|
#
|
|
6
6
|
|
|
7
|
+
"""Turn context provider for OpenTelemetry tracing in Pipecat.
|
|
8
|
+
|
|
9
|
+
This module provides a singleton context provider that manages the current
|
|
10
|
+
turn's tracing context, allowing services to create child spans that are
|
|
11
|
+
properly associated with the conversation turn.
|
|
12
|
+
"""
|
|
13
|
+
|
|
7
14
|
from typing import TYPE_CHECKING, Optional
|
|
8
15
|
|
|
9
16
|
# Import types for type checking only
|
|
@@ -30,7 +37,11 @@ class TurnContextProvider:
|
|
|
30
37
|
|
|
31
38
|
@classmethod
|
|
32
39
|
def get_instance(cls):
|
|
33
|
-
"""Get the singleton instance.
|
|
40
|
+
"""Get the singleton instance.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
The singleton TurnContextProvider instance.
|
|
44
|
+
"""
|
|
34
45
|
if cls._instance is None:
|
|
35
46
|
cls._instance = TurnContextProvider()
|
|
36
47
|
return cls._instance
|
|
@@ -60,7 +71,6 @@ class TurnContextProvider:
|
|
|
60
71
|
return self._current_turn_context
|
|
61
72
|
|
|
62
73
|
|
|
63
|
-
# Create a simple helper function to get the current turn context
|
|
64
74
|
def get_current_turn_context() -> Optional["Context"]:
|
|
65
75
|
"""Get the OpenTelemetry context for the current turn.
|
|
66
76
|
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
# SPDX-License-Identifier: BSD 2-Clause License
|
|
5
5
|
#
|
|
6
6
|
|
|
7
|
+
"""Turn trace observer for OpenTelemetry tracing in Pipecat.
|
|
8
|
+
|
|
9
|
+
This module provides an observer that creates trace spans for each conversation
|
|
10
|
+
turn, integrating with the turn tracking system to provide hierarchical tracing
|
|
11
|
+
of conversation flows.
|
|
12
|
+
"""
|
|
13
|
+
|
|
7
14
|
from typing import TYPE_CHECKING, Dict, Optional
|
|
8
15
|
|
|
9
16
|
from loguru import logger
|
|
@@ -41,6 +48,14 @@ class TurnTraceObserver(BaseObserver):
|
|
|
41
48
|
additional_span_attributes: Optional[dict] = None,
|
|
42
49
|
**kwargs,
|
|
43
50
|
):
|
|
51
|
+
"""Initialize the turn trace observer.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
turn_tracker: The turn tracking observer to monitor.
|
|
55
|
+
conversation_id: Optional conversation ID for grouping turns.
|
|
56
|
+
additional_span_attributes: Additional attributes to add to spans.
|
|
57
|
+
**kwargs: Additional arguments passed to parent class.
|
|
58
|
+
"""
|
|
44
59
|
super().__init__(**kwargs)
|
|
45
60
|
self._turn_tracker = turn_tracker
|
|
46
61
|
self._current_span: Optional["Span"] = None
|
|
@@ -68,6 +83,9 @@ class TurnTraceObserver(BaseObserver):
|
|
|
68
83
|
|
|
69
84
|
This observer doesn't need to process individual frames as it
|
|
70
85
|
relies on turn start/end events from the turn tracker.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
data: The frame push event data.
|
|
71
89
|
"""
|
|
72
90
|
pass
|
|
73
91
|
|
|
@@ -198,6 +216,9 @@ class TurnTraceObserver(BaseObserver):
|
|
|
198
216
|
"""Get the span context for the current turn.
|
|
199
217
|
|
|
200
218
|
This can be used by services to create child spans.
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
The current turn's span context or None if not available.
|
|
201
222
|
"""
|
|
202
223
|
if not is_tracing_available() or not self._current_span:
|
|
203
224
|
return None
|
|
@@ -208,6 +229,12 @@ class TurnTraceObserver(BaseObserver):
|
|
|
208
229
|
"""Get the span context for a specific turn.
|
|
209
230
|
|
|
210
231
|
This can be used by services to create child spans.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
turn_number: The turn number to get context for.
|
|
235
|
+
|
|
236
|
+
Returns:
|
|
237
|
+
The specified turn's span context or None if not available.
|
|
211
238
|
"""
|
|
212
239
|
if not is_tracing_available():
|
|
213
240
|
return None
|
pipecat/utils/utils.py
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
# SPDX-License-Identifier: BSD 2-Clause License
|
|
5
5
|
#
|
|
6
6
|
|
|
7
|
+
"""Utility functions for object identification and counting.
|
|
8
|
+
|
|
9
|
+
This module provides thread-safe utilities for generating unique identifiers
|
|
10
|
+
and maintaining per-class instance counts across the Pipecat framework.
|
|
11
|
+
"""
|
|
12
|
+
|
|
7
13
|
import collections
|
|
8
14
|
import itertools
|
|
9
15
|
import threading
|
|
@@ -17,27 +23,21 @@ _ID_LOCK = threading.Lock()
|
|
|
17
23
|
def obj_id() -> int:
|
|
18
24
|
"""Generate a unique id for an object.
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
>>> obj_id()
|
|
23
|
-
1
|
|
24
|
-
>>> obj_id()
|
|
25
|
-
2
|
|
26
|
+
Returns:
|
|
27
|
+
A unique integer identifier that increments globally across all objects.
|
|
26
28
|
"""
|
|
27
29
|
with _ID_LOCK:
|
|
28
30
|
return next(_ID)
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
def obj_count(obj) -> int:
|
|
32
|
-
"""Generate a unique
|
|
34
|
+
"""Generate a unique count for an object based on its class.
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
>>> obj_count(new_type())
|
|
40
|
-
0
|
|
36
|
+
Args:
|
|
37
|
+
obj: The object instance to count.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
A unique integer count that increments per class type.
|
|
41
41
|
"""
|
|
42
42
|
with _COUNTS_LOCK:
|
|
43
43
|
return next(_COUNTS[obj.__class__.__name__])
|