@qvac/sdk 0.9.2 → 0.10.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/NOTICE +42 -95
- package/dist/client/api/cancel.d.ts +1 -1
- package/dist/client/api/cancel.js +1 -1
- package/dist/client/api/completion-stream.d.ts +51 -12
- package/dist/client/api/completion-stream.js +129 -56
- package/dist/client/api/delete-cache.d.ts +1 -0
- package/dist/client/api/delete-cache.js +1 -0
- package/dist/client/api/diffusion.d.ts +17 -2
- package/dist/client/api/diffusion.js +21 -4
- package/dist/client/api/embed.d.ts +4 -0
- package/dist/client/api/finetune.d.ts +21 -0
- package/dist/client/api/get-loaded-model-info.d.ts +25 -0
- package/dist/client/api/get-loaded-model-info.js +36 -0
- package/dist/client/api/get-model-info.d.ts +9 -1
- package/dist/client/api/get-model-info.js +8 -0
- package/dist/client/api/heartbeat.d.ts +2 -2
- package/dist/client/api/heartbeat.js +2 -2
- package/dist/client/api/index.d.ts +3 -1
- package/dist/client/api/index.js +3 -1
- package/dist/client/api/invoke-plugin.d.ts +16 -0
- package/dist/client/api/invoke-plugin.js +16 -0
- package/dist/client/api/load-model.d.ts +36 -3
- package/dist/client/api/load-model.js +31 -10
- package/dist/client/api/provide.d.ts +11 -5
- package/dist/client/api/provide.js +11 -6
- package/dist/client/api/rag.d.ts +9 -0
- package/dist/client/api/rag.js +9 -0
- package/dist/client/api/registry.d.ts +26 -0
- package/dist/client/api/registry.js +26 -0
- package/dist/client/api/resume.d.ts +20 -4
- package/dist/client/api/resume.js +20 -4
- package/dist/client/api/state.d.ts +23 -0
- package/dist/client/api/state.js +29 -0
- package/dist/client/api/stop-provider.d.ts +11 -5
- package/dist/client/api/stop-provider.js +11 -5
- package/dist/client/api/suspend.d.ts +21 -3
- package/dist/client/api/suspend.js +21 -3
- package/dist/client/api/text-to-speech.d.ts +64 -6
- package/dist/client/api/text-to-speech.js +423 -47
- package/dist/client/api/transcribe.d.ts +29 -4
- package/dist/client/api/transcribe.js +86 -28
- package/dist/client/api/translate.d.ts +1 -0
- package/dist/client/api/translate.js +1 -0
- package/dist/client/rpc/bare-client.js +22 -1
- package/dist/client/rpc/expo-rpc-client.d.ts +1 -1
- package/dist/client/rpc/expo-rpc-client.js +96 -4
- package/dist/client/rpc/node-rpc-client.js +36 -0
- package/dist/examples/audio/mic-input.d.ts +9 -0
- package/dist/examples/audio/mic-input.js +111 -0
- package/dist/examples/completion-events.d.ts +18 -0
- package/dist/examples/completion-events.js +79 -0
- package/dist/examples/delegated-inference/composite.js +12 -18
- package/dist/examples/delegated-inference/consumer-profiled.js +4 -11
- package/dist/examples/delegated-inference/consumer.js +8 -13
- package/dist/examples/delegated-inference/provider.js +11 -16
- package/dist/examples/diffusion-flux2-klein-img2img.d.ts +2 -0
- package/dist/examples/diffusion-flux2-klein-img2img.js +60 -0
- package/dist/examples/diffusion-flux2-klein.js +1 -0
- package/dist/examples/diffusion-img2img.d.ts +2 -0
- package/dist/examples/diffusion-img2img.js +49 -0
- package/dist/examples/diffusion-txt2img.js +2 -1
- package/dist/examples/kv-cache-example.js +11 -12
- package/dist/examples/llamacpp-cache.d.ts +2 -0
- package/dist/examples/llamacpp-cache.js +107 -0
- package/dist/examples/llamacpp-dynamic-tools.d.ts +2 -0
- package/dist/examples/llamacpp-dynamic-tools.js +144 -0
- package/dist/examples/llamacpp-structured-output.d.ts +2 -0
- package/dist/examples/llamacpp-structured-output.js +106 -0
- package/dist/examples/plugins.js +4 -4
- package/dist/examples/suspend-resume.js +21 -4
- package/dist/examples/{llamacpp-native-tools.js → tools/llamacpp-native-tools.js} +6 -55
- package/dist/examples/tools/llamacpp-tools-harmony-multiturn.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-harmony-multiturn.js +81 -0
- package/dist/examples/tools/llamacpp-tools-pythonic.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-pythonic.js +50 -0
- package/dist/examples/tools/shared.d.ts +21 -0
- package/dist/examples/tools/shared.js +42 -0
- package/dist/examples/transcription/parakeet-microphone-record.js +6 -33
- package/dist/examples/transcription/whispercpp-filesystem-streaming.js +7 -5
- package/dist/examples/transcription/whispercpp-filesystem.js +12 -3
- package/dist/examples/transcription/whispercpp-microphone-record.js +6 -29
- package/dist/examples/translation/translation-stream.js +5 -5
- package/dist/examples/tts/llm-to-tts-streaming.d.ts +16 -0
- package/dist/examples/tts/llm-to-tts-streaming.js +143 -0
- package/dist/examples/tts/supertonic-multilingual.js +3 -3
- package/dist/examples/tts/supertonic.js +3 -3
- package/dist/examples/tts/utils.d.ts +11 -1
- package/dist/examples/tts/utils.js +70 -17
- package/dist/examples/voice-assistant/voice-assistant.d.ts +2 -0
- package/dist/examples/voice-assistant/voice-assistant.js +207 -0
- package/dist/expo/plugins/withMobileBundle.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/logging/logger.d.ts +11 -0
- package/dist/logging/logger.js +11 -0
- package/dist/logging/types.d.ts +18 -0
- package/dist/models/registry/models.d.ts +6973 -7457
- package/dist/models/registry/models.js +6889 -6855
- package/dist/models/update-models/codegen.js +84 -23
- package/dist/models/update-models/companions.d.ts +18 -0
- package/dist/models/update-models/companions.js +175 -0
- package/dist/models/update-models/naming.js +0 -25
- package/dist/models/update-models/registry.d.ts +1 -0
- package/dist/models/update-models/registry.js +23 -3
- package/dist/models/update-models/types.d.ts +37 -9
- package/dist/profiling/index.d.ts +49 -0
- package/dist/profiling/index.js +49 -0
- package/dist/schemas/cancel.d.ts +6 -2
- package/dist/schemas/cancel.js +14 -7
- package/dist/schemas/common.d.ts +354 -271
- package/dist/schemas/common.js +26 -5
- package/dist/schemas/completion-event.d.ts +225 -0
- package/dist/schemas/completion-event.js +79 -0
- package/dist/schemas/completion-stream.d.ts +126 -31
- package/dist/schemas/completion-stream.js +138 -36
- package/dist/schemas/delegate.d.ts +0 -2
- package/dist/schemas/delegate.js +25 -6
- package/dist/schemas/download-asset.d.ts +5 -5
- package/dist/schemas/embed.js +21 -9
- package/dist/schemas/engine-addon-map.d.ts +11 -1
- package/dist/schemas/engine-addon-map.js +2 -2
- package/dist/schemas/get-loaded-model-info.d.ts +52 -0
- package/dist/schemas/get-loaded-model-info.js +44 -0
- package/dist/schemas/get-model-info.d.ts +2 -2
- package/dist/schemas/get-model-info.js +103 -32
- package/dist/schemas/heartbeat.d.ts +0 -1
- package/dist/schemas/index.d.ts +4 -1
- package/dist/schemas/index.js +4 -1
- package/dist/schemas/llamacpp-config.d.ts +14 -4
- package/dist/schemas/llamacpp-config.js +5 -0
- package/dist/schemas/load-model.d.ts +3233 -1260
- package/dist/schemas/load-model.js +23 -16
- package/dist/schemas/model-src-utils.d.ts +7 -6
- package/dist/schemas/model-src-utils.js +27 -1
- package/dist/schemas/model-types.d.ts +4 -4
- package/dist/schemas/ocr.d.ts +1 -1
- package/dist/schemas/plugin.d.ts +27 -3
- package/dist/schemas/plugin.js +27 -2
- package/dist/schemas/profiling.js +11 -3
- package/dist/schemas/provide.d.ts +1 -3
- package/dist/schemas/provide.js +0 -3
- package/dist/schemas/rag.d.ts +4 -4
- package/dist/schemas/registry.d.ts +10 -10
- package/dist/schemas/registry.js +36 -14
- package/dist/schemas/reload-config.d.ts +73 -7
- package/dist/schemas/sdcpp-config.d.ts +16 -8
- package/dist/schemas/sdcpp-config.js +118 -25
- package/dist/schemas/sdk-config.d.ts +116 -90
- package/dist/schemas/sdk-config.js +16 -0
- package/dist/schemas/sdk-errors-client.d.ts +3 -0
- package/dist/schemas/sdk-errors-client.js +16 -1
- package/dist/schemas/sdk-errors-server.d.ts +3 -0
- package/dist/schemas/sdk-errors-server.js +23 -0
- package/dist/schemas/state.d.ts +23 -0
- package/dist/schemas/state.js +14 -0
- package/dist/schemas/stop-provide.d.ts +0 -5
- package/dist/schemas/stop-provide.js +2 -6
- package/dist/schemas/text-to-speech.d.ts +93 -27
- package/dist/schemas/text-to-speech.js +27 -0
- package/dist/schemas/tools.d.ts +16 -0
- package/dist/schemas/tools.js +15 -0
- package/dist/schemas/transcription-config.d.ts +8 -8
- package/dist/schemas/transcription.d.ts +33 -0
- package/dist/schemas/transcription.js +9 -0
- package/dist/schemas/translate.js +59 -19
- package/dist/schemas/translation-config.d.ts +157 -133
- package/dist/schemas/translation-config.js +34 -11
- package/dist/server/bare/delegate-rpc-client.d.ts +1 -1
- package/dist/server/bare/delegate-rpc-client.js +131 -122
- package/dist/server/bare/hyperswarm.d.ts +2 -2
- package/dist/server/bare/hyperswarm.js +12 -7
- package/dist/server/bare/ops/cancel.js +7 -0
- package/dist/server/bare/ops/kv-cache-utils.d.ts +7 -10
- package/dist/server/bare/ops/kv-cache-utils.js +31 -40
- package/dist/server/bare/ops/load-model.js +0 -1
- package/dist/server/bare/ops/transcribe.d.ts +11 -4
- package/dist/server/bare/ops/transcribe.js +25 -4
- package/dist/server/bare/ops/translate.js +42 -4
- package/dist/server/bare/ops/unload-model.js +21 -19
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +1 -2
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +13 -8
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +257 -85
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +101 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +135 -0
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +80 -22
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +57 -32
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -16
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +69 -44
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +54 -116
- package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.d.ts +32 -0
- package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.js +117 -0
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +1 -1
- package/dist/server/bare/plugins/onnx-ocr/plugin.js +1 -2
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech-stream.d.ts +7 -0
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech-stream.js +116 -0
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.d.ts +2 -3
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.js +71 -9
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +41 -13
- package/dist/server/bare/plugins/onnx-tts/plugin.js +48 -3
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +15 -7
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +5 -6
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +6 -0
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +8 -5
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +13 -13
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +17 -1
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +40 -17
- package/dist/server/bare/registry/config-registry.js +14 -3
- package/dist/server/bare/registry/model-registry.d.ts +8 -10
- package/dist/server/bare/registry/model-registry.js +17 -12
- package/dist/server/bare/registry/registry-client.js +79 -19
- package/dist/server/bare/runtime-lifecycle.d.ts +2 -1
- package/dist/server/bare/runtime-lifecycle.js +13 -2
- package/dist/server/bare/types/addon-responses.d.ts +8 -3
- package/dist/server/bare/utils/transcribe-metadata.d.ts +21 -0
- package/dist/server/bare/utils/transcribe-metadata.js +28 -0
- package/dist/server/bare/utils/tts-stats.d.ts +22 -0
- package/dist/server/bare/utils/tts-stats.js +10 -0
- package/dist/server/rpc/create-server.d.ts +4 -1
- package/dist/server/rpc/create-server.js +5 -1
- package/dist/server/rpc/delegate-transport.js +36 -29
- package/dist/server/rpc/handle-request.js +28 -3
- package/dist/server/rpc/handler-registry.js +7 -1
- package/dist/server/rpc/handler-utils.d.ts +5 -0
- package/dist/server/rpc/handler-utils.js +22 -0
- package/dist/server/rpc/handlers/cancel-delegated.js +3 -5
- package/dist/server/rpc/handlers/cancelHandler.js +4 -5
- package/dist/server/rpc/handlers/completion-stream-delegated.js +14 -5
- package/dist/server/rpc/handlers/delete-cache.js +8 -3
- package/dist/server/rpc/handlers/download-asset.js +3 -24
- package/dist/server/rpc/handlers/get-loaded-model-info.d.ts +3 -0
- package/dist/server/rpc/handlers/get-loaded-model-info.js +39 -0
- package/dist/server/rpc/handlers/get-model-info.js +93 -84
- package/dist/server/rpc/handlers/heartbeat-delegated.js +2 -2
- package/dist/server/rpc/handlers/index.d.ts +6 -0
- package/dist/server/rpc/handlers/index.js +6 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +35 -9
- package/dist/server/rpc/handlers/load-model/download-manager.js +142 -38
- package/dist/server/rpc/handlers/load-model/download-stats.d.ts +5 -4
- package/dist/server/rpc/handlers/load-model/download-stats.js +49 -8
- package/dist/server/rpc/handlers/load-model/handler.js +31 -50
- package/dist/server/rpc/handlers/load-model/http.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/http.js +97 -142
- package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +55 -74
- package/dist/server/rpc/handlers/load-model/index.d.ts +0 -1
- package/dist/server/rpc/handlers/load-model/index.js +0 -1
- package/dist/server/rpc/handlers/load-model/registry-client-options.d.ts +27 -0
- package/dist/server/rpc/handlers/load-model/registry-client-options.js +19 -0
- package/dist/server/rpc/handlers/load-model/registry-companion-set.d.ts +22 -0
- package/dist/server/rpc/handlers/load-model/registry-companion-set.js +208 -0
- package/dist/server/rpc/handlers/load-model/registry-download-utils.d.ts +24 -0
- package/dist/server/rpc/handlers/load-model/registry-download-utils.js +114 -0
- package/dist/server/rpc/handlers/load-model/registry.d.ts +2 -20
- package/dist/server/rpc/handlers/load-model/registry.js +109 -381
- package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +15 -0
- package/dist/server/rpc/handlers/load-model/resolve-session.js +61 -0
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/resolve.js +14 -23
- package/dist/server/rpc/handlers/load-model/types.d.ts +11 -4
- package/dist/server/rpc/handlers/load-model/types.js +28 -1
- package/dist/server/rpc/handlers/load-model-delegated.js +2 -4
- package/dist/server/rpc/handlers/plugin-dispatch.js +9 -5
- package/dist/server/rpc/handlers/plugin-invoke.js +1 -1
- package/dist/server/rpc/handlers/provideHandler/connection.js +13 -2
- package/dist/server/rpc/handlers/provideHandler/handler.js +42 -29
- package/dist/server/rpc/handlers/state.d.ts +3 -0
- package/dist/server/rpc/handlers/state.js +7 -0
- package/dist/server/rpc/handlers/stopProvideHandler.d.ts +2 -2
- package/dist/server/rpc/handlers/stopProvideHandler.js +12 -7
- package/dist/server/rpc/handlers/text-to-speech-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/text-to-speech-stream.js +4 -0
- package/dist/server/rpc/handlers/unload-model-delegated.js +3 -3
- package/dist/server/rpc/profiling/operation-metrics.js +20 -0
- package/dist/server/rpc/rpc-utils.js +1 -1
- package/dist/server/rpc/transport-selector.d.ts +3 -0
- package/dist/server/rpc/transport-selector.js +18 -0
- package/dist/server/utils/cache/auto-history.d.ts +4 -0
- package/dist/server/utils/cache/auto-history.js +22 -0
- package/dist/server/utils/{cache.d.ts → cache/paths.d.ts} +22 -5
- package/dist/server/utils/{cache.js → cache/paths.js} +36 -20
- package/dist/server/utils/cache/types.d.ts +8 -0
- package/dist/server/utils/cache/types.js +1 -0
- package/dist/server/utils/checksum.d.ts +2 -2
- package/dist/server/utils/checksum.js +1 -1
- package/dist/server/utils/clear-storage.d.ts +5 -0
- package/dist/server/utils/clear-storage.js +17 -0
- package/dist/server/utils/completion-normalizer.d.ts +17 -0
- package/dist/server/utils/completion-normalizer.js +413 -0
- package/dist/server/utils/expand-gguf-shards.d.ts +3 -0
- package/dist/server/utils/expand-gguf-shards.js +22 -0
- package/dist/server/utils/formatting.js +1 -1
- package/dist/server/utils/index.d.ts +4 -2
- package/dist/server/utils/index.js +4 -2
- package/dist/server/utils/qvac-paths.d.ts +2 -0
- package/dist/server/utils/qvac-paths.js +5 -0
- package/dist/server/utils/response-format.d.ts +3 -0
- package/dist/server/utils/response-format.js +20 -0
- package/dist/server/utils/tool-integration.d.ts +15 -4
- package/dist/server/utils/tool-integration.js +21 -41
- package/dist/server/utils/tools/dialect.d.ts +8 -0
- package/dist/server/utils/tools/dialect.js +14 -0
- package/dist/server/utils/tools/index.d.ts +3 -0
- package/dist/server/utils/tools/index.js +2 -0
- package/dist/server/utils/tools/parser.d.ts +6 -0
- package/dist/server/utils/tools/parser.js +46 -0
- package/dist/server/utils/tools/parsers/harmony.d.ts +4 -0
- package/dist/server/utils/tools/parsers/harmony.js +59 -0
- package/dist/server/utils/tools/parsers/hermes.d.ts +4 -0
- package/dist/server/utils/tools/parsers/hermes.js +100 -0
- package/dist/server/utils/tools/parsers/json.d.ts +6 -0
- package/dist/server/utils/tools/parsers/json.js +115 -0
- package/dist/server/utils/tools/parsers/pythonic.d.ts +4 -0
- package/dist/server/utils/tools/parsers/pythonic.js +267 -0
- package/dist/server/utils/tools/shared.d.ts +18 -0
- package/dist/server/utils/tools/shared.js +54 -0
- package/dist/server/utils/worker-lock.d.ts +3 -0
- package/dist/server/utils/worker-lock.js +67 -0
- package/dist/server/worker-core.d.ts +16 -1
- package/dist/server/worker-core.js +114 -14
- package/dist/utils/aggregate-events.d.ts +16 -0
- package/dist/utils/aggregate-events.js +52 -0
- package/dist/utils/cache-normalize.d.ts +10 -0
- package/dist/utils/cache-normalize.js +23 -0
- package/dist/utils/encoding.d.ts +8 -0
- package/dist/utils/encoding.js +13 -0
- package/dist/utils/errors-client.d.ts +12 -0
- package/dist/utils/errors-client.js +20 -0
- package/dist/utils/errors-server.d.ts +14 -0
- package/dist/utils/errors-server.js +31 -0
- package/dist/utils/load-model-validation.d.ts +7 -0
- package/dist/utils/load-model-validation.js +18 -0
- package/expo/plugins/patches/android-link.mjs +1 -1
- package/expo/plugins/patches/ios-link.mjs +1 -1
- package/package.json +14 -18
- package/dist/examples/translation/translation-opus.d.ts +0 -2
- package/dist/examples/translation/translation-opus.js +0 -33
- package/dist/server/bare/utils/loader-adapter.d.ts +0 -7
- package/dist/server/bare/utils/loader-adapter.js +0 -9
- package/dist/server/utils/model-path.d.ts +0 -5
- package/dist/server/utils/model-path.js +0 -7
- package/dist/server/utils/tool-parser.d.ts +0 -7
- package/dist/server/utils/tool-parser.js +0 -248
- /package/dist/examples/{llamacpp-native-tools.d.ts → tools/llamacpp-native-tools.d.ts} +0 -0
|
@@ -4,35 +4,6 @@ export declare const nmtPlugin: {
|
|
|
4
4
|
displayName: string;
|
|
5
5
|
addonPackage: "@qvac/translation-nmtcpp";
|
|
6
6
|
loadConfigSchema: import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
7
|
-
mode: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
8
|
-
full: "full";
|
|
9
|
-
}>>;
|
|
10
|
-
beamsize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
11
|
-
lengthpenalty: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
12
|
-
maxlength: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
13
|
-
repetitionpenalty: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
14
|
-
norepeatngramsize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
15
|
-
temperature: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
16
|
-
topk: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
17
|
-
topp: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
18
|
-
engine: import("zod").ZodLiteral<"Opus">;
|
|
19
|
-
from: import("zod").ZodEnum<{
|
|
20
|
-
en: "en";
|
|
21
|
-
de: "de";
|
|
22
|
-
es: "es";
|
|
23
|
-
it: "it";
|
|
24
|
-
ru: "ru";
|
|
25
|
-
ja: "ja";
|
|
26
|
-
}>;
|
|
27
|
-
to: import("zod").ZodEnum<{
|
|
28
|
-
en: "en";
|
|
29
|
-
de: "de";
|
|
30
|
-
es: "es";
|
|
31
|
-
it: "it";
|
|
32
|
-
ru: "ru";
|
|
33
|
-
ja: "ja";
|
|
34
|
-
}>;
|
|
35
|
-
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
36
7
|
mode: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
37
8
|
full: "full";
|
|
38
9
|
}>>;
|
|
@@ -46,58 +17,112 @@ export declare const nmtPlugin: {
|
|
|
46
17
|
topp: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
47
18
|
engine: import("zod").ZodLiteral<"Bergamot">;
|
|
48
19
|
from: import("zod").ZodEnum<{
|
|
20
|
+
id: "id";
|
|
49
21
|
en: "en";
|
|
50
|
-
de: "de";
|
|
51
|
-
es: "es";
|
|
52
|
-
it: "it";
|
|
53
|
-
ru: "ru";
|
|
54
|
-
ja: "ja";
|
|
55
22
|
ar: "ar";
|
|
56
23
|
bg: "bg";
|
|
57
24
|
ca: "ca";
|
|
58
25
|
cs: "cs";
|
|
26
|
+
de: "de";
|
|
27
|
+
es: "es";
|
|
59
28
|
et: "et";
|
|
60
29
|
fi: "fi";
|
|
61
30
|
fr: "fr";
|
|
62
31
|
hu: "hu";
|
|
63
32
|
is: "is";
|
|
33
|
+
it: "it";
|
|
34
|
+
ja: "ja";
|
|
64
35
|
ko: "ko";
|
|
65
36
|
lt: "lt";
|
|
66
37
|
lv: "lv";
|
|
67
38
|
nl: "nl";
|
|
68
39
|
pl: "pl";
|
|
69
40
|
pt: "pt";
|
|
41
|
+
ru: "ru";
|
|
70
42
|
sk: "sk";
|
|
71
43
|
sl: "sl";
|
|
72
44
|
uk: "uk";
|
|
73
45
|
zh: "zh";
|
|
46
|
+
az: "az";
|
|
47
|
+
be: "be";
|
|
48
|
+
bn: "bn";
|
|
49
|
+
bs: "bs";
|
|
50
|
+
da: "da";
|
|
51
|
+
el: "el";
|
|
52
|
+
fa: "fa";
|
|
53
|
+
gu: "gu";
|
|
54
|
+
he: "he";
|
|
55
|
+
hi: "hi";
|
|
56
|
+
hr: "hr";
|
|
57
|
+
kn: "kn";
|
|
58
|
+
ml: "ml";
|
|
59
|
+
ms: "ms";
|
|
60
|
+
mt: "mt";
|
|
61
|
+
nb: "nb";
|
|
62
|
+
nn: "nn";
|
|
63
|
+
re: "re";
|
|
64
|
+
ro: "ro";
|
|
65
|
+
sq: "sq";
|
|
66
|
+
sr: "sr";
|
|
67
|
+
sv: "sv";
|
|
68
|
+
ta: "ta";
|
|
69
|
+
te: "te";
|
|
70
|
+
tr: "tr";
|
|
71
|
+
vi: "vi";
|
|
74
72
|
}>;
|
|
75
73
|
to: import("zod").ZodEnum<{
|
|
74
|
+
id: "id";
|
|
76
75
|
en: "en";
|
|
77
|
-
de: "de";
|
|
78
|
-
es: "es";
|
|
79
|
-
it: "it";
|
|
80
|
-
ru: "ru";
|
|
81
|
-
ja: "ja";
|
|
82
76
|
ar: "ar";
|
|
83
77
|
bg: "bg";
|
|
84
78
|
ca: "ca";
|
|
85
79
|
cs: "cs";
|
|
80
|
+
de: "de";
|
|
81
|
+
es: "es";
|
|
86
82
|
et: "et";
|
|
87
83
|
fi: "fi";
|
|
88
84
|
fr: "fr";
|
|
89
85
|
hu: "hu";
|
|
90
86
|
is: "is";
|
|
87
|
+
it: "it";
|
|
88
|
+
ja: "ja";
|
|
91
89
|
ko: "ko";
|
|
92
90
|
lt: "lt";
|
|
93
91
|
lv: "lv";
|
|
94
92
|
nl: "nl";
|
|
95
93
|
pl: "pl";
|
|
96
94
|
pt: "pt";
|
|
95
|
+
ru: "ru";
|
|
97
96
|
sk: "sk";
|
|
98
97
|
sl: "sl";
|
|
99
98
|
uk: "uk";
|
|
100
99
|
zh: "zh";
|
|
100
|
+
az: "az";
|
|
101
|
+
be: "be";
|
|
102
|
+
bn: "bn";
|
|
103
|
+
bs: "bs";
|
|
104
|
+
da: "da";
|
|
105
|
+
el: "el";
|
|
106
|
+
fa: "fa";
|
|
107
|
+
gu: "gu";
|
|
108
|
+
he: "he";
|
|
109
|
+
hi: "hi";
|
|
110
|
+
hr: "hr";
|
|
111
|
+
kn: "kn";
|
|
112
|
+
ml: "ml";
|
|
113
|
+
ms: "ms";
|
|
114
|
+
mt: "mt";
|
|
115
|
+
nb: "nb";
|
|
116
|
+
nn: "nn";
|
|
117
|
+
re: "re";
|
|
118
|
+
ro: "ro";
|
|
119
|
+
sq: "sq";
|
|
120
|
+
sr: "sr";
|
|
121
|
+
sv: "sv";
|
|
122
|
+
ta: "ta";
|
|
123
|
+
te: "te";
|
|
124
|
+
tr: "tr";
|
|
125
|
+
vi: "vi";
|
|
101
126
|
}>;
|
|
102
127
|
srcVocabSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
103
128
|
src: import("zod").ZodString;
|
|
@@ -111,6 +136,7 @@ export declare const nmtPlugin: {
|
|
|
111
136
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
112
137
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
113
138
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
139
|
+
embeddings: "embeddings";
|
|
114
140
|
"llamacpp-completion": "llamacpp-completion";
|
|
115
141
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
116
142
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -121,7 +147,6 @@ export declare const nmtPlugin: {
|
|
|
121
147
|
"sdcpp-generation": "sdcpp-generation";
|
|
122
148
|
llm: "llm";
|
|
123
149
|
whisper: "whisper";
|
|
124
|
-
embeddings: "embeddings";
|
|
125
150
|
nmt: "nmt";
|
|
126
151
|
parakeet: "parakeet";
|
|
127
152
|
tts: "tts";
|
|
@@ -141,6 +166,7 @@ export declare const nmtPlugin: {
|
|
|
141
166
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
142
167
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
143
168
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
169
|
+
embeddings: "embeddings";
|
|
144
170
|
"llamacpp-completion": "llamacpp-completion";
|
|
145
171
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
146
172
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -151,7 +177,6 @@ export declare const nmtPlugin: {
|
|
|
151
177
|
"sdcpp-generation": "sdcpp-generation";
|
|
152
178
|
llm: "llm";
|
|
153
179
|
whisper: "whisper";
|
|
154
|
-
embeddings: "embeddings";
|
|
155
180
|
nmt: "nmt";
|
|
156
181
|
parakeet: "parakeet";
|
|
157
182
|
tts: "tts";
|
|
@@ -184,6 +209,7 @@ export declare const nmtPlugin: {
|
|
|
184
209
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
185
210
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
186
211
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
212
|
+
embeddings: "embeddings";
|
|
187
213
|
"llamacpp-completion": "llamacpp-completion";
|
|
188
214
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
189
215
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -194,7 +220,6 @@ export declare const nmtPlugin: {
|
|
|
194
220
|
"sdcpp-generation": "sdcpp-generation";
|
|
195
221
|
llm: "llm";
|
|
196
222
|
whisper: "whisper";
|
|
197
|
-
embeddings: "embeddings";
|
|
198
223
|
nmt: "nmt";
|
|
199
224
|
parakeet: "parakeet";
|
|
200
225
|
tts: "tts";
|
|
@@ -214,6 +239,7 @@ export declare const nmtPlugin: {
|
|
|
214
239
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
215
240
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
216
241
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
242
|
+
embeddings: "embeddings";
|
|
217
243
|
"llamacpp-completion": "llamacpp-completion";
|
|
218
244
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
219
245
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -224,7 +250,6 @@ export declare const nmtPlugin: {
|
|
|
224
250
|
"sdcpp-generation": "sdcpp-generation";
|
|
225
251
|
llm: "llm";
|
|
226
252
|
whisper: "whisper";
|
|
227
|
-
embeddings: "embeddings";
|
|
228
253
|
nmt: "nmt";
|
|
229
254
|
parakeet: "parakeet";
|
|
230
255
|
tts: "tts";
|
|
@@ -244,6 +269,7 @@ export declare const nmtPlugin: {
|
|
|
244
269
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
245
270
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
246
271
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
272
|
+
embeddings: "embeddings";
|
|
247
273
|
"llamacpp-completion": "llamacpp-completion";
|
|
248
274
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
249
275
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -254,7 +280,6 @@ export declare const nmtPlugin: {
|
|
|
254
280
|
"sdcpp-generation": "sdcpp-generation";
|
|
255
281
|
llm: "llm";
|
|
256
282
|
whisper: "whisper";
|
|
257
|
-
embeddings: "embeddings";
|
|
258
283
|
nmt: "nmt";
|
|
259
284
|
parakeet: "parakeet";
|
|
260
285
|
tts: "tts";
|
|
@@ -1,57 +1,44 @@
|
|
|
1
1
|
import nmtAddonLogging from "@qvac/translation-nmtcpp/addonLogging.js";
|
|
2
2
|
import TranslationNmtcpp, {} from "@qvac/translation-nmtcpp";
|
|
3
|
-
import { definePlugin, defineHandler, translateRequestSchema, translateResponseSchema, ModelType, nmtConfigBaseSchema, ADDON_NMT, } from "../../../../schemas/index.js";
|
|
3
|
+
import { definePlugin, defineHandler, translateRequestSchema, translateResponseSchema, ModelType, nmtConfigBaseSchema, ADDON_NMT, BERGAMOT_CJK_LANG_PAIRS, } from "../../../../schemas/index.js";
|
|
4
4
|
import { createStreamLogger, registerAddonLogger } from "../../../../logging/index.js";
|
|
5
|
-
import
|
|
6
|
-
import FilesystemDL from "@qvac/dl-filesystem";
|
|
7
|
-
import { ModelLoadFailedError } from "../../../../utils/errors-server.js";
|
|
8
|
-
import { asLoader } from "../../utils/loader-adapter.js";
|
|
5
|
+
import path from "bare-path";
|
|
9
6
|
import { translate } from "../../ops/translate.js";
|
|
10
7
|
import { attachModelExecutionMs } from "../../../../profiling/model-execution.js";
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import { resolveBergamotVocab, } from "./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];
|
|
13
22
|
if (BERGAMOT_CJK_LANG_PAIRS.includes(langPair)) {
|
|
14
23
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
srcVocabPath: path.join(dirPath, `srcvocab.${langPair}.spm`),
|
|
25
|
+
dstVocabPath: path.join(dirPath, `trgvocab.${langPair}.spm`),
|
|
17
26
|
};
|
|
18
27
|
}
|
|
19
|
-
const
|
|
20
|
-
return {
|
|
21
|
-
}
|
|
22
|
-
function deriveBergamotVocabSources(modelSrc) {
|
|
23
|
-
const match = modelSrc.match(/^pear:\/\/([a-f0-9]+)\/model\.([a-z]+)\.intgemm\.alphas\.bin$/);
|
|
24
|
-
if (!match?.[1] || !match[2])
|
|
25
|
-
return null;
|
|
26
|
-
const basePath = `pear://${match[1]}/`;
|
|
27
|
-
const langPair = match[2];
|
|
28
|
-
return buildBergamotVocabSources(basePath, langPair);
|
|
29
|
-
}
|
|
30
|
-
function deriveBergamotRegistryVocabSources(modelSrc) {
|
|
31
|
-
const match = modelSrc.match(/^(registry:\/\/.+\/)model\.([a-z]+)\.intgemm\.alphas\.bin$/);
|
|
32
|
-
if (!match?.[1] || !match[2])
|
|
33
|
-
return null;
|
|
34
|
-
const basePath = match[1];
|
|
35
|
-
const langPair = match[2];
|
|
36
|
-
return buildBergamotVocabSources(basePath, langPair);
|
|
28
|
+
const sharedPath = path.join(dirPath, `vocab.${langPair}.spm`);
|
|
29
|
+
return { srcVocabPath: sharedPath, dstVocabPath: sharedPath };
|
|
37
30
|
}
|
|
38
31
|
function createNmtModel(modelId, modelPath, nmtConfig, srcVocabPath, dstVocabPath, pivotModelPath, pivotSrcVocabPath, pivotDstVocabPath) {
|
|
39
|
-
const { dirPath, basePath } = parseModelPath(modelPath);
|
|
40
|
-
const loader = new FilesystemDL({ dirPath });
|
|
41
32
|
const logger = createStreamLogger(modelId, ModelType.nmtcppTranslation);
|
|
42
33
|
registerAddonLogger(modelId, ModelType.nmtcppTranslation, logger);
|
|
43
34
|
const { mode, from, to, engine, beamsize, lengthpenalty, maxlength, repetitionpenalty, norepeatngramsize, temperature, topk, topp, } = nmtConfig;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
mode,
|
|
52
|
-
srcLang: from,
|
|
53
|
-
dstLang: to,
|
|
54
|
-
},
|
|
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 }),
|
|
55
42
|
};
|
|
56
43
|
const generationParams = {
|
|
57
44
|
beamsize,
|
|
@@ -67,33 +54,26 @@ function createNmtModel(modelId, modelPath, nmtConfig, srcVocabPath, dstVocabPat
|
|
|
67
54
|
modelType: TranslationNmtcpp.ModelTypes[engine],
|
|
68
55
|
...generationParams,
|
|
69
56
|
...(nmtConfig.engine === "Bergamot" && {
|
|
70
|
-
...(srcVocabPath && { srcVocabPath }),
|
|
71
|
-
...(dstVocabPath && { dstVocabPath }),
|
|
72
57
|
...(nmtConfig.normalize !== undefined && {
|
|
73
58
|
normalize: nmtConfig.normalize,
|
|
74
59
|
}),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
bergamotPivotModel: (() => {
|
|
60
|
+
...(nmtConfig.pivotModel && pivotModelPath && {
|
|
61
|
+
pivotConfig: (() => {
|
|
78
62
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
-
const { modelSrc, dstVocabSrc, srcVocabSrc, ...
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
loader: asLoader(new FilesystemDL({ dirPath })),
|
|
83
|
-
modelName: basePath,
|
|
84
|
-
diskPath: dirPath,
|
|
85
|
-
config: {
|
|
86
|
-
...config,
|
|
87
|
-
srcVocabPath: pivotSrcVocabPath,
|
|
88
|
-
dstVocabPath: pivotDstVocabPath
|
|
89
|
-
}
|
|
90
|
-
};
|
|
63
|
+
const { modelSrc, dstVocabSrc, srcVocabSrc, ...pivotGenConfig } = nmtConfig.pivotModel;
|
|
64
|
+
return pivotGenConfig;
|
|
91
65
|
})(),
|
|
92
66
|
}),
|
|
93
67
|
}),
|
|
94
68
|
};
|
|
95
|
-
const model = new TranslationNmtcpp(
|
|
96
|
-
|
|
69
|
+
const model = new TranslationNmtcpp({
|
|
70
|
+
files,
|
|
71
|
+
params: { mode, srcLang: from, dstLang: to },
|
|
72
|
+
config,
|
|
73
|
+
logger,
|
|
74
|
+
opts: { stats: true },
|
|
75
|
+
});
|
|
76
|
+
return { model };
|
|
97
77
|
}
|
|
98
78
|
export const nmtPlugin = definePlugin({
|
|
99
79
|
modelType: ModelType.nmtcppTranslation,
|
|
@@ -101,69 +81,27 @@ export const nmtPlugin = definePlugin({
|
|
|
101
81
|
addonPackage: ADDON_NMT,
|
|
102
82
|
loadConfigSchema: nmtConfigBaseSchema,
|
|
103
83
|
async resolveConfig(cfg, ctx) {
|
|
104
|
-
const { srcVocabSrc, dstVocabSrc, ...nmtConfig } = cfg;
|
|
84
|
+
const { srcVocabSrc, dstVocabSrc, pivotModel, ...nmtConfig } = cfg;
|
|
105
85
|
if (nmtConfig.engine !== "Bergamot") {
|
|
106
86
|
return { config: nmtConfig };
|
|
107
87
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (!srcSrc || !dstSrc) {
|
|
111
|
-
const derived = ctx.modelSrc.startsWith("pear://")
|
|
112
|
-
? deriveBergamotVocabSources(ctx.modelSrc)
|
|
113
|
-
: ctx.modelSrc.startsWith("registry://")
|
|
114
|
-
? deriveBergamotRegistryVocabSources(ctx.modelSrc)
|
|
115
|
-
: null;
|
|
116
|
-
if (derived) {
|
|
117
|
-
srcSrc = srcSrc ?? derived.srcVocabSrc;
|
|
118
|
-
dstSrc = dstSrc ?? derived.dstVocabSrc;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (!srcSrc || !dstSrc) {
|
|
122
|
-
throw new ModelLoadFailedError("Bergamot requires srcVocabSrc and dstVocabSrc. Provide them in modelConfig or use a pear:// or registry:// model source for auto-derivation.");
|
|
123
|
-
}
|
|
124
|
-
const pivotModel = nmtConfig.pivotModel;
|
|
125
|
-
if (!pivotModel) {
|
|
126
|
-
const [srcVocabPath, dstVocabPath] = await Promise.all([
|
|
127
|
-
ctx.resolveModelPath(srcSrc),
|
|
128
|
-
ctx.resolveModelPath(dstSrc),
|
|
129
|
-
]);
|
|
130
|
-
return {
|
|
131
|
-
config: nmtConfig,
|
|
132
|
-
artifacts: { srcVocabPath, dstVocabPath },
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
let pivotSrcSrc = pivotModel.srcVocabSrc;
|
|
136
|
-
let pivotDstSrc = pivotModel.dstVocabSrc;
|
|
137
|
-
if (!pivotSrcSrc || !pivotDstSrc) {
|
|
138
|
-
const pivotDerived = pivotModel.modelSrc.startsWith("pear://")
|
|
139
|
-
? deriveBergamotVocabSources(pivotModel.modelSrc)
|
|
140
|
-
: pivotModel.modelSrc.startsWith("registry://")
|
|
141
|
-
? deriveBergamotRegistryVocabSources(pivotModel.modelSrc)
|
|
142
|
-
: null;
|
|
143
|
-
if (pivotDerived) {
|
|
144
|
-
pivotSrcSrc = pivotSrcSrc ?? pivotDerived.srcVocabSrc;
|
|
145
|
-
pivotDstSrc = pivotDstSrc ?? pivotDerived.dstVocabSrc;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (!pivotSrcSrc || !pivotDstSrc) {
|
|
149
|
-
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.");
|
|
150
|
-
}
|
|
151
|
-
const [srcVocabPath, dstVocabPath, pivotSrcVocabPath, pivotDstVocabPath, pivotModelPath] = await Promise.all([
|
|
152
|
-
ctx.resolveModelPath(srcSrc),
|
|
153
|
-
ctx.resolveModelPath(dstSrc),
|
|
154
|
-
ctx.resolveModelPath(pivotSrcSrc),
|
|
155
|
-
ctx.resolveModelPath(pivotDstSrc),
|
|
156
|
-
ctx.resolveModelPath(pivotModel.modelSrc),
|
|
157
|
-
]);
|
|
158
|
-
return {
|
|
159
|
-
config: nmtConfig,
|
|
160
|
-
artifacts: { srcVocabPath, dstVocabPath, pivotSrcVocabPath, pivotDstVocabPath, pivotModelPath },
|
|
161
|
-
};
|
|
88
|
+
const bergamotConfig = { ...nmtConfig, ...(pivotModel && { pivotModel }) };
|
|
89
|
+
return resolveBergamotVocab(bergamotConfig, ctx, srcVocabSrc, dstVocabSrc, pivotModel);
|
|
162
90
|
},
|
|
163
91
|
createModel(params) {
|
|
164
92
|
const nmtConfig = (params.modelConfig ?? {});
|
|
165
|
-
const
|
|
166
|
-
|
|
93
|
+
const artifacts = params.artifacts ?? {};
|
|
94
|
+
const derived = deriveColocatedBergamotVocabPaths(params.modelPath);
|
|
95
|
+
const srcVocabPath = artifacts["srcVocabPath"] ?? derived?.srcVocabPath;
|
|
96
|
+
const dstVocabPath = artifacts["dstVocabPath"] ?? derived?.dstVocabPath;
|
|
97
|
+
const pivotModelPath = artifacts["pivotModelPath"];
|
|
98
|
+
const pivotDerived = pivotModelPath
|
|
99
|
+
? deriveColocatedBergamotVocabPaths(pivotModelPath)
|
|
100
|
+
: null;
|
|
101
|
+
const pivotSrcVocabPath = artifacts["pivotSrcVocabPath"] ?? pivotDerived?.srcVocabPath;
|
|
102
|
+
const pivotDstVocabPath = artifacts["pivotDstVocabPath"] ?? pivotDerived?.dstVocabPath;
|
|
103
|
+
const { model } = createNmtModel(params.modelId, params.modelPath, nmtConfig, srcVocabPath, dstVocabPath, pivotModelPath, pivotSrcVocabPath, pivotDstVocabPath);
|
|
104
|
+
return { model };
|
|
167
105
|
},
|
|
168
106
|
handlers: {
|
|
169
107
|
translate: defineHandler({
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ModelSrcInput, type NmtConfig, type ResolveContext, type ResolveResult } from "../../../../schemas/index";
|
|
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 SDK
|
|
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>>>;
|
|
32
|
+
//# sourceMappingURL=resolve-vocab.d.ts.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { BERGAMOT_CJK_LANG_PAIRS, } from "../../../../schemas/index.js";
|
|
2
|
+
import { ModelLoadFailedError } from "../../../../utils/errors-server.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 SDK
|
|
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 &&
|
|
94
|
+
pivotIsRegistry &&
|
|
95
|
+
primaryVocabsAreDerived &&
|
|
96
|
+
pivotVocabsAreDerived) {
|
|
97
|
+
const pivotModelPath = await ctx.resolveModelPath(pivotModel.modelSrc);
|
|
98
|
+
return { config: nmtConfig, artifacts: { pivotModelPath } };
|
|
99
|
+
}
|
|
100
|
+
const [srcVocabPath, dstVocabPath, pivotSrcVocabPath, pivotDstVocabPath, pivotModelPath,] = await Promise.all([
|
|
101
|
+
ctx.resolveModelPath(srcSrc),
|
|
102
|
+
ctx.resolveModelPath(dstSrc),
|
|
103
|
+
ctx.resolveModelPath(pivotSrcSrc),
|
|
104
|
+
ctx.resolveModelPath(pivotDstSrc),
|
|
105
|
+
ctx.resolveModelPath(pivotModel.modelSrc),
|
|
106
|
+
]);
|
|
107
|
+
return {
|
|
108
|
+
config: nmtConfig,
|
|
109
|
+
artifacts: {
|
|
110
|
+
srcVocabPath,
|
|
111
|
+
dstVocabPath,
|
|
112
|
+
pivotSrcVocabPath,
|
|
113
|
+
pivotDstVocabPath,
|
|
114
|
+
pivotModelPath,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -33,6 +33,7 @@ export declare const ocrPlugin: {
|
|
|
33
33
|
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
34
34
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
35
35
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
36
|
+
embeddings: "embeddings";
|
|
36
37
|
"llamacpp-completion": "llamacpp-completion";
|
|
37
38
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
38
39
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -43,7 +44,6 @@ export declare const ocrPlugin: {
|
|
|
43
44
|
"sdcpp-generation": "sdcpp-generation";
|
|
44
45
|
llm: "llm";
|
|
45
46
|
whisper: "whisper";
|
|
46
|
-
embeddings: "embeddings";
|
|
47
47
|
nmt: "nmt";
|
|
48
48
|
parakeet: "parakeet";
|
|
49
49
|
tts: "tts";
|
|
@@ -54,7 +54,6 @@ function createOCRModel(modelId, detectorPath, recognizerPath, ocrConfig) {
|
|
|
54
54
|
params,
|
|
55
55
|
opts: { stats: true },
|
|
56
56
|
};
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
58
57
|
const model = new ONNXOcr(args);
|
|
59
58
|
return model;
|
|
60
59
|
}
|
|
@@ -83,7 +82,7 @@ export const ocrPlugin = definePlugin({
|
|
|
83
82
|
}
|
|
84
83
|
const model = createOCRModel(params.modelId, detectorModelPath, params.modelPath, // recognizerPath
|
|
85
84
|
ocrConfig);
|
|
86
|
-
return { model
|
|
85
|
+
return { model };
|
|
87
86
|
},
|
|
88
87
|
handlers: {
|
|
89
88
|
ocrStream: defineHandler({
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type TextToSpeechStreamRequest, type TtsStats } from "../../../../../schemas/index";
|
|
2
|
+
import { type TtsOpYield } from "../../../utils/tts-stats";
|
|
3
|
+
export declare function textToSpeechStream(params: TextToSpeechStreamRequest, inputStream: AsyncIterable<Buffer>): AsyncGenerator<TtsOpYield, {
|
|
4
|
+
modelExecutionMs: number;
|
|
5
|
+
stats?: TtsStats;
|
|
6
|
+
}, unknown>;
|
|
7
|
+
//# sourceMappingURL=text-to-speech-stream.d.ts.map
|