@qvac/sdk 0.10.2 → 0.12.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/NOTICE +1455 -29
- package/README.md +2 -0
- package/dist/client/api/cancel.d.ts +24 -32
- package/dist/client/api/cancel.js +58 -31
- package/dist/client/api/classify.d.ts +23 -0
- package/dist/client/api/classify.js +43 -0
- package/dist/client/api/client-request-id.d.ts +17 -0
- package/dist/client/api/client-request-id.js +27 -0
- package/dist/client/api/completion-stream.d.ts +1 -1
- package/dist/client/api/completion-stream.js +34 -3
- package/dist/client/api/diffusion.d.ts +46 -0
- package/dist/client/api/diffusion.js +50 -1
- package/dist/client/api/download-asset.d.ts +12 -2
- package/dist/client/api/download-asset.js +21 -3
- package/dist/client/api/embed.d.ts +8 -4
- package/dist/client/api/embed.js +14 -1
- package/dist/client/api/get-model-info.d.ts +1 -1
- package/dist/client/api/index.d.ts +5 -0
- package/dist/client/api/index.js +5 -0
- package/dist/client/api/load-model.d.ts +12 -4
- package/dist/client/api/load-model.js +49 -2
- package/dist/client/api/rag.d.ts +9 -3
- package/dist/client/api/rag.js +23 -3
- package/dist/client/api/transcribe.d.ts +23 -8
- package/dist/client/api/transcribe.js +69 -4
- package/dist/client/api/unload-model.d.ts +5 -2
- package/dist/client/api/unload-model.js +9 -4
- package/dist/client/api/upscale.d.ts +45 -0
- package/dist/client/api/upscale.js +99 -0
- package/dist/client/api/video.d.ts +64 -0
- package/dist/client/api/video.js +147 -0
- package/dist/client/api/vla-helpers.d.ts +45 -0
- package/dist/client/api/vla-helpers.js +130 -0
- package/dist/client/api/vla.d.ts +65 -0
- package/dist/client/api/vla.js +109 -0
- package/dist/client/config-loader/resolve-config.node.d.ts +16 -0
- package/dist/client/config-loader/resolve-config.node.js +77 -23
- package/dist/client/plugins-factory.d.ts +8 -0
- package/dist/client/plugins-factory.js +10 -0
- package/dist/client/rpc/bare-client.js +62 -66
- package/dist/client/rpc/ensure-worker-ready.d.ts +9 -0
- package/dist/client/rpc/ensure-worker-ready.js +17 -0
- package/dist/client/rpc/expo-rpc-client.js +2 -1
- package/dist/client/rpc/node-rpc-client.js +22 -8
- package/dist/client/rpc/rpc-client.d.ts +2 -2
- package/dist/client/rpc/rpc-client.js +10 -4
- package/dist/client/rpc/rpc-error.d.ts +9 -0
- package/dist/client/rpc/rpc-error.js +105 -0
- package/dist/commands/bundle/bare-pack.d.ts +13 -0
- package/dist/commands/bundle/bare-pack.js +54 -0
- package/dist/commands/bundle/constants.d.ts +7 -0
- package/dist/commands/bundle/constants.js +23 -0
- package/dist/commands/bundle/entry-gen.d.ts +2 -0
- package/dist/commands/bundle/entry-gen.js +48 -0
- package/dist/commands/bundle/index.d.ts +20 -0
- package/dist/commands/bundle/index.js +141 -0
- package/dist/commands/bundle/manifest.d.ts +21 -0
- package/dist/commands/bundle/manifest.js +193 -0
- package/dist/commands/bundle/plugins.d.ts +9 -0
- package/dist/commands/bundle/plugins.js +51 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/verify/abi.d.ts +52 -0
- package/dist/commands/verify/abi.js +125 -0
- package/dist/commands/verify/addon-source.d.ts +43 -0
- package/dist/commands/verify/addon-source.js +75 -0
- package/dist/commands/verify/bundle-source.d.ts +12 -0
- package/dist/commands/verify/bundle-source.js +53 -0
- package/dist/commands/verify/index.d.ts +59 -0
- package/dist/commands/verify/index.js +371 -0
- package/dist/commands/verify/node-modules-source.d.ts +11 -0
- package/dist/commands/verify/node-modules-source.js +76 -0
- package/dist/commands/verify/prebuilds.d.ts +15 -0
- package/dist/commands/verify/prebuilds.js +39 -0
- package/dist/examples/cancel-by-request-id.d.ts +38 -0
- package/dist/examples/cancel-by-request-id.js +103 -0
- package/dist/examples/classification/classify-image.d.ts +2 -0
- package/dist/examples/classification/classify-image.js +23 -0
- package/dist/examples/diffusion-esrgan-upscale.d.ts +2 -0
- package/dist/examples/diffusion-esrgan-upscale.js +78 -0
- package/dist/examples/diffusion-txt2vid.d.ts +2 -0
- package/dist/examples/diffusion-txt2vid.js +81 -0
- package/dist/examples/download-with-cancel.js +10 -10
- package/dist/examples/embed-multi-gpu.d.ts +2 -0
- package/dist/examples/embed-multi-gpu.js +46 -0
- package/dist/examples/llamacpp-multi-gpu.d.ts +2 -0
- package/dist/examples/llamacpp-multi-gpu.js +57 -0
- package/dist/examples/plugins.js +3 -7
- package/dist/examples/rag/rag-hyperdb/cancellation.js +20 -17
- package/dist/examples/tools/llamacpp-tools-gemma4.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-gemma4.js +73 -0
- package/dist/examples/tools/llamacpp-tools-qwen35.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-qwen35.js +69 -0
- package/dist/examples/transcription/parakeet-ctc-filesystem.js +18 -12
- package/dist/examples/transcription/parakeet-microphone-record.js +7 -12
- package/dist/examples/transcription/parakeet-microphone-stream.d.ts +2 -0
- package/dist/examples/transcription/parakeet-microphone-stream.js +79 -0
- package/dist/examples/transcription/parakeet-sortformer-streaming.d.ts +2 -0
- package/dist/examples/transcription/parakeet-sortformer-streaming.js +121 -0
- package/dist/examples/transcription/parakeet-sortformer.js +58 -55
- package/dist/examples/transcription/parakeet-tdt-filesystem.js +18 -15
- package/dist/examples/transcription/whispercpp-microphone-conversation.d.ts +2 -0
- package/dist/examples/transcription/whispercpp-microphone-conversation.js +107 -0
- package/dist/examples/tts/chatterbox.js +7 -16
- package/dist/examples/tts/llm-to-tts-streaming.js +3 -10
- package/dist/examples/tts/supertonic-multilingual.js +4 -12
- package/dist/examples/tts/supertonic.js +5 -12
- package/dist/examples/vla-smolvla.d.ts +2 -0
- package/dist/examples/vla-smolvla.js +75 -0
- package/dist/examples/voice-assistant/voice-assistant.js +3 -10
- package/dist/expo/plugins/find-in-ancestor-node-modules.d.ts +14 -0
- package/dist/expo/plugins/find-in-ancestor-node-modules.js +24 -0
- package/dist/expo/plugins/get-project-root.d.ts +22 -0
- package/dist/expo/plugins/get-project-root.js +23 -0
- package/dist/expo/plugins/index.d.ts +4 -0
- package/dist/expo/plugins/index.js +4 -0
- package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +9 -2
- package/dist/expo/plugins/resolve-sdk-package-dir.js +38 -11
- package/dist/expo/plugins/withDeviceInfo.js +2 -1
- package/dist/expo/plugins/withMobileBundle.d.ts +5 -4
- package/dist/expo/plugins/withMobileBundle.js +42 -58
- package/dist/index.d.ts +6 -2
- package/dist/index.js +23 -2
- package/dist/models/registry/models.d.ts +3725 -514
- package/dist/models/registry/models.js +7269 -3910
- package/dist/models/update-models/naming.js +22 -8
- package/dist/pear/pre.d.ts +3 -0
- package/dist/pear/pre.js +9 -2
- package/dist/schemas/cancel.d.ts +172 -28
- package/dist/schemas/cancel.js +120 -19
- package/dist/schemas/classification.d.ts +53 -0
- package/dist/schemas/classification.js +33 -0
- package/dist/schemas/common.d.ts +860 -1379
- package/dist/schemas/common.js +8 -1
- package/dist/schemas/completion-event.d.ts +17 -0
- package/dist/schemas/completion-event.js +12 -1
- package/dist/schemas/completion-stream.d.ts +16 -1
- package/dist/schemas/completion-stream.js +25 -7
- package/dist/schemas/download-asset.d.ts +25 -9
- package/dist/schemas/download-asset.js +17 -6
- package/dist/schemas/embed.d.ts +1 -0
- package/dist/schemas/embed.js +5 -0
- package/dist/schemas/engine-addon-map.d.ts +3 -0
- package/dist/schemas/engine-addon-map.js +18 -5
- package/dist/schemas/error.d.ts +31 -0
- package/dist/schemas/error.js +29 -1
- package/dist/schemas/finetune.d.ts +2 -0
- package/dist/schemas/finetune.js +5 -0
- package/dist/schemas/get-model-info.d.ts +10 -6
- package/dist/schemas/get-model-info.js +2 -0
- package/dist/schemas/index.d.ts +3 -0
- package/dist/schemas/index.js +3 -0
- package/dist/schemas/llamacpp-config.d.ts +64 -8
- package/dist/schemas/llamacpp-config.js +12 -0
- package/dist/schemas/load-model.d.ts +4644 -8605
- package/dist/schemas/load-model.js +90 -7
- package/dist/schemas/model-src-utils.d.ts +34 -14
- package/dist/schemas/model-types.d.ts +54 -14
- package/dist/schemas/model-types.js +28 -5
- package/dist/schemas/ocr.d.ts +8 -3
- package/dist/schemas/plugin.d.ts +60 -6
- package/dist/schemas/plugin.js +31 -5
- package/dist/schemas/rag.d.ts +9 -0
- package/dist/schemas/rag.js +17 -9
- package/dist/schemas/registry.d.ts +74 -30
- package/dist/schemas/registry.js +5 -0
- package/dist/schemas/reload-config.d.ts +34 -14
- package/dist/schemas/sdcpp-config.d.ts +445 -16
- package/dist/schemas/sdcpp-config.js +387 -26
- package/dist/schemas/sdk-config.d.ts +2431 -2723
- package/dist/schemas/sdk-config.js +16 -1
- package/dist/schemas/sdk-errors-client.d.ts +6 -0
- package/dist/schemas/sdk-errors-client.js +31 -1
- package/dist/schemas/sdk-errors-server.d.ts +8 -1
- package/dist/schemas/sdk-errors-server.js +45 -5
- package/dist/schemas/text-to-speech.d.ts +81 -698
- package/dist/schemas/text-to-speech.js +46 -19
- package/dist/schemas/transcription-config.d.ts +40 -229
- package/dist/schemas/transcription-config.js +76 -15
- package/dist/schemas/transcription.d.ts +108 -2
- package/dist/schemas/transcription.js +81 -0
- package/dist/schemas/translate.d.ts +2 -0
- package/dist/schemas/translate.js +13 -2
- package/dist/schemas/translation-config.d.ts +90 -40
- package/dist/schemas/unload-model.d.ts +2 -1
- package/dist/schemas/unload-model.js +4 -1
- package/dist/schemas/vla.d.ts +87 -0
- package/dist/schemas/vla.js +108 -0
- package/dist/scripts/run-unit-tests.js +22 -3
- package/dist/server/bare/ops/cancel.d.ts +27 -1
- package/dist/server/bare/ops/cancel.js +36 -10
- package/dist/server/bare/ops/embed.d.ts +3 -3
- package/dist/server/bare/ops/embed.js +144 -28
- package/dist/server/bare/ops/kv-cache-utils.d.ts +0 -7
- package/dist/server/bare/ops/kv-cache-utils.js +8 -47
- package/dist/server/bare/ops/transcribe.d.ts +11 -5
- package/dist/server/bare/ops/transcribe.js +230 -50
- package/dist/server/bare/ops/translate.d.ts +1 -1
- package/dist/server/bare/ops/translate.js +197 -88
- package/dist/server/bare/plugins/ggml-classification/ops/classify.d.ts +6 -0
- package/dist/server/bare/plugins/ggml-classification/ops/classify.js +30 -0
- package/dist/server/bare/plugins/ggml-classification/plugin.d.ts +32 -0
- package/dist/server/bare/plugins/ggml-classification/plugin.js +55 -0
- package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.d.ts +3 -0
- package/dist/server/bare/plugins/ggml-vla/ops/vla-hparams.js +12 -0
- package/dist/server/bare/plugins/ggml-vla/ops/vla-run.d.ts +3 -0
- package/dist/server/bare/plugins/ggml-vla/ops/vla-run.js +75 -0
- package/dist/server/bare/plugins/ggml-vla/plugin.d.ts +54 -0
- package/dist/server/bare/plugins/ggml-vla/plugin.js +57 -0
- package/dist/server/bare/plugins/index.d.ts +3 -1
- package/dist/server/bare/plugins/index.js +3 -1
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +12 -3
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +173 -172
- package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.d.ts +29 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/context-overflow.js +65 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +125 -21
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +154 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +448 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +21 -73
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +18 -101
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +36 -3
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +183 -85
- package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +10 -0
- package/dist/server/bare/plugins/llamacpp-completion/transform.js +34 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +7 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -1
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +42 -15
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +5 -1
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +8 -3
- package/dist/server/bare/plugins/onnx-ocr/plugin.js +3 -0
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +73 -244
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +68 -96
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +8 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +3 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +40 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.d.ts +3 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/video.js +199 -0
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +288 -15
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +150 -7
- package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.js +2 -15
- package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.js +2 -1
- package/dist/server/bare/plugins/tts-ggml/plugin.d.ts +75 -0
- package/dist/server/bare/plugins/tts-ggml/plugin.js +189 -0
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +47 -3
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +61 -14
- package/dist/server/bare/rag-hyperdb/index.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/index.js +1 -1
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +26 -4
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +65 -28
- package/dist/server/bare/registry/model-config-utils.js +7 -0
- package/dist/server/bare/runtime/disposable-scope.d.ts +36 -0
- package/dist/server/bare/runtime/disposable-scope.js +69 -0
- package/dist/server/bare/runtime/index.d.ts +8 -0
- package/dist/server/bare/runtime/index.js +3 -0
- package/dist/server/bare/runtime/request-context.d.ts +49 -0
- package/dist/server/bare/runtime/request-context.js +1 -0
- package/dist/server/bare/runtime/request-id.d.ts +12 -0
- package/dist/server/bare/runtime/request-id.js +14 -0
- package/dist/server/bare/runtime/request-registry-singleton.d.ts +4 -0
- package/dist/server/bare/runtime/request-registry-singleton.js +27 -0
- package/dist/server/bare/runtime/request-registry.d.ts +136 -0
- package/dist/server/bare/runtime/request-registry.js +297 -0
- package/dist/server/bare/runtime/with-request-context.d.ts +22 -0
- package/dist/server/bare/runtime/with-request-context.js +53 -0
- package/dist/server/bare/runtime-lifecycle.js +9 -9
- package/dist/server/bare/types/addon-responses.d.ts +12 -1
- package/dist/server/env.js +4 -1
- package/dist/server/plugins/index.d.ts +1 -1
- package/dist/server/plugins/index.js +1 -1
- package/dist/server/plugins/registry.d.ts +1 -0
- package/dist/server/plugins/registry.js +5 -0
- package/dist/server/rpc/handler-registry.js +30 -7
- package/dist/server/rpc/handler-selection.d.ts +9 -0
- package/dist/server/rpc/handler-selection.js +14 -0
- package/dist/server/rpc/handler-utils.js +5 -13
- package/dist/server/rpc/handlers/cancel-delegated.js +28 -31
- package/dist/server/rpc/handlers/cancelHandler.d.ts +30 -1
- package/dist/server/rpc/handlers/cancelHandler.js +54 -22
- package/dist/server/rpc/handlers/classify.d.ts +3 -0
- package/dist/server/rpc/handlers/classify.js +4 -0
- package/dist/server/rpc/handlers/delete-cache.d.ts +9 -0
- package/dist/server/rpc/handlers/delete-cache.js +13 -15
- package/dist/server/rpc/handlers/download-asset.js +133 -40
- package/dist/server/rpc/handlers/index.d.ts +4 -0
- package/dist/server/rpc/handlers/index.js +4 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +60 -2
- package/dist/server/rpc/handlers/load-model/download-manager.js +141 -8
- package/dist/server/rpc/handlers/load-model/handler.js +216 -98
- package/dist/server/rpc/handlers/load-model/http.js +3 -3
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +1 -1
- package/dist/server/rpc/handlers/load-model/registry.js +1 -1
- package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +20 -1
- package/dist/server/rpc/handlers/load-model/resolve-session.js +6 -5
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -2
- package/dist/server/rpc/handlers/load-model/resolve.js +18 -6
- package/dist/server/rpc/handlers/load-model/types.d.ts +24 -0
- package/dist/server/rpc/handlers/rag.js +133 -15
- package/dist/server/rpc/handlers/upscale-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/upscale-stream.js +4 -0
- package/dist/server/rpc/handlers/video-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/video-stream.js +4 -0
- package/dist/server/rpc/profiling/operation-metrics.js +23 -0
- package/dist/server/utils/completion-normalizer.js +8 -0
- package/dist/server/utils/config-transform.js +1 -1
- package/dist/server/utils/tools/dialect.js +4 -0
- package/dist/server/utils/tools/parser.js +16 -1
- package/dist/server/utils/tools/parsers/gemma4native.d.ts +4 -0
- package/dist/server/utils/tools/parsers/gemma4native.js +60 -0
- package/dist/server/utils/tools/parsers/qwen35.d.ts +4 -0
- package/dist/server/utils/tools/parsers/qwen35.js +120 -0
- package/dist/server/worker.js +14 -11
- package/dist/utils/aggregate-events.d.ts +9 -0
- package/dist/utils/aggregate-events.js +18 -3
- package/dist/utils/decorate-promise.d.ts +34 -0
- package/dist/utils/decorate-promise.js +35 -0
- package/dist/utils/errors-client.d.ts +18 -0
- package/dist/utils/errors-client.js +31 -0
- package/dist/utils/errors-server.d.ts +115 -2
- package/dist/utils/errors-server.js +148 -3
- package/package.json +68 -77
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +0 -490
- package/dist/server/bare/plugins/onnx-tts/plugin.js +0 -266
- package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +0 -14
- package/dist/server/bare/plugins/onnx-tts/wav-helper.js +0 -107
- /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech-stream.d.ts +0 -0
- /package/dist/server/bare/plugins/{onnx-tts → tts-ggml}/ops/text-to-speech.d.ts +0 -0
|
@@ -1,96 +1,33 @@
|
|
|
1
1
|
import parakeetAddonLogging from "@qvac/transcription-parakeet/addonLogging.js";
|
|
2
2
|
import TranscriptionParakeet, {} from "@qvac/transcription-parakeet";
|
|
3
|
-
import { definePlugin, defineHandler, transcribeRequestSchema, transcribeResponseSchema, ModelType,
|
|
3
|
+
import { definePlugin, defineHandler, defineDuplexHandler, transcribeRequestSchema, transcribeResponseSchema, transcribeStreamRequestSchema, transcribeStreamResponseSchema, ModelType, parakeetLoadConfigSchema, LEGACY_PARAKEET_ONNX_MODEL_CONFIG_FIELDS, ADDON_PARAKEET, } from "../../../../schemas/index.js";
|
|
4
4
|
import { createStreamLogger, registerAddonLogger } from "../../../../logging/index.js";
|
|
5
|
-
import { ModelLoadFailedError,
|
|
6
|
-
import { transcribe } from "../../ops/transcribe.js";
|
|
5
|
+
import { ModelLoadFailedError, TranscriptionFailedError, LegacyParakeetModelDeprecatedError, } from "../../../../utils/errors-server.js";
|
|
6
|
+
import { transcribe, transcribeStream } from "../../ops/transcribe.js";
|
|
7
7
|
import { attachModelExecutionMs } from "../../../../profiling/model-execution.js";
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
!parakeetPreprocessorSrc) {
|
|
14
|
-
throw new ParakeetArtifactsRequiredError("TDT requires: parakeetEncoderSrc, parakeetDecoderSrc, parakeetVocabSrc, parakeetPreprocessorSrc");
|
|
8
|
+
function resolveParakeetConfig(cfg) {
|
|
9
|
+
const cfgRecord = cfg;
|
|
10
|
+
const legacyFields = LEGACY_PARAKEET_ONNX_MODEL_CONFIG_FIELDS.filter((name) => cfgRecord[name] !== undefined);
|
|
11
|
+
if (legacyFields.length > 0) {
|
|
12
|
+
throw new LegacyParakeetModelDeprecatedError(legacyFields);
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
const [encoderPath, encoderDataPath, decoderPath, vocabPath, preprocessorPath,] = await Promise.all([
|
|
18
|
-
resolve(parakeetEncoderSrc),
|
|
19
|
-
parakeetEncoderDataSrc ? resolve(parakeetEncoderDataSrc) : undefined,
|
|
20
|
-
resolve(parakeetDecoderSrc),
|
|
21
|
-
resolve(parakeetVocabSrc),
|
|
22
|
-
resolve(parakeetPreprocessorSrc),
|
|
23
|
-
]);
|
|
24
|
-
return {
|
|
25
|
-
config: cfg,
|
|
26
|
-
artifacts: {
|
|
27
|
-
encoder: encoderPath,
|
|
28
|
-
...(encoderDataPath !== undefined && { encoderData: encoderDataPath }),
|
|
29
|
-
...(decoderPath !== undefined && { decoder: decoderPath }),
|
|
30
|
-
...(vocabPath !== undefined && { vocab: vocabPath }),
|
|
31
|
-
...(preprocessorPath !== undefined && { preprocessor: preprocessorPath }),
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
async function resolveCtcConfig(cfg, ctx) {
|
|
36
|
-
const { parakeetCtcModelSrc, parakeetCtcModelDataSrc, parakeetTokenizerSrc } = cfg;
|
|
37
|
-
if (!parakeetCtcModelSrc || !parakeetTokenizerSrc) {
|
|
38
|
-
throw new ParakeetArtifactsRequiredError("CTC requires: parakeetCtcModelSrc, parakeetTokenizerSrc");
|
|
39
|
-
}
|
|
40
|
-
const resolve = ctx.resolveModelPath;
|
|
41
|
-
const [ctcModelPath, ctcModelDataPath, tokenizerPath] = await Promise.all([
|
|
42
|
-
resolve(parakeetCtcModelSrc),
|
|
43
|
-
parakeetCtcModelDataSrc ? resolve(parakeetCtcModelDataSrc) : undefined,
|
|
44
|
-
resolve(parakeetTokenizerSrc),
|
|
45
|
-
]);
|
|
46
|
-
return {
|
|
47
|
-
config: cfg,
|
|
48
|
-
artifacts: {
|
|
49
|
-
model: ctcModelPath,
|
|
50
|
-
...(ctcModelDataPath !== undefined && { modelData: ctcModelDataPath }),
|
|
51
|
-
...(tokenizerPath !== undefined && { tokenizer: tokenizerPath }),
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
async function resolveSortformerConfig(cfg, ctx) {
|
|
56
|
-
const { parakeetSortformerSrc } = cfg;
|
|
57
|
-
if (!parakeetSortformerSrc) {
|
|
58
|
-
throw new ParakeetArtifactsRequiredError("Sortformer requires: parakeetSortformerSrc");
|
|
59
|
-
}
|
|
60
|
-
const resolve = ctx.resolveModelPath;
|
|
61
|
-
const sortformerPath = await resolve(parakeetSortformerSrc);
|
|
62
|
-
return {
|
|
63
|
-
config: cfg,
|
|
64
|
-
artifacts: {
|
|
65
|
-
...(sortformerPath !== undefined && { sortformer: sortformerPath }),
|
|
66
|
-
},
|
|
67
|
-
};
|
|
14
|
+
return Promise.resolve({ config: cfg });
|
|
68
15
|
}
|
|
69
|
-
function createParakeetModel(params
|
|
16
|
+
function createParakeetModel(params) {
|
|
70
17
|
const config = (params.modelConfig ?? {});
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!primaryPath) {
|
|
75
|
-
throw new ModelLoadFailedError(`Parakeet ${modelType} requires a model source`);
|
|
18
|
+
const modelPath = params.modelPath;
|
|
19
|
+
if (!modelPath) {
|
|
20
|
+
throw new ModelLoadFailedError("Parakeet requires a GGUF model source");
|
|
76
21
|
}
|
|
77
22
|
const logger = createStreamLogger(params.modelId, ModelType.parakeetTranscription);
|
|
78
23
|
registerAddonLogger(params.modelId, ModelType.parakeetTranscription, logger);
|
|
79
24
|
const files = {
|
|
80
|
-
|
|
81
|
-
...artifacts,
|
|
25
|
+
model: modelPath,
|
|
82
26
|
};
|
|
27
|
+
const parakeetConfig = Object.fromEntries(Object.entries(config).filter(([, value]) => value !== undefined));
|
|
83
28
|
const addonConfig = {
|
|
84
29
|
enableStats: true,
|
|
85
|
-
parakeetConfig
|
|
86
|
-
modelType,
|
|
87
|
-
maxThreads: config.maxThreads,
|
|
88
|
-
useGPU: config.useGPU,
|
|
89
|
-
sampleRate: config.sampleRate,
|
|
90
|
-
channels: config.channels,
|
|
91
|
-
captionEnabled: config.captionEnabled,
|
|
92
|
-
timestampsEnabled: config.timestampsEnabled,
|
|
93
|
-
},
|
|
30
|
+
parakeetConfig,
|
|
94
31
|
};
|
|
95
32
|
const model = new TranscriptionParakeet({
|
|
96
33
|
files,
|
|
@@ -101,31 +38,21 @@ function createParakeetModel(params, primaryFileKey) {
|
|
|
101
38
|
}
|
|
102
39
|
export const parakeetPlugin = definePlugin({
|
|
103
40
|
modelType: ModelType.parakeetTranscription,
|
|
104
|
-
displayName: "Parakeet (NVIDIA NeMo
|
|
41
|
+
displayName: "Parakeet (NVIDIA NeMo GGML)",
|
|
105
42
|
addonPackage: ADDON_PARAKEET,
|
|
106
|
-
loadConfigSchema:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const modelType = cfg.modelType ?? "tdt";
|
|
110
|
-
if (modelType === "ctc")
|
|
111
|
-
return resolveCtcConfig(cfg, ctx);
|
|
112
|
-
if (modelType === "sortformer")
|
|
113
|
-
return resolveSortformerConfig(cfg, ctx);
|
|
114
|
-
return resolveTdtConfig(cfg, ctx);
|
|
43
|
+
loadConfigSchema: parakeetLoadConfigSchema,
|
|
44
|
+
resolveConfig(cfg) {
|
|
45
|
+
return resolveParakeetConfig(cfg);
|
|
115
46
|
},
|
|
116
47
|
createModel(params) {
|
|
117
|
-
|
|
118
|
-
if (modelType === "ctc")
|
|
119
|
-
return createParakeetModel(params, "model");
|
|
120
|
-
if (modelType === "sortformer")
|
|
121
|
-
return createParakeetModel(params, "sortformer");
|
|
122
|
-
return createParakeetModel(params, "encoder");
|
|
48
|
+
return createParakeetModel(params);
|
|
123
49
|
},
|
|
124
50
|
handlers: {
|
|
125
51
|
transcribe: defineHandler({
|
|
126
52
|
requestSchema: transcribeRequestSchema,
|
|
127
53
|
responseSchema: transcribeResponseSchema,
|
|
128
54
|
streaming: true,
|
|
55
|
+
cancel: { scope: "model", hard: true },
|
|
129
56
|
handler: async function* (request) {
|
|
130
57
|
if (request.metadata === true) {
|
|
131
58
|
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.`);
|
|
@@ -134,7 +61,7 @@ export const parakeetPlugin = definePlugin({
|
|
|
134
61
|
modelId: request.modelId,
|
|
135
62
|
audioChunk: request.audioChunk,
|
|
136
63
|
prompt: request.prompt,
|
|
137
|
-
});
|
|
64
|
+
}, request.requestId);
|
|
138
65
|
try {
|
|
139
66
|
let result = await stream.next();
|
|
140
67
|
while (!result.done) {
|
|
@@ -157,6 +84,51 @@ export const parakeetPlugin = definePlugin({
|
|
|
157
84
|
}
|
|
158
85
|
},
|
|
159
86
|
}),
|
|
87
|
+
transcribeStream: defineDuplexHandler({
|
|
88
|
+
requestSchema: transcribeStreamRequestSchema,
|
|
89
|
+
responseSchema: transcribeStreamResponseSchema,
|
|
90
|
+
streaming: true,
|
|
91
|
+
duplex: true,
|
|
92
|
+
cancel: { scope: "model", hard: true },
|
|
93
|
+
// TODO(QVAC-17869-followup): wire `AbortSignal` through the duplex
|
|
94
|
+
// handler signature so the worker learns about consumer disconnects
|
|
95
|
+
// without depending on `inputStream.end()` (which does not fire if the
|
|
96
|
+
// client drops packets while TCP stays alive). Under sustained slow
|
|
97
|
+
// consumers, `runStreaming` may buffer between the server generator and
|
|
98
|
+
// the duplex RPC writer — backpressure is not yet characterised. Pair
|
|
99
|
+
// the fix with request-lifecycle `cancel({ requestId })` routing.
|
|
100
|
+
handler: async function* (request, inputStream) {
|
|
101
|
+
if (request.metadata === true) {
|
|
102
|
+
throw new TranscriptionFailedError(`Parakeet transcribeStream does not support metadata: true; only the whisper engine emits per-segment metadata.`);
|
|
103
|
+
}
|
|
104
|
+
const streamOpts = {
|
|
105
|
+
...(request.parakeetStreamingConfig && {
|
|
106
|
+
parakeetStreamingConfig: request.parakeetStreamingConfig,
|
|
107
|
+
}),
|
|
108
|
+
};
|
|
109
|
+
const iterator = transcribeStream(request.modelId, inputStream, undefined, false, streamOpts, request.requestId);
|
|
110
|
+
for await (const value of iterator) {
|
|
111
|
+
if (typeof value === "object" && value !== null && "type" in value) {
|
|
112
|
+
if (value.type === "endOfTurn") {
|
|
113
|
+
yield {
|
|
114
|
+
type: "transcribeStream",
|
|
115
|
+
endOfTurn: { source: "parakeet" },
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
yield {
|
|
121
|
+
type: "transcribeStream",
|
|
122
|
+
text: value,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
yield {
|
|
126
|
+
type: "transcribeStream",
|
|
127
|
+
text: "",
|
|
128
|
+
done: true,
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
160
132
|
},
|
|
161
133
|
logging: {
|
|
162
134
|
module: parakeetAddonLogging,
|
|
@@ -4,6 +4,9 @@ export async function* diffusion(request) {
|
|
|
4
4
|
const init_image = request.init_image
|
|
5
5
|
? Buffer.from(request.init_image, "base64")
|
|
6
6
|
: undefined;
|
|
7
|
+
const init_images = request.init_images
|
|
8
|
+
? request.init_images.map((b64) => Buffer.from(b64, "base64"))
|
|
9
|
+
: undefined;
|
|
7
10
|
const response = await model.run({
|
|
8
11
|
prompt: request.prompt,
|
|
9
12
|
negative_prompt: request.negative_prompt,
|
|
@@ -20,7 +23,12 @@ export async function* diffusion(request) {
|
|
|
20
23
|
vae_tiling: request.vae_tiling,
|
|
21
24
|
cache_preset: request.cache_preset,
|
|
22
25
|
init_image,
|
|
26
|
+
init_images,
|
|
27
|
+
increase_ref_index: request.increase_ref_index,
|
|
28
|
+
auto_resize_ref_image: request.auto_resize_ref_image,
|
|
23
29
|
strength: request.strength,
|
|
30
|
+
lora: request.lora,
|
|
31
|
+
upscale: request.upscale === false ? undefined : request.upscale,
|
|
24
32
|
});
|
|
25
33
|
let outputIndex = 0;
|
|
26
34
|
for await (const chunk of response.iterate()) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { EsrganUpscaler } from "@qvac/diffusion-cpp";
|
|
2
|
+
import { getModel, getModelEntry, } from "../../../registry/model-registry.js";
|
|
3
|
+
import { ModelOperationNotSupportedError } from "../../../../../utils/errors-server.js";
|
|
4
|
+
import { ModelType } from "../../../../../schemas/index.js";
|
|
5
|
+
// The diffusion plugin instantiates `EsrganUpscaler` when the model is loaded
|
|
6
|
+
// with `modelConfig.mode === "upscale"` and `ImgStableDiffusion` otherwise. The
|
|
7
|
+
// latter has no `.upscale()` method, so we refuse the call upfront with a
|
|
8
|
+
// structured error rather than letting a TypeError propagate.
|
|
9
|
+
function asUpscalerModel(model, modelId) {
|
|
10
|
+
if (model instanceof EsrganUpscaler) {
|
|
11
|
+
return model;
|
|
12
|
+
}
|
|
13
|
+
const entry = getModelEntry(modelId);
|
|
14
|
+
const modelType = entry && !entry.isDelegated ? entry.local.modelType : ModelType.sdcppGeneration;
|
|
15
|
+
throw new ModelOperationNotSupportedError(modelId, modelType, "upscale", ["diffusion"], []);
|
|
16
|
+
}
|
|
17
|
+
export async function* upscale(request) {
|
|
18
|
+
const model = asUpscalerModel(getModel(request.modelId), request.modelId);
|
|
19
|
+
const response = await model.upscale(Buffer.from(request.image, "base64"), request.repeats === undefined ? undefined : { repeats: request.repeats });
|
|
20
|
+
// The addon emits exactly one final PNG regardless of `repeats`, so
|
|
21
|
+
// this loop typically iterates once. `outputIndex` is still emitted for
|
|
22
|
+
// wire parity with diffusionStream and to leave headroom for future
|
|
23
|
+
// multi-output variants.
|
|
24
|
+
let outputIndex = 0;
|
|
25
|
+
for await (const chunk of response.iterate()) {
|
|
26
|
+
if (chunk instanceof Uint8Array) {
|
|
27
|
+
yield {
|
|
28
|
+
type: "upscaleStream",
|
|
29
|
+
data: Buffer.from(chunk).toString("base64"),
|
|
30
|
+
outputIndex: outputIndex++,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const responseWithStats = response;
|
|
35
|
+
yield {
|
|
36
|
+
type: "upscaleStream",
|
|
37
|
+
done: true,
|
|
38
|
+
stats: responseWithStats.stats ?? undefined,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { VideoStableDiffusion } from "@qvac/diffusion-cpp";
|
|
54
|
+
import { getServerLogger } from "../../../../../logging/index.js";
|
|
55
|
+
import { getModel, getModelEntry, } from "../../../registry/model-registry.js";
|
|
56
|
+
import { getRequestRegistry, withRequestContext } from "../../../runtime/index.js";
|
|
57
|
+
import { generateServerRequestId } from "../../../runtime/request-id.js";
|
|
58
|
+
import { ModelOperationNotSupportedError } from "../../../../../utils/errors-server.js";
|
|
59
|
+
import { ModelType } from "../../../../../schemas/index.js";
|
|
60
|
+
// The diffusion plugin instantiates `VideoStableDiffusion` when the model is
|
|
61
|
+
// loaded with `modelConfig.mode === "video"` and `ImgStableDiffusion` (or
|
|
62
|
+
// `EsrganUpscaler`) otherwise. Those have no video `run()` shape, so we refuse
|
|
63
|
+
// the call upfront with a structured error rather than letting a native-addon
|
|
64
|
+
// error propagate.
|
|
65
|
+
function asVideoModel(model, modelId) {
|
|
66
|
+
if (model instanceof VideoStableDiffusion) {
|
|
67
|
+
return model;
|
|
68
|
+
}
|
|
69
|
+
const entry = getModelEntry(modelId);
|
|
70
|
+
const modelType = entry && !entry.isDelegated
|
|
71
|
+
? entry.local.modelType
|
|
72
|
+
: ModelType.sdcppGeneration;
|
|
73
|
+
throw new ModelOperationNotSupportedError(modelId, modelType, "video", ["diffusion"], []);
|
|
74
|
+
}
|
|
75
|
+
export async function* video(request) {
|
|
76
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
77
|
+
try {
|
|
78
|
+
const ctx = __addDisposableResource(env_1, getRequestRegistry().begin({
|
|
79
|
+
requestId: request.requestId ?? generateServerRequestId(),
|
|
80
|
+
kind: "diffusion",
|
|
81
|
+
modelId: request.modelId,
|
|
82
|
+
}), true);
|
|
83
|
+
const requestLogger = withRequestContext(getServerLogger(), ctx);
|
|
84
|
+
const model = asVideoModel(getModel(request.modelId), request.modelId);
|
|
85
|
+
const onAbort = () => {
|
|
86
|
+
model.cancel().catch((err) => {
|
|
87
|
+
requestLogger.warn(`[cancel] model.cancel() rejected during abort for modelId=${request.modelId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
|
91
|
+
if (ctx.signal.aborted)
|
|
92
|
+
onAbort();
|
|
93
|
+
ctx.scope.defer(() => {
|
|
94
|
+
ctx.signal.removeEventListener("abort", onAbort);
|
|
95
|
+
});
|
|
96
|
+
const response = await model.run({
|
|
97
|
+
mode: request.mode,
|
|
98
|
+
prompt: request.prompt,
|
|
99
|
+
...(request.negative_prompt !== undefined && {
|
|
100
|
+
negative_prompt: request.negative_prompt,
|
|
101
|
+
}),
|
|
102
|
+
...(request.width !== undefined && { width: request.width }),
|
|
103
|
+
...(request.height !== undefined && { height: request.height }),
|
|
104
|
+
...(request.video_frames !== undefined && {
|
|
105
|
+
video_frames: request.video_frames,
|
|
106
|
+
}),
|
|
107
|
+
...(request.fps !== undefined && { fps: request.fps }),
|
|
108
|
+
...(request.seed !== undefined && { seed: request.seed }),
|
|
109
|
+
...(request.steps !== undefined && { steps: request.steps }),
|
|
110
|
+
...(request.sampling_method !== undefined && {
|
|
111
|
+
sampling_method: request.sampling_method,
|
|
112
|
+
}),
|
|
113
|
+
...(request.scheduler !== undefined && { scheduler: request.scheduler }),
|
|
114
|
+
...(request.cfg_scale !== undefined && { cfg_scale: request.cfg_scale }),
|
|
115
|
+
...(request.flow_shift !== undefined && { flow_shift: request.flow_shift }),
|
|
116
|
+
...(request.high_noise_steps !== undefined && {
|
|
117
|
+
high_noise_steps: request.high_noise_steps,
|
|
118
|
+
}),
|
|
119
|
+
...(request.high_noise_sampler !== undefined && {
|
|
120
|
+
high_noise_sampler: request.high_noise_sampler,
|
|
121
|
+
}),
|
|
122
|
+
...(request.high_noise_scheduler !== undefined && {
|
|
123
|
+
high_noise_scheduler: request.high_noise_scheduler,
|
|
124
|
+
}),
|
|
125
|
+
...(request.high_noise_cfg_scale !== undefined && {
|
|
126
|
+
high_noise_cfg_scale: request.high_noise_cfg_scale,
|
|
127
|
+
}),
|
|
128
|
+
...(request.high_noise_flow_shift !== undefined && {
|
|
129
|
+
high_noise_flow_shift: request.high_noise_flow_shift,
|
|
130
|
+
}),
|
|
131
|
+
...(request.moe_boundary !== undefined && {
|
|
132
|
+
moe_boundary: request.moe_boundary,
|
|
133
|
+
}),
|
|
134
|
+
...(request.vace_strength !== undefined && {
|
|
135
|
+
vace_strength: request.vace_strength,
|
|
136
|
+
}),
|
|
137
|
+
...(request.control_frames !== undefined && {
|
|
138
|
+
control_frames: request.control_frames.map((b64) => Buffer.from(b64, "base64")),
|
|
139
|
+
}),
|
|
140
|
+
...(request.vae_tiling !== undefined && { vae_tiling: request.vae_tiling }),
|
|
141
|
+
...(request.vae_tile_size !== undefined && {
|
|
142
|
+
vae_tile_size: request.vae_tile_size,
|
|
143
|
+
}),
|
|
144
|
+
...(request.vae_tile_overlap !== undefined && {
|
|
145
|
+
vae_tile_overlap: request.vae_tile_overlap,
|
|
146
|
+
}),
|
|
147
|
+
...(request.cache_mode !== undefined && { cache_mode: request.cache_mode }),
|
|
148
|
+
...(request.cache_preset !== undefined && {
|
|
149
|
+
cache_preset: request.cache_preset,
|
|
150
|
+
}),
|
|
151
|
+
...(request.cache_threshold !== undefined && {
|
|
152
|
+
cache_threshold: request.cache_threshold,
|
|
153
|
+
}),
|
|
154
|
+
});
|
|
155
|
+
let outputIndex = 0;
|
|
156
|
+
for await (const chunk of response.iterate()) {
|
|
157
|
+
if (ctx.signal.aborted)
|
|
158
|
+
break;
|
|
159
|
+
if (chunk instanceof Uint8Array) {
|
|
160
|
+
yield {
|
|
161
|
+
type: "videoStream",
|
|
162
|
+
data: Buffer.from(chunk).toString("base64"),
|
|
163
|
+
outputIndex: outputIndex++,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
else if (typeof chunk === "string") {
|
|
167
|
+
try {
|
|
168
|
+
const tick = JSON.parse(chunk);
|
|
169
|
+
if ("step" in tick) {
|
|
170
|
+
yield {
|
|
171
|
+
type: "videoStream",
|
|
172
|
+
step: tick["step"],
|
|
173
|
+
totalSteps: tick["total"],
|
|
174
|
+
elapsedMs: tick["elapsed_ms"],
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
// Non-JSON string output — skip
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const responseWithStats = response;
|
|
184
|
+
yield {
|
|
185
|
+
type: "videoStream",
|
|
186
|
+
done: true,
|
|
187
|
+
stats: responseWithStats.stats ?? undefined,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
catch (e_1) {
|
|
191
|
+
env_1.error = e_1;
|
|
192
|
+
env_1.hasError = true;
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
const result_1 = __disposeResources(env_1);
|
|
196
|
+
if (result_1)
|
|
197
|
+
await result_1;
|
|
198
|
+
}
|
|
199
|
+
}
|