@pipedog/core 0.0.0 → 0.2.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/engine.d.ts +60 -0
- package/dist/audio/resamplers/engine.js +89 -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/sinc_engine.d.ts +10 -0
- package/dist/audio/resamplers/sinc_engine.js +235 -0
- package/dist/audio/resamplers/soxr_resampler.d.ts +58 -0
- package/dist/audio/resamplers/soxr_resampler.js +79 -0
- package/dist/audio/resamplers/soxr_stream_resampler.d.ts +78 -0
- package/dist/audio/resamplers/soxr_stream_resampler.js +159 -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 +151 -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 +134 -0
- package/dist/audio/vad/vad_analyzer.js +249 -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 +821 -0
- package/dist/pipeline/worker.js +1656 -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 +115 -0
- package/dist/utils/file_storage.js +178 -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 +14 -0
- package/dist/utils/image.js +63 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/jpeg_encoder.d.ts +14 -0
- package/dist/utils/jpeg_encoder.js +315 -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/acronyms.d.ts +21 -0
- package/dist/utils/text/transforms/acronyms.js +31 -0
- package/dist/utils/text/transforms/currency.d.ts +16 -0
- package/dist/utils/text/transforms/currency.js +56 -0
- package/dist/utils/text/transforms/dates.d.ts +18 -0
- package/dist/utils/text/transforms/dates.js +102 -0
- package/dist/utils/text/transforms/email.d.ts +17 -0
- package/dist/utils/text/transforms/email.js +35 -0
- package/dist/utils/text/transforms/index.d.ts +37 -0
- package/dist/utils/text/transforms/index.js +42 -0
- package/dist/utils/text/transforms/numbers.d.ts +25 -0
- package/dist/utils/text/transforms/numbers.js +59 -0
- package/dist/utils/text/transforms/percentages.d.ts +16 -0
- package/dist/utils/text/transforms/percentages.js +32 -0
- package/dist/utils/text/transforms/phone.d.ts +21 -0
- package/dist/utils/text/transforms/phone.js +39 -0
- package/dist/utils/text/transforms/pronunciations.d.ts +65 -0
- package/dist/utils/text/transforms/pronunciations.js +112 -0
- package/dist/utils/text/transforms/replacements.d.ts +39 -0
- package/dist/utils/text/transforms/replacements.js +46 -0
- package/dist/utils/text/transforms/strip_markdown.d.ts +25 -0
- package/dist/utils/text/transforms/strip_markdown.js +60 -0
- package/dist/utils/text/transforms/units.d.ts +22 -0
- package/dist/utils/text/transforms/units.js +81 -0
- package/dist/utils/text/transforms/voice_formatter.d.ts +86 -0
- package/dist/utils/text/transforms/voice_formatter.js +98 -0
- package/dist/utils/text/unicode_digits.d.ts +3 -0
- package/dist/utils/text/unicode_digits.js +34 -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 +107 -0
- package/dist/utils/tracing/setup.js +160 -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 +95 -0
- package/dist/utils/tracing/turn_trace_observer.js +233 -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 +179 -0
- package/dist/utils/yaml.js +556 -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/proxy/index.d.ts +3 -0
- package/dist/workers/proxy/index.js +9 -0
- package/dist/workers/proxy/websocket/client.d.ts +110 -0
- package/dist/workers/proxy/websocket/client.js +196 -0
- package/dist/workers/proxy/websocket/index.d.ts +3 -0
- package/dist/workers/proxy/websocket/index.js +10 -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 +61 -3
- package/README.md +0 -5
|
@@ -0,0 +1,110 @@
|
|
|
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/loggers/llm_log_observer.py
|
|
6
|
+
/** LLM logging observer for Pipecat. */
|
|
7
|
+
import { FunctionCallInProgressFrame, FunctionCallResultFrame, LLMContextFrame, LLMFullResponseEndFrame, LLMFullResponseStartFrame, LLMTextFrame, } from "../../frames/frames.js";
|
|
8
|
+
import { FrameDirection } from "../../processors/frame_processor.js";
|
|
9
|
+
import { LLMService } from "../../services/llm_service.js";
|
|
10
|
+
import { logger } from "../../utils/logger.js";
|
|
11
|
+
import { BaseObserver } from "../base_observer.js";
|
|
12
|
+
/** Python's `repr()` of a string: single-quoted unless it holds only single quotes. */
|
|
13
|
+
function reprStr(s) {
|
|
14
|
+
const quote = s.includes("'") && !s.includes('"') ? '"' : "'";
|
|
15
|
+
let out = "";
|
|
16
|
+
for (const ch of s) {
|
|
17
|
+
if (ch === "\\")
|
|
18
|
+
out += "\\\\";
|
|
19
|
+
else if (ch === quote)
|
|
20
|
+
out += `\\${ch}`;
|
|
21
|
+
else if (ch === "\n")
|
|
22
|
+
out += "\\n";
|
|
23
|
+
else if (ch === "\r")
|
|
24
|
+
out += "\\r";
|
|
25
|
+
else if (ch === "\t")
|
|
26
|
+
out += "\\t";
|
|
27
|
+
else if (ch < " " || ch === "\x7f")
|
|
28
|
+
out += `\\x${ch.charCodeAt(0).toString(16).padStart(2, "0")}`;
|
|
29
|
+
else
|
|
30
|
+
out += ch;
|
|
31
|
+
}
|
|
32
|
+
return `${quote}${out}${quote}`;
|
|
33
|
+
}
|
|
34
|
+
/** Approximation of Python's `repr()` for log lines. */
|
|
35
|
+
function repr(value) {
|
|
36
|
+
if (typeof value === "string")
|
|
37
|
+
return reprStr(value);
|
|
38
|
+
return String(value);
|
|
39
|
+
}
|
|
40
|
+
/** Approximation of Python's `str()` on containers for log lines. */
|
|
41
|
+
function str(value) {
|
|
42
|
+
if (value === null || value === undefined)
|
|
43
|
+
return "None";
|
|
44
|
+
if (typeof value === "object") {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.stringify(value);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return String(value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return String(value);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Observer to log LLM activity to the console.
|
|
56
|
+
*
|
|
57
|
+
* Logs all frame instances (only from/to LLM service) of:
|
|
58
|
+
*
|
|
59
|
+
* - LLMFullResponseStartFrame
|
|
60
|
+
* - LLMFullResponseEndFrame
|
|
61
|
+
* - LLMTextFrame
|
|
62
|
+
* - FunctionCallInProgressFrame
|
|
63
|
+
*
|
|
64
|
+
* This allows you to track when the LLM starts responding, what it generates,
|
|
65
|
+
* and when it finishes.
|
|
66
|
+
*/
|
|
67
|
+
export class LLMLogObserver extends BaseObserver {
|
|
68
|
+
/**
|
|
69
|
+
* Handle frame push events and log LLM-related activities.
|
|
70
|
+
*
|
|
71
|
+
* @param data The frame push event data containing source, destination,
|
|
72
|
+
* frame, direction, and timestamp information.
|
|
73
|
+
*/
|
|
74
|
+
async onPushFrame(data) {
|
|
75
|
+
const src = data.source;
|
|
76
|
+
const dst = data.destination;
|
|
77
|
+
const frame = data.frame;
|
|
78
|
+
const direction = data.direction;
|
|
79
|
+
const timestamp = data.timestamp;
|
|
80
|
+
if (!(src instanceof LLMService) && !(dst instanceof LLMService)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const timeSec = (timestamp / 1_000_000_000).toFixed(2);
|
|
84
|
+
const arrow = "→";
|
|
85
|
+
// Log LLM start/end frames (output)
|
|
86
|
+
if (frame instanceof LLMFullResponseStartFrame || frame instanceof LLMFullResponseEndFrame) {
|
|
87
|
+
const event = frame instanceof LLMFullResponseStartFrame ? "START" : "END";
|
|
88
|
+
logger.debug(`🧠 ${src} ${arrow} LLM ${event} RESPONSE at ${timeSec}s`);
|
|
89
|
+
}
|
|
90
|
+
// Log all LLMTextFrames (output)
|
|
91
|
+
else if (frame instanceof LLMTextFrame) {
|
|
92
|
+
logger.debug(`🧠 ${src} ${arrow} LLM GENERATING: ${repr(frame.text)} at ${timeSec}s`);
|
|
93
|
+
}
|
|
94
|
+
// Log function calling (output)
|
|
95
|
+
else if (frame instanceof FunctionCallInProgressFrame &&
|
|
96
|
+
direction !== FrameDirection.DOWNSTREAM) {
|
|
97
|
+
logger.debug(`🧠 ${src} ${arrow} LLM FUNCTION CALL (${frame.toolCallId}): ${repr(frame.functionName)}(${str(frame.arguments)}) at ${timeSec}s`);
|
|
98
|
+
}
|
|
99
|
+
// Log LLMContextFrame (input)
|
|
100
|
+
else if (frame instanceof LLMContextFrame) {
|
|
101
|
+
const messages = frame.context.getMessages();
|
|
102
|
+
logger.debug(`🧠 ${arrow} ${dst} LLM CONTEXT FRAME: ${str(messages)} at ${timeSec}s`);
|
|
103
|
+
}
|
|
104
|
+
// Log function call result (input)
|
|
105
|
+
else if (frame instanceof FunctionCallResultFrame) {
|
|
106
|
+
logger.debug(`🧠 ${arrow} ${src} LLM FUNCTION CALL RESULT (${frame.toolCallId}): ${str(frame.result)} at ${timeSec}s`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=llm_log_observer.js.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { LLMUsageMetricsData, type MetricsData, TurnMetricsData } from "../../metrics/metrics.ts";
|
|
2
|
+
import { BaseObserver, type BaseObserverOptions, type FramePushed } from "../base_observer.ts";
|
|
3
|
+
export type MetricsDataClass = abstract new (...args: any[]) => MetricsData;
|
|
4
|
+
export interface MetricsLogObserverOptions extends Omit<BaseObserverOptions, "observeEveryPush"> {
|
|
5
|
+
/**
|
|
6
|
+
* Set of metrics types to include. If specified, only these metrics types
|
|
7
|
+
* will be logged. If null, all metrics are logged.
|
|
8
|
+
*/
|
|
9
|
+
includeMetrics?: ReadonlySet<MetricsDataClass> | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Observer to log metrics activity to the console.
|
|
13
|
+
*
|
|
14
|
+
* Monitors and logs all MetricsFrame instances, including:
|
|
15
|
+
*
|
|
16
|
+
* - TTFBMetricsData (Time To First Byte)
|
|
17
|
+
* - TTFAMetricsData (Time To First Audio)
|
|
18
|
+
* - TTFATMetricsData (Time To First Answer Token)
|
|
19
|
+
* - ProcessingMetricsData (General processing time)
|
|
20
|
+
* - LLMUsageMetricsData (Token usage statistics)
|
|
21
|
+
* - STTUsageMetricsData (Speech-to-Text audio seconds)
|
|
22
|
+
* - TTSUsageMetricsData (Text-to-Speech character counts)
|
|
23
|
+
* - TurnMetricsData (Turn prediction metrics)
|
|
24
|
+
*
|
|
25
|
+
* This allows developers to track performance metrics, token usage, and other
|
|
26
|
+
* statistics throughout the pipeline.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Log all metrics types
|
|
30
|
+
* const observers = [new MetricsLogObserver()];
|
|
31
|
+
*
|
|
32
|
+
* // Log only LLM and TTS metrics
|
|
33
|
+
* const observers = [
|
|
34
|
+
* new MetricsLogObserver({
|
|
35
|
+
* includeMetrics: new Set([LLMUsageMetricsData, TTSUsageMetricsData]),
|
|
36
|
+
* }),
|
|
37
|
+
* ];
|
|
38
|
+
*/
|
|
39
|
+
export declare class MetricsLogObserver extends BaseObserver {
|
|
40
|
+
protected _includeMetrics: ReadonlySet<MetricsDataClass> | null;
|
|
41
|
+
/** Initialize the metrics log observer. */
|
|
42
|
+
constructor(options?: MetricsLogObserverOptions);
|
|
43
|
+
/**
|
|
44
|
+
* Handle frame push events and log metrics frames.
|
|
45
|
+
*
|
|
46
|
+
* Logs MetricsFrame instances with detailed information about the metrics
|
|
47
|
+
* data, formatted appropriately for each metrics type.
|
|
48
|
+
*
|
|
49
|
+
* @param data Frame push event data containing source, frame, and timestamp.
|
|
50
|
+
*/
|
|
51
|
+
onPushFrame(data: FramePushed): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Determine if a metrics data item should be logged based on filters.
|
|
54
|
+
*
|
|
55
|
+
* @param metricsData The metrics data to check.
|
|
56
|
+
* @returns True if the metrics should be logged, false otherwise.
|
|
57
|
+
*/
|
|
58
|
+
protected _shouldLogMetrics(metricsData: MetricsData): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Log a single metrics data item.
|
|
61
|
+
*
|
|
62
|
+
* @param metricsData The metrics data to log.
|
|
63
|
+
* @param timeSec Timestamp in seconds.
|
|
64
|
+
*/
|
|
65
|
+
protected _logMetricsData(metricsData: MetricsData, timeSec: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Log LLM token usage metrics.
|
|
68
|
+
*
|
|
69
|
+
* @param metricsData The LLM usage metrics data.
|
|
70
|
+
* @param processorInfo Formatted processor name string.
|
|
71
|
+
* @param modelInfo Formatted model name string.
|
|
72
|
+
* @param timeSec Timestamp in seconds.
|
|
73
|
+
*/
|
|
74
|
+
protected _logLlmUsage(metricsData: LLMUsageMetricsData, processorInfo: string, modelInfo: string, timeSec: number): void;
|
|
75
|
+
/**
|
|
76
|
+
* Log turn prediction metrics.
|
|
77
|
+
*
|
|
78
|
+
* @param metricsData The turn metrics data.
|
|
79
|
+
* @param processorInfo Formatted processor name string.
|
|
80
|
+
* @param modelInfo Formatted model name string.
|
|
81
|
+
* @param timeSec Timestamp in seconds.
|
|
82
|
+
*/
|
|
83
|
+
protected _logTurn(metricsData: TurnMetricsData, processorInfo: string, modelInfo: string, timeSec: number): void;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=metrics_log_observer.d.ts.map
|
|
@@ -0,0 +1,186 @@
|
|
|
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/loggers/metrics_log_observer.py
|
|
6
|
+
/**
|
|
7
|
+
* Metrics logging observer for Pipecat.
|
|
8
|
+
*
|
|
9
|
+
* This module provides an observer that logs metrics frames to the console,
|
|
10
|
+
* allowing developers to monitor performance metrics, token usage, and other
|
|
11
|
+
* statistics in real-time.
|
|
12
|
+
*/
|
|
13
|
+
import { MetricsFrame } from "../../frames/frames.js";
|
|
14
|
+
import { LLMUsageMetricsData, ProcessingMetricsData, STTUsageMetricsData, TTFAMetricsData, TTFATMetricsData, TTFBMetricsData, TTSUsageMetricsData, TurnMetricsData, } from "../../metrics/metrics.js";
|
|
15
|
+
import { logger } from "../../utils/logger.js";
|
|
16
|
+
import { BaseObserver } from "../base_observer.js";
|
|
17
|
+
/**
|
|
18
|
+
* Observer to log metrics activity to the console.
|
|
19
|
+
*
|
|
20
|
+
* Monitors and logs all MetricsFrame instances, including:
|
|
21
|
+
*
|
|
22
|
+
* - TTFBMetricsData (Time To First Byte)
|
|
23
|
+
* - TTFAMetricsData (Time To First Audio)
|
|
24
|
+
* - TTFATMetricsData (Time To First Answer Token)
|
|
25
|
+
* - ProcessingMetricsData (General processing time)
|
|
26
|
+
* - LLMUsageMetricsData (Token usage statistics)
|
|
27
|
+
* - STTUsageMetricsData (Speech-to-Text audio seconds)
|
|
28
|
+
* - TTSUsageMetricsData (Text-to-Speech character counts)
|
|
29
|
+
* - TurnMetricsData (Turn prediction metrics)
|
|
30
|
+
*
|
|
31
|
+
* This allows developers to track performance metrics, token usage, and other
|
|
32
|
+
* statistics throughout the pipeline.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Log all metrics types
|
|
36
|
+
* const observers = [new MetricsLogObserver()];
|
|
37
|
+
*
|
|
38
|
+
* // Log only LLM and TTS metrics
|
|
39
|
+
* const observers = [
|
|
40
|
+
* new MetricsLogObserver({
|
|
41
|
+
* includeMetrics: new Set([LLMUsageMetricsData, TTSUsageMetricsData]),
|
|
42
|
+
* }),
|
|
43
|
+
* ];
|
|
44
|
+
*/
|
|
45
|
+
export class MetricsLogObserver extends BaseObserver {
|
|
46
|
+
_includeMetrics;
|
|
47
|
+
/** Initialize the metrics log observer. */
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
super({ ...options, observeEveryPush: false });
|
|
50
|
+
this._includeMetrics = options.includeMetrics ?? null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Handle frame push events and log metrics frames.
|
|
54
|
+
*
|
|
55
|
+
* Logs MetricsFrame instances with detailed information about the metrics
|
|
56
|
+
* data, formatted appropriately for each metrics type.
|
|
57
|
+
*
|
|
58
|
+
* @param data Frame push event data containing source, frame, and timestamp.
|
|
59
|
+
*/
|
|
60
|
+
async onPushFrame(data) {
|
|
61
|
+
const frame = data.frame;
|
|
62
|
+
const timestamp = data.timestamp;
|
|
63
|
+
if (!(frame instanceof MetricsFrame)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const timeSec = timestamp / 1_000_000_000;
|
|
67
|
+
// Process each metrics data item in the frame
|
|
68
|
+
for (const metricsData of frame.data) {
|
|
69
|
+
// Check if this metrics type should be logged
|
|
70
|
+
if (!this._shouldLogMetrics(metricsData)) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
this._logMetricsData(metricsData, timeSec);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Determine if a metrics data item should be logged based on filters.
|
|
78
|
+
*
|
|
79
|
+
* @param metricsData The metrics data to check.
|
|
80
|
+
* @returns True if the metrics should be logged, false otherwise.
|
|
81
|
+
*/
|
|
82
|
+
_shouldLogMetrics(metricsData) {
|
|
83
|
+
// If includeMetrics is specified, only log those types
|
|
84
|
+
if (this._includeMetrics !== null) {
|
|
85
|
+
return this._includeMetrics.has(metricsData.constructor);
|
|
86
|
+
}
|
|
87
|
+
// Otherwise, log all metrics
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Log a single metrics data item.
|
|
92
|
+
*
|
|
93
|
+
* @param metricsData The metrics data to log.
|
|
94
|
+
* @param timeSec Timestamp in seconds.
|
|
95
|
+
*/
|
|
96
|
+
_logMetricsData(metricsData, timeSec) {
|
|
97
|
+
const processorInfo = `[${metricsData.processor}]`;
|
|
98
|
+
const modelInfo = metricsData.model ? ` (${metricsData.model})` : "";
|
|
99
|
+
const t = timeSec.toFixed(3);
|
|
100
|
+
if (metricsData instanceof TTFBMetricsData) {
|
|
101
|
+
logger.debug(`📊 ${processorInfo} TTFB${modelInfo}: ${metricsData.value}s at ${t}s`);
|
|
102
|
+
}
|
|
103
|
+
else if (metricsData instanceof TTFAMetricsData) {
|
|
104
|
+
logger.debug(`📊 ${processorInfo} TTFA${modelInfo}: ${metricsData.ttfa}s ` +
|
|
105
|
+
`(${metricsData.leadingSilence}s leading silence) at ${t}s`);
|
|
106
|
+
}
|
|
107
|
+
else if (metricsData instanceof TTFATMetricsData) {
|
|
108
|
+
logger.debug(`📊 ${processorInfo} TTFAT${modelInfo}: ${metricsData.ttfat}s ` +
|
|
109
|
+
`(${metricsData.thinkingTime}s thinking) at ${t}s`);
|
|
110
|
+
}
|
|
111
|
+
else if (metricsData instanceof ProcessingMetricsData) {
|
|
112
|
+
logger.debug(`📊 ${processorInfo} PROCESSING TIME${modelInfo}: ${metricsData.value}s at ${t}s`);
|
|
113
|
+
}
|
|
114
|
+
else if (metricsData instanceof LLMUsageMetricsData) {
|
|
115
|
+
this._logLlmUsage(metricsData, processorInfo, modelInfo, timeSec);
|
|
116
|
+
}
|
|
117
|
+
else if (metricsData instanceof STTUsageMetricsData) {
|
|
118
|
+
logger.debug(`📊 ${processorInfo} STT USAGE${modelInfo}: ` +
|
|
119
|
+
`${metricsData.value.audioSeconds.toFixed(3)}s audio at ${t}s`);
|
|
120
|
+
}
|
|
121
|
+
else if (metricsData instanceof TTSUsageMetricsData) {
|
|
122
|
+
logger.debug(`📊 ${processorInfo} TTS USAGE${modelInfo}: ${metricsData.value} characters at ${t}s`);
|
|
123
|
+
}
|
|
124
|
+
else if (metricsData instanceof TurnMetricsData) {
|
|
125
|
+
this._logTurn(metricsData, processorInfo, modelInfo, timeSec);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Generic fallback for unknown metrics types
|
|
129
|
+
logger.debug(`📊 ${processorInfo} METRICS${modelInfo}: ${metricsData} at ${t}s`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Log LLM token usage metrics.
|
|
134
|
+
*
|
|
135
|
+
* @param metricsData The LLM usage metrics data.
|
|
136
|
+
* @param processorInfo Formatted processor name string.
|
|
137
|
+
* @param modelInfo Formatted model name string.
|
|
138
|
+
* @param timeSec Timestamp in seconds.
|
|
139
|
+
*/
|
|
140
|
+
_logLlmUsage(metricsData, processorInfo, modelInfo, timeSec) {
|
|
141
|
+
const usage = metricsData.value;
|
|
142
|
+
// Build usage details
|
|
143
|
+
const details = [
|
|
144
|
+
`prompt: ${usage.promptTokens}`,
|
|
145
|
+
`completion: ${usage.completionTokens}`,
|
|
146
|
+
`total: ${usage.totalTokens}`,
|
|
147
|
+
];
|
|
148
|
+
if (usage.cacheReadInputTokens !== null && usage.cacheReadInputTokens !== undefined) {
|
|
149
|
+
details.push(`cache_read: ${usage.cacheReadInputTokens}`);
|
|
150
|
+
}
|
|
151
|
+
if (usage.cacheCreationInputTokens !== null && usage.cacheCreationInputTokens !== undefined) {
|
|
152
|
+
details.push(`cache_creation: ${usage.cacheCreationInputTokens}`);
|
|
153
|
+
}
|
|
154
|
+
if (usage.reasoningTokens !== null && usage.reasoningTokens !== undefined) {
|
|
155
|
+
details.push(`reasoning: ${usage.reasoningTokens}`);
|
|
156
|
+
}
|
|
157
|
+
if (usage.inputAudioTokens !== null && usage.inputAudioTokens !== undefined) {
|
|
158
|
+
details.push(`input_audio: ${usage.inputAudioTokens}`);
|
|
159
|
+
}
|
|
160
|
+
if (usage.outputAudioTokens !== null && usage.outputAudioTokens !== undefined) {
|
|
161
|
+
details.push(`output_audio: ${usage.outputAudioTokens}`);
|
|
162
|
+
}
|
|
163
|
+
if (usage.cacheReadInputAudioTokens !== null && usage.cacheReadInputAudioTokens !== undefined) {
|
|
164
|
+
details.push(`cache_read_audio: ${usage.cacheReadInputAudioTokens}`);
|
|
165
|
+
}
|
|
166
|
+
const usageStr = details.join(", ");
|
|
167
|
+
logger.debug(`📊 ${processorInfo} LLM TOKEN USAGE${modelInfo}: ${usageStr} at ${timeSec.toFixed(2)}s`);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Log turn prediction metrics.
|
|
171
|
+
*
|
|
172
|
+
* @param metricsData The turn metrics data.
|
|
173
|
+
* @param processorInfo Formatted processor name string.
|
|
174
|
+
* @param modelInfo Formatted model name string.
|
|
175
|
+
* @param timeSec Timestamp in seconds.
|
|
176
|
+
*/
|
|
177
|
+
_logTurn(metricsData, processorInfo, modelInfo, timeSec) {
|
|
178
|
+
const completeStr = metricsData.isComplete ? "COMPLETE" : "INCOMPLETE";
|
|
179
|
+
const e2eStr = `${metricsData.e2eProcessingTimeMs.toFixed(1)}ms`;
|
|
180
|
+
logger.debug(`📊 ${processorInfo} TURN${modelInfo}: ${completeStr} ` +
|
|
181
|
+
`(probability: ${(metricsData.probability * 100).toFixed(2)}%, ` +
|
|
182
|
+
`e2e: ${e2eStr}) ` +
|
|
183
|
+
`at ${timeSec.toFixed(2)}s`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=metrics_log_observer.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseObserver, type FramePushed } from "../base_observer.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Observer to log transcription activity to the console.
|
|
4
|
+
*
|
|
5
|
+
* Monitors and logs all transcription frames from STT services, including both
|
|
6
|
+
* final transcriptions and interim results. This allows developers to track
|
|
7
|
+
* speech recognition activity and debug transcription issues.
|
|
8
|
+
*
|
|
9
|
+
* Only processes frames from STTService instances to avoid logging unrelated
|
|
10
|
+
* transcription frames from other sources.
|
|
11
|
+
*/
|
|
12
|
+
export declare class TranscriptionLogObserver extends BaseObserver {
|
|
13
|
+
/**
|
|
14
|
+
* Handle frame push events and log transcription frames.
|
|
15
|
+
*
|
|
16
|
+
* Logs TranscriptionFrame and InterimTranscriptionFrame instances with
|
|
17
|
+
* timestamps and user information for debugging purposes.
|
|
18
|
+
*
|
|
19
|
+
* @param data Frame push event data containing source, frame, and timestamp.
|
|
20
|
+
*/
|
|
21
|
+
onPushFrame(data: FramePushed): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=transcription_log_observer.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
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/loggers/transcription_log_observer.py
|
|
6
|
+
/**
|
|
7
|
+
* Transcription logging observer for Pipecat.
|
|
8
|
+
*
|
|
9
|
+
* This module provides an observer that logs transcription frames to the
|
|
10
|
+
* console, allowing developers to monitor speech-to-text activity in real-time.
|
|
11
|
+
*/
|
|
12
|
+
import { InterimTranscriptionFrame, TranscriptionFrame } from "../../frames/frames.js";
|
|
13
|
+
import { STTService } from "../../services/stt_service.js";
|
|
14
|
+
import { logger } from "../../utils/logger.js";
|
|
15
|
+
import { BaseObserver } from "../base_observer.js";
|
|
16
|
+
/** Python's `repr()` of a string: single-quoted unless it holds only single quotes. */
|
|
17
|
+
function reprStr(s) {
|
|
18
|
+
const quote = s.includes("'") && !s.includes('"') ? '"' : "'";
|
|
19
|
+
let out = "";
|
|
20
|
+
for (const ch of s) {
|
|
21
|
+
if (ch === "\\")
|
|
22
|
+
out += "\\\\";
|
|
23
|
+
else if (ch === quote)
|
|
24
|
+
out += `\\${ch}`;
|
|
25
|
+
else if (ch === "\n")
|
|
26
|
+
out += "\\n";
|
|
27
|
+
else if (ch === "\r")
|
|
28
|
+
out += "\\r";
|
|
29
|
+
else if (ch === "\t")
|
|
30
|
+
out += "\\t";
|
|
31
|
+
else if (ch < " " || ch === "\x7f")
|
|
32
|
+
out += `\\x${ch.charCodeAt(0).toString(16).padStart(2, "0")}`;
|
|
33
|
+
else
|
|
34
|
+
out += ch;
|
|
35
|
+
}
|
|
36
|
+
return `${quote}${out}${quote}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Observer to log transcription activity to the console.
|
|
40
|
+
*
|
|
41
|
+
* Monitors and logs all transcription frames from STT services, including both
|
|
42
|
+
* final transcriptions and interim results. This allows developers to track
|
|
43
|
+
* speech recognition activity and debug transcription issues.
|
|
44
|
+
*
|
|
45
|
+
* Only processes frames from STTService instances to avoid logging unrelated
|
|
46
|
+
* transcription frames from other sources.
|
|
47
|
+
*/
|
|
48
|
+
export class TranscriptionLogObserver extends BaseObserver {
|
|
49
|
+
/**
|
|
50
|
+
* Handle frame push events and log transcription frames.
|
|
51
|
+
*
|
|
52
|
+
* Logs TranscriptionFrame and InterimTranscriptionFrame instances with
|
|
53
|
+
* timestamps and user information for debugging purposes.
|
|
54
|
+
*
|
|
55
|
+
* @param data Frame push event data containing source, frame, and timestamp.
|
|
56
|
+
*/
|
|
57
|
+
async onPushFrame(data) {
|
|
58
|
+
const src = data.source;
|
|
59
|
+
const frame = data.frame;
|
|
60
|
+
const timestamp = data.timestamp;
|
|
61
|
+
if (!(src instanceof STTService)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const timeSec = (timestamp / 1_000_000_000).toFixed(2);
|
|
65
|
+
const arrow = "→";
|
|
66
|
+
if (frame instanceof TranscriptionFrame) {
|
|
67
|
+
logger.debug(`💬 ${src} ${arrow} TRANSCRIPTION: ${reprStr(frame.text)} from ${reprStr(frame.userId)} at ${timeSec}s`);
|
|
68
|
+
}
|
|
69
|
+
else if (frame instanceof InterimTranscriptionFrame) {
|
|
70
|
+
logger.debug(`💬 ${src} ${arrow} INTERIM TRANSCRIPTION: ${reprStr(frame.text)} from ${reprStr(frame.userId)} at ${timeSec}s`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=transcription_log_observer.js.map
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { type MetricsData } from "../metrics/metrics.ts";
|
|
2
|
+
import { BaseObserver, type BaseObserverOptions, type FramePushed } from "./base_observer.ts";
|
|
3
|
+
/** Which measurement of a service's own time a record carries. */
|
|
4
|
+
export declare const ServiceLatencyKind: {
|
|
5
|
+
readonly TTFB: "ttfb";
|
|
6
|
+
readonly TTFA: "ttfa";
|
|
7
|
+
readonly TTFAT: "ttfat";
|
|
8
|
+
};
|
|
9
|
+
export type ServiceLatencyKind = (typeof ServiceLatencyKind)[keyof typeof ServiceLatencyKind];
|
|
10
|
+
/** Which kind of service consumed something. */
|
|
11
|
+
export declare const ServiceUsageKind: {
|
|
12
|
+
readonly STT: "stt";
|
|
13
|
+
readonly LLM: "llm";
|
|
14
|
+
readonly TTS: "tts";
|
|
15
|
+
};
|
|
16
|
+
export type ServiceUsageKind = (typeof ServiceUsageKind)[keyof typeof ServiceUsageKind];
|
|
17
|
+
export interface ServiceLatencyRecordOptions {
|
|
18
|
+
/** Which wait was measured. */
|
|
19
|
+
kind: ServiceLatencyKind;
|
|
20
|
+
/** Name of the processor that reported it. */
|
|
21
|
+
processor: string;
|
|
22
|
+
/** Model the processor was using, where it names one. */
|
|
23
|
+
model?: string | null;
|
|
24
|
+
/** Unix timestamp when the measurement was observed. */
|
|
25
|
+
timestamp: number;
|
|
26
|
+
/** The measurement itself. */
|
|
27
|
+
seconds: number;
|
|
28
|
+
/** The time to first byte the measurement builds on, for the kinds that report one. */
|
|
29
|
+
ttfbSecs?: number | null;
|
|
30
|
+
/** Silence at the head of the first audio, for time to first audio. */
|
|
31
|
+
leadingSilenceSecs?: number | null;
|
|
32
|
+
/**
|
|
33
|
+
* Time between a model's first output and its first answer token, for time
|
|
34
|
+
* to first answer token.
|
|
35
|
+
*/
|
|
36
|
+
thinkingTimeSecs?: number | null;
|
|
37
|
+
}
|
|
38
|
+
/** One measurement of how long a service took. */
|
|
39
|
+
export declare class ServiceLatencyRecord {
|
|
40
|
+
kind: ServiceLatencyKind;
|
|
41
|
+
processor: string;
|
|
42
|
+
model: string | null;
|
|
43
|
+
timestamp: number;
|
|
44
|
+
seconds: number;
|
|
45
|
+
ttfbSecs: number | null;
|
|
46
|
+
leadingSilenceSecs: number | null;
|
|
47
|
+
thinkingTimeSecs: number | null;
|
|
48
|
+
constructor(options: ServiceLatencyRecordOptions);
|
|
49
|
+
}
|
|
50
|
+
export interface ServiceUsageRecordOptions {
|
|
51
|
+
/** Which kind of service reported. */
|
|
52
|
+
kind: ServiceUsageKind;
|
|
53
|
+
/** Name of the processor that reported it. */
|
|
54
|
+
processor: string;
|
|
55
|
+
/** Model the processor was using, where it names one. */
|
|
56
|
+
model?: string | null;
|
|
57
|
+
/** Unix timestamp when the usage was observed. */
|
|
58
|
+
timestamp: number;
|
|
59
|
+
/** Audio transcribed, for speech-to-text. */
|
|
60
|
+
audioSeconds?: number | null;
|
|
61
|
+
/** Characters synthesised, for text-to-speech. */
|
|
62
|
+
characters?: number | null;
|
|
63
|
+
/** Tokens in the prompt, for an LLM. */
|
|
64
|
+
promptTokens?: number | null;
|
|
65
|
+
/** Tokens generated, for an LLM. */
|
|
66
|
+
completionTokens?: number | null;
|
|
67
|
+
/** Tokens in the prompt and the completion together. */
|
|
68
|
+
totalTokens?: number | null;
|
|
69
|
+
/** Prompt tokens served from cache. */
|
|
70
|
+
cacheReadInputTokens?: number | null;
|
|
71
|
+
/** Prompt tokens written to cache. */
|
|
72
|
+
cacheCreationInputTokens?: number | null;
|
|
73
|
+
/** Tokens spent reasoning before answering. */
|
|
74
|
+
reasoningTokens?: number | null;
|
|
75
|
+
/** Audio tokens in the prompt. */
|
|
76
|
+
inputAudioTokens?: number | null;
|
|
77
|
+
/** Audio tokens generated. */
|
|
78
|
+
outputAudioTokens?: number | null;
|
|
79
|
+
/** Audio prompt tokens served from cache. */
|
|
80
|
+
cacheReadInputAudioTokens?: number | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* What one service consumed doing a piece of work.
|
|
84
|
+
*
|
|
85
|
+
* A field is set only where the kind of service reports it, so an LLM record
|
|
86
|
+
* carries token counts and a text-to-speech record carries characters.
|
|
87
|
+
*/
|
|
88
|
+
export declare class ServiceUsageRecord {
|
|
89
|
+
kind: ServiceUsageKind;
|
|
90
|
+
processor: string;
|
|
91
|
+
model: string | null;
|
|
92
|
+
timestamp: number;
|
|
93
|
+
audioSeconds: number | null;
|
|
94
|
+
characters: number | null;
|
|
95
|
+
promptTokens: number | null;
|
|
96
|
+
completionTokens: number | null;
|
|
97
|
+
totalTokens: number | null;
|
|
98
|
+
cacheReadInputTokens: number | null;
|
|
99
|
+
cacheCreationInputTokens: number | null;
|
|
100
|
+
reasoningTokens: number | null;
|
|
101
|
+
inputAudioTokens: number | null;
|
|
102
|
+
outputAudioTokens: number | null;
|
|
103
|
+
cacheReadInputAudioTokens: number | null;
|
|
104
|
+
constructor(options: ServiceUsageRecordOptions);
|
|
105
|
+
}
|
|
106
|
+
export interface ServiceMetricsObserverOptions extends Omit<BaseObserverOptions, "observeEveryPush"> {
|
|
107
|
+
/**
|
|
108
|
+
* Reads the current time in seconds. Supplying one lets a test place
|
|
109
|
+
* records without waiting. Defaults to `time()`.
|
|
110
|
+
*/
|
|
111
|
+
timeSource?: () => number;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Reports each metric a service publishes as its own record.
|
|
115
|
+
*
|
|
116
|
+
* A record arrives per piece of work rather than per turn or per session: a
|
|
117
|
+
* turn that runs two inferences reports two, and a consumer that wants a
|
|
118
|
+
* total groups them itself. Summing here would lose the grain, and a total
|
|
119
|
+
* held in memory is lost with the process holding it.
|
|
120
|
+
*
|
|
121
|
+
* What a service made someone wait for is here; what it did with its own
|
|
122
|
+
* time is not. Processing time, text aggregation and smart-turn predictions
|
|
123
|
+
* are all deliberately absent: aggregation already appears as a span in
|
|
124
|
+
* `LatencyBreakdown` (see `user_bot_latency_observer`), and the other two
|
|
125
|
+
* describe how work was done rather than what it cost the person waiting.
|
|
126
|
+
*
|
|
127
|
+
* Events:
|
|
128
|
+
*
|
|
129
|
+
* - on_service_latency(observer, record): Emitted for each measurement of a
|
|
130
|
+
* service's own time, as a `ServiceLatencyRecord`.
|
|
131
|
+
* - on_service_usage(observer, record): Emitted for each report of what a
|
|
132
|
+
* service consumed, as a `ServiceUsageRecord`.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* const observer = new ServiceMetricsObserver();
|
|
136
|
+
*
|
|
137
|
+
* observer.eventHandler("on_service_usage", async (observer, record: ServiceUsageRecord) => {
|
|
138
|
+
* logger.info(JSON.stringify(record));
|
|
139
|
+
* });
|
|
140
|
+
*/
|
|
141
|
+
export declare class ServiceMetricsObserver extends BaseObserver {
|
|
142
|
+
protected _now: () => number;
|
|
143
|
+
constructor(options?: ServiceMetricsObserverOptions);
|
|
144
|
+
/**
|
|
145
|
+
* Report the metrics carried by a frame.
|
|
146
|
+
*
|
|
147
|
+
* Metrics travel in one direction. A frame broadcast both ways would arrive
|
|
148
|
+
* as two frames, and would be reported twice.
|
|
149
|
+
*
|
|
150
|
+
* @param data Frame push event containing the frame and direction.
|
|
151
|
+
*/
|
|
152
|
+
onPushFrame(data: FramePushed): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Build a latency record, for the metrics that measure time spent.
|
|
155
|
+
*
|
|
156
|
+
* @param metrics One metric a processor reported.
|
|
157
|
+
* @returns The record, or null if this metric measures something else.
|
|
158
|
+
*/
|
|
159
|
+
protected _asLatency(metrics: MetricsData): ServiceLatencyRecord | null;
|
|
160
|
+
/**
|
|
161
|
+
* Build a usage record, for the metrics that measure what was consumed.
|
|
162
|
+
*
|
|
163
|
+
* @param metrics One metric a processor reported.
|
|
164
|
+
* @returns The record, or null if this metric measures something else.
|
|
165
|
+
*/
|
|
166
|
+
protected _asUsage(metrics: MetricsData): ServiceUsageRecord | null;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=service_metrics_observer.d.ts.map
|