@pipedog/core 0.0.0 → 0.1.0
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.
- package/LICENSE +25 -0
- package/NOTICE +9 -0
- package/dist/adapters/base_llm_adapter.d.ts +266 -0
- package/dist/adapters/base_llm_adapter.js +489 -0
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.js +8 -0
- package/dist/adapters/schemas/direct_function.d.ts +202 -0
- package/dist/adapters/schemas/direct_function.js +302 -0
- package/dist/adapters/schemas/function_schema.d.ts +67 -0
- package/dist/adapters/schemas/function_schema.js +72 -0
- package/dist/adapters/schemas/index.d.ts +2 -0
- package/dist/adapters/schemas/index.js +8 -0
- package/dist/adapters/schemas/tools_schema.d.ts +57 -0
- package/dist/adapters/schemas/tools_schema.js +79 -0
- package/dist/adapters/services/index.d.ts +2 -0
- package/dist/adapters/services/index.js +8 -0
- package/dist/adapters/services/open_ai_adapter.d.ts +147 -0
- package/dist/adapters/services/open_ai_adapter.js +250 -0
- package/dist/audio/dtmf/dtmf_data.d.ts +3 -0
- package/dist/audio/dtmf/dtmf_data.js +22 -0
- package/dist/audio/dtmf/index.d.ts +2 -0
- package/dist/audio/dtmf/index.js +8 -0
- package/dist/audio/dtmf/types.d.ts +31 -0
- package/dist/audio/dtmf/types.js +35 -0
- package/dist/audio/dtmf/utils.d.ts +13 -0
- package/dist/audio/dtmf/utils.js +62 -0
- package/dist/audio/filters/base_audio_filter.d.ts +51 -0
- package/dist/audio/filters/base_audio_filter.js +17 -0
- package/dist/audio/filters/index.d.ts +2 -0
- package/dist/audio/filters/index.js +8 -0
- package/dist/audio/index.d.ts +2 -0
- package/dist/audio/index.js +8 -0
- package/dist/audio/krisp_instance.d.ts +95 -0
- package/dist/audio/krisp_instance.js +229 -0
- package/dist/audio/mixers/base_audio_mixer.d.ts +56 -0
- package/dist/audio/mixers/base_audio_mixer.js +16 -0
- package/dist/audio/mixers/index.d.ts +2 -0
- package/dist/audio/mixers/index.js +8 -0
- package/dist/audio/resamplers/base_audio_resampler.d.ts +46 -0
- package/dist/audio/resamplers/base_audio_resampler.js +35 -0
- package/dist/audio/resamplers/index.d.ts +2 -0
- package/dist/audio/resamplers/index.js +8 -0
- package/dist/audio/resamplers/resampy_resampler.d.ts +10 -0
- package/dist/audio/resamplers/resampy_resampler.js +15 -0
- package/dist/audio/resamplers/soxr_resampler.d.ts +54 -0
- package/dist/audio/resamplers/soxr_resampler.js +69 -0
- package/dist/audio/resamplers/soxr_stream_resampler.d.ts +75 -0
- package/dist/audio/resamplers/soxr_stream_resampler.js +146 -0
- package/dist/audio/turn/base_turn_analyzer.d.ts +84 -0
- package/dist/audio/turn/base_turn_analyzer.js +61 -0
- package/dist/audio/turn/index.d.ts +2 -0
- package/dist/audio/turn/index.js +8 -0
- package/dist/audio/turn/smart_turn/_whisper_features.d.ts +30 -0
- package/dist/audio/turn/smart_turn/_whisper_features.js +225 -0
- package/dist/audio/turn/smart_turn/base_smart_turn.d.ts +94 -0
- package/dist/audio/turn/smart_turn/base_smart_turn.js +239 -0
- package/dist/audio/turn/smart_turn/local_smart_turn_v3.d.ts +76 -0
- package/dist/audio/turn/smart_turn/local_smart_turn_v3.js +143 -0
- package/dist/audio/utils.d.ts +224 -0
- package/dist/audio/utils.js +634 -0
- package/dist/audio/vad/data/index.d.ts +2 -0
- package/dist/audio/vad/data/index.js +8 -0
- package/dist/audio/vad/index.d.ts +2 -0
- package/dist/audio/vad/index.js +8 -0
- package/dist/audio/vad/vad_analyzer.d.ts +126 -0
- package/dist/audio/vad/vad_analyzer.js +211 -0
- package/dist/audio/vad/vad_controller.d.ts +143 -0
- package/dist/audio/vad/vad_controller.js +228 -0
- package/dist/audio/volume.d.ts +38 -0
- package/dist/audio/volume.js +75 -0
- package/dist/bus/adapters/base.d.ts +35 -0
- package/dist/bus/adapters/base.js +19 -0
- package/dist/bus/adapters/index.d.ts +10 -0
- package/dist/bus/adapters/index.js +15 -0
- package/dist/bus/adapters/llm_context_adapter.d.ts +36 -0
- package/dist/bus/adapters/llm_context_adapter.js +82 -0
- package/dist/bus/adapters/tools_schema_adapter.d.ts +25 -0
- package/dist/bus/adapters/tools_schema_adapter.js +70 -0
- package/dist/bus/bridge_processor.d.ts +111 -0
- package/dist/bus/bridge_processor.js +166 -0
- package/dist/bus/bus.d.ts +110 -0
- package/dist/bus/bus.js +200 -0
- package/dist/bus/index.d.ts +22 -0
- package/dist/bus/index.js +27 -0
- package/dist/bus/local/async_queue.d.ts +12 -0
- package/dist/bus/local/async_queue.js +21 -0
- package/dist/bus/local/index.d.ts +3 -0
- package/dist/bus/local/index.js +8 -0
- package/dist/bus/messages.d.ts +378 -0
- package/dist/bus/messages.js +357 -0
- package/dist/bus/network/index.d.ts +16 -0
- package/dist/bus/network/index.js +21 -0
- package/dist/bus/queue.d.ts +27 -0
- package/dist/bus/queue.js +51 -0
- package/dist/bus/serializers/base.d.ts +25 -0
- package/dist/bus/serializers/base.js +14 -0
- package/dist/bus/serializers/index.d.ts +9 -0
- package/dist/bus/serializers/index.js +14 -0
- package/dist/bus/serializers/json.d.ts +77 -0
- package/dist/bus/serializers/json.js +367 -0
- package/dist/bus/subscriber.d.ts +46 -0
- package/dist/bus/subscriber.js +27 -0
- package/dist/bus/ui/index.d.ts +3 -0
- package/dist/bus/ui/index.js +8 -0
- package/dist/bus/ui/messages.d.ts +186 -0
- package/dist/bus/ui/messages.js +171 -0
- package/dist/classifiers/base_classifier.d.ts +263 -0
- package/dist/classifiers/base_classifier.js +346 -0
- package/dist/classifiers/cloudflare/clef/classifier.d.ts +70 -0
- package/dist/classifiers/cloudflare/clef/classifier.js +204 -0
- package/dist/classifiers/cloudflare/clef/client.d.ts +104 -0
- package/dist/classifiers/cloudflare/clef/client.js +234 -0
- package/dist/classifiers/cloudflare/clef/index.d.ts +2 -0
- package/dist/classifiers/cloudflare/clef/index.js +8 -0
- package/dist/classifiers/cloudflare/index.d.ts +2 -0
- package/dist/classifiers/cloudflare/index.js +8 -0
- package/dist/classifiers/http_client.d.ts +70 -0
- package/dist/classifiers/http_client.js +161 -0
- package/dist/classifiers/index.d.ts +2 -0
- package/dist/classifiers/index.js +8 -0
- package/dist/classifiers/jev/classifier.d.ts +8 -0
- package/dist/classifiers/jev/classifier.js +13 -0
- package/dist/classifiers/jev/client.d.ts +8 -0
- package/dist/classifiers/jev/client.js +13 -0
- package/dist/classifiers/jev/index.d.ts +2 -0
- package/dist/classifiers/jev/index.js +8 -0
- package/dist/classifiers/llm/classifier.d.ts +72 -0
- package/dist/classifiers/llm/classifier.js +304 -0
- package/dist/classifiers/llm/index.d.ts +2 -0
- package/dist/classifiers/llm/index.js +8 -0
- package/dist/classifiers/openai/decisions/classifier.d.ts +77 -0
- package/dist/classifiers/openai/decisions/classifier.js +241 -0
- package/dist/classifiers/openai/decisions/client.d.ts +108 -0
- package/dist/classifiers/openai/decisions/client.js +234 -0
- package/dist/classifiers/openai/decisions/index.d.ts +2 -0
- package/dist/classifiers/openai/decisions/index.js +8 -0
- package/dist/classifiers/openai/index.d.ts +2 -0
- package/dist/classifiers/openai/index.js +8 -0
- package/dist/classifiers/typesafe/index.d.ts +2 -0
- package/dist/classifiers/typesafe/index.js +8 -0
- package/dist/classifiers/typesafe/jev/classifier.d.ts +70 -0
- package/dist/classifiers/typesafe/jev/classifier.js +220 -0
- package/dist/classifiers/typesafe/jev/client.d.ts +105 -0
- package/dist/classifiers/typesafe/jev/client.js +233 -0
- package/dist/classifiers/typesafe/jev/index.d.ts +2 -0
- package/dist/classifiers/typesafe/jev/index.js +8 -0
- package/dist/clocks/base_clock.d.ts +13 -0
- package/dist/clocks/base_clock.js +14 -0
- package/dist/clocks/index.d.ts +2 -0
- package/dist/clocks/index.js +8 -0
- package/dist/clocks/system_clock.d.ts +15 -0
- package/dist/clocks/system_clock.js +25 -0
- package/dist/frames/frames.d.ts +2533 -0
- package/dist/frames/frames.js +2485 -0
- package/dist/frames/index.d.ts +2 -0
- package/dist/frames/index.js +8 -0
- package/dist/frames/protobufs/frames_pb2.d.ts +229 -0
- package/dist/frames/protobufs/frames_pb2.js +466 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +56 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.js +8 -0
- package/dist/metrics/metrics.d.ts +276 -0
- package/dist/metrics/metrics.js +254 -0
- package/dist/observers/base_observer.d.ts +173 -0
- package/dist/observers/base_observer.js +151 -0
- package/dist/observers/error_observer.d.ts +75 -0
- package/dist/observers/error_observer.js +87 -0
- package/dist/observers/function_call_observer.d.ts +157 -0
- package/dist/observers/function_call_observer.js +222 -0
- package/dist/observers/index.d.ts +2 -0
- package/dist/observers/index.js +8 -0
- package/dist/observers/loggers/debug_log_observer.d.ts +91 -0
- package/dist/observers/loggers/debug_log_observer.js +228 -0
- package/dist/observers/loggers/index.d.ts +2 -0
- package/dist/observers/loggers/index.js +8 -0
- package/dist/observers/loggers/llm_log_observer.d.ts +24 -0
- package/dist/observers/loggers/llm_log_observer.js +110 -0
- package/dist/observers/loggers/metrics_log_observer.d.ts +85 -0
- package/dist/observers/loggers/metrics_log_observer.js +186 -0
- package/dist/observers/loggers/transcription_log_observer.d.ts +23 -0
- package/dist/observers/loggers/transcription_log_observer.js +74 -0
- package/dist/observers/service_metrics_observer.d.ts +168 -0
- package/dist/observers/service_metrics_observer.js +236 -0
- package/dist/observers/speaking_observer.d.ts +104 -0
- package/dist/observers/speaking_observer.js +150 -0
- package/dist/observers/startup_timing_observer.d.ts +221 -0
- package/dist/observers/startup_timing_observer.js +365 -0
- package/dist/observers/turn_tracking_observer.d.ts +78 -0
- package/dist/observers/turn_tracking_observer.js +189 -0
- package/dist/observers/user_bot_latency_observer.d.ts +411 -0
- package/dist/observers/user_bot_latency_observer.js +974 -0
- package/dist/pipeline/base_pipeline.d.ts +49 -0
- package/dist/pipeline/base_pipeline.js +101 -0
- package/dist/pipeline/capabilities.d.ts +76 -0
- package/dist/pipeline/capabilities.js +97 -0
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +8 -0
- package/dist/pipeline/job_context.d.ts +317 -0
- package/dist/pipeline/job_context.js +450 -0
- package/dist/pipeline/job_decorator.d.ts +54 -0
- package/dist/pipeline/job_decorator.js +92 -0
- package/dist/pipeline/llm_switcher.d.ts +84 -0
- package/dist/pipeline/llm_switcher.js +107 -0
- package/dist/pipeline/llm_with_backend.d.ts +435 -0
- package/dist/pipeline/llm_with_backend.js +806 -0
- package/dist/pipeline/parallel_pipeline.d.ts +83 -0
- package/dist/pipeline/parallel_pipeline.js +200 -0
- package/dist/pipeline/pipeline.d.ts +126 -0
- package/dist/pipeline/pipeline.js +196 -0
- package/dist/pipeline/service_switcher.d.ts +287 -0
- package/dist/pipeline/service_switcher.js +509 -0
- package/dist/pipeline/sync_parallel_pipeline.d.ts +192 -0
- package/dist/pipeline/sync_parallel_pipeline.js +387 -0
- package/dist/pipeline/worker.d.ts +814 -0
- package/dist/pipeline/worker.js +1639 -0
- package/dist/pipeline/worker_observer.d.ts +131 -0
- package/dist/pipeline/worker_observer.js +274 -0
- package/dist/pipeline/worker_ready_decorator.d.ts +45 -0
- package/dist/pipeline/worker_ready_decorator.js +76 -0
- package/dist/processors/aggregators/async_tool_messages.d.ts +146 -0
- package/dist/processors/aggregators/async_tool_messages.js +291 -0
- package/dist/processors/aggregators/dtmf_aggregator.d.ts +61 -0
- package/dist/processors/aggregators/dtmf_aggregator.js +144 -0
- package/dist/processors/aggregators/gated.d.ts +43 -0
- package/dist/processors/aggregators/gated.js +86 -0
- package/dist/processors/aggregators/gated_llm_context.d.ts +42 -0
- package/dist/processors/aggregators/gated_llm_context.js +86 -0
- package/dist/processors/aggregators/index.d.ts +2 -0
- package/dist/processors/aggregators/index.js +8 -0
- package/dist/processors/aggregators/llm_context.d.ts +370 -0
- package/dist/processors/aggregators/llm_context.js +580 -0
- package/dist/processors/aggregators/llm_context_summarizer.d.ts +219 -0
- package/dist/processors/aggregators/llm_context_summarizer.js +447 -0
- package/dist/processors/aggregators/llm_response.d.ts +37 -0
- package/dist/processors/aggregators/llm_response.js +71 -0
- package/dist/processors/aggregators/llm_response_universal.d.ts +966 -0
- package/dist/processors/aggregators/llm_response_universal.js +2394 -0
- package/dist/processors/aggregators/llm_text_processor.d.ts +53 -0
- package/dist/processors/aggregators/llm_text_processor.js +102 -0
- package/dist/processors/aggregators/sentence.d.ts +39 -0
- package/dist/processors/aggregators/sentence.js +69 -0
- package/dist/processors/async_generator.d.ts +42 -0
- package/dist/processors/async_generator.js +76 -0
- package/dist/processors/audio/audio_buffer_processor.d.ts +241 -0
- package/dist/processors/audio/audio_buffer_processor.js +565 -0
- package/dist/processors/audio/index.d.ts +2 -0
- package/dist/processors/audio/index.js +8 -0
- package/dist/processors/audio/vad_processor.d.ts +67 -0
- package/dist/processors/audio/vad_processor.js +103 -0
- package/dist/processors/consumer_processor.d.ts +49 -0
- package/dist/processors/consumer_processor.js +85 -0
- package/dist/processors/filters/frame_filter.d.ts +39 -0
- package/dist/processors/filters/frame_filter.js +52 -0
- package/dist/processors/filters/function_filter.d.ts +59 -0
- package/dist/processors/filters/function_filter.js +78 -0
- package/dist/processors/filters/identity_filter.d.ts +33 -0
- package/dist/processors/filters/identity_filter.js +37 -0
- package/dist/processors/filters/index.d.ts +2 -0
- package/dist/processors/filters/index.js +8 -0
- package/dist/processors/filters/null_filter.d.ts +34 -0
- package/dist/processors/filters/null_filter.js +47 -0
- package/dist/processors/filters/wake_notifier_filter.d.ts +48 -0
- package/dist/processors/filters/wake_notifier_filter.js +49 -0
- package/dist/processors/frame_processor.d.ts +360 -0
- package/dist/processors/frame_processor.js +932 -0
- package/dist/processors/frameworks/index.d.ts +2 -0
- package/dist/processors/frameworks/index.js +8 -0
- package/dist/processors/frameworks/rtvi/frames.d.ts +241 -0
- package/dist/processors/frameworks/rtvi/frames.js +259 -0
- package/dist/processors/frameworks/rtvi/index.d.ts +6 -0
- package/dist/processors/frameworks/rtvi/index.js +11 -0
- package/dist/processors/frameworks/rtvi/models.d.ts +1741 -0
- package/dist/processors/frameworks/rtvi/models.js +1807 -0
- package/dist/processors/frameworks/rtvi/observer.d.ts +340 -0
- package/dist/processors/frameworks/rtvi/observer.js +1113 -0
- package/dist/processors/frameworks/rtvi/processor.d.ts +182 -0
- package/dist/processors/frameworks/rtvi/processor.js +676 -0
- package/dist/processors/idle_frame_processor.d.ts +44 -0
- package/dist/processors/idle_frame_processor.js +86 -0
- package/dist/processors/index.d.ts +2 -0
- package/dist/processors/index.js +8 -0
- package/dist/processors/logger.d.ts +42 -0
- package/dist/processors/logger.js +87 -0
- package/dist/processors/metrics/frame_processor_metrics.d.ts +172 -0
- package/dist/processors/metrics/frame_processor_metrics.js +372 -0
- package/dist/processors/metrics/index.d.ts +2 -0
- package/dist/processors/metrics/index.js +8 -0
- package/dist/processors/producer_processor.d.ts +68 -0
- package/dist/processors/producer_processor.js +78 -0
- package/dist/processors/text_transformer.d.ts +30 -0
- package/dist/processors/text_transformer.js +48 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.js +8 -0
- package/dist/registry/registry.d.ts +69 -0
- package/dist/registry/registry.js +149 -0
- package/dist/registry/types.d.ts +47 -0
- package/dist/registry/types.js +39 -0
- package/dist/serializers/base_serializer.d.ts +94 -0
- package/dist/serializers/base_serializer.js +82 -0
- package/dist/serializers/index.d.ts +2 -0
- package/dist/serializers/index.js +8 -0
- package/dist/services/ai_service.d.ts +145 -0
- package/dist/services/ai_service.js +262 -0
- package/dist/services/anthropic/index.d.ts +2 -0
- package/dist/services/anthropic/index.js +7 -0
- package/dist/services/assemblyai/index.d.ts +2 -0
- package/dist/services/assemblyai/index.js +7 -0
- package/dist/services/asyncai/index.d.ts +2 -0
- package/dist/services/asyncai/index.js +7 -0
- package/dist/services/aws/index.d.ts +2 -0
- package/dist/services/aws/index.js +7 -0
- package/dist/services/azure/index.d.ts +2 -0
- package/dist/services/azure/index.js +7 -0
- package/dist/services/baseten/index.d.ts +2 -0
- package/dist/services/baseten/index.js +7 -0
- package/dist/services/bland/index.d.ts +2 -0
- package/dist/services/bland/index.js +7 -0
- package/dist/services/camb/index.d.ts +2 -0
- package/dist/services/camb/index.js +7 -0
- package/dist/services/cartesia/index.d.ts +2 -0
- package/dist/services/cartesia/index.js +7 -0
- package/dist/services/cerebras/index.d.ts +2 -0
- package/dist/services/cerebras/index.js +7 -0
- package/dist/services/crusoe/index.d.ts +2 -0
- package/dist/services/crusoe/index.js +7 -0
- package/dist/services/deepgram/index.d.ts +2 -0
- package/dist/services/deepgram/index.js +7 -0
- package/dist/services/deepseek/index.d.ts +2 -0
- package/dist/services/deepseek/index.js +7 -0
- package/dist/services/elevenlabs/index.d.ts +2 -0
- package/dist/services/elevenlabs/index.js +7 -0
- package/dist/services/fal/index.d.ts +2 -0
- package/dist/services/fal/index.js +7 -0
- package/dist/services/fireworks/index.d.ts +2 -0
- package/dist/services/fireworks/index.js +7 -0
- package/dist/services/fish/index.d.ts +2 -0
- package/dist/services/fish/index.js +7 -0
- package/dist/services/funasr/index.d.ts +3 -0
- package/dist/services/funasr/index.js +8 -0
- package/dist/services/gladia/index.d.ts +2 -0
- package/dist/services/gladia/index.js +7 -0
- package/dist/services/google/index.d.ts +2 -0
- package/dist/services/google/index.js +7 -0
- package/dist/services/gradium/index.d.ts +2 -0
- package/dist/services/gradium/index.js +7 -0
- package/dist/services/grok/index.d.ts +2 -0
- package/dist/services/grok/index.js +7 -0
- package/dist/services/groq/index.d.ts +2 -0
- package/dist/services/groq/index.js +7 -0
- package/dist/services/heygen/index.d.ts +2 -0
- package/dist/services/heygen/index.js +7 -0
- package/dist/services/hume/index.d.ts +2 -0
- package/dist/services/hume/index.js +7 -0
- package/dist/services/image_service.d.ts +52 -0
- package/dist/services/image_service.js +60 -0
- package/dist/services/inception/index.d.ts +2 -0
- package/dist/services/inception/index.js +7 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +8 -0
- package/dist/services/inworld/index.d.ts +2 -0
- package/dist/services/inworld/index.js +7 -0
- package/dist/services/keenable/index.d.ts +2 -0
- package/dist/services/keenable/index.js +7 -0
- package/dist/services/kokoro/index.d.ts +2 -0
- package/dist/services/kokoro/index.js +7 -0
- package/dist/services/llm_service.d.ts +1106 -0
- package/dist/services/llm_service.js +2231 -0
- package/dist/services/mem0/index.d.ts +2 -0
- package/dist/services/mem0/index.js +7 -0
- package/dist/services/meta/index.d.ts +2 -0
- package/dist/services/meta/index.js +7 -0
- package/dist/services/minimax/index.d.ts +2 -0
- package/dist/services/minimax/index.js +7 -0
- package/dist/services/mistral/index.d.ts +2 -0
- package/dist/services/mistral/index.js +7 -0
- package/dist/services/moondream/index.d.ts +2 -0
- package/dist/services/moondream/index.js +7 -0
- package/dist/services/moonshine/index.d.ts +2 -0
- package/dist/services/moonshine/index.js +7 -0
- package/dist/services/nebius/index.d.ts +2 -0
- package/dist/services/nebius/index.js +7 -0
- package/dist/services/neuphonic/index.d.ts +2 -0
- package/dist/services/neuphonic/index.js +7 -0
- package/dist/services/novita/index.d.ts +2 -0
- package/dist/services/novita/index.js +7 -0
- package/dist/services/nvidia/index.d.ts +2 -0
- package/dist/services/nvidia/index.js +11 -0
- package/dist/services/ollama/index.d.ts +2 -0
- package/dist/services/ollama/index.js +7 -0
- package/dist/services/openai/index.d.ts +2 -0
- package/dist/services/openai/index.js +7 -0
- package/dist/services/openclaw/index.d.ts +14 -0
- package/dist/services/openclaw/index.js +19 -0
- package/dist/services/openrouter/index.d.ts +2 -0
- package/dist/services/openrouter/index.js +7 -0
- package/dist/services/perplexity/index.d.ts +2 -0
- package/dist/services/perplexity/index.js +7 -0
- package/dist/services/piper/index.d.ts +2 -0
- package/dist/services/piper/index.js +7 -0
- package/dist/services/pocket_tts/index.d.ts +2 -0
- package/dist/services/pocket_tts/index.js +7 -0
- package/dist/services/qwen/index.d.ts +2 -0
- package/dist/services/qwen/index.js +7 -0
- package/dist/services/resembleai/index.d.ts +2 -0
- package/dist/services/resembleai/index.js +7 -0
- package/dist/services/rime/index.d.ts +2 -0
- package/dist/services/rime/index.js +7 -0
- package/dist/services/sambanova/index.d.ts +2 -0
- package/dist/services/sambanova/index.js +7 -0
- package/dist/services/sarvam/index.d.ts +2 -0
- package/dist/services/sarvam/index.js +7 -0
- package/dist/services/settings.d.ts +356 -0
- package/dist/services/settings.js +437 -0
- package/dist/services/simli/index.d.ts +2 -0
- package/dist/services/simli/index.js +7 -0
- package/dist/services/smallest/index.d.ts +2 -0
- package/dist/services/smallest/index.js +7 -0
- package/dist/services/soniox/index.d.ts +2 -0
- package/dist/services/soniox/index.js +7 -0
- package/dist/services/speechify/index.d.ts +2 -0
- package/dist/services/speechify/index.js +7 -0
- package/dist/services/speechmatics/index.d.ts +2 -0
- package/dist/services/speechmatics/index.js +7 -0
- package/dist/services/stt_latency.d.ts +62 -0
- package/dist/services/stt_latency.js +71 -0
- package/dist/services/stt_service.d.ts +601 -0
- package/dist/services/stt_service.js +1044 -0
- package/dist/services/tavus/index.d.ts +2 -0
- package/dist/services/tavus/index.js +7 -0
- package/dist/services/together/index.d.ts +2 -0
- package/dist/services/together/index.js +7 -0
- package/dist/services/tts_service.d.ts +909 -0
- package/dist/services/tts_service.js +2018 -0
- package/dist/services/ultravox/index.d.ts +2 -0
- package/dist/services/ultravox/index.js +9 -0
- package/dist/services/vision_service.d.ts +56 -0
- package/dist/services/vision_service.js +62 -0
- package/dist/services/websocket_service.d.ts +213 -0
- package/dist/services/websocket_service.js +654 -0
- package/dist/services/whisper/index.d.ts +2 -0
- package/dist/services/whisper/index.js +9 -0
- package/dist/services/xai/index.d.ts +2 -0
- package/dist/services/xai/index.js +9 -0
- package/dist/services/xtts/index.d.ts +2 -0
- package/dist/services/xtts/index.js +9 -0
- package/dist/tests/index.d.ts +2 -0
- package/dist/tests/index.js +8 -0
- package/dist/tests/utils.d.ts +123 -0
- package/dist/tests/utils.js +212 -0
- package/dist/transcriptions/index.d.ts +2 -0
- package/dist/transcriptions/index.js +8 -0
- package/dist/transcriptions/language.d.ts +376 -0
- package/dist/transcriptions/language.js +543 -0
- package/dist/transports/base_input.d.ts +149 -0
- package/dist/transports/base_input.js +338 -0
- package/dist/transports/base_output.d.ts +432 -0
- package/dist/transports/base_output.js +1231 -0
- package/dist/transports/base_transport.d.ts +223 -0
- package/dist/transports/base_transport.js +167 -0
- package/dist/transports/daily/index.d.ts +2 -0
- package/dist/transports/daily/index.js +9 -0
- package/dist/transports/heygen/index.d.ts +2 -0
- package/dist/transports/heygen/index.js +9 -0
- package/dist/transports/index.d.ts +2 -0
- package/dist/transports/index.js +8 -0
- package/dist/transports/lemonslice/index.d.ts +2 -0
- package/dist/transports/lemonslice/index.js +9 -0
- package/dist/transports/livekit/index.d.ts +2 -0
- package/dist/transports/livekit/index.js +9 -0
- package/dist/transports/local/index.d.ts +2 -0
- package/dist/transports/local/index.js +9 -0
- package/dist/transports/moq/index.d.ts +2 -0
- package/dist/transports/moq/index.js +9 -0
- package/dist/transports/smallwebrtc/index.d.ts +2 -0
- package/dist/transports/smallwebrtc/index.js +9 -0
- package/dist/transports/tavus/index.d.ts +2 -0
- package/dist/transports/tavus/index.js +9 -0
- package/dist/transports/video_in_sampler.d.ts +157 -0
- package/dist/transports/video_in_sampler.js +258 -0
- package/dist/transports/vonage/index.d.ts +2 -0
- package/dist/transports/vonage/index.js +9 -0
- package/dist/transports/websocket/index.d.ts +2 -0
- package/dist/transports/websocket/index.js +9 -0
- package/dist/transports/whatsapp/index.d.ts +2 -0
- package/dist/transports/whatsapp/index.js +9 -0
- package/dist/turns/eager_end_of_turn_mixin.d.ts +70 -0
- package/dist/turns/eager_end_of_turn_mixin.js +122 -0
- package/dist/turns/empty_user_turn.d.ts +55 -0
- package/dist/turns/empty_user_turn.js +53 -0
- package/dist/turns/index.d.ts +2 -0
- package/dist/turns/index.js +8 -0
- package/dist/turns/speculation_gate.d.ts +169 -0
- package/dist/turns/speculation_gate.js +294 -0
- package/dist/turns/types.d.ts +33 -0
- package/dist/turns/types.js +35 -0
- package/dist/turns/user_idle_controller.d.ts +94 -0
- package/dist/turns/user_idle_controller.js +187 -0
- package/dist/turns/user_mute/always_user_mute_strategy.d.ts +15 -0
- package/dist/turns/user_mute/always_user_mute_strategy.js +29 -0
- package/dist/turns/user_mute/base_user_mute_strategy.d.ts +39 -0
- package/dist/turns/user_mute/base_user_mute_strategy.js +45 -0
- package/dist/turns/user_mute/first_speech_user_mute_strategy.d.ts +28 -0
- package/dist/turns/user_mute/first_speech_user_mute_strategy.js +52 -0
- package/dist/turns/user_mute/function_call_user_mute_strategy.d.ts +25 -0
- package/dist/turns/user_mute/function_call_user_mute_strategy.js +50 -0
- package/dist/turns/user_mute/index.d.ts +6 -0
- package/dist/turns/user_mute/index.js +11 -0
- package/dist/turns/user_mute/mute_until_first_bot_complete_user_mute_strategy.d.ts +43 -0
- package/dist/turns/user_mute/mute_until_first_bot_complete_user_mute_strategy.js +76 -0
- package/dist/turns/user_start/base_user_turn_start_strategy.d.ts +135 -0
- package/dist/turns/user_start/base_user_turn_start_strategy.js +134 -0
- package/dist/turns/user_start/external_user_turn_start_strategy.d.ts +45 -0
- package/dist/turns/user_start/external_user_turn_start_strategy.js +64 -0
- package/dist/turns/user_start/index.d.ts +8 -0
- package/dist/turns/user_start/index.js +16 -0
- package/dist/turns/user_start/krisp_viva_ip_user_turn_start_strategy.d.ts +133 -0
- package/dist/turns/user_start/krisp_viva_ip_user_turn_start_strategy.js +243 -0
- package/dist/turns/user_start/min_words_user_turn_start_strategy.d.ts +60 -0
- package/dist/turns/user_start/min_words_user_turn_start_strategy.js +102 -0
- package/dist/turns/user_start/transcription_user_turn_start_strategy.d.ts +29 -0
- package/dist/turns/user_start/transcription_user_turn_start_strategy.js +43 -0
- package/dist/turns/user_start/vad_user_turn_start_strategy.d.ts +20 -0
- package/dist/turns/user_start/vad_user_turn_start_strategy.js +31 -0
- package/dist/turns/user_start/wake_phrase_user_turn_start_strategy.d.ts +141 -0
- package/dist/turns/user_start/wake_phrase_user_turn_start_strategy.js +238 -0
- package/dist/turns/user_stop/base_user_turn_stop_strategy.d.ts +174 -0
- package/dist/turns/user_stop/base_user_turn_stop_strategy.js +170 -0
- package/dist/turns/user_stop/deferred_user_turn_stop_strategy.d.ts +81 -0
- package/dist/turns/user_stop/deferred_user_turn_stop_strategy.js +107 -0
- package/dist/turns/user_stop/eager_match_policy.d.ts +36 -0
- package/dist/turns/user_stop/eager_match_policy.js +50 -0
- package/dist/turns/user_stop/eager_user_turn_stop_strategy.d.ts +84 -0
- package/dist/turns/user_stop/eager_user_turn_stop_strategy.js +154 -0
- package/dist/turns/user_stop/external_user_turn_completion_stop_strategy.d.ts +45 -0
- package/dist/turns/user_stop/external_user_turn_completion_stop_strategy.js +55 -0
- package/dist/turns/user_stop/external_user_turn_stop_strategy.d.ts +115 -0
- package/dist/turns/user_stop/external_user_turn_stop_strategy.js +205 -0
- package/dist/turns/user_stop/index.d.ts +10 -0
- package/dist/turns/user_stop/index.js +15 -0
- package/dist/turns/user_stop/llm_turn_completion_user_turn_stop_strategy.d.ts +44 -0
- package/dist/turns/user_stop/llm_turn_completion_user_turn_stop_strategy.js +59 -0
- package/dist/turns/user_stop/speech_timeout_user_turn_stop_strategy.d.ts +140 -0
- package/dist/turns/user_stop/speech_timeout_user_turn_stop_strategy.js +303 -0
- package/dist/turns/user_stop/turn_analyzer_user_turn_stop_strategy.d.ts +135 -0
- package/dist/turns/user_stop/turn_analyzer_user_turn_stop_strategy.js +332 -0
- package/dist/turns/user_turn_completion_mixin.d.ts +147 -0
- package/dist/turns/user_turn_completion_mixin.js +591 -0
- package/dist/turns/user_turn_controller.d.ts +134 -0
- package/dist/turns/user_turn_controller.js +335 -0
- package/dist/turns/user_turn_processor.d.ts +87 -0
- package/dist/turns/user_turn_processor.js +180 -0
- package/dist/turns/user_turn_strategies.d.ts +187 -0
- package/dist/turns/user_turn_strategies.js +222 -0
- package/dist/utils/async_tool_cancellation.d.ts +35 -0
- package/dist/utils/async_tool_cancellation.js +78 -0
- package/dist/utils/asyncio/index.d.ts +2 -0
- package/dist/utils/asyncio/index.js +7 -0
- package/dist/utils/asyncio/task_manager.d.ts +49 -0
- package/dist/utils/asyncio/task_manager.js +105 -0
- package/dist/utils/base_object.d.ts +76 -0
- package/dist/utils/base_object.js +154 -0
- package/dist/utils/context/aggregated_frame_sequencer.d.ts +491 -0
- package/dist/utils/context/aggregated_frame_sequencer.js +803 -0
- package/dist/utils/context/audio_context_manager.d.ts +131 -0
- package/dist/utils/context/audio_context_manager.js +233 -0
- package/dist/utils/context/index.d.ts +2 -0
- package/dist/utils/context/index.js +7 -0
- package/dist/utils/context/llm_context_summarization.d.ts +258 -0
- package/dist/utils/context/llm_context_summarization.js +511 -0
- package/dist/utils/context/text_segment_map.d.ts +611 -0
- package/dist/utils/context/text_segment_map.js +1132 -0
- package/dist/utils/context/word_completion_tracker.d.ts +273 -0
- package/dist/utils/context/word_completion_tracker.js +441 -0
- package/dist/utils/context/word_timestamp_tracker.d.ts +72 -0
- package/dist/utils/context/word_timestamp_tracker.js +98 -0
- package/dist/utils/deprecation.d.ts +28 -0
- package/dist/utils/deprecation.js +75 -0
- package/dist/utils/env.d.ts +38 -0
- package/dist/utils/env.js +62 -0
- package/dist/utils/errors.d.ts +75 -0
- package/dist/utils/errors.js +202 -0
- package/dist/utils/file_resolver.d.ts +126 -0
- package/dist/utils/file_resolver.js +314 -0
- package/dist/utils/file_storage.d.ts +99 -0
- package/dist/utils/file_storage.js +100 -0
- package/dist/utils/frame_queue.d.ts +36 -0
- package/dist/utils/frame_queue.js +66 -0
- package/dist/utils/http.d.ts +39 -0
- package/dist/utils/http.js +53 -0
- package/dist/utils/image.d.ts +15 -0
- package/dist/utils/image.js +30 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/log_config.d.ts +34 -0
- package/dist/utils/log_config.js +76 -0
- package/dist/utils/logger.d.ts +40 -0
- package/dist/utils/logger.js +91 -0
- package/dist/utils/mixin.d.ts +14 -0
- package/dist/utils/mixin.js +63 -0
- package/dist/utils/network.d.ts +73 -0
- package/dist/utils/network.js +90 -0
- package/dist/utils/security/allowed_origins.d.ts +16 -0
- package/dist/utils/security/allowed_origins.js +34 -0
- package/dist/utils/security/index.d.ts +2 -0
- package/dist/utils/security/index.js +7 -0
- package/dist/utils/security/redaction.d.ts +27 -0
- package/dist/utils/security/redaction.js +123 -0
- package/dist/utils/security/ssrf.d.ts +79 -0
- package/dist/utils/security/ssrf.js +327 -0
- package/dist/utils/shared.d.ts +35 -0
- package/dist/utils/shared.js +136 -0
- package/dist/utils/startup.d.ts +17 -0
- package/dist/utils/startup.js +130 -0
- package/dist/utils/string.d.ts +116 -0
- package/dist/utils/string.js +460 -0
- package/dist/utils/sync/base_notifier.d.ts +25 -0
- package/dist/utils/sync/base_notifier.js +16 -0
- package/dist/utils/sync/event_notifier.d.ts +38 -0
- package/dist/utils/sync/event_notifier.js +51 -0
- package/dist/utils/sync/index.d.ts +2 -0
- package/dist/utils/sync/index.js +7 -0
- package/dist/utils/text/alnum_utils.d.ts +109 -0
- package/dist/utils/text/alnum_utils.js +262 -0
- package/dist/utils/text/base_text_aggregator.d.ts +146 -0
- package/dist/utils/text/base_text_aggregator.js +102 -0
- package/dist/utils/text/base_text_filter.d.ts +54 -0
- package/dist/utils/text/base_text_filter.js +50 -0
- package/dist/utils/text/index.d.ts +2 -0
- package/dist/utils/text/index.js +7 -0
- package/dist/utils/text/markdown_text_filter.d.ts +147 -0
- package/dist/utils/text/markdown_text_filter.js +522 -0
- package/dist/utils/text/markup_utils.d.ts +54 -0
- package/dist/utils/text/markup_utils.js +156 -0
- package/dist/utils/text/pattern_pair_aggregator.d.ts +251 -0
- package/dist/utils/text/pattern_pair_aggregator.js +478 -0
- package/dist/utils/text/phonemes.d.ts +60 -0
- package/dist/utils/text/phonemes.js +172 -0
- package/dist/utils/text/simple_text_aggregator.d.ts +135 -0
- package/dist/utils/text/simple_text_aggregator.js +254 -0
- package/dist/utils/text/skip_tags_aggregator.d.ts +85 -0
- package/dist/utils/text/skip_tags_aggregator.js +147 -0
- package/dist/utils/text/transforms/pronunciations.d.ts +65 -0
- package/dist/utils/text/transforms/pronunciations.js +111 -0
- package/dist/utils/text/word_timestamp_utils.d.ts +26 -0
- package/dist/utils/text/word_timestamp_utils.js +52 -0
- package/dist/utils/time.d.ts +13 -0
- package/dist/utils/time.js +31 -0
- package/dist/utils/tracing/index.d.ts +3 -0
- package/dist/utils/tracing/index.js +8 -0
- package/dist/utils/tracing/service_attributes.d.ts +198 -0
- package/dist/utils/tracing/service_attributes.js +434 -0
- package/dist/utils/tracing/service_decorators.d.ts +214 -0
- package/dist/utils/tracing/service_decorators.js +1662 -0
- package/dist/utils/tracing/setup.d.ts +95 -0
- package/dist/utils/tracing/setup.js +110 -0
- package/dist/utils/tracing/tracing_context.d.ts +55 -0
- package/dist/utils/tracing/tracing_context.js +97 -0
- package/dist/utils/tracing/turn_trace_observer.d.ts +90 -0
- package/dist/utils/tracing/turn_trace_observer.js +219 -0
- package/dist/utils/types.d.ts +80 -0
- package/dist/utils/types.js +108 -0
- package/dist/utils/utils.d.ts +5 -0
- package/dist/utils/utils.js +22 -0
- package/dist/utils/yaml.d.ts +64 -0
- package/dist/utils/yaml.js +41 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +7 -0
- package/dist/workers/base_worker.d.ts +772 -0
- package/dist/workers/base_worker.js +1298 -0
- package/dist/workers/index.d.ts +2 -0
- package/dist/workers/index.js +8 -0
- package/dist/workers/llm/backend_llm_worker.d.ts +552 -0
- package/dist/workers/llm/backend_llm_worker.js +1055 -0
- package/dist/workers/llm/index.d.ts +6 -0
- package/dist/workers/llm/index.js +11 -0
- package/dist/workers/llm/llm_context_worker.d.ts +66 -0
- package/dist/workers/llm/llm_context_worker.js +72 -0
- package/dist/workers/llm/llm_worker.d.ts +180 -0
- package/dist/workers/llm/llm_worker.js +323 -0
- package/dist/workers/llm/tool_decorator.d.ts +68 -0
- package/dist/workers/llm/tool_decorator.js +60 -0
- package/dist/workers/runner.d.ts +268 -0
- package/dist/workers/runner.js +489 -0
- package/dist/workers/ui/index.d.ts +22 -0
- package/dist/workers/ui/index.js +27 -0
- package/dist/workers/ui/ui_event_decorator.d.ts +43 -0
- package/dist/workers/ui/ui_event_decorator.js +75 -0
- package/dist/workers/ui/ui_job_context.d.ts +12 -0
- package/dist/workers/ui/ui_job_context.js +17 -0
- package/dist/workers/ui/ui_prompts.d.ts +21 -0
- package/dist/workers/ui/ui_prompts.js +41 -0
- package/dist/workers/ui/ui_tools.d.ts +32 -0
- package/dist/workers/ui/ui_tools.js +112 -0
- package/dist/workers/ui/ui_worker.d.ts +571 -0
- package/dist/workers/ui/ui_worker.js +1156 -0
- package/package.json +46 -3
- package/README.md +0 -5
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026, Daily
|
|
2
|
+
// Copyright (c) 2026, pipedog contributors
|
|
3
|
+
// SPDX-License-Identifier: BSD-2-Clause
|
|
4
|
+
//
|
|
5
|
+
// Ported from pipecat: src/pipecat/observers/service_metrics_observer.py
|
|
6
|
+
/**
|
|
7
|
+
* Observer reporting what each service spent and consumed.
|
|
8
|
+
*
|
|
9
|
+
* Services report metrics as they finish a piece of work, and this observer
|
|
10
|
+
* turns each one into a record: what was measured, which processor and model
|
|
11
|
+
* reported it, and when. Nothing is summed, so a consumer groups the records
|
|
12
|
+
* by turn, session or model as it needs, and a session that ends abruptly
|
|
13
|
+
* still leaves behind everything that happened before it did.
|
|
14
|
+
*/
|
|
15
|
+
import { time } from "@pipedog/asyncio";
|
|
16
|
+
import { MetricsFrame } from "../frames/frames.js";
|
|
17
|
+
import { LLMUsageMetricsData, STTUsageMetricsData, TTFAMetricsData, TTFATMetricsData, TTFBMetricsData, TTSUsageMetricsData, } from "../metrics/metrics.js";
|
|
18
|
+
import { BaseObserver } from "./base_observer.js";
|
|
19
|
+
/** Which measurement of a service's own time a record carries. */
|
|
20
|
+
export const ServiceLatencyKind = {
|
|
21
|
+
TTFB: "ttfb",
|
|
22
|
+
TTFA: "ttfa",
|
|
23
|
+
TTFAT: "ttfat",
|
|
24
|
+
};
|
|
25
|
+
/** Which kind of service consumed something. */
|
|
26
|
+
export const ServiceUsageKind = {
|
|
27
|
+
STT: "stt",
|
|
28
|
+
LLM: "llm",
|
|
29
|
+
TTS: "tts",
|
|
30
|
+
};
|
|
31
|
+
/** One measurement of how long a service took. */
|
|
32
|
+
export class ServiceLatencyRecord {
|
|
33
|
+
kind;
|
|
34
|
+
processor;
|
|
35
|
+
model;
|
|
36
|
+
timestamp;
|
|
37
|
+
seconds;
|
|
38
|
+
ttfbSecs;
|
|
39
|
+
leadingSilenceSecs;
|
|
40
|
+
thinkingTimeSecs;
|
|
41
|
+
constructor(options) {
|
|
42
|
+
this.kind = options.kind;
|
|
43
|
+
this.processor = options.processor;
|
|
44
|
+
this.model = options.model ?? null;
|
|
45
|
+
this.timestamp = options.timestamp;
|
|
46
|
+
this.seconds = options.seconds;
|
|
47
|
+
this.ttfbSecs = options.ttfbSecs ?? null;
|
|
48
|
+
this.leadingSilenceSecs = options.leadingSilenceSecs ?? null;
|
|
49
|
+
this.thinkingTimeSecs = options.thinkingTimeSecs ?? null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* What one service consumed doing a piece of work.
|
|
54
|
+
*
|
|
55
|
+
* A field is set only where the kind of service reports it, so an LLM record
|
|
56
|
+
* carries token counts and a text-to-speech record carries characters.
|
|
57
|
+
*/
|
|
58
|
+
export class ServiceUsageRecord {
|
|
59
|
+
kind;
|
|
60
|
+
processor;
|
|
61
|
+
model;
|
|
62
|
+
timestamp;
|
|
63
|
+
audioSeconds;
|
|
64
|
+
characters;
|
|
65
|
+
promptTokens;
|
|
66
|
+
completionTokens;
|
|
67
|
+
totalTokens;
|
|
68
|
+
cacheReadInputTokens;
|
|
69
|
+
cacheCreationInputTokens;
|
|
70
|
+
reasoningTokens;
|
|
71
|
+
inputAudioTokens;
|
|
72
|
+
outputAudioTokens;
|
|
73
|
+
cacheReadInputAudioTokens;
|
|
74
|
+
constructor(options) {
|
|
75
|
+
this.kind = options.kind;
|
|
76
|
+
this.processor = options.processor;
|
|
77
|
+
this.model = options.model ?? null;
|
|
78
|
+
this.timestamp = options.timestamp;
|
|
79
|
+
this.audioSeconds = options.audioSeconds ?? null;
|
|
80
|
+
this.characters = options.characters ?? null;
|
|
81
|
+
this.promptTokens = options.promptTokens ?? null;
|
|
82
|
+
this.completionTokens = options.completionTokens ?? null;
|
|
83
|
+
this.totalTokens = options.totalTokens ?? null;
|
|
84
|
+
this.cacheReadInputTokens = options.cacheReadInputTokens ?? null;
|
|
85
|
+
this.cacheCreationInputTokens = options.cacheCreationInputTokens ?? null;
|
|
86
|
+
this.reasoningTokens = options.reasoningTokens ?? null;
|
|
87
|
+
this.inputAudioTokens = options.inputAudioTokens ?? null;
|
|
88
|
+
this.outputAudioTokens = options.outputAudioTokens ?? null;
|
|
89
|
+
this.cacheReadInputAudioTokens = options.cacheReadInputAudioTokens ?? null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Reports each metric a service publishes as its own record.
|
|
94
|
+
*
|
|
95
|
+
* A record arrives per piece of work rather than per turn or per session: a
|
|
96
|
+
* turn that runs two inferences reports two, and a consumer that wants a
|
|
97
|
+
* total groups them itself. Summing here would lose the grain, and a total
|
|
98
|
+
* held in memory is lost with the process holding it.
|
|
99
|
+
*
|
|
100
|
+
* What a service made someone wait for is here; what it did with its own
|
|
101
|
+
* time is not. Processing time, text aggregation and smart-turn predictions
|
|
102
|
+
* are all deliberately absent: aggregation already appears as a span in
|
|
103
|
+
* `LatencyBreakdown` (see `user_bot_latency_observer`), and the other two
|
|
104
|
+
* describe how work was done rather than what it cost the person waiting.
|
|
105
|
+
*
|
|
106
|
+
* Events:
|
|
107
|
+
*
|
|
108
|
+
* - on_service_latency(observer, record): Emitted for each measurement of a
|
|
109
|
+
* service's own time, as a `ServiceLatencyRecord`.
|
|
110
|
+
* - on_service_usage(observer, record): Emitted for each report of what a
|
|
111
|
+
* service consumed, as a `ServiceUsageRecord`.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* const observer = new ServiceMetricsObserver();
|
|
115
|
+
*
|
|
116
|
+
* observer.eventHandler("on_service_usage", async (observer, record: ServiceUsageRecord) => {
|
|
117
|
+
* logger.info(JSON.stringify(record));
|
|
118
|
+
* });
|
|
119
|
+
*/
|
|
120
|
+
export class ServiceMetricsObserver extends BaseObserver {
|
|
121
|
+
_now;
|
|
122
|
+
constructor(options = {}) {
|
|
123
|
+
super({ ...options, observeEveryPush: false });
|
|
124
|
+
this._now = options.timeSource ?? time;
|
|
125
|
+
this._registerEventHandler("on_service_latency");
|
|
126
|
+
this._registerEventHandler("on_service_usage");
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Report the metrics carried by a frame.
|
|
130
|
+
*
|
|
131
|
+
* Metrics travel in one direction. A frame broadcast both ways would arrive
|
|
132
|
+
* as two frames, and would be reported twice.
|
|
133
|
+
*
|
|
134
|
+
* @param data Frame push event containing the frame and direction.
|
|
135
|
+
*/
|
|
136
|
+
async onPushFrame(data) {
|
|
137
|
+
if (!(data.frame instanceof MetricsFrame)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
for (const metrics of data.frame.data) {
|
|
141
|
+
const latency = this._asLatency(metrics);
|
|
142
|
+
if (latency) {
|
|
143
|
+
await this._callEventHandler("on_service_latency", latency);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const usage = this._asUsage(metrics);
|
|
147
|
+
if (usage) {
|
|
148
|
+
await this._callEventHandler("on_service_usage", usage);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Build a latency record, for the metrics that measure time spent.
|
|
154
|
+
*
|
|
155
|
+
* @param metrics One metric a processor reported.
|
|
156
|
+
* @returns The record, or null if this metric measures something else.
|
|
157
|
+
*/
|
|
158
|
+
_asLatency(metrics) {
|
|
159
|
+
const common = {
|
|
160
|
+
processor: metrics.processor,
|
|
161
|
+
model: metrics.model,
|
|
162
|
+
timestamp: this._now(),
|
|
163
|
+
};
|
|
164
|
+
if (metrics instanceof TTFAMetricsData) {
|
|
165
|
+
return new ServiceLatencyRecord({
|
|
166
|
+
kind: ServiceLatencyKind.TTFA,
|
|
167
|
+
seconds: metrics.ttfa,
|
|
168
|
+
ttfbSecs: metrics.ttfb,
|
|
169
|
+
leadingSilenceSecs: metrics.leadingSilence,
|
|
170
|
+
...common,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else if (metrics instanceof TTFATMetricsData) {
|
|
174
|
+
return new ServiceLatencyRecord({
|
|
175
|
+
kind: ServiceLatencyKind.TTFAT,
|
|
176
|
+
seconds: metrics.ttfat,
|
|
177
|
+
ttfbSecs: metrics.ttfb,
|
|
178
|
+
thinkingTimeSecs: metrics.thinkingTime,
|
|
179
|
+
...common,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else if (metrics instanceof TTFBMetricsData) {
|
|
183
|
+
return new ServiceLatencyRecord({
|
|
184
|
+
kind: ServiceLatencyKind.TTFB,
|
|
185
|
+
seconds: metrics.value,
|
|
186
|
+
...common,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Build a usage record, for the metrics that measure what was consumed.
|
|
193
|
+
*
|
|
194
|
+
* @param metrics One metric a processor reported.
|
|
195
|
+
* @returns The record, or null if this metric measures something else.
|
|
196
|
+
*/
|
|
197
|
+
_asUsage(metrics) {
|
|
198
|
+
const common = {
|
|
199
|
+
processor: metrics.processor,
|
|
200
|
+
model: metrics.model,
|
|
201
|
+
timestamp: this._now(),
|
|
202
|
+
};
|
|
203
|
+
if (metrics instanceof LLMUsageMetricsData) {
|
|
204
|
+
const tokens = metrics.value;
|
|
205
|
+
return new ServiceUsageRecord({
|
|
206
|
+
kind: ServiceUsageKind.LLM,
|
|
207
|
+
promptTokens: tokens.promptTokens,
|
|
208
|
+
completionTokens: tokens.completionTokens,
|
|
209
|
+
totalTokens: tokens.totalTokens,
|
|
210
|
+
cacheReadInputTokens: tokens.cacheReadInputTokens,
|
|
211
|
+
cacheCreationInputTokens: tokens.cacheCreationInputTokens,
|
|
212
|
+
reasoningTokens: tokens.reasoningTokens,
|
|
213
|
+
inputAudioTokens: tokens.inputAudioTokens,
|
|
214
|
+
outputAudioTokens: tokens.outputAudioTokens,
|
|
215
|
+
cacheReadInputAudioTokens: tokens.cacheReadInputAudioTokens,
|
|
216
|
+
...common,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
else if (metrics instanceof STTUsageMetricsData) {
|
|
220
|
+
return new ServiceUsageRecord({
|
|
221
|
+
kind: ServiceUsageKind.STT,
|
|
222
|
+
audioSeconds: metrics.value.audioSeconds,
|
|
223
|
+
...common,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
else if (metrics instanceof TTSUsageMetricsData) {
|
|
227
|
+
return new ServiceUsageRecord({
|
|
228
|
+
kind: ServiceUsageKind.TTS,
|
|
229
|
+
characters: metrics.value,
|
|
230
|
+
...common,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=service_metrics_observer.js.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type Frame } from "../frames/frames.ts";
|
|
2
|
+
import { BaseObserver, type BaseObserverOptions, type FramePushed } from "./base_observer.ts";
|
|
3
|
+
/**
|
|
4
|
+
* What happened, to whom, and at which layer.
|
|
5
|
+
*
|
|
6
|
+
* The user appears at two layers, and they answer different questions.
|
|
7
|
+
* `user_speech_*` is the speech itself, as the voice activity detector heard
|
|
8
|
+
* it: speech that never becomes a turn — a cough, a false start, a pause
|
|
9
|
+
* mid-sentence — appears only here. `user_turn_*` is the turn strategy's
|
|
10
|
+
* ruling on that speech, which is what the rest of the pipeline acts on, and
|
|
11
|
+
* follows the speech by however long the ruling took.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SpeechEventKind: {
|
|
14
|
+
readonly USER_SPEECH_STARTED: "user_speech_started";
|
|
15
|
+
readonly USER_SPEECH_STOPPED: "user_speech_stopped";
|
|
16
|
+
readonly USER_TURN_STARTED: "user_turn_started";
|
|
17
|
+
readonly USER_TURN_STOPPED: "user_turn_stopped";
|
|
18
|
+
readonly BOT_SPEECH_STARTED: "bot_speech_started";
|
|
19
|
+
readonly BOT_SPEECH_STOPPED: "bot_speech_stopped";
|
|
20
|
+
readonly INTERRUPTION: "interruption";
|
|
21
|
+
};
|
|
22
|
+
export type SpeechEventKind = (typeof SpeechEventKind)[keyof typeof SpeechEventKind];
|
|
23
|
+
export interface SpeechEventOptions {
|
|
24
|
+
/** What happened, to whom, and at which layer. */
|
|
25
|
+
kind: SpeechEventKind;
|
|
26
|
+
/**
|
|
27
|
+
* Unix timestamp of the moment itself. Speech is timed to when it began and
|
|
28
|
+
* ended, not to when the detector confirmed it, so an interval drawn from
|
|
29
|
+
* these matches what was said.
|
|
30
|
+
*/
|
|
31
|
+
timestamp: number;
|
|
32
|
+
/**
|
|
33
|
+
* When the matching stretch of speech began, on the moments that end one,
|
|
34
|
+
* so a stretch reads as an interval without pairing it with the moment that
|
|
35
|
+
* opened it.
|
|
36
|
+
*/
|
|
37
|
+
startedAt?: number | null;
|
|
38
|
+
}
|
|
39
|
+
/** One moment in the conversation's speaking lifecycle. */
|
|
40
|
+
export declare class SpeechEvent {
|
|
41
|
+
kind: SpeechEventKind;
|
|
42
|
+
timestamp: number;
|
|
43
|
+
startedAt: number | null;
|
|
44
|
+
constructor(options: SpeechEventOptions);
|
|
45
|
+
}
|
|
46
|
+
export interface SpeakingObserverOptions extends Omit<BaseObserverOptions, "observeEveryPush"> {
|
|
47
|
+
/**
|
|
48
|
+
* Reads the current time in seconds. Supplying one lets a test place
|
|
49
|
+
* moments without waiting. Defaults to `time()`.
|
|
50
|
+
*/
|
|
51
|
+
timeSource?: () => number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Reports the speaking lifecycle of a conversation.
|
|
55
|
+
*
|
|
56
|
+
* Every moment is reported as it happens, and the moments that close a
|
|
57
|
+
* stretch of speech name where it began, so an interval reads whole from one
|
|
58
|
+
* record: a stretch whose closing moment never arrives stays open rather than
|
|
59
|
+
* quietly joining itself to the next one. What a turn is stays with the
|
|
60
|
+
* reader: a turn built here would freeze one definition into every record,
|
|
61
|
+
* where the moments themselves can be grouped again later, differently, over
|
|
62
|
+
* the same history.
|
|
63
|
+
*
|
|
64
|
+
* Events:
|
|
65
|
+
*
|
|
66
|
+
* - on_speech_event(observer, event): Emitted for each moment, as a
|
|
67
|
+
* `SpeechEvent`.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const observer = new SpeakingObserver();
|
|
71
|
+
*
|
|
72
|
+
* observer.eventHandler("on_speech_event", async (observer, event: SpeechEvent) => {
|
|
73
|
+
* logger.info(JSON.stringify(event));
|
|
74
|
+
* });
|
|
75
|
+
*/
|
|
76
|
+
export declare class SpeakingObserver extends BaseObserver {
|
|
77
|
+
protected _now: () => number;
|
|
78
|
+
protected _open: Map<SpeechEventKind, number>;
|
|
79
|
+
constructor(options?: SpeakingObserverOptions);
|
|
80
|
+
/**
|
|
81
|
+
* Report the moment a frame represents.
|
|
82
|
+
*
|
|
83
|
+
* @param data Frame push event containing the frame and direction.
|
|
84
|
+
*/
|
|
85
|
+
onPushFrame(data: FramePushed): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Build the moment a frame represents.
|
|
88
|
+
*
|
|
89
|
+
* @param frame The frame being pushed.
|
|
90
|
+
* @returns The moment, or null if this frame is not part of the speaking
|
|
91
|
+
* lifecycle.
|
|
92
|
+
*/
|
|
93
|
+
protected _asEvent(frame: Frame): SpeechEvent | null;
|
|
94
|
+
/** Record the start of a stretch of speech. */
|
|
95
|
+
protected _opens(kind: SpeechEventKind, at: number): SpeechEvent;
|
|
96
|
+
/**
|
|
97
|
+
* Record the end of a stretch, naming its start where one is known.
|
|
98
|
+
*
|
|
99
|
+
* A stretch that began before the observer was watching closes without a
|
|
100
|
+
* start rather than borrowing one from another stretch.
|
|
101
|
+
*/
|
|
102
|
+
protected _closes(kind: SpeechEventKind, openedBy: SpeechEventKind, at: number): SpeechEvent;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=speaking_observer.d.ts.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026, Daily
|
|
2
|
+
// Copyright (c) 2026, pipedog contributors
|
|
3
|
+
// SPDX-License-Identifier: BSD-2-Clause
|
|
4
|
+
//
|
|
5
|
+
// Ported from pipecat: src/pipecat/observers/speaking_observer.py
|
|
6
|
+
/**
|
|
7
|
+
* Observer reporting who was speaking, and when.
|
|
8
|
+
*
|
|
9
|
+
* A conversation is a sequence of people taking the floor and occasionally
|
|
10
|
+
* taking it from each other. This observer reports each of those moments as
|
|
11
|
+
* it happens, leaving what counts as a turn to whoever reads them: a turn
|
|
12
|
+
* boundary is a policy, and a policy that ships inside a record can never be
|
|
13
|
+
* revised.
|
|
14
|
+
*/
|
|
15
|
+
import { time } from "@pipedog/asyncio";
|
|
16
|
+
import { BotStartedSpeakingFrame, BotStoppedSpeakingFrame, InterruptionFrame, UserStartedSpeakingFrame, UserStoppedSpeakingFrame, VADUserStartedSpeakingFrame, VADUserStoppedSpeakingFrame, } from "../frames/frames.js";
|
|
17
|
+
import { FrameDirection } from "../processors/frame_processor.js";
|
|
18
|
+
import { BaseObserver } from "./base_observer.js";
|
|
19
|
+
/**
|
|
20
|
+
* What happened, to whom, and at which layer.
|
|
21
|
+
*
|
|
22
|
+
* The user appears at two layers, and they answer different questions.
|
|
23
|
+
* `user_speech_*` is the speech itself, as the voice activity detector heard
|
|
24
|
+
* it: speech that never becomes a turn — a cough, a false start, a pause
|
|
25
|
+
* mid-sentence — appears only here. `user_turn_*` is the turn strategy's
|
|
26
|
+
* ruling on that speech, which is what the rest of the pipeline acts on, and
|
|
27
|
+
* follows the speech by however long the ruling took.
|
|
28
|
+
*/
|
|
29
|
+
export const SpeechEventKind = {
|
|
30
|
+
USER_SPEECH_STARTED: "user_speech_started",
|
|
31
|
+
USER_SPEECH_STOPPED: "user_speech_stopped",
|
|
32
|
+
USER_TURN_STARTED: "user_turn_started",
|
|
33
|
+
USER_TURN_STOPPED: "user_turn_stopped",
|
|
34
|
+
BOT_SPEECH_STARTED: "bot_speech_started",
|
|
35
|
+
BOT_SPEECH_STOPPED: "bot_speech_stopped",
|
|
36
|
+
INTERRUPTION: "interruption",
|
|
37
|
+
};
|
|
38
|
+
/** One moment in the conversation's speaking lifecycle. */
|
|
39
|
+
export class SpeechEvent {
|
|
40
|
+
kind;
|
|
41
|
+
timestamp;
|
|
42
|
+
startedAt;
|
|
43
|
+
constructor(options) {
|
|
44
|
+
this.kind = options.kind;
|
|
45
|
+
this.timestamp = options.timestamp;
|
|
46
|
+
this.startedAt = options.startedAt ?? null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reports the speaking lifecycle of a conversation.
|
|
51
|
+
*
|
|
52
|
+
* Every moment is reported as it happens, and the moments that close a
|
|
53
|
+
* stretch of speech name where it began, so an interval reads whole from one
|
|
54
|
+
* record: a stretch whose closing moment never arrives stays open rather than
|
|
55
|
+
* quietly joining itself to the next one. What a turn is stays with the
|
|
56
|
+
* reader: a turn built here would freeze one definition into every record,
|
|
57
|
+
* where the moments themselves can be grouped again later, differently, over
|
|
58
|
+
* the same history.
|
|
59
|
+
*
|
|
60
|
+
* Events:
|
|
61
|
+
*
|
|
62
|
+
* - on_speech_event(observer, event): Emitted for each moment, as a
|
|
63
|
+
* `SpeechEvent`.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const observer = new SpeakingObserver();
|
|
67
|
+
*
|
|
68
|
+
* observer.eventHandler("on_speech_event", async (observer, event: SpeechEvent) => {
|
|
69
|
+
* logger.info(JSON.stringify(event));
|
|
70
|
+
* });
|
|
71
|
+
*/
|
|
72
|
+
export class SpeakingObserver extends BaseObserver {
|
|
73
|
+
_now;
|
|
74
|
+
// When each open stretch of speech began, so the moment that closes one can
|
|
75
|
+
// carry it.
|
|
76
|
+
_open = new Map();
|
|
77
|
+
constructor(options = {}) {
|
|
78
|
+
super({ ...options, observeEveryPush: false });
|
|
79
|
+
this._now = options.timeSource ?? time;
|
|
80
|
+
this._registerEventHandler("on_speech_event");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Report the moment a frame represents.
|
|
84
|
+
*
|
|
85
|
+
* @param data Frame push event containing the frame and direction.
|
|
86
|
+
*/
|
|
87
|
+
async onPushFrame(data) {
|
|
88
|
+
const frame = data.frame;
|
|
89
|
+
// An interruption is broadcast, arriving as two frames, each pushed for
|
|
90
|
+
// the first time once. Read the downstream one.
|
|
91
|
+
if (frame.broadcastSiblingId !== null && data.direction !== FrameDirection.DOWNSTREAM) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const event = this._asEvent(frame);
|
|
95
|
+
if (!event) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
await this._callEventHandler("on_speech_event", event);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Build the moment a frame represents.
|
|
102
|
+
*
|
|
103
|
+
* @param frame The frame being pushed.
|
|
104
|
+
* @returns The moment, or null if this frame is not part of the speaking
|
|
105
|
+
* lifecycle.
|
|
106
|
+
*/
|
|
107
|
+
_asEvent(frame) {
|
|
108
|
+
if (frame instanceof VADUserStartedSpeakingFrame) {
|
|
109
|
+
// The detector's account of when speech began, which precedes its
|
|
110
|
+
// confirmation by the time it needed to be sure.
|
|
111
|
+
return this._opens(SpeechEventKind.USER_SPEECH_STARTED, frame.timestamp - frame.startSecs);
|
|
112
|
+
}
|
|
113
|
+
else if (frame instanceof VADUserStoppedSpeakingFrame) {
|
|
114
|
+
return this._closes(SpeechEventKind.USER_SPEECH_STOPPED, SpeechEventKind.USER_SPEECH_STARTED, frame.timestamp - frame.stopSecs);
|
|
115
|
+
}
|
|
116
|
+
else if (frame instanceof UserStartedSpeakingFrame) {
|
|
117
|
+
return this._opens(SpeechEventKind.USER_TURN_STARTED, this._now());
|
|
118
|
+
}
|
|
119
|
+
else if (frame instanceof UserStoppedSpeakingFrame) {
|
|
120
|
+
return this._closes(SpeechEventKind.USER_TURN_STOPPED, SpeechEventKind.USER_TURN_STARTED, this._now());
|
|
121
|
+
}
|
|
122
|
+
else if (frame instanceof BotStartedSpeakingFrame) {
|
|
123
|
+
return this._opens(SpeechEventKind.BOT_SPEECH_STARTED, this._now());
|
|
124
|
+
}
|
|
125
|
+
else if (frame instanceof BotStoppedSpeakingFrame) {
|
|
126
|
+
return this._closes(SpeechEventKind.BOT_SPEECH_STOPPED, SpeechEventKind.BOT_SPEECH_STARTED, this._now());
|
|
127
|
+
}
|
|
128
|
+
else if (frame instanceof InterruptionFrame) {
|
|
129
|
+
return new SpeechEvent({ kind: SpeechEventKind.INTERRUPTION, timestamp: this._now() });
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
/** Record the start of a stretch of speech. */
|
|
134
|
+
_opens(kind, at) {
|
|
135
|
+
this._open.set(kind, at);
|
|
136
|
+
return new SpeechEvent({ kind, timestamp: at });
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Record the end of a stretch, naming its start where one is known.
|
|
140
|
+
*
|
|
141
|
+
* A stretch that began before the observer was watching closes without a
|
|
142
|
+
* start rather than borrowing one from another stretch.
|
|
143
|
+
*/
|
|
144
|
+
_closes(kind, openedBy, at) {
|
|
145
|
+
const startedAt = this._open.get(openedBy) ?? null;
|
|
146
|
+
this._open.delete(openedBy);
|
|
147
|
+
return new SpeechEvent({ kind, timestamp: at, startedAt });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=speaking_observer.js.map
|