@qvac/inference 0.23.0 → 0.24.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 +60 -28
- package/README.md +3 -1
- package/dist/api/assess-model-fit.d.ts +14 -14
- package/dist/api/assess-model-fit.js +14 -14
- package/dist/api/audio-gen.d.ts +2 -2
- package/dist/api/audio-gen.js +135 -44
- package/dist/api/batch-completion.js +2 -1
- package/dist/api/calc-tokens.d.ts +30 -0
- package/dist/api/calc-tokens.js +41 -0
- package/dist/api/classify.d.ts +5 -2
- package/dist/api/classify.js +5 -2
- package/dist/api/completion-stream.d.ts +1 -1
- package/dist/api/completion-stream.js +2 -1
- package/dist/api/delete-cache.d.ts +7 -1
- package/dist/api/delete-cache.js +11 -1
- package/dist/api/diffusion.d.ts +14 -1
- package/dist/api/diffusion.js +14 -1
- package/dist/api/embed.d.ts +82 -29
- package/dist/api/embed.js +64 -18
- package/dist/api/get-model-info.d.ts +1 -1
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.js +2 -1
- package/dist/api/rag.d.ts +1 -1
- package/dist/api/rag.js +1 -1
- package/dist/api/registry.d.ts +16 -6
- package/dist/api/registry.js +32 -9
- package/dist/api/text-to-speech.d.ts +14 -5
- package/dist/api/text-to-speech.js +83 -29
- package/dist/api/transcribe.d.ts +6 -2
- package/dist/api/transcribe.js +7 -1
- package/dist/api/vector-index.d.ts +25 -3
- package/dist/api/vector-index.js +17 -2
- package/dist/api/video-request.d.ts +15 -15
- package/dist/dispatch.d.ts +10 -4
- package/dist/dispatch.js +65 -15
- package/dist/engine.d.ts +1 -1
- package/dist/errors/index.d.ts +70 -0
- package/dist/errors/index.js +128 -0
- package/dist/handlers/assess-model-fit.d.ts +3 -21
- package/dist/handlers/assess-model-fit.js +4 -303
- package/dist/handlers/cancelHandler.d.ts +10 -9
- package/dist/handlers/cancelHandler.js +17 -13
- package/dist/handlers/completion-orchestrate.d.ts +14 -2
- package/dist/handlers/completion-orchestrate.js +164 -22
- package/dist/handlers/delete-cache.d.ts +2 -1
- package/dist/handlers/delete-cache.js +6 -1
- package/dist/handlers/download-asset.js +11 -4
- package/dist/handlers/get-loaded-model-info.js +1 -0
- package/dist/handlers/get-model-info.js +71 -2
- package/dist/handlers/load-model/coreml-sidecars.d.ts +2 -13
- package/dist/handlers/load-model/coreml-sidecars.js +16 -119
- package/dist/handlers/load-model/download-lock.d.ts +20 -0
- package/dist/handlers/load-model/download-lock.js +213 -0
- package/dist/handlers/load-model/download-manager.d.ts +10 -2
- package/dist/handlers/load-model/download-manager.js +62 -11
- package/dist/handlers/load-model/handler.js +88 -35
- package/dist/handlers/load-model/http.js +327 -205
- package/dist/handlers/load-model/hyperdrive.d.ts +15 -0
- package/dist/handlers/load-model/hyperdrive.js +123 -50
- package/dist/handlers/load-model/registry-client-options.d.ts +2 -0
- package/dist/handlers/load-model/registry-client-options.js +4 -2
- package/dist/handlers/load-model/registry-companion-set.d.ts +5 -0
- package/dist/handlers/load-model/registry-companion-set.js +19 -1
- package/dist/handlers/load-model/registry-delete.d.ts +5 -0
- package/dist/handlers/load-model/registry-delete.js +269 -0
- package/dist/handlers/load-model/registry-download-utils.d.ts +4 -2
- package/dist/handlers/load-model/registry-download-utils.js +93 -22
- package/dist/handlers/load-model/registry.d.ts +20 -0
- package/dist/handlers/load-model/registry.js +308 -175
- package/dist/handlers/load-model/resolve.js +4 -1
- package/dist/handlers/load-model/types.d.ts +2 -0
- package/dist/handlers/logging-stream.js +17 -5
- package/dist/handlers/plugin-invoke.js +152 -39
- package/dist/handlers/registry.d.ts +2 -2
- package/dist/handlers/registry.js +105 -28
- package/dist/handlers/rpc-server.js +7 -7
- package/dist/handlers/session.d.ts +11 -0
- package/dist/handlers/session.js +40 -0
- package/dist/handlers/unload-model.js +8 -3
- package/dist/handlers/vector-index.js +118 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/logging/utils.js +10 -2
- package/dist/model-cache-layout.d.ts +1 -0
- package/dist/model-cache-layout.js +2 -0
- package/dist/model-fit/assess.d.ts +18 -67
- package/dist/model-fit/assess.js +96 -665
- package/dist/model-fit/describe.d.ts +12 -0
- package/dist/model-fit/describe.js +29 -0
- package/dist/model-fit/description/fetch.d.ts +1 -1
- package/dist/model-fit/description/fetch.js +95 -16
- package/dist/model-fit/description/resolve-load.d.ts +5 -3
- package/dist/model-fit/description/resolve-load.js +14 -14
- package/dist/model-fit/fit-load.d.ts +23 -0
- package/dist/model-fit/fit-load.js +29 -0
- package/dist/model-fit/load-check.d.ts +15 -33
- package/dist/model-fit/load-check.js +50 -195
- package/dist/model-fit/run/engine.d.ts +12 -72
- package/dist/model-fit/run/engine.js +4 -8
- package/dist/model-fit/run/run.d.ts +10 -7
- package/dist/model-fit/run/run.js +22 -18
- package/dist/model-fit/sum.d.ts +32 -0
- package/dist/model-fit/sum.js +60 -0
- package/dist/models/registry/models.d.ts +865 -128
- package/dist/models/registry/models.js +3737 -2963
- package/dist/plugins/builtin/asr-ggml/config.d.ts +19 -4
- package/dist/plugins/builtin/asr-ggml/config.js +39 -3
- package/dist/plugins/builtin/asr-ggml/fit.d.ts +18 -0
- package/dist/{model-fit/request/engines/asr.js → plugins/builtin/asr-ggml/fit.js} +55 -71
- package/dist/plugins/builtin/audiogen-ggml/config.d.ts +6 -0
- package/dist/plugins/builtin/audiogen-ggml/config.js +9 -0
- package/dist/plugins/builtin/audiogen-ggml/fit.d.ts +3 -0
- package/dist/{model-fit/request/engines/audiogen.js → plugins/builtin/audiogen-ggml/fit.js} +28 -18
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-edit-stream.d.ts +3 -1
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-edit-stream.js +2 -1
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-encode.d.ts +17 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-encode.js +68 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-run.d.ts +11 -3
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-run.js +47 -11
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.d.ts +3 -1
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +2 -1
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-understand.d.ts +3 -1
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-understand.js +2 -1
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +143 -18
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +13 -1
- package/dist/plugins/builtin/bci-whispercpp-transcription/fit.d.ts +3 -0
- package/dist/plugins/builtin/bci-whispercpp-transcription/fit.js +22 -0
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +45 -4
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +8 -6
- package/dist/plugins/builtin/ggml-classification/plugin.d.ts +4 -1
- package/dist/plugins/builtin/ggml-classification/plugin.js +88 -8
- package/dist/plugins/builtin/ggml-image-embedding/ops/embed.d.ts +24 -0
- package/dist/plugins/builtin/ggml-image-embedding/ops/embed.js +184 -0
- package/dist/plugins/builtin/ggml-image-embedding/plugin.d.ts +120 -0
- package/dist/plugins/builtin/ggml-image-embedding/plugin.js +39 -0
- package/dist/plugins/builtin/ggml-ocr/fit.d.ts +6 -0
- package/dist/plugins/builtin/ggml-ocr/fit.js +19 -0
- package/dist/plugins/builtin/ggml-ocr/params.d.ts +1 -1
- package/dist/plugins/builtin/ggml-ocr/plugin.d.ts +9 -3
- package/dist/plugins/builtin/ggml-ocr/plugin.js +107 -21
- package/dist/plugins/builtin/ggml-vla/ops/vla-run.d.ts +2 -2
- package/dist/plugins/builtin/ggml-vla/ops/vla-run.js +18 -2
- package/dist/plugins/builtin/ggml-vla/plugin.d.ts +3 -3
- package/dist/plugins/builtin/index.d.ts +1 -0
- package/dist/plugins/builtin/index.js +1 -0
- package/dist/plugins/builtin/llamacpp-completion/fit.d.ts +3 -0
- package/dist/plugins/builtin/llamacpp-completion/fit.js +28 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +1 -1
- package/dist/plugins/builtin/llamacpp-completion/ops/cache-logger.js +15 -4
- package/dist/plugins/builtin/llamacpp-completion/ops/calc-tokens.d.ts +2 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/calc-tokens.js +32 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.d.ts +1 -1
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.d.ts +17 -3
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +61 -5
- package/dist/plugins/builtin/llamacpp-completion/ops/finetune.d.ts +5 -4
- package/dist/plugins/builtin/llamacpp-completion/ops/finetune.js +54 -19
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +148 -19
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +26 -9
- package/dist/plugins/builtin/llamacpp-decision/ops/decide.d.ts +3 -1
- package/dist/plugins/builtin/llamacpp-decision/ops/decide.js +5 -2
- package/dist/plugins/builtin/llamacpp-decision/plugin.d.ts +4 -2
- package/dist/plugins/builtin/llamacpp-decision/plugin.js +2 -2
- package/dist/plugins/builtin/llamacpp-embedding/fit.d.ts +3 -0
- package/dist/plugins/builtin/llamacpp-embedding/fit.js +23 -0
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +194 -4
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +37 -11
- package/dist/plugins/builtin/llamacpp-embedding/transform.d.ts +2 -2
- package/dist/plugins/builtin/llamacpp-embedding/transform.js +23 -2
- package/dist/plugins/builtin/llamacpp-rerank/ops/rerank.d.ts +3 -1
- package/dist/plugins/builtin/llamacpp-rerank/ops/rerank.js +5 -2
- package/dist/plugins/builtin/llamacpp-rerank/plugin.d.ts +6 -5
- package/dist/plugins/builtin/llamacpp-rerank/plugin.js +2 -3
- package/dist/plugins/builtin/moss-transcribe/plugin.d.ts +30 -3
- package/dist/plugins/builtin/moss-transcribe/plugin.js +5 -3
- package/dist/plugins/builtin/nmtcpp-translation/fit.d.ts +3 -0
- package/dist/plugins/builtin/nmtcpp-translation/fit.js +11 -0
- package/dist/plugins/builtin/nmtcpp-translation/plugin.d.ts +14 -5
- package/dist/plugins/builtin/nmtcpp-translation/plugin.js +4 -2
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +205 -9
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +39 -13
- package/dist/plugins/builtin/sdcpp-generation/fit.d.ts +3 -0
- package/dist/plugins/builtin/sdcpp-generation/fit.js +68 -0
- package/dist/plugins/builtin/sdcpp-generation/load-files.d.ts +30 -0
- package/dist/plugins/builtin/sdcpp-generation/load-files.js +121 -0
- package/dist/plugins/builtin/sdcpp-generation/ops/diffusion.d.ts +4 -1
- package/dist/plugins/builtin/sdcpp-generation/ops/diffusion.js +8 -3
- package/dist/plugins/builtin/sdcpp-generation/ops/upscale.d.ts +4 -1
- package/dist/plugins/builtin/sdcpp-generation/ops/upscale.js +107 -22
- package/dist/plugins/builtin/sdcpp-generation/ops/video.d.ts +3 -1
- package/dist/plugins/builtin/sdcpp-generation/ops/video.js +4 -1
- package/dist/plugins/builtin/sdcpp-generation/ops/world.d.ts +4 -2
- package/dist/plugins/builtin/sdcpp-generation/ops/world.js +7 -2
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +79 -16
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +29 -117
- package/dist/plugins/builtin/tts-ggml/fit.d.ts +3 -0
- package/dist/plugins/builtin/tts-ggml/fit.js +162 -0
- package/dist/plugins/builtin/tts-ggml/ops/cancel-binding.d.ts +2 -1
- package/dist/plugins/builtin/tts-ggml/ops/cancel-binding.js +4 -1
- package/dist/plugins/builtin/tts-ggml/ops/moss-options.d.ts +1 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.d.ts +2 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.js +22 -9
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.d.ts +2 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +51 -16
- package/dist/plugins/builtin/tts-ggml/ops/voice-options.d.ts +50 -0
- package/dist/plugins/builtin/tts-ggml/ops/voice-options.js +74 -0
- package/dist/plugins/builtin/tts-ggml/plugin.d.ts +368 -25
- package/dist/plugins/builtin/tts-ggml/plugin.js +180 -31
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +70 -7
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +8 -6
- package/dist/plugins/ops/bci-transcribe.d.ts +5 -4
- package/dist/plugins/ops/bci-transcribe.js +18 -4
- package/dist/plugins/ops/cancel.d.ts +1 -0
- package/dist/plugins/ops/cancel.js +11 -2
- package/dist/plugins/ops/embed.d.ts +5 -3
- package/dist/plugins/ops/embed.js +89 -34
- package/dist/plugins/ops/kv-cache-utils.d.ts +1 -0
- package/dist/plugins/ops/kv-cache-utils.js +6 -2
- package/dist/plugins/ops/load-model.d.ts +2 -0
- package/dist/plugins/ops/load-model.js +33 -16
- package/dist/plugins/ops/transcribe.d.ts +5 -4
- package/dist/plugins/ops/transcribe.js +62 -27
- package/dist/plugins/ops/translate.d.ts +2 -1
- package/dist/plugins/ops/translate.js +4 -1
- package/dist/plugins/ops/unload-model.d.ts +17 -1
- package/dist/plugins/ops/unload-model.js +31 -2
- package/dist/plugins/turbovec-backend.d.ts +1 -1
- package/dist/plugins/turbovec-backend.js +16 -1
- package/dist/profiling/operation-metrics.js +22 -19
- package/dist/rag/embedding-scope.d.ts +16 -0
- package/dist/rag/embedding-scope.js +81 -0
- package/dist/rag/handler.d.ts +25 -0
- package/dist/rag/handler.js +50 -16
- package/dist/rag/handlers/ingest.js +2 -6
- package/dist/rag/handlers/search.d.ts +10 -1
- package/dist/rag/handlers/search.js +16 -7
- package/dist/rag/rag-operation-manager.d.ts +27 -3
- package/dist/rag/rag-operation-manager.js +10 -27
- package/dist/registry.js +5 -0
- package/dist/resources/collector.d.ts +70 -36
- package/dist/resources/collector.js +8 -1
- package/dist/resources/types.d.ts +2 -0
- package/dist/rpc/inventory.js +1 -12
- package/dist/runtime/env.d.ts +5 -1
- package/dist/runtime/env.js +6 -21
- package/dist/runtime/index.d.ts +4 -1
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/lifecycle.d.ts +6 -4
- package/dist/runtime/lifecycle.js +9 -5
- package/dist/runtime/model-config-utils.js +5 -1
- package/dist/runtime/model-registry.d.ts +28 -4
- package/dist/runtime/model-registry.js +46 -1
- package/dist/runtime/model-work-lock.d.ts +13 -0
- package/dist/runtime/model-work-lock.js +48 -0
- package/dist/runtime/registry-client.d.ts +47 -1
- package/dist/runtime/registry-client.js +446 -88
- package/dist/runtime/request-context.d.ts +9 -1
- package/dist/runtime/request-context.js +25 -1
- package/dist/runtime/request-registry.d.ts +55 -7
- package/dist/runtime/request-registry.js +189 -71
- package/dist/runtime/runtime-lifecycle.js +10 -1
- package/dist/runtime/session-id.d.ts +18 -0
- package/dist/runtime/session-id.js +20 -0
- package/dist/runtime/session-registry.d.ts +39 -0
- package/dist/runtime/session-registry.js +114 -0
- package/dist/runtime/vector-index-backend.d.ts +4 -0
- package/dist/runtime/vector-index-registry.d.ts +21 -0
- package/dist/runtime/vector-index-registry.js +56 -18
- package/dist/schemas/abort-signal.d.ts +8 -0
- package/dist/schemas/abort-signal.js +1 -0
- package/dist/schemas/assess-model-fit.d.ts +132 -282
- package/dist/schemas/assess-model-fit.js +82 -216
- package/dist/schemas/audio-gen.d.ts +278 -24
- package/dist/schemas/audio-gen.js +127 -23
- package/dist/schemas/batch-completion-stream.d.ts +105 -13
- package/dist/schemas/batch-completion-stream.js +8 -4
- package/dist/schemas/bci-config.d.ts +2 -1
- package/dist/schemas/bci.d.ts +54 -3
- package/dist/schemas/bci.js +11 -16
- package/dist/schemas/calc-tokens.d.ts +141 -0
- package/dist/schemas/calc-tokens.js +53 -0
- package/dist/schemas/cancel.d.ts +26 -0
- package/dist/schemas/cancel.js +10 -2
- package/dist/schemas/classification.d.ts +3 -0
- package/dist/schemas/classification.js +6 -2
- package/dist/schemas/common.d.ts +1831 -348
- package/dist/schemas/common.js +18 -2
- package/dist/schemas/completion-event.d.ts +3 -0
- package/dist/schemas/completion-event.js +1 -1
- package/dist/schemas/completion-stream.d.ts +162 -17
- package/dist/schemas/completion-stream.js +83 -13
- package/dist/schemas/config.d.ts +1212 -169
- package/dist/schemas/config.js +9 -13
- package/dist/schemas/decision.d.ts +4 -2
- package/dist/schemas/decision.js +2 -1
- package/dist/schemas/download-asset.d.ts +10 -5
- package/dist/schemas/download-asset.js +3 -6
- package/dist/schemas/embed.d.ts +286 -3
- package/dist/schemas/embed.js +162 -16
- package/dist/schemas/engine-addon-map.d.ts +1 -0
- package/dist/schemas/engine-addon-map.js +1 -0
- package/dist/schemas/errors.d.ts +12 -0
- package/dist/schemas/errors.js +66 -1
- package/dist/schemas/finetune.d.ts +14 -4
- package/dist/schemas/finetune.js +5 -6
- package/dist/schemas/heartbeat.d.ts +1 -0
- package/dist/schemas/heartbeat.js +5 -2
- package/dist/schemas/image-embedding.d.ts +27 -0
- package/dist/schemas/image-embedding.js +107 -0
- package/dist/schemas/index.d.ts +7 -3
- package/dist/schemas/index.js +7 -3
- package/dist/schemas/lifecycle.d.ts +3 -0
- package/dist/schemas/lifecycle.js +13 -6
- package/dist/schemas/llamacpp-config.d.ts +269 -22
- package/dist/schemas/llamacpp-config.js +86 -7
- package/dist/schemas/load-model.d.ts +6418 -1960
- package/dist/schemas/load-model.js +39 -8
- package/dist/schemas/logging-stream.d.ts +1 -0
- package/dist/schemas/logging-stream.js +5 -2
- package/dist/schemas/model-config-schemas.d.ts +542 -116
- package/dist/schemas/model-config-schemas.js +2 -0
- package/dist/schemas/model-fit-policy.d.ts +2 -2
- package/dist/schemas/model-info.d.ts +54 -56
- package/dist/schemas/model-info.js +17 -6
- package/dist/schemas/model-ops.d.ts +12 -0
- package/dist/schemas/model-ops.js +33 -5
- package/dist/schemas/model-src-utils.d.ts +10 -6
- package/dist/schemas/model-types.d.ts +8 -4
- package/dist/schemas/model-types.js +1 -0
- package/dist/schemas/ocr.d.ts +9 -4
- package/dist/schemas/ocr.js +6 -2
- package/dist/schemas/plugin.d.ts +62 -6
- package/dist/schemas/plugin.js +26 -4
- package/dist/schemas/profiling.d.ts +32 -32
- package/dist/schemas/rag.d.ts +9 -0
- package/dist/schemas/rag.js +10 -16
- package/dist/schemas/registry.d.ts +30 -10
- package/dist/schemas/registry.js +14 -6
- package/dist/schemas/reload-config.d.ts +41 -6
- package/dist/schemas/reload-config.js +11 -4
- package/dist/schemas/request-base.d.ts +39 -0
- package/dist/schemas/request-base.js +64 -0
- package/dist/schemas/rerank.d.ts +8 -7
- package/dist/schemas/rerank.js +6 -4
- package/dist/schemas/rpc-server.d.ts +3 -0
- package/dist/schemas/rpc-server.js +15 -15
- package/dist/schemas/sdcpp-config.d.ts +90 -20
- package/dist/schemas/sdcpp-config.js +96 -19
- package/dist/schemas/session.d.ts +37 -0
- package/dist/schemas/session.js +53 -0
- package/dist/schemas/system-resources.d.ts +364 -179
- package/dist/schemas/system-resources.js +8 -3
- package/dist/schemas/text-to-speech.d.ts +1343 -271
- package/dist/schemas/text-to-speech.js +547 -33
- package/dist/schemas/tools.d.ts +7 -0
- package/dist/schemas/tools.js +29 -0
- package/dist/schemas/transcription-config.d.ts +262 -2
- package/dist/schemas/transcription-config.js +122 -6
- package/dist/schemas/transcription.d.ts +93 -6
- package/dist/schemas/transcription.js +98 -21
- package/dist/schemas/translate.d.ts +2 -0
- package/dist/schemas/translate.js +5 -9
- package/dist/schemas/translation-config.d.ts +30 -20
- package/dist/schemas/tts-pcm.d.ts +35 -0
- package/dist/schemas/tts-pcm.js +69 -0
- package/dist/schemas/vector-index.d.ts +47 -1
- package/dist/schemas/vector-index.js +37 -10
- package/dist/schemas/vla.d.ts +3 -3
- package/dist/surface.d.ts +3 -3
- package/dist/surface.js +3 -3
- package/dist/utils/addon-responses.d.ts +69 -2
- package/dist/utils/archive.d.ts +7 -0
- package/dist/utils/archive.js +88 -29
- package/dist/utils/asr-events.d.ts +5 -0
- package/dist/utils/asr-events.js +10 -1
- package/dist/utils/cache/auto-history.js +3 -1
- package/dist/utils/cache/layout.d.ts +48 -0
- package/dist/utils/cache/layout.js +190 -0
- package/dist/utils/cache/paths.js +2 -4
- package/dist/utils/cache/types.d.ts +2 -1
- package/dist/utils/checksum.d.ts +5 -0
- package/dist/utils/checksum.js +18 -0
- package/dist/utils/completion-normalizer.js +286 -87
- package/dist/utils/gguf-tensor-extractor.d.ts +0 -6
- package/dist/utils/gguf-tensor-extractor.js +1 -50
- package/dist/utils/shard-utils.d.ts +0 -21
- package/dist/utils/shard-utils.js +12 -62
- package/dist/utils/tool-integration.d.ts +2 -2
- package/dist/utils/tools/defer.d.ts +39 -10
- package/dist/utils/tools/defer.js +72 -17
- package/dist/utils/tools/index.d.ts +1 -1
- package/dist/utils/tools/index.js +1 -1
- package/dist/utils/transcribe-metadata.d.ts +28 -2
- package/dist/utils/transcribe-metadata.js +16 -0
- package/dist/utils/tts-stats.d.ts +42 -0
- package/dist/utils/tts-stats.js +120 -22
- package/package.json +43 -39
- package/dist/model-fit/classify.d.ts +0 -6
- package/dist/model-fit/classify.js +0 -166
- package/dist/model-fit/description/project.d.ts +0 -27
- package/dist/model-fit/description/project.js +0 -33
- package/dist/model-fit/floor.d.ts +0 -31
- package/dist/model-fit/floor.js +0 -65
- package/dist/model-fit/kv-cache.d.ts +0 -23
- package/dist/model-fit/kv-cache.js +0 -85
- package/dist/model-fit/platform.d.ts +0 -14
- package/dist/model-fit/platform.js +0 -26
- package/dist/model-fit/request/create.d.ts +0 -31
- package/dist/model-fit/request/create.js +0 -61
- package/dist/model-fit/request/engines/asr.d.ts +0 -14
- package/dist/model-fit/request/engines/audiogen.d.ts +0 -8
- package/dist/model-fit/request/engines/diffusion.d.ts +0 -7
- package/dist/model-fit/request/engines/diffusion.js +0 -93
- package/dist/model-fit/request/engines/llama.d.ts +0 -12
- package/dist/model-fit/request/engines/llama.js +0 -44
- package/dist/model-fit/request/engines/nmt.d.ts +0 -8
- package/dist/model-fit/request/engines/nmt.js +0 -11
- package/dist/model-fit/request/engines/ocr.d.ts +0 -9
- package/dist/model-fit/request/engines/ocr.js +0 -13
- package/dist/model-fit/request/engines/tts.d.ts +0 -10
- package/dist/model-fit/request/engines/tts.js +0 -152
- package/dist/models/registry/resource-profiles.d.ts +0 -17
- package/dist/models/registry/resource-profiles.js +0 -5859
- package/dist/schemas/model-resource-profile.d.ts +0 -109
- package/dist/schemas/model-resource-profile.js +0 -80
- /package/dist/model-fit/{request/gpu.d.ts → gpu.d.ts} +0 -0
- /package/dist/model-fit/{request/gpu.js → gpu.js} +0 -0
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { ModelLoadFailedError, InvalidShardUrlPatternError } from '../errors/index.js';
|
|
2
2
|
import { generateShortHash } from '../utils/formatting.js';
|
|
3
|
+
import { SHARD_FILENAME_PATTERN } from '../utils/cache/layout.js';
|
|
3
4
|
import { validateAndJoinPath } from '../utils/path-security.js';
|
|
4
|
-
import { extractAndWriteTensorsFile } from '../utils/gguf-tensor-extractor.js';
|
|
5
5
|
import { promises as fsPromises } from 'bare-fs';
|
|
6
|
-
import path from 'bare-path';
|
|
7
6
|
/**
|
|
8
7
|
* Detect if model filename follows shard pattern (00001-of-0000x)
|
|
9
8
|
*/
|
|
10
9
|
export function detectShardedModel(filename) {
|
|
11
|
-
const
|
|
12
|
-
const match = filename.match(shardPattern);
|
|
10
|
+
const match = filename.match(SHARD_FILENAME_PATTERN);
|
|
13
11
|
if (match && match[1] && match[2] && match[3] && match[4]) {
|
|
14
12
|
return {
|
|
15
13
|
isSharded: true,
|
|
@@ -56,21 +54,6 @@ export function generateShardFilenames(shardName) {
|
|
|
56
54
|
}
|
|
57
55
|
return filenames;
|
|
58
56
|
}
|
|
59
|
-
/**
|
|
60
|
-
* List the files a model path loads: the path itself, or for a sharded model
|
|
61
|
-
* its tensors file followed by every shard in order
|
|
62
|
-
*/
|
|
63
|
-
export function getModelShardFiles(modelPath) {
|
|
64
|
-
const filename = path.basename(modelPath);
|
|
65
|
-
const info = detectShardedModel(filename);
|
|
66
|
-
if (!info.isSharded)
|
|
67
|
-
return [modelPath];
|
|
68
|
-
const directory = path.dirname(modelPath);
|
|
69
|
-
return [
|
|
70
|
-
path.join(directory, `${info.baseFilename}.tensors.txt`),
|
|
71
|
-
...generateShardFilenames(filename).map((shard) => path.join(directory, shard))
|
|
72
|
-
];
|
|
73
|
-
}
|
|
74
57
|
/**
|
|
75
58
|
* Parse pattern-based shard URL and generate all shard URLs with cache key
|
|
76
59
|
* Works with patterns like: https://example.com/path/model-00002-of-00005.gguf
|
|
@@ -95,22 +78,6 @@ export function parsePatternBasedShardUrl(shardUrl) {
|
|
|
95
78
|
cacheKey: generateShortHash(`${baseUrl}/${shardInfo.baseFilename}`)
|
|
96
79
|
};
|
|
97
80
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Extract tensor information from all shards and write to baseFilename.tensors.txt
|
|
100
|
-
* Required for sharded models to enable incremental/async loading
|
|
101
|
-
* @param shardDir - Directory containing the shard files
|
|
102
|
-
* @param shardFilename - Filename of any shard (e.g., "model-00001-of-00002.gguf")
|
|
103
|
-
* @returns Path to the created tensors.txt file
|
|
104
|
-
* @throws If not a sharded model or extraction fails
|
|
105
|
-
*/
|
|
106
|
-
export async function extractTensorsFromShards(shardDir, shardFilename) {
|
|
107
|
-
const shardInfo = detectShardedModel(shardFilename);
|
|
108
|
-
if (!shardInfo.isSharded || !shardInfo.baseFilename || !shardInfo.totalShards) {
|
|
109
|
-
throw new ModelLoadFailedError(`Not a sharded model filename: ${shardFilename}`);
|
|
110
|
-
}
|
|
111
|
-
const allShardFilenames = generateShardFilenames(shardFilename);
|
|
112
|
-
return extractAndWriteTensorsFile(shardDir, allShardFilenames, shardInfo.baseFilename);
|
|
113
|
-
}
|
|
114
81
|
/**
|
|
115
82
|
* Check if all numbered shard files exist
|
|
116
83
|
* @param shardDir - Directory containing the shard files
|
|
@@ -122,32 +89,15 @@ export async function checkAllShardsExist(shardDir, shardFilename) {
|
|
|
122
89
|
if (!shardInfo.isSharded) {
|
|
123
90
|
return false;
|
|
124
91
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
* @param shardDir - Directory containing the shard files
|
|
135
|
-
* @param shardFilename - Filename of any shard (e.g., "model-00001-of-00002.gguf")
|
|
136
|
-
* @returns true if all shards and tensors.txt exist, false otherwise
|
|
137
|
-
*/
|
|
138
|
-
export async function validateShardedModelCache(shardDir, shardFilename) {
|
|
139
|
-
const shardInfo = detectShardedModel(shardFilename);
|
|
140
|
-
if (!shardInfo.isSharded || !shardInfo.baseFilename) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
const allShardsExist = await checkAllShardsExist(shardDir, shardFilename);
|
|
144
|
-
if (!allShardsExist) {
|
|
145
|
-
return false;
|
|
92
|
+
// Sequential with an early exit: the shard count comes from the filename, so a
|
|
93
|
+
// crafted name must not fan out one filesystem call per claimed shard.
|
|
94
|
+
for (const f of generateShardFilenames(shardFilename)) {
|
|
95
|
+
try {
|
|
96
|
+
await fsPromises.access(validateAndJoinPath(shardDir, f));
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
146
101
|
}
|
|
147
|
-
|
|
148
|
-
const tensorsExist = await fsPromises
|
|
149
|
-
.access(validateAndJoinPath(shardDir, tensorsFile))
|
|
150
|
-
.then(() => true)
|
|
151
|
-
.catch(() => false);
|
|
152
|
-
return tensorsExist;
|
|
102
|
+
return true;
|
|
153
103
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Tool, ToolDialect } from '../schemas/index.js';
|
|
1
|
+
import type { HistoryContent, Tool, ToolDialect } from '../schemas/index.js';
|
|
2
2
|
interface HistoryMessage {
|
|
3
3
|
role: string;
|
|
4
|
-
content:
|
|
4
|
+
content: HistoryContent;
|
|
5
5
|
attachments?: {
|
|
6
6
|
path: string;
|
|
7
7
|
}[] | undefined;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HistoryContent } from '../../schemas/completion-stream.js';
|
|
2
|
+
import { type Tool, type ToolSearchOptions } from '../../schemas/tools.js';
|
|
3
|
+
import type { McpClientInput } from '../../schemas/mcp-adapter.js';
|
|
2
4
|
import { type ToolInput } from '../../utils/tool-helpers.js';
|
|
3
5
|
/**
|
|
4
6
|
* Reserved name of the built-in search tool. A caller cannot register a tool
|
|
@@ -8,8 +10,17 @@ import { type ToolInput } from '../../utils/tool-helpers.js';
|
|
|
8
10
|
export declare const TOOL_SEARCH_NAME = "tool_search";
|
|
9
11
|
export type HistoryMessage = {
|
|
10
12
|
role: string;
|
|
11
|
-
content:
|
|
13
|
+
content: HistoryContent;
|
|
12
14
|
};
|
|
15
|
+
export type ToolSearchLimits = {
|
|
16
|
+
defaultLimit: number;
|
|
17
|
+
maxLimit: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The limits a request's `toolSearch` options resolve to. Both the prompt and
|
|
21
|
+
* the search read them from here, so what the model is told is what applies.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveToolSearchLimits(options?: ToolSearchOptions): ToolSearchLimits;
|
|
13
24
|
export declare function isDeferred(tool: Tool): boolean;
|
|
14
25
|
export declare function partitionTools(tools: readonly Tool[]): {
|
|
15
26
|
alwaysLoaded: Tool[];
|
|
@@ -34,12 +45,16 @@ export declare function buildCatalog(deferred: readonly Tool[]): string;
|
|
|
34
45
|
* tool whose schema the model has never seen. Description text cannot be
|
|
35
46
|
* called, which is the whole point.
|
|
36
47
|
*/
|
|
37
|
-
export declare function buildToolSearchTool(deferred: readonly Tool[]): Tool;
|
|
48
|
+
export declare function buildToolSearchTool(deferred: readonly Tool[], options?: ToolSearchOptions): Tool;
|
|
38
49
|
/**
|
|
39
50
|
* Rank the deferred inventory against a query. Exact name first, then text
|
|
40
51
|
* match. Ties keep registration order so repeated searches are deterministic.
|
|
52
|
+
*
|
|
53
|
+
* An exact name loads that tool alone. Otherwise a match scoring under half of
|
|
54
|
+
* the best is left out: one query word in a description or group is not enough
|
|
55
|
+
* to load a tool beside a strong match, while tools tied at the top load together.
|
|
41
56
|
*/
|
|
42
|
-
export declare function searchDeferredTools(deferred: readonly Tool[], query: string, limit?: number): Tool[];
|
|
57
|
+
export declare function searchDeferredTools(deferred: readonly Tool[], query: string, limit?: number, options?: ToolSearchOptions): Tool[];
|
|
43
58
|
export declare function buildToolSearchResult(query: string, matches: readonly Tool[], alreadyLoaded: readonly string[]): string;
|
|
44
59
|
/**
|
|
45
60
|
* Which deferred definitions this conversation already carries.
|
|
@@ -70,14 +85,28 @@ export type DeferredResolution = {
|
|
|
70
85
|
*
|
|
71
86
|
* Returns `null` when nothing defers, so the existing path is untouched.
|
|
72
87
|
*/
|
|
73
|
-
export declare function resolveDeferredTools(tools: readonly Tool[] | undefined, history: readonly HistoryMessage[]): DeferredResolution | null;
|
|
88
|
+
export declare function resolveDeferredTools(tools: readonly Tool[] | undefined, history: readonly HistoryMessage[], options?: ToolSearchOptions): DeferredResolution | null;
|
|
89
|
+
/** What `executeToolSearch` searches: the params passed to `completion()`. */
|
|
90
|
+
export type ToolSearchSource = {
|
|
91
|
+
tools?: readonly Tool[] | readonly ToolInput[] | undefined;
|
|
92
|
+
toolSearch?: ToolSearchOptions | undefined;
|
|
93
|
+
mcp?: readonly McpClientInput[] | undefined;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Resolve completion params into a source `executeToolSearch` can search,
|
|
97
|
+
* listing MCP tools first as `completion()` does. Needed only when the params
|
|
98
|
+
* carry `mcp`; resolve once per conversation and reuse the result.
|
|
99
|
+
*/
|
|
100
|
+
export declare function resolveToolSearchSource(params: ToolSearchSource): Promise<ToolSearchSource>;
|
|
74
101
|
/**
|
|
75
102
|
* Run a `tool_search` call and produce the `tool` message that carries its
|
|
76
103
|
* result. Pure over the history it is given; the caller appends the message.
|
|
77
104
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
105
|
+
* Pass the same params given to `completion()`, so the search applies the
|
|
106
|
+
* `toolSearch` limits the model was told; with `mcp`, pass
|
|
107
|
+
* `resolveToolSearchSource(params)` instead. A bare tool list applies the default
|
|
108
|
+
* limits. Tools may be wire `Tool`s or the Zod-schema `ToolInput` form; both
|
|
109
|
+
* are converted to wire form first, so the size cap measures the JSON schemas
|
|
110
|
+
* the prompt will declare, not Zod objects.
|
|
82
111
|
*/
|
|
83
|
-
export declare function executeToolSearch(
|
|
112
|
+
export declare function executeToolSearch(source: readonly Tool[] | readonly ToolInput[] | ToolSearchSource, args: Record<string, unknown>, history: readonly HistoryMessage[]): string;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { DEFAULT_TOOL_SEARCH_LIMIT, MAX_TOOL_SEARCH_LIMIT, toolSearchOptionsSchema } from '../../schemas/tools.js';
|
|
2
|
+
import { InvalidToolSchemaError } from '../../errors/index.js';
|
|
3
|
+
import { getMcpTools } from '../../utils/mcp-adapter.js';
|
|
1
4
|
import { validateTools } from '../../utils/tool-helpers.js';
|
|
2
5
|
/**
|
|
3
6
|
* Reserved name of the built-in search tool. A caller cannot register a tool
|
|
@@ -5,14 +8,28 @@ import { validateTools } from '../../utils/tool-helpers.js';
|
|
|
5
8
|
* callable entry point to reach everything else.
|
|
6
9
|
*/
|
|
7
10
|
export const TOOL_SEARCH_NAME = 'tool_search';
|
|
8
|
-
const
|
|
9
|
-
const MAX_SEARCH_LIMIT = 8;
|
|
11
|
+
const EXACT_NAME_SCORE = 1000;
|
|
10
12
|
// Ceiling on the definitions one search may declare. A query matching a dozen
|
|
11
13
|
// large schemas would otherwise undo the saving the catalog just made.
|
|
12
14
|
const MAX_DEFINITION_BYTES = 8 * 1024;
|
|
13
15
|
// Fixed text, so a repeated no-match search stays byte-identical and cannot
|
|
14
16
|
// move the KV divergence point.
|
|
15
17
|
const NO_MATCH_HINT = 'No tool matched. Search again with a different capability word, or answer without a tool.';
|
|
18
|
+
/**
|
|
19
|
+
* The limits a request's `toolSearch` options resolve to. Both the prompt and
|
|
20
|
+
* the search read them from here, so what the model is told is what applies.
|
|
21
|
+
*/
|
|
22
|
+
export function resolveToolSearchLimits(options) {
|
|
23
|
+
const parsed = toolSearchOptionsSchema.safeParse(options ?? {});
|
|
24
|
+
if (!parsed.success) {
|
|
25
|
+
throw new InvalidToolSchemaError(`toolSearch: ${parsed.error.message}`, parsed.error);
|
|
26
|
+
}
|
|
27
|
+
const maxLimit = parsed.data.maxLimit ?? MAX_TOOL_SEARCH_LIMIT;
|
|
28
|
+
return {
|
|
29
|
+
defaultLimit: parsed.data.defaultLimit ?? Math.min(DEFAULT_TOOL_SEARCH_LIMIT, maxLimit),
|
|
30
|
+
maxLimit
|
|
31
|
+
};
|
|
32
|
+
}
|
|
16
33
|
export function isDeferred(tool) {
|
|
17
34
|
return tool.deferLoading === true;
|
|
18
35
|
}
|
|
@@ -73,7 +90,8 @@ export function buildCatalog(deferred) {
|
|
|
73
90
|
* tool whose schema the model has never seen. Description text cannot be
|
|
74
91
|
* called, which is the whole point.
|
|
75
92
|
*/
|
|
76
|
-
export function buildToolSearchTool(deferred) {
|
|
93
|
+
export function buildToolSearchTool(deferred, options) {
|
|
94
|
+
const { defaultLimit, maxLimit } = resolveToolSearchLimits(options);
|
|
77
95
|
return {
|
|
78
96
|
type: 'function',
|
|
79
97
|
name: TOOL_SEARCH_NAME,
|
|
@@ -90,7 +108,7 @@ export function buildToolSearchTool(deferred) {
|
|
|
90
108
|
},
|
|
91
109
|
limit: {
|
|
92
110
|
type: 'integer',
|
|
93
|
-
description: `Maximum definitions to load (default ${
|
|
111
|
+
description: `Maximum definitions to load (default ${defaultLimit}, max ${maxLimit}).`
|
|
94
112
|
}
|
|
95
113
|
},
|
|
96
114
|
required: ['query']
|
|
@@ -117,7 +135,7 @@ function scoreTool(tool, query, tokens) {
|
|
|
117
135
|
// Exact name wins outright: the model asking for a tool by name is not a
|
|
118
136
|
// capability search and must not be outranked by a wordier description.
|
|
119
137
|
if (name === normalizedQuery)
|
|
120
|
-
return
|
|
138
|
+
return EXACT_NAME_SCORE;
|
|
121
139
|
let score = 0;
|
|
122
140
|
if (normalizedQuery.length > 2 && name.includes(normalizedQuery))
|
|
123
141
|
score += 100;
|
|
@@ -134,20 +152,37 @@ function scoreTool(tool, query, tokens) {
|
|
|
134
152
|
}
|
|
135
153
|
return score;
|
|
136
154
|
}
|
|
155
|
+
// Names score case-insensitively, so `GetWeather` and `getWeather` both score as
|
|
156
|
+
// exact; the one spelled as asked wins, and with neither, both load.
|
|
157
|
+
function namedBy(scored, query) {
|
|
158
|
+
const exact = scored.filter(({ score }) => score === EXACT_NAME_SCORE);
|
|
159
|
+
const literal = exact.filter(({ tool }) => tool.name === query.trim());
|
|
160
|
+
return literal.length > 0 ? literal : exact;
|
|
161
|
+
}
|
|
137
162
|
/**
|
|
138
163
|
* Rank the deferred inventory against a query. Exact name first, then text
|
|
139
164
|
* match. Ties keep registration order so repeated searches are deterministic.
|
|
165
|
+
*
|
|
166
|
+
* An exact name loads that tool alone. Otherwise a match scoring under half of
|
|
167
|
+
* the best is left out: one query word in a description or group is not enough
|
|
168
|
+
* to load a tool beside a strong match, while tools tied at the top load together.
|
|
140
169
|
*/
|
|
141
|
-
export function searchDeferredTools(deferred, query, limit) {
|
|
170
|
+
export function searchDeferredTools(deferred, query, limit, options) {
|
|
171
|
+
const { defaultLimit, maxLimit } = resolveToolSearchLimits(options);
|
|
142
172
|
const tokens = tokenize(query);
|
|
143
173
|
const scored = deferred
|
|
144
174
|
.map((tool, index) => ({ tool, index, score: scoreTool(tool, query, tokens) }))
|
|
145
175
|
.filter((entry) => entry.score > 0)
|
|
146
176
|
.sort((a, b) => b.score - a.score || a.index - b.index);
|
|
147
|
-
const
|
|
177
|
+
const best = scored[0]?.score ?? 0;
|
|
178
|
+
const matches = best === EXACT_NAME_SCORE
|
|
179
|
+
? namedBy(scored, query)
|
|
180
|
+
: scored.filter(({ score }) => score >= best / 2);
|
|
181
|
+
const requested = limit !== undefined && Number.isFinite(limit) ? Math.trunc(limit) : defaultLimit;
|
|
182
|
+
const cap = Math.min(Math.max(requested, 1), maxLimit);
|
|
148
183
|
const picked = [];
|
|
149
184
|
let bytes = 0;
|
|
150
|
-
for (const { tool } of
|
|
185
|
+
for (const { tool } of matches) {
|
|
151
186
|
if (picked.length >= cap)
|
|
152
187
|
break;
|
|
153
188
|
const size = JSON.stringify(toWireTool(tool)).length;
|
|
@@ -208,7 +243,7 @@ function readSearchResult(content) {
|
|
|
208
243
|
export function loadedToolNames(history) {
|
|
209
244
|
const loaded = new Set();
|
|
210
245
|
for (const message of history) {
|
|
211
|
-
if (message.role !== 'tool')
|
|
246
|
+
if (message.role !== 'tool' || typeof message.content !== 'string')
|
|
212
247
|
continue;
|
|
213
248
|
const envelope = readSearchResult(message.content);
|
|
214
249
|
if (!envelope)
|
|
@@ -256,7 +291,7 @@ function declarableDeferred(alwaysLoaded, deferred) {
|
|
|
256
291
|
*
|
|
257
292
|
* Returns `null` when nothing defers, so the existing path is untouched.
|
|
258
293
|
*/
|
|
259
|
-
export function resolveDeferredTools(tools, history) {
|
|
294
|
+
export function resolveDeferredTools(tools, history, options) {
|
|
260
295
|
if (!tools || tools.length === 0)
|
|
261
296
|
return null;
|
|
262
297
|
const partitioned = partitionTools(tools);
|
|
@@ -268,29 +303,49 @@ export function resolveDeferredTools(tools, history) {
|
|
|
268
303
|
return {
|
|
269
304
|
toolsToRender: [
|
|
270
305
|
...alwaysLoaded.map(toWireTool),
|
|
271
|
-
buildToolSearchTool(deferred),
|
|
306
|
+
buildToolSearchTool(deferred, options),
|
|
272
307
|
...deferred.filter((tool) => loaded.has(tool.name)).map(toWireTool)
|
|
273
308
|
],
|
|
274
309
|
deferred
|
|
275
310
|
};
|
|
276
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Resolve completion params into a source `executeToolSearch` can search,
|
|
314
|
+
* listing MCP tools first as `completion()` does. Needed only when the params
|
|
315
|
+
* carry `mcp`; resolve once per conversation and reuse the result.
|
|
316
|
+
*/
|
|
317
|
+
export async function resolveToolSearchSource(params) {
|
|
318
|
+
const { tools: wire } = validateTools([...(params.tools ?? [])]);
|
|
319
|
+
const mcpTools = params.mcp?.length ? await getMcpTools([...params.mcp]) : [];
|
|
320
|
+
return { tools: [...mcpTools, ...wire], toolSearch: params.toolSearch };
|
|
321
|
+
}
|
|
277
322
|
/**
|
|
278
323
|
* Run a `tool_search` call and produce the `tool` message that carries its
|
|
279
324
|
* result. Pure over the history it is given; the caller appends the message.
|
|
280
325
|
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
326
|
+
* Pass the same params given to `completion()`, so the search applies the
|
|
327
|
+
* `toolSearch` limits the model was told; with `mcp`, pass
|
|
328
|
+
* `resolveToolSearchSource(params)` instead. A bare tool list applies the default
|
|
329
|
+
* limits. Tools may be wire `Tool`s or the Zod-schema `ToolInput` form; both
|
|
330
|
+
* are converted to wire form first, so the size cap measures the JSON schemas
|
|
331
|
+
* the prompt will declare, not Zod objects.
|
|
285
332
|
*/
|
|
286
|
-
export function executeToolSearch(
|
|
333
|
+
export function executeToolSearch(source, args, history) {
|
|
334
|
+
const { tools = [], toolSearch, mcp } = Array.isArray(source)
|
|
335
|
+
? { tools: source, toolSearch: undefined, mcp: [] }
|
|
336
|
+
: source;
|
|
337
|
+
// MCP tools are listed asynchronously; searching without them would find
|
|
338
|
+
// nothing the model was shown from those servers.
|
|
339
|
+
if (mcp && mcp.length > 0) {
|
|
340
|
+
throw new InvalidToolSchemaError('executeToolSearch cannot list MCP tools. Pass the result of `await resolveToolSearchSource(params)` instead.');
|
|
341
|
+
}
|
|
287
342
|
const { tools: wire } = validateTools([...tools]);
|
|
288
343
|
const { alwaysLoaded, deferred: registered } = partitionTools(wire);
|
|
289
344
|
const deferred = declarableDeferred(alwaysLoaded, registered);
|
|
290
345
|
const query = typeof args['query'] === 'string' ? args['query'] : '';
|
|
291
346
|
const limit = typeof args['limit'] === 'number' ? args['limit'] : undefined;
|
|
292
347
|
const loaded = loadedToolNames(history);
|
|
293
|
-
const matches = searchDeferredTools(deferred, query, limit);
|
|
348
|
+
const matches = searchDeferredTools(deferred, query, limit, toolSearch);
|
|
294
349
|
// A tool the history already loaded is not reported as loaded again; naming
|
|
295
350
|
// it back tells the model it can call the tool without searching again.
|
|
296
351
|
const alreadyLoaded = matches.filter((tool) => loaded.has(tool.name)).map((tool) => tool.name);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { matchToolDialectFromArchitecture, matchToolDialectFromName, resolveToolDialect } from '../../utils/tools/dialect.js';
|
|
2
2
|
export { parseToolCalls } from '../../utils/tools/parser.js';
|
|
3
|
-
export { TOOL_SEARCH_NAME, buildCatalog, buildToolSearchTool, executeToolSearch, loadedToolNames, partitionTools, resolveDeferredTools, searchDeferredTools } from '../../utils/tools/defer.js';
|
|
3
|
+
export { TOOL_SEARCH_NAME, buildCatalog, buildToolSearchTool, executeToolSearch, loadedToolNames, partitionTools, resolveDeferredTools, resolveToolSearchSource, searchDeferredTools } from '../../utils/tools/defer.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { matchToolDialectFromArchitecture, matchToolDialectFromName, resolveToolDialect } from '../../utils/tools/dialect.js';
|
|
2
2
|
export { parseToolCalls } from '../../utils/tools/parser.js';
|
|
3
|
-
export { TOOL_SEARCH_NAME, buildCatalog, buildToolSearchTool, executeToolSearch, loadedToolNames, partitionTools, resolveDeferredTools, searchDeferredTools } from '../../utils/tools/defer.js';
|
|
3
|
+
export { TOOL_SEARCH_NAME, buildCatalog, buildToolSearchTool, executeToolSearch, loadedToolNames, partitionTools, resolveDeferredTools, resolveToolSearchSource, searchDeferredTools } from '../../utils/tools/defer.js';
|
|
@@ -2,9 +2,19 @@ import { type TranscribeSegment } from '../schemas/index.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* A native transcript segment, as emitted by the engines of
|
|
4
4
|
* `@qvac/asr-ggml` and by `@qvac/bci-whispercpp`. `text` plus the timing
|
|
5
|
-
* fields are shared; `isEndOfTurn` and `startsWord` are parakeet-only,
|
|
6
|
-
* `
|
|
5
|
+
* fields are shared; `isEndOfTurn` and `startsWord` are parakeet-only,
|
|
6
|
+
* `tokenIds`, `isFinal`, `chunkIndex` and `eotConfidence` are parakeet
|
|
7
|
+
* streaming-only, `language`, `noSpeechProb`, `speakerTurnNext` and `tokens`
|
|
8
|
+
* are whisper-only, and `windowStartTimestep` is BCI delta-streaming-only.
|
|
7
9
|
*/
|
|
10
|
+
export interface AsrAddonToken {
|
|
11
|
+
text: string;
|
|
12
|
+
/** Token start time in seconds. */
|
|
13
|
+
start: number;
|
|
14
|
+
/** Token end time in seconds. */
|
|
15
|
+
end: number;
|
|
16
|
+
probability: number;
|
|
17
|
+
}
|
|
8
18
|
export interface AsrAddonSegment {
|
|
9
19
|
text: string;
|
|
10
20
|
speakerId?: number;
|
|
@@ -22,6 +32,22 @@ export interface AsrAddonSegment {
|
|
|
22
32
|
isEndOfTurn?: boolean;
|
|
23
33
|
/** Parakeet: the segment begins a new SentencePiece word. */
|
|
24
34
|
startsWord?: boolean;
|
|
35
|
+
/** Parakeet streaming: native token ids of the segment. */
|
|
36
|
+
tokenIds?: number[];
|
|
37
|
+
/** Parakeet streaming: explicit native finality, including empty final markers. */
|
|
38
|
+
isFinal?: boolean;
|
|
39
|
+
/** Parakeet streaming: native chunk index; -1 when unknown. */
|
|
40
|
+
chunkIndex?: number;
|
|
41
|
+
/** Parakeet EOU streaming: native end-of-turn confidence. */
|
|
42
|
+
eotConfidence?: number;
|
|
43
|
+
/** Whisper: language the window was decoded in (e.g. `"en"`). */
|
|
44
|
+
language?: string;
|
|
45
|
+
/** Whisper: probability that the segment's window holds no speech. */
|
|
46
|
+
noSpeechProb?: number;
|
|
47
|
+
/** Whisper with `tdrz_enable`: a speaker turn follows this segment. */
|
|
48
|
+
speakerTurnNext?: boolean;
|
|
49
|
+
/** Whisper with `token_timestamps`: per-token text, timing and probability. */
|
|
50
|
+
tokens?: AsrAddonToken[];
|
|
25
51
|
/** BCI delta streaming: absolute timestep at which the owning window began. */
|
|
26
52
|
windowStartTimestep?: number;
|
|
27
53
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { ModelType } from '../schemas/index.js';
|
|
2
2
|
import { TranscriptionFailedError } from '../errors/index.js';
|
|
3
|
+
function toTranscribeToken(token) {
|
|
4
|
+
return {
|
|
5
|
+
text: token.text,
|
|
6
|
+
startMs: token.start * 1000,
|
|
7
|
+
endMs: token.end * 1000,
|
|
8
|
+
probability: token.probability
|
|
9
|
+
};
|
|
10
|
+
}
|
|
3
11
|
/**
|
|
4
12
|
* Normalize a native transcript segment to the engine-level
|
|
5
13
|
* `TranscribeSegment` shape exposed to callers: seconds → milliseconds,
|
|
@@ -25,6 +33,14 @@ export function toTranscribeSegment(chunk) {
|
|
|
25
33
|
id: chunk.id ?? 0,
|
|
26
34
|
...(chunk.isEndOfTurn !== undefined && { isEndOfTurn: chunk.isEndOfTurn }),
|
|
27
35
|
...(chunk.startsWord !== undefined && { startsWord: chunk.startsWord }),
|
|
36
|
+
...(chunk.tokenIds !== undefined && { tokenIds: [...chunk.tokenIds] }),
|
|
37
|
+
...(chunk.isFinal !== undefined && { isFinal: chunk.isFinal }),
|
|
38
|
+
...(chunk.chunkIndex !== undefined && { chunkIndex: chunk.chunkIndex }),
|
|
39
|
+
...(chunk.eotConfidence !== undefined && { eotConfidence: chunk.eotConfidence }),
|
|
40
|
+
...(chunk.language !== undefined && { language: chunk.language }),
|
|
41
|
+
...(chunk.noSpeechProb !== undefined && { noSpeechProb: chunk.noSpeechProb }),
|
|
42
|
+
...(chunk.speakerTurnNext !== undefined && { speakerTurnNext: chunk.speakerTurnNext }),
|
|
43
|
+
...(chunk.tokens !== undefined && { tokens: chunk.tokens.map(toTranscribeToken) }),
|
|
28
44
|
...(chunk.windowStartTimestep !== undefined && {
|
|
29
45
|
windowStartTimestep: chunk.windowStartTimestep
|
|
30
46
|
})
|
|
@@ -8,10 +8,14 @@ export type TtsStreamChunk = TtsOutputChunk;
|
|
|
8
8
|
export type TtsOpYield = {
|
|
9
9
|
text?: string;
|
|
10
10
|
buffer: number[];
|
|
11
|
+
/** Base64 int16 LE PCM; set instead of `buffer` by the ops (see `encodeTtsPcm`). */
|
|
12
|
+
pcm?: string;
|
|
11
13
|
sampleRate?: number;
|
|
12
14
|
chunkIndex?: number;
|
|
13
15
|
sentenceChunk?: string;
|
|
14
16
|
isLast?: boolean;
|
|
17
|
+
/** CosyVoice3: the speech tokens of the synthesis this frame belongs to. */
|
|
18
|
+
speechTokenIds?: number[];
|
|
15
19
|
};
|
|
16
20
|
/**
|
|
17
21
|
* Everything an addon chunk carries beyond its PCM. Shared by both TTS ops so
|
|
@@ -20,17 +24,55 @@ export type TtsOpYield = {
|
|
|
20
24
|
* forwarded the metadata.
|
|
21
25
|
*/
|
|
22
26
|
export declare function chunkMetadata(chunk: TtsStreamChunk): {
|
|
27
|
+
speechTokenIds?: number[];
|
|
23
28
|
isLast?: boolean;
|
|
24
29
|
sentenceChunk?: string;
|
|
25
30
|
chunkIndex?: number;
|
|
26
31
|
sampleRate?: number;
|
|
27
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Whether a chunk has anything to forward besides PCM. CosyVoice3's native
|
|
35
|
+
* chunk streaming ends with an empty-PCM `isLast` chunk that carries the
|
|
36
|
+
* run's `speechTokenIds`; Audio8's native end markers are empty too but carry
|
|
37
|
+
* nothing, so the ops skip those and forward these.
|
|
38
|
+
*/
|
|
39
|
+
export declare function carriesSpeechTokenIds(chunk: TtsStreamChunk): boolean;
|
|
28
40
|
/**
|
|
29
41
|
* Appends a chunk's samples to `target` in place, which keeps collecting an
|
|
30
42
|
* utterance linear in its length — a natively chunked MOSS run emits dozens of
|
|
31
43
|
* chunks into one buffer.
|
|
32
44
|
*/
|
|
33
45
|
export declare function appendPcm(target: number[], samples: ArrayLike<number>): void;
|
|
46
|
+
/**
|
|
47
|
+
* One contiguous buffer from the engine's per-chunk output arrays: an
|
|
48
|
+
* `Int16Array` when every part is one (the engines' PCM), else a plain array.
|
|
49
|
+
*/
|
|
50
|
+
export declare function concatPcm(parts: readonly ArrayLike<number>[]): Int16Array | number[];
|
|
51
|
+
/**
|
|
52
|
+
* The audio fields of a frame: int16 engine output rides the wire as base64
|
|
53
|
+
* `pcm`; anything else (test doubles, non-int16 engines) stays a `buffer`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function pcmFrame(samples: ArrayLike<number>): {
|
|
56
|
+
buffer: number[];
|
|
57
|
+
pcm?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The addon stats that keep their name on the wire. `audioDurationMs` is the
|
|
61
|
+
* one rename (`audioDuration`, the name the SDK has always exposed) and is
|
|
62
|
+
* handled on its own below.
|
|
63
|
+
*
|
|
64
|
+
* Two compile-time checks keep this table honest. `satisfies` requires every
|
|
65
|
+
* entry to be a key of both the addon's stats and `ttsStatsSchema`, and
|
|
66
|
+
* `UnforwardedTtsStats` below requires every key of either type to be an
|
|
67
|
+
* entry. A stat added to one side only, or to both without a line here, fails
|
|
68
|
+
* to compile rather than being dropped silently.
|
|
69
|
+
*/
|
|
70
|
+
declare const TTS_FORWARDED_STATS: readonly ["totalTime", "realTimeFactor", "tokensPerSecond", "totalSamples", "generatedFrames", "firstAudioMs", "backendDevice", "backendId", "gpuUnsupported", "enhancerBackendDevice", "enhancerBackendId", "denoiserBackendDevice", "denoiserBackendId", "codecSidecarLoaded", "codecOnCoreml", "decoderSidecarLoaded", "dacSidecarLoaded", "decoderOnCoreml", "dacOnCoreml", "t3Ms", "s3genMs", "t3Tokens", "stageTotalMs", "lmPrefillMs", "lmDecodeMs", "flowFrontendMs", "ditEulerMs", "hiftF0Ms", "hiftSourceMs", "hiftStftMs", "hiftDecodeMs", "decodeSteps", "speechTokens", "flowFrames", "melFrames", "textIds", "promptSpeechTokens", "voiceEncodeMs", "promptMs", "prefillMs", "sampleMs", "fastDecodeMs", "slowDecodeMs", "codecLatentMs", "codecSynthMs", "resampleMs"];
|
|
71
|
+
type ForwardedTtsStat = (typeof TTS_FORWARDED_STATS)[number];
|
|
72
|
+
type UnforwardedTtsStats = Exclude<keyof AddonTtsStats, ForwardedTtsStat | 'audioDurationMs'> | Exclude<keyof TtsStats, ForwardedTtsStat | 'audioDuration'>;
|
|
73
|
+
type AssertNoUnforwardedTtsStats<T extends never> = T;
|
|
74
|
+
export type TtsStatsTableIsExhaustive = AssertNoUnforwardedTtsStats<UnforwardedTtsStats>;
|
|
34
75
|
export declare function collectTtsStats(response: {
|
|
35
76
|
stats?: AddonTtsStats;
|
|
36
77
|
}): TtsStats;
|
|
78
|
+
export {};
|