@qvac/inference 0.0.0 → 0.17.1
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 +179 -0
- package/NOTICE +928 -0
- package/README.md +138 -0
- package/dist/api/audio-gen.d.ts +18 -0
- package/dist/api/audio-gen.js +148 -0
- package/dist/api/batch-completion.d.ts +14 -0
- package/dist/api/batch-completion.js +332 -0
- package/dist/api/bci-transcribe.d.ts +56 -0
- package/dist/api/bci-transcribe.js +172 -0
- package/dist/api/cancel.d.ts +34 -0
- package/dist/api/cancel.js +82 -0
- package/dist/api/classify.d.ts +22 -0
- package/dist/api/classify.js +46 -0
- package/dist/api/completion-stream.d.ts +106 -0
- package/dist/api/completion-stream.js +351 -0
- package/dist/api/delete-cache.d.ts +29 -0
- package/dist/api/delete-cache.js +49 -0
- package/dist/api/diffusion.d.ts +92 -0
- package/dist/api/diffusion.js +176 -0
- package/dist/api/download-asset.d.ts +49 -0
- package/dist/api/download-asset.js +87 -0
- package/dist/api/embed.d.ts +41 -0
- package/dist/api/embed.js +29 -0
- package/dist/api/finetune.d.ts +89 -0
- package/dist/api/finetune.js +138 -0
- package/dist/api/get-loaded-model-info.d.ts +24 -0
- package/dist/api/get-loaded-model-info.js +34 -0
- package/dist/api/get-model-info.d.ts +43 -0
- package/dist/api/get-model-info.js +21 -0
- package/dist/api/get-system-resources.d.ts +2 -0
- package/dist/api/get-system-resources.js +16 -0
- package/dist/api/heartbeat.d.ts +29 -0
- package/dist/api/heartbeat.js +37 -0
- package/dist/api/index.d.ts +35 -0
- package/dist/api/index.js +35 -0
- package/dist/api/invoke-plugin.d.ts +30 -0
- package/dist/api/invoke-plugin.js +54 -0
- package/dist/api/load-model.d.ts +169 -0
- package/dist/api/load-model.js +129 -0
- package/dist/api/logging-stream-registry.d.ts +4 -0
- package/dist/api/logging-stream-registry.js +61 -0
- package/dist/api/logging-stream.d.ts +23 -0
- package/dist/api/logging-stream.js +36 -0
- package/dist/api/ocr.d.ts +30 -0
- package/dist/api/ocr.js +88 -0
- package/dist/api/parse-input.d.ts +2 -0
- package/dist/api/parse-input.js +14 -0
- package/dist/api/provide.d.ts +23 -0
- package/dist/api/provide.js +32 -0
- package/dist/api/rag.d.ts +251 -0
- package/dist/api/rag.js +485 -0
- package/dist/api/registry.d.ts +39 -0
- package/dist/api/registry.js +63 -0
- package/dist/api/resume.d.ts +29 -0
- package/dist/api/resume.js +36 -0
- package/dist/api/state.d.ts +22 -0
- package/dist/api/state.js +29 -0
- package/dist/api/stop-provider.d.ts +20 -0
- package/dist/api/stop-provider.js +30 -0
- package/dist/api/subscribe-logs.d.ts +27 -0
- package/dist/api/subscribe-logs.js +43 -0
- package/dist/api/suspend.d.ts +30 -0
- package/dist/api/suspend.js +37 -0
- package/dist/api/text-to-speech.d.ts +64 -0
- package/dist/api/text-to-speech.js +434 -0
- package/dist/api/transcribe.d.ts +75 -0
- package/dist/api/transcribe.js +256 -0
- package/dist/api/translate.d.ts +47 -0
- package/dist/api/translate.js +115 -0
- package/dist/api/unload-model.d.ts +17 -0
- package/dist/api/unload-model.js +42 -0
- package/dist/api/upscale.d.ts +44 -0
- package/dist/api/upscale.js +99 -0
- package/dist/api/video.d.ts +86 -0
- package/dist/api/video.js +176 -0
- package/dist/api/vla-helpers.d.ts +43 -0
- package/dist/api/vla-helpers.js +124 -0
- package/dist/api/vla.d.ts +68 -0
- package/dist/api/vla.js +113 -0
- package/dist/config/config-utils.d.ts +4 -0
- package/dist/config/config-utils.js +18 -0
- package/dist/config/resolve-config.d.ts +8 -0
- package/dist/config/resolve-config.js +74 -0
- package/dist/constants/audio.d.ts +1 -0
- package/dist/constants/audio.js +1 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +2 -0
- package/dist/constants/registry.d.ts +1 -0
- package/dist/constants/registry.js +1 -0
- package/dist/dispatch.d.ts +18 -0
- package/dist/dispatch.js +271 -0
- package/dist/engine.d.ts +5 -0
- package/dist/engine.js +27 -0
- package/dist/errors/index.d.ts +416 -0
- package/dist/errors/index.js +681 -0
- package/dist/errors/options.d.ts +2 -0
- package/dist/errors/options.js +13 -0
- package/dist/handlers/cancelHandler.d.ts +29 -0
- package/dist/handlers/cancelHandler.js +67 -0
- package/dist/handlers/completion-orchestrate.d.ts +41 -0
- package/dist/handlers/completion-orchestrate.js +190 -0
- package/dist/handlers/delete-cache.d.ts +11 -0
- package/dist/handlers/delete-cache.js +37 -0
- package/dist/handlers/download-asset.d.ts +2 -0
- package/dist/handlers/download-asset.js +146 -0
- package/dist/handlers/finetune.d.ts +2 -0
- package/dist/handlers/finetune.js +18 -0
- package/dist/handlers/get-loaded-model-info.d.ts +2 -0
- package/dist/handlers/get-loaded-model-info.js +45 -0
- package/dist/handlers/get-model-info.d.ts +2 -0
- package/dist/handlers/get-model-info.js +173 -0
- package/dist/handlers/get-system-resources.d.ts +2 -0
- package/dist/handlers/get-system-resources.js +53 -0
- package/dist/handlers/heartbeat.d.ts +2 -0
- package/dist/handlers/heartbeat.js +3 -0
- package/dist/handlers/load-model/download-manager.d.ts +95 -0
- package/dist/handlers/load-model/download-manager.js +306 -0
- package/dist/handlers/load-model/download-stats.d.ts +7 -0
- package/dist/handlers/load-model/download-stats.js +126 -0
- package/dist/handlers/load-model/handler.d.ts +2 -0
- package/dist/handlers/load-model/handler.js +287 -0
- package/dist/handlers/load-model/http.d.ts +3 -0
- package/dist/handlers/load-model/http.js +857 -0
- package/dist/handlers/load-model/hyperdrive.d.ts +4 -0
- package/dist/handlers/load-model/hyperdrive.js +560 -0
- package/dist/handlers/load-model/index.d.ts +2 -0
- package/dist/handlers/load-model/index.js +2 -0
- package/dist/handlers/load-model/registry-client-options.d.ts +27 -0
- package/dist/handlers/load-model/registry-client-options.js +18 -0
- package/dist/handlers/load-model/registry-companion-set.d.ts +22 -0
- package/dist/handlers/load-model/registry-companion-set.js +206 -0
- package/dist/handlers/load-model/registry-download-utils.d.ts +23 -0
- package/dist/handlers/load-model/registry-download-utils.js +112 -0
- package/dist/handlers/load-model/registry-metadata.d.ts +10 -0
- package/dist/handlers/load-model/registry-metadata.js +23 -0
- package/dist/handlers/load-model/registry.d.ts +4 -0
- package/dist/handlers/load-model/registry.js +298 -0
- package/dist/handlers/load-model/resolve-session.d.ts +33 -0
- package/dist/handlers/load-model/resolve-session.js +62 -0
- package/dist/handlers/load-model/resolve.d.ts +5 -0
- package/dist/handlers/load-model/resolve.js +158 -0
- package/dist/handlers/load-model/types.d.ts +59 -0
- package/dist/handlers/load-model/types.js +28 -0
- package/dist/handlers/logging-stream.d.ts +2 -0
- package/dist/handlers/logging-stream.js +39 -0
- package/dist/handlers/plugin-dispatch.d.ts +3 -0
- package/dist/handlers/plugin-dispatch.js +63 -0
- package/dist/handlers/plugin-invoke.d.ts +3 -0
- package/dist/handlers/plugin-invoke.js +81 -0
- package/dist/handlers/registry.d.ts +4 -0
- package/dist/handlers/registry.js +156 -0
- package/dist/handlers/resume.d.ts +2 -0
- package/dist/handlers/resume.js +11 -0
- package/dist/handlers/state.d.ts +2 -0
- package/dist/handlers/state.js +7 -0
- package/dist/handlers/suspend.d.ts +2 -0
- package/dist/handlers/suspend.js +11 -0
- package/dist/handlers/types.d.ts +13 -0
- package/dist/handlers/types.js +1 -0
- package/dist/handlers/unload-model.d.ts +2 -0
- package/dist/handlers/unload-model.js +29 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -0
- package/dist/logging/addon.d.ts +5 -0
- package/dist/logging/addon.js +75 -0
- package/dist/logging/index.d.ts +5 -0
- package/dist/logging/index.js +4 -0
- package/dist/logging/logger.d.ts +41 -0
- package/dist/logging/logger.js +209 -0
- package/dist/logging/namespaces.d.ts +6 -0
- package/dist/logging/namespaces.js +7 -0
- package/dist/logging/types.d.ts +37 -0
- package/dist/logging/types.js +1 -0
- package/dist/logging/utils.d.ts +5 -0
- package/dist/logging/utils.js +113 -0
- package/dist/models/registry/index.d.ts +18 -0
- package/dist/models/registry/index.js +21 -0
- package/dist/models/registry/models.d.ts +22680 -0
- package/dist/models/registry/models.js +23908 -0
- package/dist/p2p/cancel-delegated.d.ts +3 -0
- package/dist/p2p/cancel-delegated.js +64 -0
- package/dist/p2p/completion-stream-delegated.d.ts +4 -0
- package/dist/p2p/completion-stream-delegated.js +51 -0
- package/dist/p2p/delegate-client.d.ts +9 -0
- package/dist/p2p/delegate-client.js +219 -0
- package/dist/p2p/delegate-connect-diagnostics.d.ts +8 -0
- package/dist/p2p/delegate-connect-diagnostics.js +38 -0
- package/dist/p2p/delegate-transport.d.ts +18 -0
- package/dist/p2p/delegate-transport.js +237 -0
- package/dist/p2p/error-handlers.d.ts +4 -0
- package/dist/p2p/error-handlers.js +31 -0
- package/dist/p2p/handle-request.d.ts +2 -0
- package/dist/p2p/handle-request.js +171 -0
- package/dist/p2p/handler-utils.d.ts +19 -0
- package/dist/p2p/handler-utils.js +180 -0
- package/dist/p2p/heartbeat-delegated.d.ts +3 -0
- package/dist/p2p/heartbeat-delegated.js +32 -0
- package/dist/p2p/load-model-delegated.d.ts +6 -0
- package/dist/p2p/load-model-delegated.js +132 -0
- package/dist/p2p/progress-throttle.d.ts +7 -0
- package/dist/p2p/progress-throttle.js +47 -0
- package/dist/p2p/provideHandler/connection.d.ts +2 -0
- package/dist/p2p/provideHandler/connection.js +38 -0
- package/dist/p2p/provideHandler/handler.d.ts +2 -0
- package/dist/p2p/provideHandler/handler.js +66 -0
- package/dist/p2p/provideHandler/proxy.d.ts +2 -0
- package/dist/p2p/provideHandler/proxy.js +24 -0
- package/dist/p2p/provideHandler.d.ts +1 -0
- package/dist/p2p/provideHandler.js +2 -0
- package/dist/p2p/rpc-utils.d.ts +4 -0
- package/dist/p2p/rpc-utils.js +8 -0
- package/dist/p2p/stopProvideHandler.d.ts +2 -0
- package/dist/p2p/stopProvideHandler.js +29 -0
- package/dist/p2p/swarm.d.ts +9 -0
- package/dist/p2p/swarm.js +103 -0
- package/dist/p2p/transport-selector.d.ts +2 -0
- package/dist/p2p/transport-selector.js +18 -0
- package/dist/p2p/unload-model-delegated.d.ts +2 -0
- package/dist/p2p/unload-model-delegated.js +31 -0
- package/dist/plugins/builtin/asr-ggml/config.d.ts +31 -0
- package/dist/plugins/builtin/asr-ggml/config.js +46 -0
- package/dist/plugins/builtin/asr-ggml/logging.d.ts +10 -0
- package/dist/plugins/builtin/asr-ggml/logging.js +12 -0
- package/dist/plugins/builtin/audiogen-ggml/config.d.ts +17 -0
- package/dist/plugins/builtin/audiogen-ggml/config.js +23 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.d.ts +2 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +163 -0
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +212 -0
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +58 -0
- package/dist/plugins/builtin/bci-whispercpp-transcription/args.d.ts +2 -0
- package/dist/plugins/builtin/bci-whispercpp-transcription/args.js +13 -0
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +173 -0
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +111 -0
- package/dist/plugins/builtin/bci-whispercpp-transcription/resolve-config.d.ts +74 -0
- package/dist/plugins/builtin/bci-whispercpp-transcription/resolve-config.js +11 -0
- package/dist/plugins/builtin/ggml-classification/ops/classify.d.ts +5 -0
- package/dist/plugins/builtin/ggml-classification/ops/classify.js +31 -0
- package/dist/plugins/builtin/ggml-classification/plugin.d.ts +31 -0
- package/dist/plugins/builtin/ggml-classification/plugin.js +55 -0
- package/dist/plugins/builtin/ggml-ocr/ops/ocr-stream.d.ts +7 -0
- package/dist/plugins/builtin/ggml-ocr/ops/ocr-stream.js +119 -0
- package/dist/plugins/builtin/ggml-ocr/plugin.d.ts +102 -0
- package/dist/plugins/builtin/ggml-ocr/plugin.js +110 -0
- package/dist/plugins/builtin/ggml-ocr/resolve-config.d.ts +5 -0
- package/dist/plugins/builtin/ggml-ocr/resolve-config.js +72 -0
- package/dist/plugins/builtin/ggml-vla/ops/vla-hparams.d.ts +2 -0
- package/dist/plugins/builtin/ggml-vla/ops/vla-hparams.js +12 -0
- package/dist/plugins/builtin/ggml-vla/ops/vla-run.d.ts +2 -0
- package/dist/plugins/builtin/ggml-vla/ops/vla-run.js +78 -0
- package/dist/plugins/builtin/ggml-vla/plugin.d.ts +65 -0
- package/dist/plugins/builtin/ggml-vla/plugin.js +57 -0
- package/dist/plugins/builtin/index.d.ts +11 -0
- package/dist/plugins/builtin/index.js +11 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-cancelled.d.ts +22 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-cancelled.js +30 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.d.ts +31 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +99 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/cache-logger.d.ts +6 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/cache-logger.js +36 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.d.ts +20 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.js +48 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.d.ts +45 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +374 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/context-overflow.d.ts +28 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/context-overflow.js +65 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/finetune.d.ts +10 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/finetune.js +209 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.d.ts +163 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.js +581 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.d.ts +56 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.js +58 -0
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +671 -0
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +481 -0
- package/dist/plugins/builtin/llamacpp-completion/transform.d.ts +9 -0
- package/dist/plugins/builtin/llamacpp-completion/transform.js +34 -0
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +76 -0
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +101 -0
- package/dist/plugins/builtin/nmtcpp-translation/plugin.d.ts +457 -0
- package/dist/plugins/builtin/nmtcpp-translation/plugin.js +143 -0
- package/dist/plugins/builtin/nmtcpp-translation/resolve-vocab.d.ts +31 -0
- package/dist/plugins/builtin/nmtcpp-translation/resolve-vocab.js +114 -0
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +133 -0
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +130 -0
- package/dist/plugins/builtin/sdcpp-generation/ops/diffusion.d.ts +2 -0
- package/dist/plugins/builtin/sdcpp-generation/ops/diffusion.js +64 -0
- package/dist/plugins/builtin/sdcpp-generation/ops/upscale.d.ts +2 -0
- package/dist/plugins/builtin/sdcpp-generation/ops/upscale.js +41 -0
- package/dist/plugins/builtin/sdcpp-generation/ops/video.d.ts +5 -0
- package/dist/plugins/builtin/sdcpp-generation/ops/video.js +239 -0
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +757 -0
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +310 -0
- package/dist/plugins/builtin/tts-ggml/ops/parler-options.d.ts +6 -0
- package/dist/plugins/builtin/tts-ggml/ops/parler-options.js +30 -0
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.d.ts +7 -0
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.js +106 -0
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.d.ts +6 -0
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +91 -0
- package/dist/plugins/builtin/tts-ggml/plugin.d.ts +196 -0
- package/dist/plugins/builtin/tts-ggml/plugin.js +305 -0
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +346 -0
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +169 -0
- package/dist/plugins/index.d.ts +9 -0
- package/dist/plugins/index.js +12 -0
- package/dist/plugins/ops/bci-transcribe.d.ts +13 -0
- package/dist/plugins/ops/bci-transcribe.js +248 -0
- package/dist/plugins/ops/cancel.d.ts +25 -0
- package/dist/plugins/ops/cancel.js +43 -0
- package/dist/plugins/ops/embed.d.ts +15 -0
- package/dist/plugins/ops/embed.js +193 -0
- package/dist/plugins/ops/kv-cache-retention.d.ts +11 -0
- package/dist/plugins/ops/kv-cache-retention.js +121 -0
- package/dist/plugins/ops/kv-cache-utils.d.ts +21 -0
- package/dist/plugins/ops/kv-cache-utils.js +120 -0
- package/dist/plugins/ops/load-model.d.ts +8 -0
- package/dist/plugins/ops/load-model.js +82 -0
- package/dist/plugins/ops/transcribe.d.ts +20 -0
- package/dist/plugins/ops/transcribe.js +343 -0
- package/dist/plugins/ops/translate.d.ts +7 -0
- package/dist/plugins/ops/translate.js +256 -0
- package/dist/plugins/ops/unload-model.d.ts +2 -0
- package/dist/plugins/ops/unload-model.js +45 -0
- package/dist/plugins/registry.d.ts +9 -0
- package/dist/plugins/registry.js +107 -0
- package/dist/profiling/aggregator.d.ts +14 -0
- package/dist/profiling/aggregator.js +100 -0
- package/dist/profiling/backend-diagnostics.d.ts +8 -0
- package/dist/profiling/backend-diagnostics.js +36 -0
- package/dist/profiling/clock.d.ts +8 -0
- package/dist/profiling/clock.js +23 -0
- package/dist/profiling/controller.d.ts +34 -0
- package/dist/profiling/controller.js +130 -0
- package/dist/profiling/delegation-profiler.d.ts +31 -0
- package/dist/profiling/delegation-profiler.js +155 -0
- package/dist/profiling/envelope.d.ts +10 -0
- package/dist/profiling/envelope.js +45 -0
- package/dist/profiling/events.d.ts +19 -0
- package/dist/profiling/events.js +35 -0
- package/dist/profiling/exporters.d.ts +9 -0
- package/dist/profiling/exporters.js +242 -0
- package/dist/profiling/index.d.ts +91 -0
- package/dist/profiling/index.js +87 -0
- package/dist/profiling/model-execution.d.ts +15 -0
- package/dist/profiling/model-execution.js +34 -0
- package/dist/profiling/operation-metrics.d.ts +24 -0
- package/dist/profiling/operation-metrics.js +370 -0
- package/dist/profiling/operation-wrappers.d.ts +17 -0
- package/dist/profiling/operation-wrappers.js +196 -0
- package/dist/profiling/profiler.d.ts +27 -0
- package/dist/profiling/profiler.js +127 -0
- package/dist/profiling/ring-buffer.d.ts +18 -0
- package/dist/profiling/ring-buffer.js +83 -0
- package/dist/profiling/types.d.ts +52 -0
- package/dist/profiling/types.js +1 -0
- package/dist/rag/handler.d.ts +2 -0
- package/dist/rag/handler.js +272 -0
- package/dist/rag/handlers/chunk.d.ts +2 -0
- package/dist/rag/handlers/chunk.js +7 -0
- package/dist/rag/handlers/close-workspace.d.ts +2 -0
- package/dist/rag/handlers/close-workspace.js +9 -0
- package/dist/rag/handlers/delete-embeddings.d.ts +2 -0
- package/dist/rag/handlers/delete-embeddings.js +11 -0
- package/dist/rag/handlers/delete-workspace.d.ts +2 -0
- package/dist/rag/handlers/delete-workspace.js +14 -0
- package/dist/rag/handlers/ingest.d.ts +9 -0
- package/dist/rag/handlers/ingest.js +19 -0
- package/dist/rag/handlers/list-workspaces.d.ts +2 -0
- package/dist/rag/handlers/list-workspaces.js +4 -0
- package/dist/rag/handlers/reindex.d.ts +9 -0
- package/dist/rag/handlers/reindex.js +16 -0
- package/dist/rag/handlers/save-embeddings.d.ts +9 -0
- package/dist/rag/handlers/save-embeddings.js +15 -0
- package/dist/rag/handlers/search.d.ts +2 -0
- package/dist/rag/handlers/search.js +16 -0
- package/dist/rag/index.d.ts +11 -0
- package/dist/rag/index.js +11 -0
- package/dist/rag/rag-operation-manager.d.ts +28 -0
- package/dist/rag/rag-operation-manager.js +76 -0
- package/dist/rag/rag-workspace-manager.d.ts +14 -0
- package/dist/rag/rag-workspace-manager.js +143 -0
- package/dist/registry.d.ts +2 -0
- package/dist/registry.js +166 -0
- package/dist/resources/collector.d.ts +643 -0
- package/dist/resources/collector.js +226 -0
- package/dist/resources/instance.d.ts +4 -0
- package/dist/resources/instance.js +15 -0
- package/dist/resources/native.d.ts +2 -0
- package/dist/resources/native.js +35 -0
- package/dist/resources/normalize.d.ts +12 -0
- package/dist/resources/normalize.js +73 -0
- package/dist/resources/types.d.ts +65 -0
- package/dist/resources/types.js +1 -0
- package/dist/runtime/cache-lock.d.ts +2 -0
- package/dist/runtime/cache-lock.js +67 -0
- package/dist/runtime/disposable-scope.d.ts +35 -0
- package/dist/runtime/disposable-scope.js +69 -0
- package/dist/runtime/env.d.ts +16 -0
- package/dist/runtime/env.js +53 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/lifecycle.d.ts +20 -0
- package/dist/runtime/lifecycle.js +102 -0
- package/dist/runtime/logging-stream-registry.d.ts +27 -0
- package/dist/runtime/logging-stream-registry.js +133 -0
- package/dist/runtime/model-config-utils.d.ts +14 -0
- package/dist/runtime/model-config-utils.js +128 -0
- package/dist/runtime/model-registry.d.ts +74 -0
- package/dist/runtime/model-registry.js +130 -0
- package/dist/runtime/registry-client.d.ts +4 -0
- package/dist/runtime/registry-client.js +118 -0
- package/dist/runtime/request-context.d.ts +72 -0
- package/dist/runtime/request-context.js +114 -0
- package/dist/runtime/request-id.d.ts +17 -0
- package/dist/runtime/request-id.js +29 -0
- package/dist/runtime/request-registry.d.ts +194 -0
- package/dist/runtime/request-registry.js +546 -0
- package/dist/runtime/runtime-lifecycle.d.ts +37 -0
- package/dist/runtime/runtime-lifecycle.js +163 -0
- package/dist/runtime/state.d.ts +26 -0
- package/dist/runtime/state.js +138 -0
- package/dist/schemas/audio-gen.d.ts +252 -0
- package/dist/schemas/audio-gen.js +69 -0
- package/dist/schemas/batch-completion-stream.d.ts +467 -0
- package/dist/schemas/batch-completion-stream.js +123 -0
- package/dist/schemas/bci-config.d.ts +74 -0
- package/dist/schemas/bci-config.js +58 -0
- package/dist/schemas/bci.d.ts +178 -0
- package/dist/schemas/bci.js +89 -0
- package/dist/schemas/cancel.d.ts +203 -0
- package/dist/schemas/cancel.js +135 -0
- package/dist/schemas/classification.d.ts +52 -0
- package/dist/schemas/classification.js +33 -0
- package/dist/schemas/common.d.ts +6420 -0
- package/dist/schemas/common.js +133 -0
- package/dist/schemas/completion-event.d.ts +248 -0
- package/dist/schemas/completion-event.js +94 -0
- package/dist/schemas/completion-stream.d.ts +475 -0
- package/dist/schemas/completion-stream.js +236 -0
- package/dist/schemas/config.d.ts +5022 -0
- package/dist/schemas/config.js +169 -0
- package/dist/schemas/delegate.d.ts +29 -0
- package/dist/schemas/delegate.js +40 -0
- package/dist/schemas/download-asset.d.ts +225 -0
- package/dist/schemas/download-asset.js +71 -0
- package/dist/schemas/embed.d.ts +41 -0
- package/dist/schemas/embed.js +35 -0
- package/dist/schemas/engine-addon-map.d.ts +20 -0
- package/dist/schemas/engine-addon-map.js +78 -0
- package/dist/schemas/error.d.ts +40 -0
- package/dist/schemas/error.js +65 -0
- package/dist/schemas/errors.d.ts +119 -0
- package/dist/schemas/errors.js +615 -0
- package/dist/schemas/finetune.d.ts +621 -0
- package/dist/schemas/finetune.js +163 -0
- package/dist/schemas/index.d.ts +45 -0
- package/dist/schemas/index.js +45 -0
- package/dist/schemas/json-schema.d.ts +15 -0
- package/dist/schemas/json-schema.js +2 -0
- package/dist/schemas/lifecycle.d.ts +38 -0
- package/dist/schemas/lifecycle.js +21 -0
- package/dist/schemas/llamacpp-config.d.ts +403 -0
- package/dist/schemas/llamacpp-config.js +133 -0
- package/dist/schemas/load-model.d.ts +25635 -0
- package/dist/schemas/load-model.js +629 -0
- package/dist/schemas/logging-stream.d.ts +33 -0
- package/dist/schemas/logging-stream.js +17 -0
- package/dist/schemas/mcp-adapter.d.ts +46 -0
- package/dist/schemas/mcp-adapter.js +1 -0
- package/dist/schemas/model-file.d.ts +27 -0
- package/dist/schemas/model-file.js +29 -0
- package/dist/schemas/model-info.d.ts +197 -0
- package/dist/schemas/model-info.js +144 -0
- package/dist/schemas/model-ops.d.ts +36 -0
- package/dist/schemas/model-ops.js +40 -0
- package/dist/schemas/model-src-utils.d.ts +192 -0
- package/dist/schemas/model-src-utils.js +61 -0
- package/dist/schemas/model-types.d.ts +275 -0
- package/dist/schemas/model-types.js +223 -0
- package/dist/schemas/ocr.d.ts +138 -0
- package/dist/schemas/ocr.js +59 -0
- package/dist/schemas/path-validation.d.ts +9 -0
- package/dist/schemas/path-validation.js +22 -0
- package/dist/schemas/plugin.d.ts +341 -0
- package/dist/schemas/plugin.js +241 -0
- package/dist/schemas/profiling.d.ts +695 -0
- package/dist/schemas/profiling.js +100 -0
- package/dist/schemas/provide.d.ts +50 -0
- package/dist/schemas/provide.js +32 -0
- package/dist/schemas/rag.d.ts +301 -0
- package/dist/schemas/rag.js +211 -0
- package/dist/schemas/registry.d.ts +453 -0
- package/dist/schemas/registry.js +104 -0
- package/dist/schemas/reload-config.d.ts +585 -0
- package/dist/schemas/reload-config.js +42 -0
- package/dist/schemas/runtime-context.d.ts +18 -0
- package/dist/schemas/runtime-context.js +7 -0
- package/dist/schemas/sdcpp-config.d.ts +1126 -0
- package/dist/schemas/sdcpp-config.js +748 -0
- package/dist/schemas/system-resources.d.ts +3966 -0
- package/dist/schemas/system-resources.js +149 -0
- package/dist/schemas/text-to-speech.d.ts +1352 -0
- package/dist/schemas/text-to-speech.js +364 -0
- package/dist/schemas/tools.d.ts +80 -0
- package/dist/schemas/tools.js +52 -0
- package/dist/schemas/transcription-config.d.ts +161 -0
- package/dist/schemas/transcription-config.js +156 -0
- package/dist/schemas/transcription.d.ts +261 -0
- package/dist/schemas/transcription.js +145 -0
- package/dist/schemas/translate.d.ts +138 -0
- package/dist/schemas/translate.js +103 -0
- package/dist/schemas/translation-config.d.ts +1031 -0
- package/dist/schemas/translation-config.js +170 -0
- package/dist/schemas/vla.d.ts +110 -0
- package/dist/schemas/vla.js +151 -0
- package/dist/selection.d.ts +8 -0
- package/dist/selection.js +14 -0
- package/dist/surface.d.ts +18 -0
- package/dist/surface.js +30 -0
- package/dist/utils/addon-responses.d.ts +58 -0
- package/dist/utils/addon-responses.js +1 -0
- package/dist/utils/aggregate-events.d.ts +25 -0
- package/dist/utils/aggregate-events.js +73 -0
- package/dist/utils/archive.d.ts +4 -0
- package/dist/utils/archive.js +180 -0
- package/dist/utils/asr-events.d.ts +14 -0
- package/dist/utils/asr-events.js +30 -0
- package/dist/utils/audio/decoder.d.ts +4 -0
- package/dist/utils/audio/decoder.js +80 -0
- package/dist/utils/audio-input.d.ts +9 -0
- package/dist/utils/audio-input.js +34 -0
- package/dist/utils/cache/auto-history.d.ts +3 -0
- package/dist/utils/cache/auto-history.js +26 -0
- package/dist/utils/cache/paths.d.ts +42 -0
- package/dist/utils/cache/paths.js +133 -0
- package/dist/utils/cache/types.d.ts +7 -0
- package/dist/utils/cache/types.js +1 -0
- package/dist/utils/cache-normalize.d.ts +9 -0
- package/dist/utils/cache-normalize.js +20 -0
- package/dist/utils/checksum.d.ts +3 -0
- package/dist/utils/checksum.js +29 -0
- package/dist/utils/clear-storage.d.ts +4 -0
- package/dist/utils/clear-storage.js +14 -0
- package/dist/utils/completion-normalizer.d.ts +17 -0
- package/dist/utils/completion-normalizer.js +453 -0
- package/dist/utils/config-transform.d.ts +2 -0
- package/dist/utils/config-transform.js +21 -0
- package/dist/utils/decorate-promise.d.ts +33 -0
- package/dist/utils/decorate-promise.js +35 -0
- package/dist/utils/encoding.d.ts +16 -0
- package/dist/utils/encoding.js +27 -0
- package/dist/utils/expand-gguf-shards.d.ts +2 -0
- package/dist/utils/expand-gguf-shards.js +22 -0
- package/dist/utils/formatting.d.ts +18 -0
- package/dist/utils/formatting.js +56 -0
- package/dist/utils/gguf-tensor-extractor.d.ts +14 -0
- package/dist/utils/gguf-tensor-extractor.js +311 -0
- package/dist/utils/global-singleton.d.ts +1 -0
- package/dist/utils/global-singleton.js +10 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +11 -0
- package/dist/utils/load-model-validation.d.ts +6 -0
- package/dist/utils/load-model-validation.js +18 -0
- package/dist/utils/mcp-adapter.d.ts +11 -0
- package/dist/utils/mcp-adapter.js +96 -0
- package/dist/utils/multi-gpu-mobile.d.ts +4 -0
- package/dist/utils/multi-gpu-mobile.js +10 -0
- package/dist/utils/object.d.ts +1 -0
- package/dist/utils/object.js +3 -0
- package/dist/utils/path-security.d.ts +22 -0
- package/dist/utils/path-security.js +69 -0
- package/dist/utils/qvac-paths.d.ts +1 -0
- package/dist/utils/qvac-paths.js +5 -0
- package/dist/utils/response-format.d.ts +2 -0
- package/dist/utils/response-format.js +20 -0
- package/dist/utils/shard-utils.d.ts +47 -0
- package/dist/utils/shard-utils.js +123 -0
- package/dist/utils/tool-helpers.d.ts +24 -0
- package/dist/utils/tool-helpers.js +111 -0
- package/dist/utils/tool-integration.d.ts +23 -0
- package/dist/utils/tool-integration.js +29 -0
- package/dist/utils/tools/dialect.d.ts +7 -0
- package/dist/utils/tools/dialect.js +20 -0
- package/dist/utils/tools/index.d.ts +2 -0
- package/dist/utils/tools/index.js +2 -0
- package/dist/utils/tools/parser.d.ts +5 -0
- package/dist/utils/tools/parser.js +69 -0
- package/dist/utils/tools/parsers/dsml.d.ts +3 -0
- package/dist/utils/tools/parsers/dsml.js +177 -0
- package/dist/utils/tools/parsers/gemma4native.d.ts +3 -0
- package/dist/utils/tools/parsers/gemma4native.js +65 -0
- package/dist/utils/tools/parsers/harmony.d.ts +3 -0
- package/dist/utils/tools/parsers/harmony.js +57 -0
- package/dist/utils/tools/parsers/hermes.d.ts +3 -0
- package/dist/utils/tools/parsers/hermes.js +122 -0
- package/dist/utils/tools/parsers/json.d.ts +5 -0
- package/dist/utils/tools/parsers/json.js +115 -0
- package/dist/utils/tools/parsers/pythonic.d.ts +3 -0
- package/dist/utils/tools/parsers/pythonic.js +267 -0
- package/dist/utils/tools/parsers/qwen35.d.ts +3 -0
- package/dist/utils/tools/parsers/qwen35.js +125 -0
- package/dist/utils/tools/shared.d.ts +17 -0
- package/dist/utils/tools/shared.js +52 -0
- package/dist/utils/transcribe-metadata.d.ts +20 -0
- package/dist/utils/transcribe-metadata.js +28 -0
- package/dist/utils/tts-stats.d.ts +25 -0
- package/dist/utils/tts-stats.js +16 -0
- package/dist/utils/withTimeout.d.ts +17 -0
- package/dist/utils/withTimeout.js +47 -0
- package/dist/utils/zod-error.d.ts +2 -0
- package/dist/utils/zod-error.js +4 -0
- package/package.json +266 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import nmtAddonLogging from '@qvac/translation-nmtcpp/addonLogging';
|
|
2
|
+
import TranslationNmtcpp from '@qvac/translation-nmtcpp';
|
|
3
|
+
import { definePlugin, defineHandler, translateRequestSchema, translateResponseSchema, ModelType, nmtConfigBaseSchema, ADDON_NMT, BERGAMOT_CJK_LANG_PAIRS } from '../../../schemas/index.js';
|
|
4
|
+
import { createStreamLogger, registerAddonLogger } from '../../../logging/index.js';
|
|
5
|
+
import path from 'bare-path';
|
|
6
|
+
import { translate } from '../../../plugins/ops/translate.js';
|
|
7
|
+
import { attachModelExecutionMs } from '../../../profiling/model-execution.js';
|
|
8
|
+
import { resolveBergamotVocab } from '../../../plugins/builtin/nmtcpp-translation/resolve-vocab.js';
|
|
9
|
+
/**
|
|
10
|
+
* Derive absolute vocab paths from a resolved Bergamot model path.
|
|
11
|
+
* Works for both companion-set layout (colocated files) and any layout where
|
|
12
|
+
* vocab follows the standard naming convention beside the model binary.
|
|
13
|
+
* Returns null if modelPath is not a recognisable Bergamot model.
|
|
14
|
+
*/
|
|
15
|
+
function deriveColocatedBergamotVocabPaths(modelPath) {
|
|
16
|
+
const dirPath = path.dirname(modelPath);
|
|
17
|
+
const basePath = path.basename(modelPath);
|
|
18
|
+
const match = basePath.match(/^model\.([a-z]+)\.intgemm\.alphas\.bin$/);
|
|
19
|
+
if (!match?.[1])
|
|
20
|
+
return null;
|
|
21
|
+
const langPair = match[1];
|
|
22
|
+
if (BERGAMOT_CJK_LANG_PAIRS.includes(langPair)) {
|
|
23
|
+
return {
|
|
24
|
+
srcVocabPath: path.join(dirPath, `srcvocab.${langPair}.spm`),
|
|
25
|
+
dstVocabPath: path.join(dirPath, `trgvocab.${langPair}.spm`)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const sharedPath = path.join(dirPath, `vocab.${langPair}.spm`);
|
|
29
|
+
return { srcVocabPath: sharedPath, dstVocabPath: sharedPath };
|
|
30
|
+
}
|
|
31
|
+
function createNmtModel(modelId, modelPath, nmtConfig, srcVocabPath, dstVocabPath, pivotModelPath, pivotSrcVocabPath, pivotDstVocabPath) {
|
|
32
|
+
const logger = createStreamLogger(modelId, ModelType.nmtcppTranslation);
|
|
33
|
+
registerAddonLogger(modelId, ModelType.nmtcppTranslation, logger);
|
|
34
|
+
const { mode, from, to, engine, beamsize, lengthpenalty, maxlength, repetitionpenalty, norepeatngramsize, temperature, topk, topp } = nmtConfig;
|
|
35
|
+
const files = {
|
|
36
|
+
model: modelPath,
|
|
37
|
+
...(srcVocabPath && { srcVocab: srcVocabPath }),
|
|
38
|
+
...(dstVocabPath && { dstVocab: dstVocabPath }),
|
|
39
|
+
...(pivotModelPath && { pivotModel: pivotModelPath }),
|
|
40
|
+
...(pivotSrcVocabPath && { pivotSrcVocab: pivotSrcVocabPath }),
|
|
41
|
+
...(pivotDstVocabPath && { pivotDstVocab: pivotDstVocabPath })
|
|
42
|
+
};
|
|
43
|
+
const generationParams = {
|
|
44
|
+
beamsize,
|
|
45
|
+
lengthpenalty,
|
|
46
|
+
maxlength,
|
|
47
|
+
repetitionpenalty,
|
|
48
|
+
norepeatngramsize,
|
|
49
|
+
temperature,
|
|
50
|
+
topk,
|
|
51
|
+
topp
|
|
52
|
+
};
|
|
53
|
+
const config = {
|
|
54
|
+
modelType: TranslationNmtcpp.ModelTypes[engine],
|
|
55
|
+
...generationParams,
|
|
56
|
+
...(nmtConfig.engine === 'Bergamot' && {
|
|
57
|
+
...(nmtConfig.normalize !== undefined && {
|
|
58
|
+
normalize: nmtConfig.normalize
|
|
59
|
+
}),
|
|
60
|
+
...(nmtConfig.pivotModel &&
|
|
61
|
+
pivotModelPath && {
|
|
62
|
+
pivotConfig: (() => {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
64
|
+
const { modelSrc, dstVocabSrc, srcVocabSrc, ...pivotGenConfig } = nmtConfig.pivotModel;
|
|
65
|
+
return pivotGenConfig;
|
|
66
|
+
})()
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
const model = new TranslationNmtcpp({
|
|
71
|
+
files,
|
|
72
|
+
params: { mode, srcLang: from, dstLang: to },
|
|
73
|
+
config,
|
|
74
|
+
logger,
|
|
75
|
+
opts: { stats: true }
|
|
76
|
+
});
|
|
77
|
+
return { model };
|
|
78
|
+
}
|
|
79
|
+
export const nmtPlugin = definePlugin({
|
|
80
|
+
modelType: ModelType.nmtcppTranslation,
|
|
81
|
+
displayName: 'NMT (nmtcpp)',
|
|
82
|
+
addonPackage: ADDON_NMT,
|
|
83
|
+
loadConfigSchema: nmtConfigBaseSchema,
|
|
84
|
+
async resolveConfig(cfg, ctx) {
|
|
85
|
+
const { srcVocabSrc, dstVocabSrc, pivotModel, ...nmtConfig } = cfg;
|
|
86
|
+
if (nmtConfig.engine !== 'Bergamot') {
|
|
87
|
+
return { config: nmtConfig };
|
|
88
|
+
}
|
|
89
|
+
const bergamotConfig = { ...nmtConfig, ...(pivotModel && { pivotModel }) };
|
|
90
|
+
return resolveBergamotVocab(bergamotConfig, ctx, srcVocabSrc, dstVocabSrc, pivotModel);
|
|
91
|
+
},
|
|
92
|
+
createModel(params) {
|
|
93
|
+
const nmtConfig = (params.modelConfig ?? {});
|
|
94
|
+
const artifacts = params.artifacts ?? {};
|
|
95
|
+
const derived = deriveColocatedBergamotVocabPaths(params.modelPath);
|
|
96
|
+
const srcVocabPath = artifacts['srcVocabPath'] ?? derived?.srcVocabPath;
|
|
97
|
+
const dstVocabPath = artifacts['dstVocabPath'] ?? derived?.dstVocabPath;
|
|
98
|
+
const pivotModelPath = artifacts['pivotModelPath'];
|
|
99
|
+
const pivotDerived = pivotModelPath ? deriveColocatedBergamotVocabPaths(pivotModelPath) : null;
|
|
100
|
+
const pivotSrcVocabPath = artifacts['pivotSrcVocabPath'] ?? pivotDerived?.srcVocabPath;
|
|
101
|
+
const pivotDstVocabPath = artifacts['pivotDstVocabPath'] ?? pivotDerived?.dstVocabPath;
|
|
102
|
+
const { model } = createNmtModel(params.modelId, params.modelPath, nmtConfig, srcVocabPath, dstVocabPath, pivotModelPath, pivotSrcVocabPath, pivotDstVocabPath);
|
|
103
|
+
return { model };
|
|
104
|
+
},
|
|
105
|
+
handlers: {
|
|
106
|
+
translate: defineHandler({
|
|
107
|
+
requestSchema: translateRequestSchema,
|
|
108
|
+
responseSchema: translateResponseSchema,
|
|
109
|
+
streaming: true,
|
|
110
|
+
// nmtcpp does not expose a cancel surface today — we fall
|
|
111
|
+
// back to soft-cancel (stop yielding, drop result, skip
|
|
112
|
+
// post-processing; the C++ work runs to completion).
|
|
113
|
+
cancel: { scope: 'none' },
|
|
114
|
+
handler: async function* (request) {
|
|
115
|
+
const stream = translate(request, request.requestId);
|
|
116
|
+
try {
|
|
117
|
+
let result = await stream.next();
|
|
118
|
+
while (!result.done) {
|
|
119
|
+
yield {
|
|
120
|
+
type: 'translate',
|
|
121
|
+
token: result.value
|
|
122
|
+
};
|
|
123
|
+
result = await stream.next();
|
|
124
|
+
}
|
|
125
|
+
const { modelExecutionMs, stats } = result.value;
|
|
126
|
+
yield attachModelExecutionMs({
|
|
127
|
+
type: 'translate',
|
|
128
|
+
token: '',
|
|
129
|
+
done: true,
|
|
130
|
+
...(stats && { stats })
|
|
131
|
+
}, modelExecutionMs);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
await stream.return?.(undefined);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
},
|
|
139
|
+
logging: {
|
|
140
|
+
module: nmtAddonLogging,
|
|
141
|
+
namespace: ModelType.nmtcppTranslation
|
|
142
|
+
}
|
|
143
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ModelSrcInput, type NmtConfig, type ResolveContext, type ResolveResult } from '../../../schemas/index.js';
|
|
2
|
+
export interface PivotModelConfig {
|
|
3
|
+
modelSrc: string;
|
|
4
|
+
srcVocabSrc?: ModelSrcInput;
|
|
5
|
+
dstVocabSrc?: ModelSrcInput;
|
|
6
|
+
}
|
|
7
|
+
export declare function buildBergamotVocabSources(basePath: string, langPair: string): {
|
|
8
|
+
srcVocabSrc: string;
|
|
9
|
+
dstVocabSrc: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function deriveBergamotVocabSources(modelSrc: string): {
|
|
12
|
+
srcVocabSrc: string;
|
|
13
|
+
dstVocabSrc: string;
|
|
14
|
+
} | null;
|
|
15
|
+
export declare function deriveBergamotRegistryVocabSources(modelSrc: string): {
|
|
16
|
+
srcVocabSrc: string;
|
|
17
|
+
dstVocabSrc: string;
|
|
18
|
+
} | null;
|
|
19
|
+
/**
|
|
20
|
+
* Resolves Bergamot vocab sources to absolute filesystem paths via the
|
|
21
|
+
* resolver context, optionally including a pivot model.
|
|
22
|
+
*
|
|
23
|
+
* For `registry://` sources with auto-derived vocabs, this skips per-vocab
|
|
24
|
+
* resolution because the companion-set download already colocates the vocabs
|
|
25
|
+
* next to the primary model under `sets/<setKey>/`. `createModel` then derives
|
|
26
|
+
* the colocated paths via `deriveColocatedBergamotVocabPaths`. This avoids a
|
|
27
|
+
* redundant flat-cache copy and sidesteps the dedup edge case in QVAC-18420
|
|
28
|
+
* where two directions of a bidirectional pair ship the same vocab blob under
|
|
29
|
+
* distinct registry paths and only one survives sha256 dedup.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveBergamotVocab(nmtConfig: NmtConfig, ctx: ResolveContext, srcVocabSrc: ModelSrcInput | undefined, dstVocabSrc: ModelSrcInput | undefined, pivotModel?: PivotModelConfig): Promise<ResolveResult<Record<string, unknown>>>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { BERGAMOT_CJK_LANG_PAIRS } from '../../../schemas/index.js';
|
|
2
|
+
import { ModelLoadFailedError } from '../../../errors/index.js';
|
|
3
|
+
export function buildBergamotVocabSources(basePath, langPair) {
|
|
4
|
+
if (BERGAMOT_CJK_LANG_PAIRS.includes(langPair)) {
|
|
5
|
+
return {
|
|
6
|
+
srcVocabSrc: `${basePath}srcvocab.${langPair}.spm`,
|
|
7
|
+
dstVocabSrc: `${basePath}trgvocab.${langPair}.spm`
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const sharedVocab = `${basePath}vocab.${langPair}.spm`;
|
|
11
|
+
return { srcVocabSrc: sharedVocab, dstVocabSrc: sharedVocab };
|
|
12
|
+
}
|
|
13
|
+
export function deriveBergamotVocabSources(modelSrc) {
|
|
14
|
+
const match = modelSrc.match(/^pear:\/\/([a-f0-9]+)\/model\.([a-z]+)\.intgemm\.alphas\.bin$/);
|
|
15
|
+
if (!match?.[1] || !match[2])
|
|
16
|
+
return null;
|
|
17
|
+
const basePath = `pear://${match[1]}/`;
|
|
18
|
+
const langPair = match[2];
|
|
19
|
+
return buildBergamotVocabSources(basePath, langPair);
|
|
20
|
+
}
|
|
21
|
+
export function deriveBergamotRegistryVocabSources(modelSrc) {
|
|
22
|
+
const match = modelSrc.match(/^(registry:\/\/.+\/)model\.([a-z]+)\.intgemm\.alphas\.bin$/);
|
|
23
|
+
if (!match?.[1] || !match[2])
|
|
24
|
+
return null;
|
|
25
|
+
const basePath = match[1];
|
|
26
|
+
const langPair = match[2];
|
|
27
|
+
return buildBergamotVocabSources(basePath, langPair);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolves Bergamot vocab sources to absolute filesystem paths via the
|
|
31
|
+
* resolver context, optionally including a pivot model.
|
|
32
|
+
*
|
|
33
|
+
* For `registry://` sources with auto-derived vocabs, this skips per-vocab
|
|
34
|
+
* resolution because the companion-set download already colocates the vocabs
|
|
35
|
+
* next to the primary model under `sets/<setKey>/`. `createModel` then derives
|
|
36
|
+
* the colocated paths via `deriveColocatedBergamotVocabPaths`. This avoids a
|
|
37
|
+
* redundant flat-cache copy and sidesteps the dedup edge case in QVAC-18420
|
|
38
|
+
* where two directions of a bidirectional pair ship the same vocab blob under
|
|
39
|
+
* distinct registry paths and only one survives sha256 dedup.
|
|
40
|
+
*/
|
|
41
|
+
export async function resolveBergamotVocab(nmtConfig, ctx, srcVocabSrc, dstVocabSrc, pivotModel) {
|
|
42
|
+
let srcSrc = srcVocabSrc;
|
|
43
|
+
let dstSrc = dstVocabSrc;
|
|
44
|
+
if (!srcSrc || !dstSrc) {
|
|
45
|
+
const derived = ctx.modelSrc.startsWith('pear://')
|
|
46
|
+
? deriveBergamotVocabSources(ctx.modelSrc)
|
|
47
|
+
: ctx.modelSrc.startsWith('registry://')
|
|
48
|
+
? deriveBergamotRegistryVocabSources(ctx.modelSrc)
|
|
49
|
+
: null;
|
|
50
|
+
if (derived) {
|
|
51
|
+
srcSrc = srcSrc ?? derived.srcVocabSrc;
|
|
52
|
+
dstSrc = dstSrc ?? derived.dstVocabSrc;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!srcSrc || !dstSrc) {
|
|
56
|
+
throw new ModelLoadFailedError('Bergamot requires srcVocabSrc and dstVocabSrc. Provide them in modelConfig or use a pear:// or registry:// model source for auto-derivation.');
|
|
57
|
+
}
|
|
58
|
+
if (!pivotModel) {
|
|
59
|
+
const modelIsRegistry = ctx.modelSrc.startsWith('registry://');
|
|
60
|
+
const vocabsAreDerived = !srcVocabSrc && !dstVocabSrc;
|
|
61
|
+
if (modelIsRegistry && vocabsAreDerived) {
|
|
62
|
+
return { config: nmtConfig };
|
|
63
|
+
}
|
|
64
|
+
const [srcVocabPath, dstVocabPath] = await Promise.all([
|
|
65
|
+
ctx.resolveModelPath(srcSrc),
|
|
66
|
+
ctx.resolveModelPath(dstSrc)
|
|
67
|
+
]);
|
|
68
|
+
return {
|
|
69
|
+
config: nmtConfig,
|
|
70
|
+
artifacts: { srcVocabPath, dstVocabPath }
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
let pivotSrcSrc = pivotModel.srcVocabSrc;
|
|
74
|
+
let pivotDstSrc = pivotModel.dstVocabSrc;
|
|
75
|
+
if (!pivotSrcSrc || !pivotDstSrc) {
|
|
76
|
+
const pivotDerived = pivotModel.modelSrc.startsWith('pear://')
|
|
77
|
+
? deriveBergamotVocabSources(pivotModel.modelSrc)
|
|
78
|
+
: pivotModel.modelSrc.startsWith('registry://')
|
|
79
|
+
? deriveBergamotRegistryVocabSources(pivotModel.modelSrc)
|
|
80
|
+
: null;
|
|
81
|
+
if (pivotDerived) {
|
|
82
|
+
pivotSrcSrc = pivotSrcSrc ?? pivotDerived.srcVocabSrc;
|
|
83
|
+
pivotDstSrc = pivotDstSrc ?? pivotDerived.dstVocabSrc;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!pivotSrcSrc || !pivotDstSrc) {
|
|
87
|
+
throw new ModelLoadFailedError('Bergamot pivot model requires srcVocabSrc and dstVocabSrc. Provide them in modelConfig or use a pear:// or registry:// model source for auto-derivation.');
|
|
88
|
+
}
|
|
89
|
+
const modelIsRegistry = ctx.modelSrc.startsWith('registry://');
|
|
90
|
+
const pivotIsRegistry = pivotModel.modelSrc.startsWith('registry://');
|
|
91
|
+
const primaryVocabsAreDerived = !srcVocabSrc && !dstVocabSrc;
|
|
92
|
+
const pivotVocabsAreDerived = !pivotModel.srcVocabSrc && !pivotModel.dstVocabSrc;
|
|
93
|
+
if (modelIsRegistry && pivotIsRegistry && primaryVocabsAreDerived && pivotVocabsAreDerived) {
|
|
94
|
+
const pivotModelPath = await ctx.resolveModelPath(pivotModel.modelSrc);
|
|
95
|
+
return { config: nmtConfig, artifacts: { pivotModelPath } };
|
|
96
|
+
}
|
|
97
|
+
const [srcVocabPath, dstVocabPath, pivotSrcVocabPath, pivotDstVocabPath, pivotModelPath] = await Promise.all([
|
|
98
|
+
ctx.resolveModelPath(srcSrc),
|
|
99
|
+
ctx.resolveModelPath(dstSrc),
|
|
100
|
+
ctx.resolveModelPath(pivotSrcSrc),
|
|
101
|
+
ctx.resolveModelPath(pivotDstSrc),
|
|
102
|
+
ctx.resolveModelPath(pivotModel.modelSrc)
|
|
103
|
+
]);
|
|
104
|
+
return {
|
|
105
|
+
config: nmtConfig,
|
|
106
|
+
artifacts: {
|
|
107
|
+
srcVocabPath,
|
|
108
|
+
dstVocabPath,
|
|
109
|
+
pivotSrcVocabPath,
|
|
110
|
+
pivotDstVocabPath,
|
|
111
|
+
pivotModelPath
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { type ParakeetConfig, type CreateModelParams, type PluginModelResult, type ResolveResult } from '../../../schemas/index.js';
|
|
2
|
+
export declare const parakeetPlugin: {
|
|
3
|
+
modelType: "parakeet-transcription";
|
|
4
|
+
displayName: string;
|
|
5
|
+
addonPackage: "@qvac/asr-ggml";
|
|
6
|
+
loadConfigSchema: import("zod").ZodObject<{
|
|
7
|
+
[x: string]: import("zod").ZodOptional<import("zod").ZodUnknown>;
|
|
8
|
+
}, import("zod/v4/core").$strict>;
|
|
9
|
+
resolveConfig(cfg: ParakeetConfig): Promise<ResolveResult<ParakeetConfig>>;
|
|
10
|
+
createModel(params: CreateModelParams): PluginModelResult;
|
|
11
|
+
handlers: {
|
|
12
|
+
transcribe: import("../../../schemas/index.js").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
13
|
+
modelId: import("zod").ZodString;
|
|
14
|
+
prompt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
15
|
+
metadata: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
16
|
+
audioChunk: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
17
|
+
type: import("zod").ZodLiteral<"base64">;
|
|
18
|
+
value: import("zod").ZodString;
|
|
19
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
20
|
+
type: import("zod").ZodLiteral<"filePath">;
|
|
21
|
+
value: import("zod").ZodString;
|
|
22
|
+
}, import("zod/v4/core").$strip>], "type">;
|
|
23
|
+
type: import("zod").ZodLiteral<"transcribe">;
|
|
24
|
+
requestId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
25
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
26
|
+
text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
27
|
+
done: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
28
|
+
stats: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
29
|
+
audioDuration: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
30
|
+
realTimeFactor: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
31
|
+
tokensPerSecond: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
32
|
+
totalTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
33
|
+
totalSegments: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
34
|
+
whisperEncodeTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
35
|
+
whisperDecodeTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
36
|
+
encoderTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
37
|
+
decoderTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
38
|
+
melSpecTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
39
|
+
backendDevice: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
40
|
+
backendId: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
41
|
+
gpuUnsupported: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
42
|
+
gpuMemTotalMb: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
43
|
+
gpuMemFreeMb: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
44
|
+
}, import("zod/v4/core").$strip>>;
|
|
45
|
+
error: import("zod").ZodOptional<import("zod").ZodString>;
|
|
46
|
+
segment: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
47
|
+
text: import("zod").ZodString;
|
|
48
|
+
startMs: import("zod").ZodNumber;
|
|
49
|
+
endMs: import("zod").ZodNumber;
|
|
50
|
+
append: import("zod").ZodBoolean;
|
|
51
|
+
id: import("zod").ZodNumber;
|
|
52
|
+
}, import("zod/v4/core").$strip>>;
|
|
53
|
+
vad: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
54
|
+
speaking: import("zod").ZodBoolean;
|
|
55
|
+
probability: import("zod").ZodNumber;
|
|
56
|
+
}, import("zod/v4/core").$strip>>;
|
|
57
|
+
endOfTurn: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
58
|
+
source: import("zod").ZodLiteral<"whisper">;
|
|
59
|
+
silenceDurationMs: import("zod").ZodNumber;
|
|
60
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
61
|
+
source: import("zod").ZodLiteral<"parakeet">;
|
|
62
|
+
}, import("zod/v4/core").$strip>], "source">>>;
|
|
63
|
+
type: import("zod").ZodLiteral<"transcribe">;
|
|
64
|
+
}, import("zod/v4/core").$strip>>;
|
|
65
|
+
transcribeStream: import("../../../schemas/index.js").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
66
|
+
modelId: import("zod").ZodString;
|
|
67
|
+
prompt: import("zod").ZodOptional<import("zod").ZodString>;
|
|
68
|
+
metadata: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
69
|
+
type: import("zod").ZodLiteral<"transcribeStream">;
|
|
70
|
+
emitVadEvents: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
71
|
+
endOfTurnSilenceMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
72
|
+
vadRunIntervalMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
73
|
+
parakeetStreamingConfig: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
74
|
+
chunkMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
75
|
+
historyMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
76
|
+
leftContextMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
77
|
+
rightLookaheadMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
78
|
+
emitPartials: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
79
|
+
emitEnergyVad: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
80
|
+
spkCacheEnable: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
81
|
+
spkCacheLen: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
82
|
+
fifoLen: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
83
|
+
chunkLeftContextMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
84
|
+
chunkRightContextMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
85
|
+
spkCacheUpdatePeriod: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
86
|
+
}, import("zod/v4/core").$strip>>;
|
|
87
|
+
requestId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
88
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
89
|
+
text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
90
|
+
done: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
91
|
+
stats: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
92
|
+
audioDuration: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
93
|
+
realTimeFactor: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
94
|
+
tokensPerSecond: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
95
|
+
totalTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
96
|
+
totalSegments: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
97
|
+
whisperEncodeTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
98
|
+
whisperDecodeTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
99
|
+
encoderTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
100
|
+
decoderTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
101
|
+
melSpecTime: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
102
|
+
backendDevice: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
103
|
+
backendId: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
104
|
+
gpuUnsupported: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
105
|
+
gpuMemTotalMb: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
106
|
+
gpuMemFreeMb: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
107
|
+
}, import("zod/v4/core").$strip>>;
|
|
108
|
+
error: import("zod").ZodOptional<import("zod").ZodString>;
|
|
109
|
+
segment: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
110
|
+
text: import("zod").ZodString;
|
|
111
|
+
startMs: import("zod").ZodNumber;
|
|
112
|
+
endMs: import("zod").ZodNumber;
|
|
113
|
+
append: import("zod").ZodBoolean;
|
|
114
|
+
id: import("zod").ZodNumber;
|
|
115
|
+
}, import("zod/v4/core").$strip>>;
|
|
116
|
+
vad: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
117
|
+
speaking: import("zod").ZodBoolean;
|
|
118
|
+
probability: import("zod").ZodNumber;
|
|
119
|
+
}, import("zod/v4/core").$strip>>;
|
|
120
|
+
endOfTurn: import("zod").ZodOptional<import("zod").ZodPreprocess<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
121
|
+
source: import("zod").ZodLiteral<"whisper">;
|
|
122
|
+
silenceDurationMs: import("zod").ZodNumber;
|
|
123
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
124
|
+
source: import("zod").ZodLiteral<"parakeet">;
|
|
125
|
+
}, import("zod/v4/core").$strip>], "source">>>;
|
|
126
|
+
type: import("zod").ZodLiteral<"transcribeStream">;
|
|
127
|
+
}, import("zod/v4/core").$strip>>;
|
|
128
|
+
};
|
|
129
|
+
logging: {
|
|
130
|
+
module: import("@qvac/asr-ggml/addonLogging").AddonLogging;
|
|
131
|
+
namespace: "@qvac/asr-ggml";
|
|
132
|
+
};
|
|
133
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import asrAddonLogging from '@qvac/asr-ggml/addonLogging';
|
|
2
|
+
import ASRGgml from '@qvac/asr-ggml';
|
|
3
|
+
import { definePlugin, defineHandler, defineDuplexHandler, transcribeRequestSchema, transcribeResponseSchema, transcribeStreamRequestSchema, transcribeStreamResponseSchema, ModelType, parakeetLoadConfigSchema, LEGACY_PARAKEET_ONNX_MODEL_CONFIG_FIELDS, ADDON_ASR } from '../../../schemas/index.js';
|
|
4
|
+
import { ModelLoadFailedError, TranscriptionFailedError, LegacyParakeetModelDeprecatedError } from '../../../errors/index.js';
|
|
5
|
+
import { transcribe, transcribeStream } from '../../../plugins/ops/transcribe.js';
|
|
6
|
+
import { attachModelExecutionMs } from '../../../profiling/model-execution.js';
|
|
7
|
+
import { buildParakeetEngineConfig } from '../../../plugins/builtin/asr-ggml/config.js';
|
|
8
|
+
import { createAsrModelLogger } from '../../../plugins/builtin/asr-ggml/logging.js';
|
|
9
|
+
function resolveParakeetConfig(cfg) {
|
|
10
|
+
const cfgRecord = cfg;
|
|
11
|
+
const legacyFields = LEGACY_PARAKEET_ONNX_MODEL_CONFIG_FIELDS.filter((name) => cfgRecord[name] !== undefined);
|
|
12
|
+
if (legacyFields.length > 0) {
|
|
13
|
+
throw new LegacyParakeetModelDeprecatedError(legacyFields);
|
|
14
|
+
}
|
|
15
|
+
return Promise.resolve({ config: cfg });
|
|
16
|
+
}
|
|
17
|
+
function createParakeetModel(params) {
|
|
18
|
+
const config = (params.modelConfig ?? {});
|
|
19
|
+
const modelPath = params.modelPath;
|
|
20
|
+
if (!modelPath) {
|
|
21
|
+
throw new ModelLoadFailedError('Parakeet requires a GGUF model source');
|
|
22
|
+
}
|
|
23
|
+
const logger = createAsrModelLogger(params.modelId, ModelType.parakeetTranscription);
|
|
24
|
+
const model = new ASRGgml({
|
|
25
|
+
files: { model: modelPath },
|
|
26
|
+
config: buildParakeetEngineConfig(config),
|
|
27
|
+
enableStats: true,
|
|
28
|
+
logger
|
|
29
|
+
});
|
|
30
|
+
return { model };
|
|
31
|
+
}
|
|
32
|
+
export const parakeetPlugin = definePlugin({
|
|
33
|
+
modelType: ModelType.parakeetTranscription,
|
|
34
|
+
displayName: 'Parakeet (NVIDIA NeMo GGML)',
|
|
35
|
+
addonPackage: ADDON_ASR,
|
|
36
|
+
loadConfigSchema: parakeetLoadConfigSchema,
|
|
37
|
+
resolveConfig(cfg) {
|
|
38
|
+
return resolveParakeetConfig(cfg);
|
|
39
|
+
},
|
|
40
|
+
createModel(params) {
|
|
41
|
+
return createParakeetModel(params);
|
|
42
|
+
},
|
|
43
|
+
handlers: {
|
|
44
|
+
transcribe: defineHandler({
|
|
45
|
+
requestSchema: transcribeRequestSchema,
|
|
46
|
+
responseSchema: transcribeResponseSchema,
|
|
47
|
+
streaming: true,
|
|
48
|
+
cancel: { scope: 'model', hard: true },
|
|
49
|
+
handler: async function* (request) {
|
|
50
|
+
if (request.metadata === true) {
|
|
51
|
+
throw new TranscriptionFailedError(`Parakeet transcription does not support metadata: true; only the whisper engine emits per-segment metadata. Use a whisper model to receive segments.`);
|
|
52
|
+
}
|
|
53
|
+
const stream = transcribe({
|
|
54
|
+
modelId: request.modelId,
|
|
55
|
+
audioChunk: request.audioChunk,
|
|
56
|
+
prompt: request.prompt
|
|
57
|
+
}, request.requestId);
|
|
58
|
+
try {
|
|
59
|
+
let result = await stream.next();
|
|
60
|
+
while (!result.done) {
|
|
61
|
+
yield {
|
|
62
|
+
type: 'transcribe',
|
|
63
|
+
text: result.value
|
|
64
|
+
};
|
|
65
|
+
result = await stream.next();
|
|
66
|
+
}
|
|
67
|
+
const { modelExecutionMs, stats } = result.value;
|
|
68
|
+
yield attachModelExecutionMs({
|
|
69
|
+
type: 'transcribe',
|
|
70
|
+
text: '',
|
|
71
|
+
done: true,
|
|
72
|
+
...(stats && { stats })
|
|
73
|
+
}, modelExecutionMs);
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
await stream.return?.(undefined);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
transcribeStream: defineDuplexHandler({
|
|
81
|
+
requestSchema: transcribeStreamRequestSchema,
|
|
82
|
+
responseSchema: transcribeStreamResponseSchema,
|
|
83
|
+
streaming: true,
|
|
84
|
+
duplex: true,
|
|
85
|
+
cancel: { scope: 'model', hard: true },
|
|
86
|
+
// TODO(QVAC-17869-followup): wire `AbortSignal` through the duplex
|
|
87
|
+
// handler signature so the handler learns about consumer disconnects
|
|
88
|
+
// without depending on `inputStream.end()` (which does not fire if the
|
|
89
|
+
// client drops packets while TCP stays alive). Under sustained slow
|
|
90
|
+
// consumers, `runStreaming` may buffer between the server generator and
|
|
91
|
+
// the duplex RPC writer — backpressure is not yet characterised. Pair
|
|
92
|
+
// the fix with request-lifecycle `cancel({ requestId })` routing.
|
|
93
|
+
handler: async function* (request, inputStream) {
|
|
94
|
+
if (request.metadata === true) {
|
|
95
|
+
throw new TranscriptionFailedError(`Parakeet transcribeStream does not support metadata: true; only the whisper engine emits per-segment metadata.`);
|
|
96
|
+
}
|
|
97
|
+
const streamOpts = {
|
|
98
|
+
...(request.parakeetStreamingConfig && {
|
|
99
|
+
parakeetStreamingConfig: request.parakeetStreamingConfig
|
|
100
|
+
})
|
|
101
|
+
};
|
|
102
|
+
const iterator = transcribeStream(request.modelId, inputStream, undefined, false, streamOpts, request.requestId);
|
|
103
|
+
for await (const value of iterator) {
|
|
104
|
+
if (typeof value === 'object' && value !== null && 'type' in value) {
|
|
105
|
+
if (value.type === 'endOfTurn') {
|
|
106
|
+
yield {
|
|
107
|
+
type: 'transcribeStream',
|
|
108
|
+
endOfTurn: { source: 'parakeet' }
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
yield {
|
|
114
|
+
type: 'transcribeStream',
|
|
115
|
+
text: value
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
yield {
|
|
119
|
+
type: 'transcribeStream',
|
|
120
|
+
text: '',
|
|
121
|
+
done: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
},
|
|
126
|
+
logging: {
|
|
127
|
+
module: asrAddonLogging,
|
|
128
|
+
namespace: ADDON_ASR
|
|
129
|
+
}
|
|
130
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getModel } from '../../../../runtime/model-registry.js';
|
|
2
|
+
import Buffer from 'bare-buffer';
|
|
3
|
+
export async function* diffusion(request) {
|
|
4
|
+
const model = getModel(request.modelId);
|
|
5
|
+
const init_image = request.init_image ? Buffer.from(request.init_image, 'base64') : undefined;
|
|
6
|
+
const init_images = request.init_images
|
|
7
|
+
? request.init_images.map((b64) => Buffer.from(b64, 'base64'))
|
|
8
|
+
: undefined;
|
|
9
|
+
const response = await model.run({
|
|
10
|
+
prompt: request.prompt,
|
|
11
|
+
negative_prompt: request.negative_prompt,
|
|
12
|
+
width: request.width,
|
|
13
|
+
height: request.height,
|
|
14
|
+
steps: request.steps,
|
|
15
|
+
cfg_scale: request.cfg_scale,
|
|
16
|
+
img_cfg_scale: request.img_cfg_scale ?? -1,
|
|
17
|
+
guidance: request.guidance,
|
|
18
|
+
sampling_method: request.sampling_method,
|
|
19
|
+
scheduler: request.scheduler,
|
|
20
|
+
seed: request.seed,
|
|
21
|
+
batch_count: request.batch_count,
|
|
22
|
+
vae_tiling: request.vae_tiling,
|
|
23
|
+
cache_preset: request.cache_preset,
|
|
24
|
+
init_image,
|
|
25
|
+
init_images,
|
|
26
|
+
increase_ref_index: request.increase_ref_index,
|
|
27
|
+
auto_resize_ref_image: request.auto_resize_ref_image,
|
|
28
|
+
strength: request.strength,
|
|
29
|
+
lora: request.lora,
|
|
30
|
+
upscale: request.upscale === false ? undefined : request.upscale
|
|
31
|
+
});
|
|
32
|
+
let outputIndex = 0;
|
|
33
|
+
for await (const chunk of response.iterate()) {
|
|
34
|
+
if (chunk instanceof Uint8Array) {
|
|
35
|
+
yield {
|
|
36
|
+
type: 'diffusionStream',
|
|
37
|
+
data: Buffer.from(chunk).toString('base64'),
|
|
38
|
+
outputIndex: outputIndex++
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else if (typeof chunk === 'string') {
|
|
42
|
+
try {
|
|
43
|
+
const tick = JSON.parse(chunk);
|
|
44
|
+
if ('step' in tick) {
|
|
45
|
+
yield {
|
|
46
|
+
type: 'diffusionStream',
|
|
47
|
+
step: tick['step'],
|
|
48
|
+
totalSteps: tick['total'],
|
|
49
|
+
elapsedMs: tick['elapsed_ms']
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Non-JSON string output — skip
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const responseWithStats = response;
|
|
59
|
+
yield {
|
|
60
|
+
type: 'diffusionStream',
|
|
61
|
+
done: true,
|
|
62
|
+
stats: responseWithStats.stats ?? undefined
|
|
63
|
+
};
|
|
64
|
+
}
|