@qvac/inference 0.21.1 → 0.23.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 +89 -41
- package/README.md +44 -1
- package/dist/api/assess-model-fit.d.ts +4 -4
- package/dist/api/assess-model-fit.js +4 -4
- package/dist/api/audio-gen.d.ts +4 -1
- package/dist/api/audio-gen.js +5 -2
- package/dist/api/batch-completion.js +1 -1
- package/dist/api/completion-stream.d.ts +2 -1
- package/dist/api/completion-stream.js +4 -2
- package/dist/api/decide.d.ts +26 -0
- package/dist/api/decide.js +26 -0
- package/dist/api/diffusion.d.ts +18 -1
- package/dist/api/diffusion.js +18 -1
- package/dist/api/download-asset.js +1 -1
- package/dist/api/finetune.js +1 -1
- package/dist/api/get-model-info.d.ts +1 -1
- package/dist/api/index.d.ts +39 -37
- package/dist/api/index.js +38 -36
- package/dist/api/load-model.js +2 -2
- package/dist/api/logging-stream-registry.js +11 -7
- package/dist/api/logging-stream.d.ts +11 -1
- package/dist/api/logging-stream.js +11 -2
- package/dist/api/registry.d.ts +2 -1
- package/dist/api/registry.js +5 -4
- package/dist/api/rerank.d.ts +17 -0
- package/dist/api/rerank.js +36 -0
- package/dist/api/subscribe-logs.js +5 -3
- package/dist/api/text-to-speech.d.ts +1 -0
- package/dist/api/text-to-speech.js +15 -19
- package/dist/api/transcribe.js +5 -2
- package/dist/api/unload-model.js +1 -1
- package/dist/api/video-request.d.ts +5 -5
- package/dist/api/video.d.ts +5 -4
- package/dist/api/video.js +6 -5
- package/dist/api/vla.js +1 -1
- package/dist/api/world-result.js +1 -1
- package/dist/api/world.d.ts +1 -1
- package/dist/api/world.js +1 -1
- package/dist/config/resolve-config.d.ts +1 -1
- package/dist/config/resolve-config.js +1 -1
- package/dist/constants/index.d.ts +2 -2
- package/dist/constants/index.js +2 -2
- package/dist/dispatch.d.ts +3 -2
- package/dist/dispatch.js +16 -4
- package/dist/errors/index.d.ts +9 -0
- package/dist/errors/index.js +18 -1
- package/dist/handlers/assess-model-fit.d.ts +5 -3
- package/dist/handlers/assess-model-fit.js +84 -32
- package/dist/handlers/cancelHandler.js +1 -1
- package/dist/handlers/completion-orchestrate.js +2 -2
- package/dist/handlers/download-asset.js +2 -2
- package/dist/handlers/finetune.js +1 -1
- package/dist/handlers/get-loaded-model-info.js +3 -5
- package/dist/handlers/get-model-info.js +1 -1
- package/dist/handlers/load-model/coreml-sidecars.d.ts +15 -0
- package/dist/handlers/load-model/coreml-sidecars.js +71 -8
- package/dist/handlers/load-model/download-manager.d.ts +1 -1
- package/dist/handlers/load-model/download-stats.d.ts +2 -2
- package/dist/handlers/load-model/download-stats.js +3 -3
- package/dist/handlers/load-model/handler.js +10 -7
- package/dist/handlers/load-model/http-verify.d.ts +1 -1
- package/dist/handlers/load-model/http.d.ts +1 -1
- package/dist/handlers/load-model/http.js +3 -3
- package/dist/handlers/load-model/hyperdrive.d.ts +1 -1
- package/dist/handlers/load-model/hyperdrive.js +2 -2
- package/dist/handlers/load-model/index.d.ts +2 -2
- package/dist/handlers/load-model/index.js +2 -2
- package/dist/handlers/load-model/registry-companion-set.d.ts +1 -1
- package/dist/handlers/load-model/registry-companion-set.js +1 -1
- package/dist/handlers/load-model/registry-download-utils.d.ts +3 -3
- package/dist/handlers/load-model/registry-download-utils.js +2 -2
- package/dist/handlers/load-model/registry.d.ts +2 -2
- package/dist/handlers/load-model/registry.js +5 -5
- package/dist/handlers/load-model/resolve-session.d.ts +1 -1
- package/dist/handlers/load-model/resolve-session.js +11 -3
- package/dist/handlers/load-model/resolve.d.ts +1 -1
- package/dist/handlers/load-model/resolve.js +5 -5
- package/dist/handlers/load-model/safe-fetch.js +5 -6
- package/dist/handlers/logging-stream.d.ts +2 -1
- package/dist/handlers/logging-stream.js +23 -7
- package/dist/handlers/registry.d.ts +3 -1
- package/dist/handlers/registry.js +7 -5
- package/dist/handlers/types.d.ts +7 -1
- package/dist/handlers/vector-index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/logging/addon.d.ts +1 -1
- package/dist/logging/addon.js +1 -1
- package/dist/logging/index.d.ts +5 -5
- package/dist/logging/index.js +4 -4
- package/dist/logging/logger.d.ts +1 -1
- package/dist/logging/logger.js +2 -2
- package/dist/{resources/model-fit → model-fit}/assess.d.ts +18 -26
- package/dist/{resources/model-fit → model-fit}/assess.js +210 -274
- package/dist/{resources/model-fit/native-probe/classify-fit.d.ts → model-fit/classify.d.ts} +2 -2
- package/dist/{resources/model-fit/native-probe/classify-fit.js → model-fit/classify.js} +36 -5
- package/dist/{resources/model-fit/fit-stub/fetch-fit-stub.d.ts → model-fit/description/fetch.d.ts} +4 -2
- package/dist/{resources/model-fit/fit-stub/fetch-fit-stub.js → model-fit/description/fetch.js} +11 -6
- package/dist/{resources/model-fit/fit-stub/project-fit-from-load.d.ts → model-fit/description/project.d.ts} +3 -3
- package/dist/{resources/model-fit/fit-stub/project-fit-from-load.js → model-fit/description/project.js} +4 -2
- package/dist/{resources/model-fit/fit-stub/resolve-load-from-stubs.d.ts → model-fit/description/resolve-load.d.ts} +6 -4
- package/dist/{resources/model-fit/fit-stub/resolve-load-from-stubs.js → model-fit/description/resolve-load.js} +14 -6
- package/dist/model-fit/floor.d.ts +31 -0
- package/dist/{resources/model-fit → model-fit}/floor.js +13 -13
- package/dist/model-fit/kv-cache.d.ts +23 -0
- package/dist/model-fit/kv-cache.js +85 -0
- package/dist/{resources/model-fit/native-probe/advisory-fit.d.ts → model-fit/load-check.d.ts} +17 -14
- package/dist/{resources/model-fit/native-probe/advisory-fit.js → model-fit/load-check.js} +23 -64
- package/dist/model-fit/platform.d.ts +14 -0
- package/dist/model-fit/platform.js +26 -0
- package/dist/{resources/model-fit/native-probe/create-fit-request.d.ts → model-fit/request/create.d.ts} +5 -2
- package/dist/model-fit/request/create.js +61 -0
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/asr.d.ts +5 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/asr.js +32 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/audiogen.d.ts +1 -1
- package/dist/model-fit/request/engines/audiogen.js +63 -0
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/diffusion.d.ts +1 -1
- package/dist/model-fit/request/engines/diffusion.js +93 -0
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/llama.d.ts +2 -3
- package/dist/model-fit/request/engines/llama.js +44 -0
- package/dist/model-fit/request/engines/nmt.d.ts +8 -0
- package/dist/model-fit/request/engines/nmt.js +11 -0
- package/dist/model-fit/request/engines/ocr.d.ts +9 -0
- package/dist/model-fit/request/engines/ocr.js +13 -0
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/tts.d.ts +3 -1
- package/dist/{resources/model-fit/native-probe → model-fit/request}/engines/tts.js +50 -4
- package/dist/{resources/model-fit/native-probe/engine-fit.d.ts → model-fit/run/engine.d.ts} +17 -4
- package/dist/{resources/model-fit/native-probe/engine-fit.js → model-fit/run/engine.js} +2 -2
- package/dist/model-fit/run/run.d.ts +43 -0
- package/dist/model-fit/run/run.js +204 -0
- package/dist/models/registry/index.d.ts +1 -1
- package/dist/models/registry/index.js +2 -2
- package/dist/models/registry/models.d.ts +1072 -815
- package/dist/models/registry/models.js +3704 -3405
- package/dist/models/registry/resource-profiles.d.ts +1 -2
- package/dist/models/registry/resource-profiles.js +406 -3
- package/dist/plugins/builtin/asr-ggml/config.d.ts +7 -1
- package/dist/plugins/builtin/asr-ggml/config.js +6 -0
- package/dist/plugins/builtin/asr-ggml/logging.d.ts +1 -1
- package/dist/plugins/builtin/audiogen-ggml/config.d.ts +1 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-edit-stream.js +29 -11
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.d.ts +27 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.js +23 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +7 -28
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-understand.js +2 -2
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +106 -13
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +5 -4
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +20 -3
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +3 -3
- package/dist/plugins/builtin/ggml-classification/plugin.js +1 -1
- package/dist/plugins/builtin/ggml-ocr/params.d.ts +18 -0
- package/dist/plugins/builtin/ggml-ocr/params.js +37 -0
- package/dist/plugins/builtin/ggml-ocr/plugin.d.ts +9 -0
- package/dist/plugins/builtin/ggml-ocr/plugin.js +17 -39
- package/dist/plugins/builtin/ggml-vla/plugin.d.ts +9 -2
- package/dist/plugins/builtin/ggml-vla/plugin.js +4 -4
- package/dist/plugins/builtin/index.d.ts +15 -12
- package/dist/plugins/builtin/index.js +15 -12
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +5 -7
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.d.ts +2 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.js +6 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.d.ts +10 -7
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +141 -204
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.d.ts +36 -92
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.js +67 -216
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.d.ts +2 -49
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.js +2 -46
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +208 -19
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +28 -20
- package/dist/plugins/builtin/llamacpp-completion/transform.js +5 -1
- package/dist/plugins/builtin/llamacpp-decision/helpers.d.ts +5 -0
- package/dist/plugins/builtin/llamacpp-decision/helpers.js +89 -0
- package/dist/plugins/builtin/llamacpp-decision/ops/decide.d.ts +91 -0
- package/dist/plugins/builtin/llamacpp-decision/ops/decide.js +129 -0
- package/dist/plugins/builtin/llamacpp-decision/plugin.d.ts +222 -0
- package/dist/plugins/builtin/llamacpp-decision/plugin.js +44 -0
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +9 -1
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +15 -5
- package/dist/plugins/builtin/llamacpp-embedding/transform.js +9 -0
- package/dist/plugins/builtin/llamacpp-rerank/helpers.d.ts +3 -0
- package/dist/plugins/builtin/llamacpp-rerank/helpers.js +16 -0
- package/dist/plugins/builtin/llamacpp-rerank/ops/rerank.d.ts +5 -0
- package/dist/plugins/builtin/llamacpp-rerank/ops/rerank.js +117 -0
- package/dist/plugins/builtin/llamacpp-rerank/plugin.d.ts +91 -0
- package/dist/plugins/builtin/llamacpp-rerank/plugin.js +45 -0
- package/dist/plugins/builtin/moss-transcribe/plugin.d.ts +143 -0
- package/dist/plugins/builtin/moss-transcribe/plugin.js +96 -0
- package/dist/plugins/builtin/nmtcpp-translation/load-files.d.ts +6 -0
- package/dist/plugins/builtin/nmtcpp-translation/load-files.js +70 -0
- package/dist/plugins/builtin/nmtcpp-translation/plugin.d.ts +17 -0
- package/dist/plugins/builtin/nmtcpp-translation/plugin.js +10 -74
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +25 -4
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +20 -5
- package/dist/plugins/builtin/sdcpp-generation/ops/diffusion.d.ts +5 -2
- package/dist/plugins/builtin/sdcpp-generation/ops/diffusion.js +168 -52
- package/dist/plugins/builtin/sdcpp-generation/ops/video.d.ts +5 -2
- package/dist/plugins/builtin/sdcpp-generation/ops/video.js +28 -13
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +83 -1
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +55 -52
- package/dist/plugins/builtin/sdcpp-generation/upscaler-config.d.ts +15 -0
- package/dist/plugins/builtin/sdcpp-generation/upscaler-config.js +19 -0
- package/dist/plugins/builtin/sdcpp-generation/world-config.d.ts +8 -0
- package/dist/plugins/builtin/sdcpp-generation/world-config.js +9 -0
- package/dist/plugins/builtin/tts-ggml/ops/moss-options.d.ts +22 -0
- package/dist/plugins/builtin/tts-ggml/ops/moss-options.js +79 -0
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.d.ts +1 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.js +5 -2
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +19 -7
- package/dist/plugins/builtin/tts-ggml/plugin.d.ts +151 -1
- package/dist/plugins/builtin/tts-ggml/plugin.js +39 -2
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +28 -4
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +8 -4
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +2 -2
- package/dist/plugins/ops/kv-cache-utils.d.ts +5 -4
- package/dist/plugins/ops/kv-cache-utils.js +25 -33
- package/dist/plugins/ops/load-model.d.ts +8 -2
- package/dist/plugins/ops/load-model.js +33 -19
- package/dist/plugins/ops/transcribe.js +18 -2
- package/dist/plugins/ops/translate.js +3 -3
- package/dist/plugins/ops/unload-model.js +1 -1
- package/dist/plugins/turbovec-backend.js +5 -5
- package/dist/profiling/aggregator.d.ts +1 -1
- package/dist/profiling/aggregator.js +1 -1
- package/dist/profiling/controller.d.ts +1 -1
- package/dist/profiling/controller.js +2 -2
- package/dist/profiling/events.d.ts +1 -1
- package/dist/profiling/events.js +2 -2
- package/dist/profiling/exporters.d.ts +1 -1
- package/dist/profiling/exporters.js +3 -3
- package/dist/profiling/index.d.ts +13 -13
- package/dist/profiling/index.js +12 -12
- package/dist/profiling/operation-metrics.d.ts +1 -1
- package/dist/profiling/operation-metrics.js +2 -2
- package/dist/profiling/operation-wrappers.js +3 -3
- package/dist/profiling/profiler.js +1 -1
- package/dist/rag/handler.js +1 -1
- package/dist/rag/handlers/close-workspace.js +1 -1
- package/dist/rag/handlers/delete-embeddings.js +1 -1
- package/dist/rag/handlers/delete-workspace.js +1 -1
- package/dist/rag/handlers/ingest.js +1 -1
- package/dist/rag/handlers/list-workspaces.d.ts +1 -1
- package/dist/rag/handlers/list-workspaces.js +1 -1
- package/dist/rag/handlers/reindex.js +1 -1
- package/dist/rag/handlers/save-embeddings.js +1 -1
- package/dist/rag/handlers/search.js +1 -1
- package/dist/rag/index.d.ts +11 -11
- package/dist/rag/index.js +11 -11
- package/dist/rag/rag-workspace-manager.js +1 -1
- package/dist/registry.js +3 -1
- package/dist/resources/collector.d.ts +1 -1
- package/dist/resources/collector.js +1 -1
- package/dist/resources/instance.d.ts +1 -1
- package/dist/resources/instance.js +1 -1
- package/dist/resources/native.d.ts +1 -1
- package/dist/resources/normalize.d.ts +1 -1
- package/dist/rpc/inventory.js +5 -7
- package/dist/runtime/env.d.ts +0 -2
- package/dist/runtime/env.js +2 -9
- package/dist/runtime/index.d.ts +5 -5
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/lifecycle.js +7 -7
- package/dist/runtime/model-config-utils.js +9 -1
- package/dist/runtime/model-registry.d.ts +3 -1
- package/dist/runtime/model-registry.js +2 -1
- package/dist/runtime/registry-client.js +1 -1
- package/dist/runtime/request-context.d.ts +3 -3
- package/dist/runtime/request-context.js +22 -1
- package/dist/runtime/request-registry.d.ts +1 -1
- package/dist/runtime/request-registry.js +1 -1
- package/dist/runtime/state.d.ts +1 -1
- package/dist/runtime/state.js +7 -2
- package/dist/runtime/vector-index-backend.d.ts +2 -2
- package/dist/runtime/vector-index-registry.d.ts +5 -5
- package/dist/runtime/vector-index-registry.js +36 -13
- package/dist/schemas/assess-model-fit.d.ts +106 -43
- package/dist/schemas/assess-model-fit.js +69 -32
- package/dist/schemas/audio-gen.d.ts +199 -19
- package/dist/schemas/audio-gen.js +183 -51
- package/dist/schemas/batch-completion-stream.d.ts +210 -36
- package/dist/schemas/batch-completion-stream.js +3 -3
- package/dist/schemas/bci-config.d.ts +3 -0
- package/dist/schemas/bci-config.js +2 -2
- package/dist/schemas/bci.d.ts +24 -3
- package/dist/schemas/bci.js +2 -2
- package/dist/schemas/cancel.d.ts +10 -0
- package/dist/schemas/cancel.js +2 -0
- package/dist/schemas/common.d.ts +1465 -162
- package/dist/schemas/common.js +37 -31
- package/dist/schemas/completion-event.d.ts +8 -2
- package/dist/schemas/completion-event.js +4 -1
- package/dist/schemas/completion-stream.d.ts +243 -39
- package/dist/schemas/completion-stream.js +100 -29
- package/dist/schemas/config.d.ts +1326 -18
- package/dist/schemas/config.js +30 -8
- package/dist/schemas/decision.d.ts +610 -0
- package/dist/schemas/decision.js +219 -0
- package/dist/schemas/download-asset.d.ts +10 -4
- package/dist/schemas/download-asset.js +1 -1
- package/dist/schemas/engine-addon-map.d.ts +9 -1
- package/dist/schemas/engine-addon-map.js +26 -5
- package/dist/schemas/errors.d.ts +2 -0
- package/dist/schemas/errors.js +11 -1
- package/dist/schemas/index.d.ts +51 -48
- package/dist/schemas/index.js +50 -47
- package/dist/schemas/llamacpp-config.d.ts +222 -6
- package/dist/schemas/llamacpp-config.js +129 -7
- package/dist/schemas/load-model.d.ts +7960 -1492
- package/dist/schemas/load-model.js +122 -10
- package/dist/schemas/mcp-adapter.d.ts +1 -1
- package/dist/schemas/model-config-schemas.d.ts +428 -9
- package/dist/schemas/model-config-schemas.js +16 -11
- package/dist/schemas/model-fit-policy.d.ts +17 -0
- package/dist/schemas/model-fit-policy.js +17 -0
- package/dist/schemas/model-info.d.ts +20 -2
- package/dist/schemas/model-info.js +4 -3
- package/dist/schemas/model-resource-profile.d.ts +4 -4
- package/dist/schemas/model-resource-profile.js +2 -5
- package/dist/schemas/model-src-utils.d.ts +14 -2
- package/dist/schemas/model-src-utils.js +2 -2
- package/dist/schemas/model-types.d.ts +14 -1
- package/dist/schemas/model-types.js +4 -0
- package/dist/schemas/ocr.d.ts +76 -0
- package/dist/schemas/ocr.js +43 -1
- package/dist/schemas/plugin.d.ts +16 -4
- package/dist/schemas/plugin.js +12 -0
- package/dist/schemas/profiling.d.ts +4 -4
- package/dist/schemas/profiling.js +1 -1
- package/dist/schemas/rag.js +1 -1
- package/dist/schemas/registry.d.ts +34 -0
- package/dist/schemas/registry.js +5 -1
- package/dist/schemas/reload-config.d.ts +14 -2
- package/dist/schemas/reload-config.js +2 -2
- package/dist/schemas/rerank.d.ts +131 -0
- package/dist/schemas/rerank.js +102 -0
- package/dist/schemas/rpc-server.js +3 -3
- package/dist/schemas/sdcpp-config.d.ts +82 -0
- package/dist/schemas/sdcpp-config.js +41 -22
- package/dist/schemas/system-resources.d.ts +4 -4
- package/dist/schemas/text-to-speech.d.ts +463 -3
- package/dist/schemas/text-to-speech.js +129 -11
- package/dist/schemas/tools.d.ts +13 -4
- package/dist/schemas/tools.js +18 -6
- package/dist/schemas/transcription-config.d.ts +20 -0
- package/dist/schemas/transcription-config.js +54 -4
- package/dist/schemas/transcription.d.ts +47 -5
- package/dist/schemas/transcription.js +52 -5
- package/dist/schemas/translate.d.ts +2 -2
- package/dist/schemas/translate.js +1 -1
- package/dist/schemas/translation-config.d.ts +40 -10
- package/dist/schemas/translation-config.js +1 -1
- package/dist/schemas/vla.d.ts +9 -2
- package/dist/schemas/vla.js +9 -5
- package/dist/surface.d.ts +3 -2
- package/dist/surface.js +3 -2
- package/dist/utils/addon-responses.d.ts +3 -0
- package/dist/utils/aggregate-events.d.ts +1 -1
- package/dist/utils/aggregate-events.js +2 -2
- package/dist/utils/archive.js +2 -2
- package/dist/utils/asr-events.d.ts +1 -0
- package/dist/utils/asr-events.js +2 -1
- package/dist/utils/audio/decoder.js +3 -1
- package/dist/utils/audio-input.js +1 -1
- package/dist/utils/cache/auto-history.d.ts +2 -1
- package/dist/utils/cache/auto-history.js +2 -2
- package/dist/utils/cache/paths.js +6 -6
- package/dist/utils/cache/types.d.ts +7 -0
- package/dist/utils/checksum.d.ts +2 -0
- package/dist/utils/checksum.js +41 -2
- package/dist/utils/completion-normalizer.js +1 -1
- package/dist/utils/gguf-architecture.d.ts +7 -0
- package/dist/utils/gguf-architecture.js +142 -0
- package/dist/utils/gguf-tensor-extractor.js +1 -1
- package/dist/utils/index.d.ts +13 -13
- package/dist/utils/index.js +13 -13
- package/dist/utils/mcp-adapter.d.ts +1 -1
- package/dist/utils/mcp-adapter.js +13 -9
- package/dist/utils/path-security.js +1 -1
- package/dist/utils/shard-utils.d.ts +5 -0
- package/dist/utils/shard-utils.js +19 -3
- package/dist/utils/tool-helpers.d.ts +1 -1
- package/dist/utils/tool-helpers.js +20 -52
- package/dist/utils/tool-integration.d.ts +1 -0
- package/dist/utils/tool-integration.js +3 -6
- package/dist/utils/tools/defer.d.ts +16 -26
- package/dist/utils/tools/defer.js +50 -41
- package/dist/utils/tools/dialect.d.ts +15 -4
- package/dist/utils/tools/dialect.js +34 -5
- package/dist/utils/tools/index.d.ts +3 -3
- package/dist/utils/tools/index.js +3 -3
- package/dist/utils/tools/parser.js +8 -8
- package/dist/utils/tools/parsers/dsml.d.ts +1 -1
- package/dist/utils/tools/parsers/dsml.js +8 -5
- package/dist/utils/tools/parsers/gemma4native.d.ts +1 -1
- package/dist/utils/tools/parsers/gemma4native.js +1 -1
- package/dist/utils/tools/parsers/harmony.d.ts +1 -1
- package/dist/utils/tools/parsers/harmony.js +1 -1
- package/dist/utils/tools/parsers/hermes.d.ts +1 -1
- package/dist/utils/tools/parsers/hermes.js +1 -1
- package/dist/utils/tools/parsers/json.d.ts +1 -1
- package/dist/utils/tools/parsers/json.js +1 -1
- package/dist/utils/tools/parsers/pythonic.d.ts +1 -1
- package/dist/utils/tools/parsers/pythonic.js +1 -1
- package/dist/utils/tools/parsers/qwen35.d.ts +1 -1
- package/dist/utils/tools/parsers/qwen35.js +7 -4
- package/dist/utils/tools/shared.d.ts +3 -0
- package/dist/utils/tools/shared.js +62 -0
- package/dist/utils/transcribe-metadata.d.ts +8 -1
- package/dist/utils/transcribe-metadata.js +13 -3
- package/dist/utils/tts-stats.d.ts +2 -1
- package/dist/utils/until-aborted.d.ts +7 -0
- package/dist/utils/until-aborted.js +34 -0
- package/package.json +68 -51
- package/dist/resources/model-fit/calibration/darwin-arm64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/darwin-arm64.js +0 -36
- package/dist/resources/model-fit/calibration/darwin-x64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/darwin-x64.js +0 -38
- package/dist/resources/model-fit/calibration/fit.d.ts +0 -73
- package/dist/resources/model-fit/calibration/fit.js +0 -152
- package/dist/resources/model-fit/calibration/index.d.ts +0 -37
- package/dist/resources/model-fit/calibration/index.js +0 -75
- package/dist/resources/model-fit/calibration/linux-arm64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/linux-arm64.js +0 -38
- package/dist/resources/model-fit/calibration/linux-x64-vulkan.d.ts +0 -8
- package/dist/resources/model-fit/calibration/linux-x64-vulkan.js +0 -39
- package/dist/resources/model-fit/calibration/linux-x64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/linux-x64.js +0 -38
- package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.d.ts +0 -8
- package/dist/resources/model-fit/calibration/win32-x64-vulkan-shared.js +0 -39
- package/dist/resources/model-fit/calibration/win32-x64-vulkan.d.ts +0 -8
- package/dist/resources/model-fit/calibration/win32-x64-vulkan.js +0 -36
- package/dist/resources/model-fit/calibration/win32-x64.d.ts +0 -8
- package/dist/resources/model-fit/calibration/win32-x64.js +0 -38
- package/dist/resources/model-fit/estimators/llm.d.ts +0 -46
- package/dist/resources/model-fit/estimators/llm.js +0 -222
- package/dist/resources/model-fit/estimators/whisper.d.ts +0 -10
- package/dist/resources/model-fit/estimators/whisper.js +0 -76
- package/dist/resources/model-fit/floor.d.ts +0 -31
- package/dist/resources/model-fit/native-probe/child-engine-fit.d.ts +0 -2
- package/dist/resources/model-fit/native-probe/child-engine-fit.js +0 -41
- package/dist/resources/model-fit/native-probe/create-fit-request.js +0 -51
- package/dist/resources/model-fit/native-probe/engines/audiogen.js +0 -35
- package/dist/resources/model-fit/native-probe/engines/diffusion.js +0 -55
- package/dist/resources/model-fit/native-probe/engines/llama.js +0 -145
- package/dist/resources/model-fit/native-probe/fit-outcome.d.ts +0 -16
- package/dist/resources/model-fit/native-probe/fit-outcome.js +0 -1
- package/dist/resources/model-fit/native-probe/fit-process.d.ts +0 -27
- package/dist/resources/model-fit/native-probe/fit-process.js +0 -55
- package/dist/resources/model-fit/native-probe/fit-runner.d.ts +0 -1
- package/dist/resources/model-fit/native-probe/fit-runner.js +0 -58
- package/dist/resources/model-fit/native-probe/run-fit.d.ts +0 -24
- package/dist/resources/model-fit/native-probe/run-fit.js +0 -20
- package/dist/resources/model-fit/native-probe/run-in-process-fit.d.ts +0 -22
- package/dist/resources/model-fit/native-probe/run-in-process-fit.js +0 -108
- package/dist/resources/model-fit/native-probe/run-isolated-fit.d.ts +0 -63
- package/dist/resources/model-fit/native-probe/run-isolated-fit.js +0 -377
- package/dist/resources/model-fit/platform.d.ts +0 -9
- package/dist/resources/model-fit/platform.js +0 -28
- package/dist/resources/model-fit/types.d.ts +0 -120
- package/dist/resources/model-fit/types.js +0 -1
- /package/dist/{resources/model-fit/native-probe/engines → model-fit/request}/gpu.d.ts +0 -0
- /package/dist/{resources/model-fit/native-probe/engines → model-fit/request}/gpu.js +0 -0
|
@@ -4,6 +4,13 @@ export declare const llmPlugin: {
|
|
|
4
4
|
displayName: string;
|
|
5
5
|
addonPackage: "@qvac/llm-llamacpp";
|
|
6
6
|
loadConfigSchema: import("zod").ZodObject<{
|
|
7
|
+
backend: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodEnum<{
|
|
8
|
+
auto: "auto";
|
|
9
|
+
cuda: "cuda";
|
|
10
|
+
vulkan: "vulkan";
|
|
11
|
+
metal: "metal";
|
|
12
|
+
opencl: "opencl";
|
|
13
|
+
}>>>;
|
|
7
14
|
ctx_size: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
8
15
|
temp: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
9
16
|
top_p: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
@@ -33,6 +40,14 @@ export declare const llmPlugin: {
|
|
|
33
40
|
stop_sequences: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
34
41
|
parallel: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
35
42
|
tools: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
43
|
+
cache_checkpoints: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
44
|
+
cache_checkpoints_max_bytes: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
45
|
+
cache_checkpoint_storage: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
46
|
+
memory: "memory";
|
|
47
|
+
disk: "disk";
|
|
48
|
+
}>>;
|
|
49
|
+
cache_checkpoint_dir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
50
|
+
cache_ram_mib: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
36
51
|
'cache-type-k': import("zod").ZodOptional<import("zod").ZodString>;
|
|
37
52
|
'cache-type-v': import("zod").ZodOptional<import("zod").ZodString>;
|
|
38
53
|
'main-gpu': import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodEnum<{
|
|
@@ -59,6 +74,9 @@ export declare const llmPlugin: {
|
|
|
59
74
|
'kv-offload': import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
60
75
|
'image-max-tokens': import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
61
76
|
'image-min-tokens': import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
77
|
+
'image-max-megapixels': import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
78
|
+
poll: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
79
|
+
pollBatch: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
62
80
|
threads: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
63
81
|
'threads-batch': import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
64
82
|
'cpu-mask': import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -77,6 +95,14 @@ export declare const llmPlugin: {
|
|
|
77
95
|
'fit-ctx': import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
78
96
|
openclCacheDir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
79
97
|
reasoning_budget: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
98
|
+
spec_type: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
99
|
+
none: "none";
|
|
100
|
+
"draft-mtp": "draft-mtp";
|
|
101
|
+
"draft-dflash": "draft-dflash";
|
|
102
|
+
}>>;
|
|
103
|
+
spec_draft_n_max: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
104
|
+
spec_draft_n_min: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
105
|
+
spec_draft_p_min: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
80
106
|
projectionModelSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
81
107
|
src: import("zod").ZodString;
|
|
82
108
|
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
@@ -99,10 +125,55 @@ export declare const llmPlugin: {
|
|
|
99
125
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
100
126
|
"bci-whispercpp-transcription": "bci-whispercpp-transcription";
|
|
101
127
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
128
|
+
"llamacpp-decision": "llamacpp-decision";
|
|
129
|
+
"llamacpp-rerank": "llamacpp-rerank";
|
|
102
130
|
"nmtcpp-translation": "nmtcpp-translation";
|
|
103
131
|
"onnx-tts": "onnx-tts";
|
|
104
132
|
"tts-ggml": "tts-ggml";
|
|
105
133
|
"parakeet-transcription": "parakeet-transcription";
|
|
134
|
+
"moss-transcribe": "moss-transcribe";
|
|
135
|
+
"ggml-ocr": "ggml-ocr";
|
|
136
|
+
"sdcpp-generation": "sdcpp-generation";
|
|
137
|
+
"audiogen-ggml": "audiogen-ggml";
|
|
138
|
+
"ggml-vla": "ggml-vla";
|
|
139
|
+
"ggml-classification": "ggml-classification";
|
|
140
|
+
llm: "llm";
|
|
141
|
+
whisper: "whisper";
|
|
142
|
+
bci: "bci";
|
|
143
|
+
nmt: "nmt";
|
|
144
|
+
parakeet: "parakeet";
|
|
145
|
+
classification: "classification";
|
|
146
|
+
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
147
|
+
}, import("zod/v4/core").$strip>]>>;
|
|
148
|
+
draftModelSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
149
|
+
src: import("zod").ZodString;
|
|
150
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
151
|
+
modelId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
152
|
+
registryPath: import("zod").ZodOptional<import("zod").ZodString>;
|
|
153
|
+
registrySource: import("zod").ZodOptional<import("zod").ZodString>;
|
|
154
|
+
blobCoreKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
155
|
+
blobIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
156
|
+
engine: import("zod").ZodOptional<import("zod").ZodString>;
|
|
157
|
+
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
158
|
+
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
159
|
+
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
160
|
+
embeddings: "embeddings";
|
|
161
|
+
diffusion: "diffusion";
|
|
162
|
+
audiogen: "audiogen";
|
|
163
|
+
tts: "tts";
|
|
164
|
+
ocr: "ocr";
|
|
165
|
+
vla: "vla";
|
|
166
|
+
"llamacpp-completion": "llamacpp-completion";
|
|
167
|
+
"whispercpp-transcription": "whispercpp-transcription";
|
|
168
|
+
"bci-whispercpp-transcription": "bci-whispercpp-transcription";
|
|
169
|
+
"llamacpp-embedding": "llamacpp-embedding";
|
|
170
|
+
"llamacpp-decision": "llamacpp-decision";
|
|
171
|
+
"llamacpp-rerank": "llamacpp-rerank";
|
|
172
|
+
"nmtcpp-translation": "nmtcpp-translation";
|
|
173
|
+
"onnx-tts": "onnx-tts";
|
|
174
|
+
"tts-ggml": "tts-ggml";
|
|
175
|
+
"parakeet-transcription": "parakeet-transcription";
|
|
176
|
+
"moss-transcribe": "moss-transcribe";
|
|
106
177
|
"ggml-ocr": "ggml-ocr";
|
|
107
178
|
"sdcpp-generation": "sdcpp-generation";
|
|
108
179
|
"audiogen-ggml": "audiogen-ggml";
|
|
@@ -130,6 +201,7 @@ export declare const llmPlugin: {
|
|
|
130
201
|
assessFit: typeof import("node_modules/@qvac/llm-llamacpp/fit").assessFit;
|
|
131
202
|
resolveConfig(cfg: LlmConfigInput, ctx: ResolveContext): Promise<{
|
|
132
203
|
config: {
|
|
204
|
+
backend?: ("auto" | "cuda" | "vulkan" | "metal" | "opencl")[] | undefined;
|
|
133
205
|
ctx_size?: number | undefined;
|
|
134
206
|
temp?: number | undefined;
|
|
135
207
|
top_p?: number | undefined;
|
|
@@ -148,6 +220,11 @@ export declare const llmPlugin: {
|
|
|
148
220
|
stop_sequences?: string[] | undefined;
|
|
149
221
|
parallel?: number | undefined;
|
|
150
222
|
tools?: boolean | undefined;
|
|
223
|
+
cache_checkpoints?: number | undefined;
|
|
224
|
+
cache_checkpoints_max_bytes?: number | undefined;
|
|
225
|
+
cache_checkpoint_storage?: "memory" | "disk" | undefined;
|
|
226
|
+
cache_checkpoint_dir?: string | undefined;
|
|
227
|
+
cache_ram_mib?: number | undefined;
|
|
151
228
|
'cache-type-k'?: string | undefined;
|
|
152
229
|
'cache-type-v'?: string | undefined;
|
|
153
230
|
'main-gpu'?: number | "integrated" | "dedicated" | undefined;
|
|
@@ -163,6 +240,9 @@ export declare const llmPlugin: {
|
|
|
163
240
|
'kv-offload'?: boolean | undefined;
|
|
164
241
|
'image-max-tokens'?: number | undefined;
|
|
165
242
|
'image-min-tokens'?: number | undefined;
|
|
243
|
+
'image-max-megapixels'?: number | undefined;
|
|
244
|
+
poll?: number | undefined;
|
|
245
|
+
pollBatch?: number | undefined;
|
|
166
246
|
threads?: number | undefined;
|
|
167
247
|
'threads-batch'?: number | undefined;
|
|
168
248
|
'cpu-mask'?: string | undefined;
|
|
@@ -177,6 +257,10 @@ export declare const llmPlugin: {
|
|
|
177
257
|
'fit-ctx'?: number | undefined;
|
|
178
258
|
openclCacheDir?: string | undefined;
|
|
179
259
|
reasoning_budget?: number | undefined;
|
|
260
|
+
spec_type?: "none" | "draft-mtp" | "draft-dflash" | undefined;
|
|
261
|
+
spec_draft_n_max?: number | undefined;
|
|
262
|
+
spec_draft_n_min?: number | undefined;
|
|
263
|
+
spec_draft_p_min?: number | undefined;
|
|
180
264
|
image_tile_mode?: "disabled" | "batched" | "sequential" | undefined;
|
|
181
265
|
image_no_upscale?: "on" | "off" | undefined;
|
|
182
266
|
'mmproj-use-gpu'?: boolean | undefined;
|
|
@@ -184,6 +268,7 @@ export declare const llmPlugin: {
|
|
|
184
268
|
artifacts?: never;
|
|
185
269
|
} | {
|
|
186
270
|
config: {
|
|
271
|
+
backend?: ("auto" | "cuda" | "vulkan" | "metal" | "opencl")[] | undefined;
|
|
187
272
|
ctx_size?: number | undefined;
|
|
188
273
|
temp?: number | undefined;
|
|
189
274
|
top_p?: number | undefined;
|
|
@@ -202,6 +287,11 @@ export declare const llmPlugin: {
|
|
|
202
287
|
stop_sequences?: string[] | undefined;
|
|
203
288
|
parallel?: number | undefined;
|
|
204
289
|
tools?: boolean | undefined;
|
|
290
|
+
cache_checkpoints?: number | undefined;
|
|
291
|
+
cache_checkpoints_max_bytes?: number | undefined;
|
|
292
|
+
cache_checkpoint_storage?: "memory" | "disk" | undefined;
|
|
293
|
+
cache_checkpoint_dir?: string | undefined;
|
|
294
|
+
cache_ram_mib?: number | undefined;
|
|
205
295
|
'cache-type-k'?: string | undefined;
|
|
206
296
|
'cache-type-v'?: string | undefined;
|
|
207
297
|
'main-gpu'?: number | "integrated" | "dedicated" | undefined;
|
|
@@ -217,6 +307,9 @@ export declare const llmPlugin: {
|
|
|
217
307
|
'kv-offload'?: boolean | undefined;
|
|
218
308
|
'image-max-tokens'?: number | undefined;
|
|
219
309
|
'image-min-tokens'?: number | undefined;
|
|
310
|
+
'image-max-megapixels'?: number | undefined;
|
|
311
|
+
poll?: number | undefined;
|
|
312
|
+
pollBatch?: number | undefined;
|
|
220
313
|
threads?: number | undefined;
|
|
221
314
|
'threads-batch'?: number | undefined;
|
|
222
315
|
'cpu-mask'?: string | undefined;
|
|
@@ -231,12 +324,17 @@ export declare const llmPlugin: {
|
|
|
231
324
|
'fit-ctx'?: number | undefined;
|
|
232
325
|
openclCacheDir?: string | undefined;
|
|
233
326
|
reasoning_budget?: number | undefined;
|
|
327
|
+
spec_type?: "none" | "draft-mtp" | "draft-dflash" | undefined;
|
|
328
|
+
spec_draft_n_max?: number | undefined;
|
|
329
|
+
spec_draft_n_min?: number | undefined;
|
|
330
|
+
spec_draft_p_min?: number | undefined;
|
|
234
331
|
image_tile_mode?: "disabled" | "batched" | "sequential" | undefined;
|
|
235
332
|
image_no_upscale?: "on" | "off" | undefined;
|
|
236
333
|
'mmproj-use-gpu'?: boolean | undefined;
|
|
237
334
|
};
|
|
238
335
|
artifacts: {
|
|
239
|
-
|
|
336
|
+
draftModelPath?: string;
|
|
337
|
+
projectionModelPath?: string;
|
|
240
338
|
};
|
|
241
339
|
}>;
|
|
242
340
|
createModel(params: CreateModelParams): PluginModelResult;
|
|
@@ -247,9 +345,9 @@ export declare const llmPlugin: {
|
|
|
247
345
|
captureThinking: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
248
346
|
emitRawDeltas: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
249
347
|
toolDialect: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
348
|
+
json: "json";
|
|
250
349
|
hermes: "hermes";
|
|
251
350
|
pythonic: "pythonic";
|
|
252
|
-
json: "json";
|
|
253
351
|
harmony: "harmony";
|
|
254
352
|
qwen35: "qwen35";
|
|
255
353
|
gemma4: "gemma4";
|
|
@@ -258,13 +356,46 @@ export declare const llmPlugin: {
|
|
|
258
356
|
requestId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
259
357
|
prompts: import("zod").ZodArray<import("zod").ZodObject<{
|
|
260
358
|
id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
261
|
-
history: import("zod").ZodArray<import("zod").ZodObject<{
|
|
359
|
+
history: import("zod").ZodArray<import("zod").ZodPipe<import("zod").ZodObject<{
|
|
262
360
|
role: import("zod").ZodString;
|
|
263
|
-
content: import("zod").ZodString
|
|
361
|
+
content: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
264
362
|
attachments: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
265
363
|
path: import("zod").ZodString;
|
|
266
364
|
}, import("zod/v4/core").$strip>>>;
|
|
267
|
-
|
|
365
|
+
toolCalls: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
366
|
+
id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
367
|
+
name: import("zod").ZodString;
|
|
368
|
+
arguments: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>;
|
|
369
|
+
}, import("zod/v4/core").$strip>>>;
|
|
370
|
+
toolCallId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
371
|
+
toolName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
372
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodTransform<{
|
|
373
|
+
content: string;
|
|
374
|
+
role: string;
|
|
375
|
+
attachments?: {
|
|
376
|
+
path: string;
|
|
377
|
+
}[] | undefined;
|
|
378
|
+
toolCalls?: {
|
|
379
|
+
name: string;
|
|
380
|
+
arguments: Record<string, unknown>;
|
|
381
|
+
id?: string | undefined;
|
|
382
|
+
}[] | undefined;
|
|
383
|
+
toolCallId?: string | undefined;
|
|
384
|
+
toolName?: string | undefined;
|
|
385
|
+
}, {
|
|
386
|
+
role: string;
|
|
387
|
+
content?: string | null | undefined;
|
|
388
|
+
attachments?: {
|
|
389
|
+
path: string;
|
|
390
|
+
}[] | undefined;
|
|
391
|
+
toolCalls?: {
|
|
392
|
+
name: string;
|
|
393
|
+
arguments: Record<string, unknown>;
|
|
394
|
+
id?: string | undefined;
|
|
395
|
+
}[] | undefined;
|
|
396
|
+
toolCallId?: string | undefined;
|
|
397
|
+
toolName?: string | undefined;
|
|
398
|
+
}>>>;
|
|
268
399
|
generationParams: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
269
400
|
temp: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
270
401
|
top_p: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
@@ -275,8 +406,8 @@ export declare const llmPlugin: {
|
|
|
275
406
|
presence_penalty: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
276
407
|
repeat_penalty: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
277
408
|
reasoning_budget: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
278
|
-
remove_thinking_from_context: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
279
409
|
tool_choice: import("zod").ZodOptional<import("zod").ZodString>;
|
|
410
|
+
parallel_tool_calls: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
280
411
|
}, import("zod/v4/core").$strict>>;
|
|
281
412
|
responseFormat: import("zod").ZodOptional<import("zod").ZodDiscriminatedUnion<[import("zod").ZodObject<{
|
|
282
413
|
type: import("zod").ZodLiteral<"text">;
|
|
@@ -300,19 +431,28 @@ export declare const llmPlugin: {
|
|
|
300
431
|
parameters: import("zod").ZodObject<{
|
|
301
432
|
type: import("zod").ZodLiteral<"object">;
|
|
302
433
|
properties: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
303
|
-
type: import("zod").ZodEnum<{
|
|
434
|
+
type: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
435
|
+
string: "string";
|
|
436
|
+
number: "number";
|
|
437
|
+
boolean: "boolean";
|
|
438
|
+
object: "object";
|
|
439
|
+
null: "null";
|
|
440
|
+
array: "array";
|
|
441
|
+
integer: "integer";
|
|
442
|
+
}>, import("zod").ZodArray<import("zod").ZodEnum<{
|
|
304
443
|
string: "string";
|
|
305
444
|
number: "number";
|
|
306
445
|
boolean: "boolean";
|
|
307
446
|
object: "object";
|
|
447
|
+
null: "null";
|
|
308
448
|
array: "array";
|
|
309
449
|
integer: "integer";
|
|
310
|
-
}
|
|
450
|
+
}>>]>>;
|
|
311
451
|
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
312
452
|
enum: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean, import("zod").ZodNull]>>>;
|
|
313
|
-
}, import("zod/v4/core").$
|
|
453
|
+
}, import("zod/v4/core").$loose>>;
|
|
314
454
|
required: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
315
|
-
}, import("zod/v4/core").$
|
|
455
|
+
}, import("zod/v4/core").$loose>;
|
|
316
456
|
}, import("zod/v4/core").$strip>>>;
|
|
317
457
|
}, import("zod/v4/core").$strict>>;
|
|
318
458
|
type: import("zod").ZodLiteral<"batchCompletionStream">;
|
|
@@ -368,6 +508,8 @@ export declare const llmPlugin: {
|
|
|
368
508
|
emittedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
369
509
|
avgConcurrentSeq: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
370
510
|
toolDefinitionsDropped: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
511
|
+
draftTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
512
|
+
draftAcceptedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
371
513
|
backendDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
372
514
|
cpu: "cpu";
|
|
373
515
|
gpu: "gpu";
|
|
@@ -407,6 +549,8 @@ export declare const llmPlugin: {
|
|
|
407
549
|
emittedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
408
550
|
avgConcurrentSeq: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
409
551
|
toolDefinitionsDropped: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
552
|
+
draftTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
553
|
+
draftAcceptedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
410
554
|
backendDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
411
555
|
cpu: "cpu";
|
|
412
556
|
gpu: "gpu";
|
|
@@ -414,14 +558,48 @@ export declare const llmPlugin: {
|
|
|
414
558
|
}, import("zod/v4/core").$strip>>;
|
|
415
559
|
}, import("zod/v4/core").$strict>>;
|
|
416
560
|
completionStream: import("../../../schemas/index.js").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
417
|
-
history: import("zod").ZodArray<import("zod").ZodObject<{
|
|
561
|
+
history: import("zod").ZodArray<import("zod").ZodPipe<import("zod").ZodObject<{
|
|
418
562
|
role: import("zod").ZodString;
|
|
419
|
-
content: import("zod").ZodString
|
|
563
|
+
content: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
420
564
|
attachments: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
421
565
|
path: import("zod").ZodString;
|
|
422
566
|
}, import("zod/v4/core").$strip>>>;
|
|
423
|
-
|
|
567
|
+
toolCalls: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
568
|
+
id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
569
|
+
name: import("zod").ZodString;
|
|
570
|
+
arguments: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>;
|
|
571
|
+
}, import("zod/v4/core").$strip>>>;
|
|
572
|
+
toolCallId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
573
|
+
toolName: import("zod").ZodOptional<import("zod").ZodString>;
|
|
574
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodTransform<{
|
|
575
|
+
content: string;
|
|
576
|
+
role: string;
|
|
577
|
+
attachments?: {
|
|
578
|
+
path: string;
|
|
579
|
+
}[] | undefined;
|
|
580
|
+
toolCalls?: {
|
|
581
|
+
name: string;
|
|
582
|
+
arguments: Record<string, unknown>;
|
|
583
|
+
id?: string | undefined;
|
|
584
|
+
}[] | undefined;
|
|
585
|
+
toolCallId?: string | undefined;
|
|
586
|
+
toolName?: string | undefined;
|
|
587
|
+
}, {
|
|
588
|
+
role: string;
|
|
589
|
+
content?: string | null | undefined;
|
|
590
|
+
attachments?: {
|
|
591
|
+
path: string;
|
|
592
|
+
}[] | undefined;
|
|
593
|
+
toolCalls?: {
|
|
594
|
+
name: string;
|
|
595
|
+
arguments: Record<string, unknown>;
|
|
596
|
+
id?: string | undefined;
|
|
597
|
+
}[] | undefined;
|
|
598
|
+
toolCallId?: string | undefined;
|
|
599
|
+
toolName?: string | undefined;
|
|
600
|
+
}>>>;
|
|
424
601
|
modelId: import("zod").ZodString;
|
|
602
|
+
prefill: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
425
603
|
tools: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
426
604
|
type: import("zod").ZodLiteral<"function">;
|
|
427
605
|
name: import("zod").ZodString;
|
|
@@ -431,19 +609,28 @@ export declare const llmPlugin: {
|
|
|
431
609
|
parameters: import("zod").ZodObject<{
|
|
432
610
|
type: import("zod").ZodLiteral<"object">;
|
|
433
611
|
properties: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
434
|
-
type: import("zod").ZodEnum<{
|
|
612
|
+
type: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
435
613
|
string: "string";
|
|
436
614
|
number: "number";
|
|
437
615
|
boolean: "boolean";
|
|
438
616
|
object: "object";
|
|
617
|
+
null: "null";
|
|
439
618
|
array: "array";
|
|
440
619
|
integer: "integer";
|
|
441
|
-
}
|
|
620
|
+
}>, import("zod").ZodArray<import("zod").ZodEnum<{
|
|
621
|
+
string: "string";
|
|
622
|
+
number: "number";
|
|
623
|
+
boolean: "boolean";
|
|
624
|
+
object: "object";
|
|
625
|
+
null: "null";
|
|
626
|
+
array: "array";
|
|
627
|
+
integer: "integer";
|
|
628
|
+
}>>]>>;
|
|
442
629
|
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
443
630
|
enum: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean, import("zod").ZodNull]>>>;
|
|
444
|
-
}, import("zod/v4/core").$
|
|
631
|
+
}, import("zod/v4/core").$loose>>;
|
|
445
632
|
required: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
446
|
-
}, import("zod/v4/core").$
|
|
633
|
+
}, import("zod/v4/core").$loose>;
|
|
447
634
|
}, import("zod/v4/core").$strip>>>;
|
|
448
635
|
stream: import("zod").ZodBoolean;
|
|
449
636
|
kvCache: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodBoolean, import("zod").ZodString]>>;
|
|
@@ -457,15 +644,15 @@ export declare const llmPlugin: {
|
|
|
457
644
|
presence_penalty: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
458
645
|
repeat_penalty: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
459
646
|
reasoning_budget: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
460
|
-
remove_thinking_from_context: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
461
647
|
tool_choice: import("zod").ZodOptional<import("zod").ZodString>;
|
|
648
|
+
parallel_tool_calls: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
462
649
|
}, import("zod/v4/core").$strict>>;
|
|
463
650
|
captureThinking: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
464
651
|
emitRawDeltas: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
465
652
|
toolDialect: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
653
|
+
json: "json";
|
|
466
654
|
hermes: "hermes";
|
|
467
655
|
pythonic: "pythonic";
|
|
468
|
-
json: "json";
|
|
469
656
|
harmony: "harmony";
|
|
470
657
|
qwen35: "qwen35";
|
|
471
658
|
gemma4: "gemma4";
|
|
@@ -535,6 +722,8 @@ export declare const llmPlugin: {
|
|
|
535
722
|
emittedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
536
723
|
avgConcurrentSeq: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
537
724
|
toolDefinitionsDropped: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
725
|
+
draftTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
726
|
+
draftAcceptedTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
538
727
|
backendDevice: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
539
728
|
cpu: "cpu";
|
|
540
729
|
gpu: "gpu";
|
|
@@ -55,11 +55,11 @@ import { definePlugin, defineHandler, finetuneRequestSchema, batchCompletionStre
|
|
|
55
55
|
import { createStreamLogger, registerAddonLogger, getEngineLogger } from '../../../logging/index.js';
|
|
56
56
|
import { getFirstShardPath } from '../../../utils/index.js';
|
|
57
57
|
import { getModelParallel } from '../../../utils/config-transform.js';
|
|
58
|
-
import { completion } from '
|
|
59
|
-
import { batchCompletion } from '
|
|
60
|
-
import { finetune } from '
|
|
61
|
-
import { translate } from '
|
|
62
|
-
import { transformLlmConfig } from '
|
|
58
|
+
import { completion } from '../../../plugins/builtin/llamacpp-completion/ops/completion-stream.js';
|
|
59
|
+
import { batchCompletion } from '../../../plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js';
|
|
60
|
+
import { finetune } from '../../../plugins/builtin/llamacpp-completion/ops/finetune.js';
|
|
61
|
+
import { translate } from '../../../plugins/ops/translate.js';
|
|
62
|
+
import { transformLlmConfig } from '../../../plugins/builtin/llamacpp-completion/transform.js';
|
|
63
63
|
import { attachModelExecutionMs } from '../../../profiling/model-execution.js';
|
|
64
64
|
import { getModelConfig } from '../../../runtime/model-registry.js';
|
|
65
65
|
import { createCompletionNormalizer } from '../../../utils/completion-normalizer.js';
|
|
@@ -67,15 +67,17 @@ import { detectToolDialect } from '../../../utils/tool-integration.js';
|
|
|
67
67
|
import { getRequestRegistry, withRequestContext } from '../../../runtime/index.js';
|
|
68
68
|
import { generateRandomRequestId } from '../../../runtime/request-id.js';
|
|
69
69
|
import { ContextOverflowError } from '../../../errors/index.js';
|
|
70
|
-
import { isAddonContextOverflowError, parseContextOverflowMessage } from '
|
|
71
|
-
import { stoppedByLength } from '
|
|
70
|
+
import { isAddonContextOverflowError, parseContextOverflowMessage } from '../../../plugins/builtin/llamacpp-completion/ops/context-overflow.js';
|
|
71
|
+
import { stoppedByLength } from '../../../plugins/builtin/llamacpp-completion/ops/completion-stats.js';
|
|
72
72
|
import { isMobile } from '../../../runtime/state.js';
|
|
73
73
|
import { stripMultiGpuKeys } from '../../../utils/multi-gpu-mobile.js';
|
|
74
74
|
import { resolveDeferredTools, toWireTool } from '../../../utils/tools/defer.js';
|
|
75
|
-
function createLlmModel(modelId, modelPath, llmConfig, projectionModelPath) {
|
|
75
|
+
function createLlmModel(modelId, modelPath, llmConfig, projectionModelPath, draftModelPath) {
|
|
76
76
|
const logger = createStreamLogger(modelId, ModelType.llamacppCompletion);
|
|
77
77
|
registerAddonLogger(modelId, ModelType.llamacppCompletion, logger);
|
|
78
78
|
const llmConfigStrings = transformLlmConfig(llmConfig);
|
|
79
|
+
if (draftModelPath)
|
|
80
|
+
llmConfigStrings['spec_draft_model'] = draftModelPath;
|
|
79
81
|
if (isMobile()) {
|
|
80
82
|
const stripped = stripMultiGpuKeys(llmConfigStrings, true);
|
|
81
83
|
if (stripped.length > 0) {
|
|
@@ -119,19 +121,25 @@ export const llmPlugin = definePlugin({
|
|
|
119
121
|
loadConfigSchema: llmConfigBaseSchema,
|
|
120
122
|
assessFit: LlmLlamacpp.assessFit,
|
|
121
123
|
async resolveConfig(cfg, ctx) {
|
|
122
|
-
const { projectionModelSrc, ...llmConfig } = cfg;
|
|
123
|
-
if (!projectionModelSrc) {
|
|
124
|
+
const { projectionModelSrc, draftModelSrc, ...llmConfig } = cfg;
|
|
125
|
+
if (!projectionModelSrc && !draftModelSrc) {
|
|
124
126
|
return { config: llmConfig };
|
|
125
127
|
}
|
|
126
|
-
const projectionModelPath = await
|
|
128
|
+
const [projectionModelPath, draftModelPath] = await Promise.all([
|
|
129
|
+
projectionModelSrc ? ctx.resolveModelPath(projectionModelSrc) : Promise.resolve(undefined),
|
|
130
|
+
draftModelSrc ? ctx.resolveModelPath(draftModelSrc) : Promise.resolve(undefined)
|
|
131
|
+
]);
|
|
127
132
|
return {
|
|
128
133
|
config: llmConfig,
|
|
129
|
-
artifacts: {
|
|
134
|
+
artifacts: {
|
|
135
|
+
...(projectionModelPath ? { projectionModelPath } : {}),
|
|
136
|
+
...(draftModelPath ? { draftModelPath } : {})
|
|
137
|
+
}
|
|
130
138
|
};
|
|
131
139
|
},
|
|
132
140
|
createModel(params) {
|
|
133
141
|
const llmConfig = (params.modelConfig ?? {});
|
|
134
|
-
const { model } = createLlmModel(params.modelId, params.modelPath, llmConfig, params.artifacts?.['projectionModelPath']);
|
|
142
|
+
const { model } = createLlmModel(params.modelId, params.modelPath, llmConfig, params.artifacts?.['projectionModelPath'], params.artifacts?.['draftModelPath']);
|
|
135
143
|
return { model };
|
|
136
144
|
},
|
|
137
145
|
handlers: {
|
|
@@ -147,9 +155,9 @@ export const llmPlugin = definePlugin({
|
|
|
147
155
|
const dialect = request.toolDialect ?? detectToolDialect(request.modelId);
|
|
148
156
|
const modelCfg = getModelConfig(request.modelId);
|
|
149
157
|
const toolsActive = modelCfg.tools === true;
|
|
150
|
-
// Parse against what each prompt
|
|
151
|
-
//
|
|
152
|
-
const toolsByPosition = request.prompts.map((prompt) => resolveDeferredTools(prompt.tools, prompt.history)?.
|
|
158
|
+
// Parse against what each prompt renders: with deferred tools that
|
|
159
|
+
// includes whatever an earlier `tool_search` loaded.
|
|
160
|
+
const toolsByPosition = request.prompts.map((prompt) => resolveDeferredTools(prompt.tools, prompt.history)?.toolsToRender ??
|
|
153
161
|
prompt.tools?.map(toWireTool) ??
|
|
154
162
|
[]);
|
|
155
163
|
const toolsById = new Map();
|
|
@@ -297,10 +305,9 @@ export const llmPlugin = definePlugin({
|
|
|
297
305
|
handler: async function* (request) {
|
|
298
306
|
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
299
307
|
try {
|
|
300
|
-
const filteredHistory = request.history.map((
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
attachments: attachments ?? []
|
|
308
|
+
const filteredHistory = request.history.map((message) => ({
|
|
309
|
+
...message,
|
|
310
|
+
attachments: message.attachments ?? []
|
|
304
311
|
}));
|
|
305
312
|
const modelCfg = getModelConfig(request.modelId);
|
|
306
313
|
const toolsActive = (request.tools?.length ?? 0) > 0 && modelCfg.tools === true;
|
|
@@ -351,6 +358,7 @@ export const llmPlugin = definePlugin({
|
|
|
351
358
|
history: filteredHistory,
|
|
352
359
|
modelId: request.modelId,
|
|
353
360
|
kvCache: request.kvCache,
|
|
361
|
+
prefill: request.prefill,
|
|
354
362
|
...(toolsActive && request.tools && { tools: request.tools }),
|
|
355
363
|
...(request.generationParams && { generationParams: request.generationParams }),
|
|
356
364
|
...(toolsActive && { toolDialect: dialect }),
|
|
@@ -8,13 +8,17 @@
|
|
|
8
8
|
export function transformLlmConfig(llmConfig) {
|
|
9
9
|
const transformed = JSON.parse(JSON.stringify(llmConfig, (key, v) => key === 'modelType' || key === 'system_prompt'
|
|
10
10
|
? undefined
|
|
11
|
-
: key === 'stop_sequences'
|
|
11
|
+
: key === 'stop_sequences' || key === 'backend'
|
|
12
12
|
? Array.isArray(v)
|
|
13
13
|
? v.join(', ')
|
|
14
14
|
: v
|
|
15
15
|
: typeof v === 'number' || typeof v === 'boolean'
|
|
16
16
|
? String(v)
|
|
17
17
|
: v).replace(/"([a-z][A-Za-z]*)":/g, (_, key) => `"${key.replace(/[A-Z]/g, (l) => `_${l.toLowerCase()}`)}":`));
|
|
18
|
+
if ('poll_batch' in transformed) {
|
|
19
|
+
transformed['poll-batch'] = transformed['poll_batch'];
|
|
20
|
+
delete transformed['poll_batch'];
|
|
21
|
+
}
|
|
18
22
|
if ('stop_sequences' in transformed) {
|
|
19
23
|
transformed['reverse_prompt'] = transformed['stop_sequences'];
|
|
20
24
|
delete transformed['stop_sequences'];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LayaConfig, LayaRequest as NativeLayaRequest, LayaResult as NativeLayaResult } from '@qvac/embed-llamacpp';
|
|
2
|
+
import type { DecisionConfig, DecisionRequest, DecisionResult } from '../../../schemas/index.js';
|
|
3
|
+
export declare function transformDecisionConfig(config: DecisionConfig): LayaConfig;
|
|
4
|
+
export declare function transformDecisionRequest(request: DecisionRequest): NativeLayaRequest;
|
|
5
|
+
export declare function transformDecisionResult(result: NativeLayaResult): DecisionResult;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export function transformDecisionConfig(config) {
|
|
2
|
+
const { pollBatch, ...nativeConfig } = config;
|
|
3
|
+
const transformed = {
|
|
4
|
+
...Object.fromEntries(Object.entries(nativeConfig)
|
|
5
|
+
.filter(([, value]) => value !== undefined)
|
|
6
|
+
.map(([key, value]) => [key, String(value)])),
|
|
7
|
+
device: config.device
|
|
8
|
+
};
|
|
9
|
+
if (pollBatch !== undefined) {
|
|
10
|
+
transformed['poll-batch'] = `${pollBatch}`;
|
|
11
|
+
}
|
|
12
|
+
return transformed;
|
|
13
|
+
}
|
|
14
|
+
function transformDecisionQuestion(question) {
|
|
15
|
+
const base = {
|
|
16
|
+
instructions: question.instructions,
|
|
17
|
+
...(question.optionOrder === undefined ? {} : { option_order: question.optionOrder })
|
|
18
|
+
};
|
|
19
|
+
if (question.type === 'choice') {
|
|
20
|
+
return { ...base, type: 'choice', criteria: question.criteria };
|
|
21
|
+
}
|
|
22
|
+
if (question.type === 'score') {
|
|
23
|
+
return { ...base, type: 'score', criteria: question.criteria };
|
|
24
|
+
}
|
|
25
|
+
const criteria = question.criteria;
|
|
26
|
+
return {
|
|
27
|
+
...base,
|
|
28
|
+
type: 'noul',
|
|
29
|
+
...(criteria === undefined
|
|
30
|
+
? {}
|
|
31
|
+
: {
|
|
32
|
+
criteria: criteria === null
|
|
33
|
+
? null
|
|
34
|
+
: {
|
|
35
|
+
...(criteria.true === undefined ? {} : { true: criteria.true }),
|
|
36
|
+
...(criteria.false === undefined ? {} : { false: criteria.false })
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
...(question.labels === undefined ? {} : { labels: question.labels })
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function transformDecisionRequest(request) {
|
|
43
|
+
return {
|
|
44
|
+
...('states' in request ? { states: request.states } : { state: request.state }),
|
|
45
|
+
questions: Object.fromEntries(Object.entries(request.questions).map(([id, question]) => [
|
|
46
|
+
id,
|
|
47
|
+
transformDecisionQuestion(question)
|
|
48
|
+
])),
|
|
49
|
+
...(request.maxLen === undefined ? {} : { max_len: request.maxLen }),
|
|
50
|
+
...(request.headMaxLen === undefined ? {} : { head_max_len: request.headMaxLen })
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function transformDecisionResult(result) {
|
|
54
|
+
const { usage } = result;
|
|
55
|
+
return {
|
|
56
|
+
model: result.model,
|
|
57
|
+
answers: Object.fromEntries(Object.entries(result.answers).map(([id, answer]) => {
|
|
58
|
+
const { answer_confidence, action, ...fields } = answer;
|
|
59
|
+
return [
|
|
60
|
+
id,
|
|
61
|
+
{
|
|
62
|
+
...fields,
|
|
63
|
+
answerConfidence: answer_confidence,
|
|
64
|
+
action: { actProbability: action.act_probability }
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
})),
|
|
68
|
+
usage: {
|
|
69
|
+
inputTokens: usage.input_tokens,
|
|
70
|
+
outputTokens: usage.output_tokens,
|
|
71
|
+
stateTokens: usage.state_tokens,
|
|
72
|
+
stateTokensDropped: usage.state_tokens_dropped,
|
|
73
|
+
truncated: usage.truncated,
|
|
74
|
+
truncatedQuestions: usage.truncated_questions,
|
|
75
|
+
...(usage.options === undefined
|
|
76
|
+
? {}
|
|
77
|
+
: {
|
|
78
|
+
options: Object.fromEntries(Object.entries(usage.options).map(([id, option]) => [
|
|
79
|
+
id,
|
|
80
|
+
{
|
|
81
|
+
total: option.total,
|
|
82
|
+
distinct: option.distinct,
|
|
83
|
+
tokensPerOption: option.tokens_per_option
|
|
84
|
+
}
|
|
85
|
+
]))
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|