@qvac/sdk 0.9.2 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +42 -95
- package/dist/client/api/cancel.d.ts +1 -1
- package/dist/client/api/cancel.js +1 -1
- package/dist/client/api/completion-stream.d.ts +51 -12
- package/dist/client/api/completion-stream.js +129 -56
- package/dist/client/api/delete-cache.d.ts +1 -0
- package/dist/client/api/delete-cache.js +1 -0
- package/dist/client/api/diffusion.d.ts +17 -2
- package/dist/client/api/diffusion.js +21 -4
- package/dist/client/api/embed.d.ts +4 -0
- package/dist/client/api/finetune.d.ts +21 -0
- package/dist/client/api/get-loaded-model-info.d.ts +25 -0
- package/dist/client/api/get-loaded-model-info.js +36 -0
- package/dist/client/api/get-model-info.d.ts +9 -1
- package/dist/client/api/get-model-info.js +8 -0
- package/dist/client/api/heartbeat.d.ts +2 -2
- package/dist/client/api/heartbeat.js +2 -2
- package/dist/client/api/index.d.ts +3 -1
- package/dist/client/api/index.js +3 -1
- package/dist/client/api/invoke-plugin.d.ts +16 -0
- package/dist/client/api/invoke-plugin.js +16 -0
- package/dist/client/api/load-model.d.ts +36 -3
- package/dist/client/api/load-model.js +31 -10
- package/dist/client/api/provide.d.ts +11 -5
- package/dist/client/api/provide.js +11 -6
- package/dist/client/api/rag.d.ts +9 -0
- package/dist/client/api/rag.js +9 -0
- package/dist/client/api/registry.d.ts +26 -0
- package/dist/client/api/registry.js +26 -0
- package/dist/client/api/resume.d.ts +20 -4
- package/dist/client/api/resume.js +20 -4
- package/dist/client/api/state.d.ts +23 -0
- package/dist/client/api/state.js +29 -0
- package/dist/client/api/stop-provider.d.ts +11 -5
- package/dist/client/api/stop-provider.js +11 -5
- package/dist/client/api/suspend.d.ts +21 -3
- package/dist/client/api/suspend.js +21 -3
- package/dist/client/api/text-to-speech.d.ts +64 -6
- package/dist/client/api/text-to-speech.js +423 -47
- package/dist/client/api/transcribe.d.ts +29 -4
- package/dist/client/api/transcribe.js +86 -28
- package/dist/client/api/translate.d.ts +1 -0
- package/dist/client/api/translate.js +1 -0
- package/dist/client/rpc/bare-client.js +22 -1
- package/dist/client/rpc/expo-rpc-client.d.ts +1 -1
- package/dist/client/rpc/expo-rpc-client.js +96 -4
- package/dist/client/rpc/node-rpc-client.js +36 -0
- package/dist/examples/audio/mic-input.d.ts +9 -0
- package/dist/examples/audio/mic-input.js +111 -0
- package/dist/examples/completion-events.d.ts +18 -0
- package/dist/examples/completion-events.js +79 -0
- package/dist/examples/delegated-inference/composite.js +12 -18
- package/dist/examples/delegated-inference/consumer-profiled.js +4 -11
- package/dist/examples/delegated-inference/consumer.js +8 -13
- package/dist/examples/delegated-inference/provider.js +11 -16
- package/dist/examples/diffusion-flux2-klein-img2img.d.ts +2 -0
- package/dist/examples/diffusion-flux2-klein-img2img.js +60 -0
- package/dist/examples/diffusion-flux2-klein.js +1 -0
- package/dist/examples/diffusion-img2img.d.ts +2 -0
- package/dist/examples/diffusion-img2img.js +49 -0
- package/dist/examples/diffusion-txt2img.js +2 -1
- package/dist/examples/kv-cache-example.js +11 -12
- package/dist/examples/llamacpp-cache.d.ts +2 -0
- package/dist/examples/llamacpp-cache.js +107 -0
- package/dist/examples/llamacpp-dynamic-tools.d.ts +2 -0
- package/dist/examples/llamacpp-dynamic-tools.js +144 -0
- package/dist/examples/llamacpp-structured-output.d.ts +2 -0
- package/dist/examples/llamacpp-structured-output.js +106 -0
- package/dist/examples/plugins.js +4 -4
- package/dist/examples/suspend-resume.js +21 -4
- package/dist/examples/{llamacpp-native-tools.js → tools/llamacpp-native-tools.js} +6 -55
- package/dist/examples/tools/llamacpp-tools-harmony-multiturn.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-harmony-multiturn.js +81 -0
- package/dist/examples/tools/llamacpp-tools-pythonic.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-pythonic.js +50 -0
- package/dist/examples/tools/shared.d.ts +21 -0
- package/dist/examples/tools/shared.js +42 -0
- package/dist/examples/transcription/parakeet-microphone-record.js +6 -33
- package/dist/examples/transcription/whispercpp-filesystem-streaming.js +7 -5
- package/dist/examples/transcription/whispercpp-filesystem.js +12 -3
- package/dist/examples/transcription/whispercpp-microphone-record.js +6 -29
- package/dist/examples/translation/translation-stream.js +5 -5
- package/dist/examples/tts/llm-to-tts-streaming.d.ts +16 -0
- package/dist/examples/tts/llm-to-tts-streaming.js +143 -0
- package/dist/examples/tts/supertonic-multilingual.js +3 -3
- package/dist/examples/tts/supertonic.js +3 -3
- package/dist/examples/tts/utils.d.ts +11 -1
- package/dist/examples/tts/utils.js +70 -17
- package/dist/examples/voice-assistant/voice-assistant.d.ts +2 -0
- package/dist/examples/voice-assistant/voice-assistant.js +207 -0
- package/dist/expo/plugins/withMobileBundle.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/logging/logger.d.ts +11 -0
- package/dist/logging/logger.js +11 -0
- package/dist/logging/types.d.ts +18 -0
- package/dist/models/registry/models.d.ts +6973 -7457
- package/dist/models/registry/models.js +6889 -6855
- package/dist/models/update-models/codegen.js +84 -23
- package/dist/models/update-models/companions.d.ts +18 -0
- package/dist/models/update-models/companions.js +175 -0
- package/dist/models/update-models/naming.js +0 -25
- package/dist/models/update-models/registry.d.ts +1 -0
- package/dist/models/update-models/registry.js +23 -3
- package/dist/models/update-models/types.d.ts +37 -9
- package/dist/profiling/index.d.ts +49 -0
- package/dist/profiling/index.js +49 -0
- package/dist/schemas/cancel.d.ts +6 -2
- package/dist/schemas/cancel.js +14 -7
- package/dist/schemas/common.d.ts +354 -271
- package/dist/schemas/common.js +26 -5
- package/dist/schemas/completion-event.d.ts +225 -0
- package/dist/schemas/completion-event.js +79 -0
- package/dist/schemas/completion-stream.d.ts +126 -31
- package/dist/schemas/completion-stream.js +138 -36
- package/dist/schemas/delegate.d.ts +0 -2
- package/dist/schemas/delegate.js +25 -6
- package/dist/schemas/download-asset.d.ts +5 -5
- package/dist/schemas/embed.js +21 -9
- package/dist/schemas/engine-addon-map.d.ts +11 -1
- package/dist/schemas/engine-addon-map.js +2 -2
- package/dist/schemas/get-loaded-model-info.d.ts +52 -0
- package/dist/schemas/get-loaded-model-info.js +44 -0
- package/dist/schemas/get-model-info.d.ts +2 -2
- package/dist/schemas/get-model-info.js +103 -32
- package/dist/schemas/heartbeat.d.ts +0 -1
- package/dist/schemas/index.d.ts +4 -1
- package/dist/schemas/index.js +4 -1
- package/dist/schemas/llamacpp-config.d.ts +14 -4
- package/dist/schemas/llamacpp-config.js +5 -0
- package/dist/schemas/load-model.d.ts +3233 -1260
- package/dist/schemas/load-model.js +23 -16
- package/dist/schemas/model-src-utils.d.ts +7 -6
- package/dist/schemas/model-src-utils.js +27 -1
- package/dist/schemas/model-types.d.ts +4 -4
- package/dist/schemas/ocr.d.ts +1 -1
- package/dist/schemas/plugin.d.ts +27 -3
- package/dist/schemas/plugin.js +27 -2
- package/dist/schemas/profiling.js +11 -3
- package/dist/schemas/provide.d.ts +1 -3
- package/dist/schemas/provide.js +0 -3
- package/dist/schemas/rag.d.ts +4 -4
- package/dist/schemas/registry.d.ts +10 -10
- package/dist/schemas/registry.js +36 -14
- package/dist/schemas/reload-config.d.ts +73 -7
- package/dist/schemas/sdcpp-config.d.ts +16 -8
- package/dist/schemas/sdcpp-config.js +118 -25
- package/dist/schemas/sdk-config.d.ts +116 -90
- package/dist/schemas/sdk-config.js +16 -0
- package/dist/schemas/sdk-errors-client.d.ts +3 -0
- package/dist/schemas/sdk-errors-client.js +16 -1
- package/dist/schemas/sdk-errors-server.d.ts +3 -0
- package/dist/schemas/sdk-errors-server.js +23 -0
- package/dist/schemas/state.d.ts +23 -0
- package/dist/schemas/state.js +14 -0
- package/dist/schemas/stop-provide.d.ts +0 -5
- package/dist/schemas/stop-provide.js +2 -6
- package/dist/schemas/text-to-speech.d.ts +93 -27
- package/dist/schemas/text-to-speech.js +27 -0
- package/dist/schemas/tools.d.ts +16 -0
- package/dist/schemas/tools.js +15 -0
- package/dist/schemas/transcription-config.d.ts +8 -8
- package/dist/schemas/transcription.d.ts +33 -0
- package/dist/schemas/transcription.js +9 -0
- package/dist/schemas/translate.js +59 -19
- package/dist/schemas/translation-config.d.ts +157 -133
- package/dist/schemas/translation-config.js +34 -11
- package/dist/server/bare/delegate-rpc-client.d.ts +1 -1
- package/dist/server/bare/delegate-rpc-client.js +131 -122
- package/dist/server/bare/hyperswarm.d.ts +2 -2
- package/dist/server/bare/hyperswarm.js +12 -7
- package/dist/server/bare/ops/cancel.js +7 -0
- package/dist/server/bare/ops/kv-cache-utils.d.ts +7 -10
- package/dist/server/bare/ops/kv-cache-utils.js +31 -40
- package/dist/server/bare/ops/load-model.js +0 -1
- package/dist/server/bare/ops/transcribe.d.ts +11 -4
- package/dist/server/bare/ops/transcribe.js +25 -4
- package/dist/server/bare/ops/translate.js +42 -4
- package/dist/server/bare/ops/unload-model.js +21 -19
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +1 -2
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +13 -8
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +257 -85
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +101 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +135 -0
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +80 -22
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +57 -32
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -16
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +69 -44
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +54 -116
- package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.d.ts +32 -0
- package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.js +117 -0
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +1 -1
- package/dist/server/bare/plugins/onnx-ocr/plugin.js +1 -2
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech-stream.d.ts +7 -0
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech-stream.js +116 -0
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.d.ts +2 -3
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.js +71 -9
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +41 -13
- package/dist/server/bare/plugins/onnx-tts/plugin.js +48 -3
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +15 -7
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +5 -6
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +6 -0
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +8 -5
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +13 -13
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +17 -1
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +40 -17
- package/dist/server/bare/registry/config-registry.js +14 -3
- package/dist/server/bare/registry/model-registry.d.ts +8 -10
- package/dist/server/bare/registry/model-registry.js +17 -12
- package/dist/server/bare/registry/registry-client.js +79 -19
- package/dist/server/bare/runtime-lifecycle.d.ts +2 -1
- package/dist/server/bare/runtime-lifecycle.js +13 -2
- package/dist/server/bare/types/addon-responses.d.ts +8 -3
- package/dist/server/bare/utils/transcribe-metadata.d.ts +21 -0
- package/dist/server/bare/utils/transcribe-metadata.js +28 -0
- package/dist/server/bare/utils/tts-stats.d.ts +22 -0
- package/dist/server/bare/utils/tts-stats.js +10 -0
- package/dist/server/rpc/create-server.d.ts +4 -1
- package/dist/server/rpc/create-server.js +5 -1
- package/dist/server/rpc/delegate-transport.js +36 -29
- package/dist/server/rpc/handle-request.js +28 -3
- package/dist/server/rpc/handler-registry.js +7 -1
- package/dist/server/rpc/handler-utils.d.ts +5 -0
- package/dist/server/rpc/handler-utils.js +22 -0
- package/dist/server/rpc/handlers/cancel-delegated.js +3 -5
- package/dist/server/rpc/handlers/cancelHandler.js +4 -5
- package/dist/server/rpc/handlers/completion-stream-delegated.js +14 -5
- package/dist/server/rpc/handlers/delete-cache.js +8 -3
- package/dist/server/rpc/handlers/download-asset.js +3 -24
- package/dist/server/rpc/handlers/get-loaded-model-info.d.ts +3 -0
- package/dist/server/rpc/handlers/get-loaded-model-info.js +39 -0
- package/dist/server/rpc/handlers/get-model-info.js +93 -84
- package/dist/server/rpc/handlers/heartbeat-delegated.js +2 -2
- package/dist/server/rpc/handlers/index.d.ts +6 -0
- package/dist/server/rpc/handlers/index.js +6 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +35 -9
- package/dist/server/rpc/handlers/load-model/download-manager.js +142 -38
- package/dist/server/rpc/handlers/load-model/download-stats.d.ts +5 -4
- package/dist/server/rpc/handlers/load-model/download-stats.js +49 -8
- package/dist/server/rpc/handlers/load-model/handler.js +31 -50
- package/dist/server/rpc/handlers/load-model/http.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/http.js +97 -142
- package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +55 -74
- package/dist/server/rpc/handlers/load-model/index.d.ts +0 -1
- package/dist/server/rpc/handlers/load-model/index.js +0 -1
- package/dist/server/rpc/handlers/load-model/registry-client-options.d.ts +27 -0
- package/dist/server/rpc/handlers/load-model/registry-client-options.js +19 -0
- package/dist/server/rpc/handlers/load-model/registry-companion-set.d.ts +22 -0
- package/dist/server/rpc/handlers/load-model/registry-companion-set.js +208 -0
- package/dist/server/rpc/handlers/load-model/registry-download-utils.d.ts +24 -0
- package/dist/server/rpc/handlers/load-model/registry-download-utils.js +114 -0
- package/dist/server/rpc/handlers/load-model/registry.d.ts +2 -20
- package/dist/server/rpc/handlers/load-model/registry.js +109 -381
- package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +15 -0
- package/dist/server/rpc/handlers/load-model/resolve-session.js +61 -0
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -3
- package/dist/server/rpc/handlers/load-model/resolve.js +14 -23
- package/dist/server/rpc/handlers/load-model/types.d.ts +11 -4
- package/dist/server/rpc/handlers/load-model/types.js +28 -1
- package/dist/server/rpc/handlers/load-model-delegated.js +2 -4
- package/dist/server/rpc/handlers/plugin-dispatch.js +9 -5
- package/dist/server/rpc/handlers/plugin-invoke.js +1 -1
- package/dist/server/rpc/handlers/provideHandler/connection.js +13 -2
- package/dist/server/rpc/handlers/provideHandler/handler.js +42 -29
- package/dist/server/rpc/handlers/state.d.ts +3 -0
- package/dist/server/rpc/handlers/state.js +7 -0
- package/dist/server/rpc/handlers/stopProvideHandler.d.ts +2 -2
- package/dist/server/rpc/handlers/stopProvideHandler.js +12 -7
- package/dist/server/rpc/handlers/text-to-speech-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/text-to-speech-stream.js +4 -0
- package/dist/server/rpc/handlers/unload-model-delegated.js +3 -3
- package/dist/server/rpc/profiling/operation-metrics.js +20 -0
- package/dist/server/rpc/rpc-utils.js +1 -1
- package/dist/server/rpc/transport-selector.d.ts +3 -0
- package/dist/server/rpc/transport-selector.js +18 -0
- package/dist/server/utils/cache/auto-history.d.ts +4 -0
- package/dist/server/utils/cache/auto-history.js +22 -0
- package/dist/server/utils/{cache.d.ts → cache/paths.d.ts} +22 -5
- package/dist/server/utils/{cache.js → cache/paths.js} +36 -20
- package/dist/server/utils/cache/types.d.ts +8 -0
- package/dist/server/utils/cache/types.js +1 -0
- package/dist/server/utils/checksum.d.ts +2 -2
- package/dist/server/utils/checksum.js +1 -1
- package/dist/server/utils/clear-storage.d.ts +5 -0
- package/dist/server/utils/clear-storage.js +17 -0
- package/dist/server/utils/completion-normalizer.d.ts +17 -0
- package/dist/server/utils/completion-normalizer.js +413 -0
- package/dist/server/utils/expand-gguf-shards.d.ts +3 -0
- package/dist/server/utils/expand-gguf-shards.js +22 -0
- package/dist/server/utils/formatting.js +1 -1
- package/dist/server/utils/index.d.ts +4 -2
- package/dist/server/utils/index.js +4 -2
- package/dist/server/utils/qvac-paths.d.ts +2 -0
- package/dist/server/utils/qvac-paths.js +5 -0
- package/dist/server/utils/response-format.d.ts +3 -0
- package/dist/server/utils/response-format.js +20 -0
- package/dist/server/utils/tool-integration.d.ts +15 -4
- package/dist/server/utils/tool-integration.js +21 -41
- package/dist/server/utils/tools/dialect.d.ts +8 -0
- package/dist/server/utils/tools/dialect.js +14 -0
- package/dist/server/utils/tools/index.d.ts +3 -0
- package/dist/server/utils/tools/index.js +2 -0
- package/dist/server/utils/tools/parser.d.ts +6 -0
- package/dist/server/utils/tools/parser.js +46 -0
- package/dist/server/utils/tools/parsers/harmony.d.ts +4 -0
- package/dist/server/utils/tools/parsers/harmony.js +59 -0
- package/dist/server/utils/tools/parsers/hermes.d.ts +4 -0
- package/dist/server/utils/tools/parsers/hermes.js +100 -0
- package/dist/server/utils/tools/parsers/json.d.ts +6 -0
- package/dist/server/utils/tools/parsers/json.js +115 -0
- package/dist/server/utils/tools/parsers/pythonic.d.ts +4 -0
- package/dist/server/utils/tools/parsers/pythonic.js +267 -0
- package/dist/server/utils/tools/shared.d.ts +18 -0
- package/dist/server/utils/tools/shared.js +54 -0
- package/dist/server/utils/worker-lock.d.ts +3 -0
- package/dist/server/utils/worker-lock.js +67 -0
- package/dist/server/worker-core.d.ts +16 -1
- package/dist/server/worker-core.js +114 -14
- package/dist/utils/aggregate-events.d.ts +16 -0
- package/dist/utils/aggregate-events.js +52 -0
- package/dist/utils/cache-normalize.d.ts +10 -0
- package/dist/utils/cache-normalize.js +23 -0
- package/dist/utils/encoding.d.ts +8 -0
- package/dist/utils/encoding.js +13 -0
- package/dist/utils/errors-client.d.ts +12 -0
- package/dist/utils/errors-client.js +20 -0
- package/dist/utils/errors-server.d.ts +14 -0
- package/dist/utils/errors-server.js +31 -0
- package/dist/utils/load-model-validation.d.ts +7 -0
- package/dist/utils/load-model-validation.js +18 -0
- package/expo/plugins/patches/android-link.mjs +1 -1
- package/expo/plugins/patches/ios-link.mjs +1 -1
- package/package.json +14 -18
- package/dist/examples/translation/translation-opus.d.ts +0 -2
- package/dist/examples/translation/translation-opus.js +0 -33
- package/dist/server/bare/utils/loader-adapter.d.ts +0 -7
- package/dist/server/bare/utils/loader-adapter.js +0 -9
- package/dist/server/utils/model-path.d.ts +0 -5
- package/dist/server/utils/model-path.js +0 -7
- package/dist/server/utils/tool-parser.d.ts +0 -7
- package/dist/server/utils/tool-parser.js +0 -248
- /package/dist/examples/{llamacpp-native-tools.d.ts → tools/llamacpp-native-tools.d.ts} +0 -0
|
@@ -1,18 +1,49 @@
|
|
|
1
1
|
import { stream as streamRpc } from "../rpc/rpc-client.js";
|
|
2
2
|
import { getClientLogger } from "../../logging/index.js";
|
|
3
3
|
import { completionStreamResponseSchema, } from "../../schemas/index.js";
|
|
4
|
+
import { CompletionFailedError } from "../../utils/errors-server.js";
|
|
4
5
|
import { getMcpToolsWithHandlers } from "../../utils/mcp-adapter.js";
|
|
5
|
-
import {
|
|
6
|
+
import { validateTools, } from "../../utils/tool-helpers.js";
|
|
7
|
+
import { buildFinalFromEvents } from "../../utils/aggregate-events.js";
|
|
6
8
|
const logger = getClientLogger();
|
|
7
9
|
/**
|
|
8
10
|
* Generates completion from a language model based on conversation history.
|
|
9
11
|
*
|
|
12
|
+
* Returns a `CompletionRun` whose canonical surfaces are:
|
|
13
|
+
*
|
|
14
|
+
* - `events` — `AsyncIterable<CompletionEvent>` of ordered, typed events.
|
|
15
|
+
* - `final` — `Promise<CompletionFinal>` with aggregated results once the
|
|
16
|
+
* stream ends (content, thinking, tool calls, stats, raw text).
|
|
17
|
+
*
|
|
18
|
+
* Legacy convenience fields (`tokenStream`, `text`, `toolCallStream`,
|
|
19
|
+
* `toolCalls`, `stats`) are still available but deprecated — they derive
|
|
20
|
+
* from `events` / `final` internally.
|
|
21
|
+
*
|
|
10
22
|
* @param params - The completion parameters
|
|
11
23
|
* @param params.modelId - The identifier of the model to use for completion
|
|
12
24
|
* @param params.history - Array of conversation messages with role, content, and optional attachments
|
|
13
25
|
* @param params.stream - Whether to stream tokens (true) or return complete response (false). Defaults to true
|
|
14
26
|
* @param params.tools - Optional array of tools (can be simple ToolInput with Zod schemas or full Tool objects)
|
|
15
27
|
* @param params.mcp - Optional array of MCP client inputs for tool integration
|
|
28
|
+
* @param params.captureThinking - Best-effort parsing of `<think>` blocks into `thinkingDelta` events; `final.raw.fullText` always preserves the original output
|
|
29
|
+
* @param params.emitRawDeltas - When true, every raw model token is also emitted as a `rawDelta` event
|
|
30
|
+
* @param params.toolDialect - Override the SDK's name-based dialect detection. Use when your model emits a known format (`"hermes"`, `"pythonic"`, or `"json"`) the auto-router doesn't recognise. Drives both streaming frame detection and finalization parsing.
|
|
31
|
+
* Common override case: Llama 3.x tool-calling fine-tunes that emit the native pythonic header (`<|start_header_id|>tool_call<|end_header_id|>...<|eot_id|>`).
|
|
32
|
+
* @param params.responseFormat - Optional structured-output constraint applied to the model's output:
|
|
33
|
+
* - `{ type: "text" }` — no constraint (default behavior)
|
|
34
|
+
* - `{ type: "json_object" }` — output must be a JSON object
|
|
35
|
+
* - `{ type: "json_schema", json_schema: { name, schema, description?, strict? } }` — output must validate against `schema`
|
|
36
|
+
*
|
|
37
|
+
* The schema is converted to GBNF natively by llama.cpp and applied for the
|
|
38
|
+
* duration of the request only. `json_schema.name` and `json_schema.description`
|
|
39
|
+
* are accepted for OpenAI compatibility but only used at the API boundary —
|
|
40
|
+
* they do not affect generation. **`json_schema.strict` is currently accepted
|
|
41
|
+
* for compatibility but does NOT trigger OpenAI's auto-tightening semantics**
|
|
42
|
+
* (implicit `additionalProperties: false`, all properties required). The
|
|
43
|
+
* schema is forwarded to the addon as-is, so callers who want strict
|
|
44
|
+
* validation must encode it explicitly in `schema`.
|
|
45
|
+
*
|
|
46
|
+
* Cannot be combined with `tools` (tools already constrain output via their parameter schema).
|
|
16
47
|
* @param params.kvCache - Optional KV cache configuration. Cache files are organized hierarchically:
|
|
17
48
|
* - Structure: `{kvCacheKey}/{modelId}/{configHash}.bin`
|
|
18
49
|
* - The configHash includes model config + system prompt to ensure cache isolation
|
|
@@ -21,17 +52,29 @@ const logger = getClientLogger();
|
|
|
21
52
|
* - `false` or `undefined`: No caching
|
|
22
53
|
* - ⚡ Performance: When cache exists, only the last message is sent to the model (includes multimodal attachments)
|
|
23
54
|
* - 🗑️ Cleanup: Use `deleteCache({ kvCacheKey })` to remove cached sessions
|
|
24
|
-
*
|
|
55
|
+
*
|
|
56
|
+
* **Auto-cache (`kvCache: true`) — assistant turn contract.** When
|
|
57
|
+
* pushing the assistant turn back into `history` for the next call,
|
|
58
|
+
* use `(await run.final).cacheableAssistantContent`. That's the exact
|
|
59
|
+
* string the SDK persisted to the cache key on this turn, so re-using
|
|
60
|
+
* it verbatim guarantees the next-turn lookup hits.
|
|
61
|
+
* - Any post-processing of the assistant text (rewriting, summarizing,
|
|
62
|
+
* stripping model stop tokens like `<|im_end|>`) before pushing it
|
|
63
|
+
* back will miss the cache. Push the canonical string unchanged.
|
|
64
|
+
* - `cacheableAssistantContent` is omitted on tool-call turns - those
|
|
65
|
+
* can't be auto-cached today.
|
|
66
|
+
* @returns A CompletionRun — consume via `events` / `final`.
|
|
25
67
|
* @example
|
|
26
68
|
* ```typescript
|
|
27
69
|
* import { z } from "zod";
|
|
28
70
|
*
|
|
29
|
-
* const
|
|
71
|
+
* const run = completion({
|
|
30
72
|
* modelId: "llama-2",
|
|
31
73
|
* history: [
|
|
32
74
|
* { role: "user", content: "What's the weather in Tokyo?" }
|
|
33
75
|
* ],
|
|
34
76
|
* stream: true,
|
|
77
|
+
* captureThinking: true,
|
|
35
78
|
* tools: [{
|
|
36
79
|
* name: "get_weather",
|
|
37
80
|
* description: "Get current weather",
|
|
@@ -44,10 +87,12 @@ const logger = getClientLogger();
|
|
|
44
87
|
* }]
|
|
45
88
|
* });
|
|
46
89
|
*
|
|
47
|
-
* for await (const
|
|
48
|
-
* process.stdout.write(
|
|
90
|
+
* for await (const event of run.events) {
|
|
91
|
+
* if (event.type === "contentDelta") process.stdout.write(event.text);
|
|
92
|
+
* if (event.type === "toolCall") console.log(event.call.name, event.call.arguments);
|
|
49
93
|
* }
|
|
50
94
|
*
|
|
95
|
+
* const result = await run.final;
|
|
51
96
|
* for (const toolCall of await result.toolCalls) {
|
|
52
97
|
* if (toolCall.invoke) {
|
|
53
98
|
* const toolResult = await toolCall.invoke();
|
|
@@ -57,7 +102,6 @@ const logger = getClientLogger();
|
|
|
57
102
|
* ```
|
|
58
103
|
*/
|
|
59
104
|
export function completion(params) {
|
|
60
|
-
let stats;
|
|
61
105
|
let statsResolver = () => { };
|
|
62
106
|
let statsRejecter = () => { };
|
|
63
107
|
const statsPromise = new Promise((resolve, reject) => {
|
|
@@ -65,7 +109,6 @@ export function completion(params) {
|
|
|
65
109
|
statsRejecter = reject;
|
|
66
110
|
});
|
|
67
111
|
statsPromise.catch(() => { });
|
|
68
|
-
let toolCallsArray = [];
|
|
69
112
|
let toolCallsResolver = () => { };
|
|
70
113
|
let toolCallsRejecter = () => { };
|
|
71
114
|
const toolCallsPromise = new Promise((resolve, reject) => {
|
|
@@ -73,14 +116,36 @@ export function completion(params) {
|
|
|
73
116
|
toolCallsRejecter = reject;
|
|
74
117
|
});
|
|
75
118
|
toolCallsPromise.catch(() => { });
|
|
119
|
+
let finalResolver = () => { };
|
|
120
|
+
let finalRejecter = () => { };
|
|
121
|
+
const finalPromise = new Promise((resolve, reject) => {
|
|
122
|
+
finalResolver = resolve;
|
|
123
|
+
finalRejecter = reject;
|
|
124
|
+
});
|
|
125
|
+
finalPromise.catch(() => { });
|
|
76
126
|
const tokenQueue = [];
|
|
77
127
|
const toolEventQueue = [];
|
|
78
|
-
|
|
79
|
-
let
|
|
128
|
+
const eventQueue = [];
|
|
129
|
+
let done = false;
|
|
80
130
|
let tokenResolve = null;
|
|
81
131
|
let toolResolve = null;
|
|
82
|
-
let
|
|
132
|
+
let eventResolve = null;
|
|
83
133
|
let streamError = null;
|
|
134
|
+
const allEvents = [];
|
|
135
|
+
function notifyWaiters() {
|
|
136
|
+
if (tokenResolve) {
|
|
137
|
+
tokenResolve();
|
|
138
|
+
tokenResolve = null;
|
|
139
|
+
}
|
|
140
|
+
if (toolResolve) {
|
|
141
|
+
toolResolve();
|
|
142
|
+
toolResolve = null;
|
|
143
|
+
}
|
|
144
|
+
if (eventResolve) {
|
|
145
|
+
eventResolve();
|
|
146
|
+
eventResolve = null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
84
149
|
const processResponses = async () => {
|
|
85
150
|
try {
|
|
86
151
|
let allTools = [];
|
|
@@ -113,6 +178,10 @@ export function completion(params) {
|
|
|
113
178
|
tools: allTools.length > 0 ? allTools : undefined,
|
|
114
179
|
stream: params.stream ?? true,
|
|
115
180
|
generationParams: params.generationParams,
|
|
181
|
+
captureThinking: params.captureThinking,
|
|
182
|
+
emitRawDeltas: params.emitRawDeltas,
|
|
183
|
+
toolDialect: params.toolDialect,
|
|
184
|
+
responseFormat: params.responseFormat,
|
|
116
185
|
};
|
|
117
186
|
const responses = streamRpc(request, params.rpcOptions);
|
|
118
187
|
for await (const response of responses) {
|
|
@@ -121,43 +190,32 @@ export function completion(params) {
|
|
|
121
190
|
"type" in response &&
|
|
122
191
|
response.type === "completionStream") {
|
|
123
192
|
const streamResponse = completionStreamResponseSchema.parse(response);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
tokenQueue.push(
|
|
129
|
-
if (tokenResolve) {
|
|
130
|
-
tokenResolve();
|
|
131
|
-
tokenResolve = null;
|
|
132
|
-
}
|
|
193
|
+
for (const event of streamResponse.events) {
|
|
194
|
+
allEvents.push(event);
|
|
195
|
+
eventQueue.push(event);
|
|
196
|
+
if (event.type === "contentDelta") {
|
|
197
|
+
tokenQueue.push(event.text);
|
|
133
198
|
}
|
|
134
|
-
if (
|
|
135
|
-
toolEventQueue.push(
|
|
136
|
-
if (toolResolve) {
|
|
137
|
-
toolResolve();
|
|
138
|
-
toolResolve = null;
|
|
139
|
-
}
|
|
199
|
+
else if (event.type === "toolCall") {
|
|
200
|
+
toolEventQueue.push(event);
|
|
140
201
|
}
|
|
141
202
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
toolCallsResolver(toolCallsArray);
|
|
151
|
-
tokenDone = true;
|
|
152
|
-
toolDone = true;
|
|
153
|
-
if (tokenResolve) {
|
|
154
|
-
tokenResolve();
|
|
155
|
-
tokenResolve = null;
|
|
203
|
+
notifyWaiters();
|
|
204
|
+
if (streamResponse.done) {
|
|
205
|
+
const { final, error } = buildFinalFromEvents(allEvents, allHandlers);
|
|
206
|
+
if (error) {
|
|
207
|
+
const err = new CompletionFailedError(error.message, error);
|
|
208
|
+
finalRejecter(err);
|
|
209
|
+
statsRejecter(err);
|
|
210
|
+
toolCallsRejecter(err);
|
|
156
211
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
212
|
+
else {
|
|
213
|
+
finalResolver(final);
|
|
214
|
+
statsResolver(final.stats);
|
|
215
|
+
toolCallsResolver(final.toolCalls);
|
|
160
216
|
}
|
|
217
|
+
done = true;
|
|
218
|
+
notifyWaiters();
|
|
161
219
|
}
|
|
162
220
|
}
|
|
163
221
|
}
|
|
@@ -166,31 +224,42 @@ export function completion(params) {
|
|
|
166
224
|
streamError = error instanceof Error ? error : new Error(String(error));
|
|
167
225
|
statsRejecter(error);
|
|
168
226
|
toolCallsRejecter(error);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
tokenResolve();
|
|
173
|
-
tokenResolve = null;
|
|
174
|
-
}
|
|
175
|
-
if (toolResolve) {
|
|
176
|
-
toolResolve();
|
|
177
|
-
toolResolve = null;
|
|
178
|
-
}
|
|
227
|
+
finalRejecter(error);
|
|
228
|
+
done = true;
|
|
229
|
+
notifyWaiters();
|
|
179
230
|
}
|
|
180
231
|
};
|
|
181
232
|
void processResponses();
|
|
182
233
|
const textPromise = (async () => {
|
|
183
|
-
await
|
|
184
|
-
return
|
|
234
|
+
const final = await finalPromise;
|
|
235
|
+
return final.contentText;
|
|
185
236
|
})();
|
|
186
237
|
textPromise.catch(() => { });
|
|
238
|
+
const eventStream = (async function* () {
|
|
239
|
+
while (true) {
|
|
240
|
+
if (eventQueue.length > 0) {
|
|
241
|
+
yield eventQueue.shift();
|
|
242
|
+
}
|
|
243
|
+
else if (done) {
|
|
244
|
+
if (streamError !== null) {
|
|
245
|
+
throw streamError;
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
await new Promise((resolve) => {
|
|
251
|
+
eventResolve = resolve;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
})();
|
|
187
256
|
if (params.stream) {
|
|
188
257
|
const tokenStream = (async function* () {
|
|
189
258
|
while (true) {
|
|
190
259
|
if (tokenQueue.length > 0) {
|
|
191
260
|
yield tokenQueue.shift();
|
|
192
261
|
}
|
|
193
|
-
else if (
|
|
262
|
+
else if (done) {
|
|
194
263
|
if (streamError !== null) {
|
|
195
264
|
throw streamError;
|
|
196
265
|
}
|
|
@@ -208,7 +277,7 @@ export function completion(params) {
|
|
|
208
277
|
if (toolEventQueue.length > 0) {
|
|
209
278
|
yield toolEventQueue.shift();
|
|
210
279
|
}
|
|
211
|
-
else if (
|
|
280
|
+
else if (done) {
|
|
212
281
|
if (streamError !== null) {
|
|
213
282
|
throw streamError;
|
|
214
283
|
}
|
|
@@ -222,6 +291,8 @@ export function completion(params) {
|
|
|
222
291
|
}
|
|
223
292
|
})();
|
|
224
293
|
return {
|
|
294
|
+
events: eventStream,
|
|
295
|
+
final: finalPromise,
|
|
225
296
|
tokenStream,
|
|
226
297
|
toolCallStream,
|
|
227
298
|
text: textPromise,
|
|
@@ -237,6 +308,8 @@ export function completion(params) {
|
|
|
237
308
|
//Empty generator for non-streaming mode
|
|
238
309
|
})();
|
|
239
310
|
return {
|
|
311
|
+
events: eventStream,
|
|
312
|
+
final: finalPromise,
|
|
240
313
|
tokenStream,
|
|
241
314
|
toolCallStream,
|
|
242
315
|
text: textPromise,
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @param params.kvCacheKey - The cache key to delete
|
|
7
7
|
* @param params.modelId - Optional: specific model ID to delete within the cache key. If not provided, deletes entire cache key.
|
|
8
8
|
* @returns Promise resolving to success status
|
|
9
|
+
* @throws {QvacErrorBase} When the cache parameters are invalid (`InvalidDeleteCacheParamsError`) or the server reports a delete failure (`DeleteCacheFailedError`).
|
|
9
10
|
* @example
|
|
10
11
|
* ```typescript
|
|
11
12
|
* // Delete all caches
|
|
@@ -8,6 +8,7 @@ import { InvalidDeleteCacheParamsError, DeleteCacheFailedError, } from "../../ut
|
|
|
8
8
|
* @param params.kvCacheKey - The cache key to delete
|
|
9
9
|
* @param params.modelId - Optional: specific model ID to delete within the cache key. If not provided, deletes entire cache key.
|
|
10
10
|
* @returns Promise resolving to success status
|
|
11
|
+
* @throws {QvacErrorBase} When the cache parameters are invalid (`InvalidDeleteCacheParamsError`) or the server reports a delete failure (`DeleteCacheFailedError`).
|
|
11
12
|
* @example
|
|
12
13
|
* ```typescript
|
|
13
14
|
* // Delete all caches
|
|
@@ -10,15 +10,30 @@ interface DiffusionResult {
|
|
|
10
10
|
stats: Promise<DiffusionStats | undefined>;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Generates images using a loaded diffusion model.
|
|
14
|
+
*
|
|
15
|
+
* @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
|
|
16
|
+
* @returns A result object exposing `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
|
|
17
|
+
*
|
|
18
|
+
* Supports both txt2img (no `init_image`) and img2img (with `init_image`).
|
|
14
19
|
*
|
|
15
20
|
* @example
|
|
16
21
|
* ```typescript
|
|
17
|
-
* //
|
|
22
|
+
* // txt2img
|
|
18
23
|
* const { outputs, stats } = diffusion({ modelId, prompt: "a cat" });
|
|
19
24
|
* const buffers = await outputs;
|
|
20
25
|
* fs.writeFileSync("output.png", buffers[0]);
|
|
21
26
|
*
|
|
27
|
+
* // img2img (SD/SDXL — SDEdit)
|
|
28
|
+
* const initImage = fs.readFileSync("input.png");
|
|
29
|
+
* const { outputs } = diffusion({ modelId, prompt: "oil painting style", init_image: initImage, strength: 0.7 });
|
|
30
|
+
*
|
|
31
|
+
* // img2img (FLUX.2 — in-context conditioning)
|
|
32
|
+
* // IMPORTANT: FLUX img2img requires `prediction: "flux2_flow"` to be set on the
|
|
33
|
+
* // model config at loadModel time (e.g. `loadModel(src, { modelType: "diffusion",
|
|
34
|
+
* // modelConfig: { prediction: "flux2_flow" } })`).
|
|
35
|
+
* const { outputs } = diffusion({ modelId, prompt: "turn into watercolor", init_image: initImage });
|
|
36
|
+
*
|
|
22
37
|
* // With progress tracking
|
|
23
38
|
* const { progressStream, outputs } = diffusion({ modelId, prompt: "a cat" });
|
|
24
39
|
* for await (const { step, totalSteps } of progressStream) {
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import { diffusionStreamResponseSchema, } from "../../schemas/index.js";
|
|
2
2
|
import { stream as streamRpc } from "../rpc/rpc-client.js";
|
|
3
|
-
import { decodeBase64 } from "../../utils/encoding.js";
|
|
3
|
+
import { decodeBase64, encodeBase64 } from "../../utils/encoding.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Generates images using a loaded diffusion model.
|
|
6
|
+
*
|
|
7
|
+
* @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
|
|
8
|
+
* @returns A result object exposing `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
|
|
9
|
+
*
|
|
10
|
+
* Supports both txt2img (no `init_image`) and img2img (with `init_image`).
|
|
6
11
|
*
|
|
7
12
|
* @example
|
|
8
13
|
* ```typescript
|
|
9
|
-
* //
|
|
14
|
+
* // txt2img
|
|
10
15
|
* const { outputs, stats } = diffusion({ modelId, prompt: "a cat" });
|
|
11
16
|
* const buffers = await outputs;
|
|
12
17
|
* fs.writeFileSync("output.png", buffers[0]);
|
|
13
18
|
*
|
|
19
|
+
* // img2img (SD/SDXL — SDEdit)
|
|
20
|
+
* const initImage = fs.readFileSync("input.png");
|
|
21
|
+
* const { outputs } = diffusion({ modelId, prompt: "oil painting style", init_image: initImage, strength: 0.7 });
|
|
22
|
+
*
|
|
23
|
+
* // img2img (FLUX.2 — in-context conditioning)
|
|
24
|
+
* // IMPORTANT: FLUX img2img requires `prediction: "flux2_flow"` to be set on the
|
|
25
|
+
* // model config at loadModel time (e.g. `loadModel(src, { modelType: "diffusion",
|
|
26
|
+
* // modelConfig: { prediction: "flux2_flow" } })`).
|
|
27
|
+
* const { outputs } = diffusion({ modelId, prompt: "turn into watercolor", init_image: initImage });
|
|
28
|
+
*
|
|
14
29
|
* // With progress tracking
|
|
15
30
|
* const { progressStream, outputs } = diffusion({ modelId, prompt: "a cat" });
|
|
16
31
|
* for await (const { step, totalSteps } of progressStream) {
|
|
@@ -20,9 +35,11 @@ import { decodeBase64 } from "../../utils/encoding.js";
|
|
|
20
35
|
* ```
|
|
21
36
|
*/
|
|
22
37
|
export function diffusion(params) {
|
|
38
|
+
const { init_image, ...rest } = params;
|
|
23
39
|
const request = {
|
|
40
|
+
...rest,
|
|
41
|
+
...(init_image !== undefined && { init_image: encodeBase64(init_image) }),
|
|
24
42
|
type: "diffusionStream",
|
|
25
|
-
...params,
|
|
26
43
|
};
|
|
27
44
|
let statsResolver = () => { };
|
|
28
45
|
let statsRejecter = () => { };
|
|
@@ -2,10 +2,12 @@ import { type EmbedStats, type RPCOptions } from "../../schemas/index";
|
|
|
2
2
|
/**
|
|
3
3
|
* Generates embeddings for a single text using a specified model.
|
|
4
4
|
*
|
|
5
|
+
* @overloadLabel "Single text"
|
|
5
6
|
* @param params - The parameters for the embedding
|
|
6
7
|
* @param params.modelId - The identifier of the embedding model to use
|
|
7
8
|
* @param params.text - The input text to embed
|
|
8
9
|
* @param options - Optional RPC options including per-call profiling
|
|
10
|
+
* @returns A promise resolving to an object with `embedding` (a single `number[]` vector) and optional `stats` performance data.
|
|
9
11
|
* @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
|
|
10
12
|
*/
|
|
11
13
|
export declare function embed(params: {
|
|
@@ -18,10 +20,12 @@ export declare function embed(params: {
|
|
|
18
20
|
/**
|
|
19
21
|
* Generates embeddings for multiple texts using a specified model.
|
|
20
22
|
*
|
|
23
|
+
* @overloadLabel "Multiple texts"
|
|
21
24
|
* @param params - The parameters for the embedding
|
|
22
25
|
* @param params.modelId - The identifier of the embedding model to use
|
|
23
26
|
* @param params.text - The input texts to embed
|
|
24
27
|
* @param options - Optional RPC options including per-call profiling
|
|
28
|
+
* @returns A promise resolving to an object with `embedding` (one `number[]` vector per input text, i.e. `number[][]`) and optional `stats` performance data.
|
|
25
29
|
* @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
|
|
26
30
|
*/
|
|
27
31
|
export declare function embed(params: {
|
|
@@ -63,7 +63,28 @@ type FinetuneReplyParams = FinetuneStopParams | FinetuneGetStateParams;
|
|
|
63
63
|
* console.log(pauseResult.status);
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
+
/**
|
|
67
|
+
* Run / start / resume a finetune job. Returns a handle with a streaming
|
|
68
|
+
* `progressStream` and a terminal `result` promise.
|
|
69
|
+
*
|
|
70
|
+
* @overloadLabel "Run / start / resume"
|
|
71
|
+
* @param params - The finetuning run parameters (see the function-level
|
|
72
|
+
* docs for the full breakdown of `params.options`).
|
|
73
|
+
* @param rpcOptions - Optional RPC transport options.
|
|
74
|
+
* @returns A `FinetuneHandle` with `progressStream` (yields per-step loss
|
|
75
|
+
* metrics) and `result` (resolves once the run terminates).
|
|
76
|
+
*/
|
|
66
77
|
export declare function finetune(params: FinetuneRunParams, rpcOptions?: RPCOptions): FinetuneHandle;
|
|
78
|
+
/**
|
|
79
|
+
* Stop / pause / cancel an in-flight finetune, or query its current state.
|
|
80
|
+
*
|
|
81
|
+
* @overloadLabel "Stop / getState / pause / cancel"
|
|
82
|
+
* @param params - Finetune control parameters; `params.operation` selects
|
|
83
|
+
* `pause`, `cancel`, or `getState`.
|
|
84
|
+
* @param rpcOptions - Optional RPC transport options.
|
|
85
|
+
* @returns A promise that resolves to the current `FinetuneResult`
|
|
86
|
+
* (status + last-known progress).
|
|
87
|
+
*/
|
|
67
88
|
export declare function finetune(params: FinetuneReplyParams, rpcOptions?: RPCOptions): Promise<FinetuneResult>;
|
|
68
89
|
export {};
|
|
69
90
|
//# sourceMappingURL=finetune.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type GetLoadedModelInfoParams, type LoadedModelInfo } from "../../schemas/index";
|
|
2
|
+
import { type RPCOptions } from "../../schemas/common";
|
|
3
|
+
/**
|
|
4
|
+
* Returns introspection info for a loaded `modelId` (local or delegated).
|
|
5
|
+
*
|
|
6
|
+
* For local models, `info.modelType` and `info.handlers` are authoritative.
|
|
7
|
+
* Use them to preflight an SDK call before sending the actual RPC, e.g.
|
|
8
|
+
* confirm that a model supports `transcribeStream` before calling `transcribe()`.
|
|
9
|
+
*
|
|
10
|
+
* For delegated models, only `modelId`, `isDelegated: true`, `providerInfo`,
|
|
11
|
+
* and `handlers: []` are populated. Preflight against a delegated model is
|
|
12
|
+
* best-effort and falls through to the provider's error response.
|
|
13
|
+
*
|
|
14
|
+
* Throws `ModelNotFoundError` if no entry exists for `modelId`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const info = await getLoadedModelInfo({ modelId });
|
|
19
|
+
* if (info.isDelegated || info.handlers.includes("completionStream")) {
|
|
20
|
+
* // safe to call completion(); delegated path defers to provider
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function getLoadedModelInfo(params: GetLoadedModelInfoParams, rpcOptions?: RPCOptions): Promise<LoadedModelInfo>;
|
|
25
|
+
//# sourceMappingURL=get-loaded-model-info.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {} from "../../schemas/index.js";
|
|
2
|
+
import {} from "../../schemas/common.js";
|
|
3
|
+
import { send } from "../rpc/rpc-client.js";
|
|
4
|
+
import { InvalidResponseError } from "../../utils/errors-client.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns introspection info for a loaded `modelId` (local or delegated).
|
|
7
|
+
*
|
|
8
|
+
* For local models, `info.modelType` and `info.handlers` are authoritative.
|
|
9
|
+
* Use them to preflight an SDK call before sending the actual RPC, e.g.
|
|
10
|
+
* confirm that a model supports `transcribeStream` before calling `transcribe()`.
|
|
11
|
+
*
|
|
12
|
+
* For delegated models, only `modelId`, `isDelegated: true`, `providerInfo`,
|
|
13
|
+
* and `handlers: []` are populated. Preflight against a delegated model is
|
|
14
|
+
* best-effort and falls through to the provider's error response.
|
|
15
|
+
*
|
|
16
|
+
* Throws `ModelNotFoundError` if no entry exists for `modelId`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const info = await getLoadedModelInfo({ modelId });
|
|
21
|
+
* if (info.isDelegated || info.handlers.includes("completionStream")) {
|
|
22
|
+
* // safe to call completion(); delegated path defers to provider
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export async function getLoadedModelInfo(params, rpcOptions) {
|
|
27
|
+
const request = {
|
|
28
|
+
type: "getLoadedModelInfo",
|
|
29
|
+
modelId: params.modelId,
|
|
30
|
+
};
|
|
31
|
+
const response = await send(request, rpcOptions);
|
|
32
|
+
if (response.type !== "getLoadedModelInfo") {
|
|
33
|
+
throw new InvalidResponseError("getLoadedModelInfo");
|
|
34
|
+
}
|
|
35
|
+
return response.info;
|
|
36
|
+
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { type GetModelInfoParams } from "../../schemas/index";
|
|
2
|
+
/**
|
|
3
|
+
* Returns status information for a catalog model, including cache state and loaded instances.
|
|
4
|
+
*
|
|
5
|
+
* @param params - Query parameters.
|
|
6
|
+
* @param params.name - The model's registry name (as found in the SDK's built-in catalog) to look up.
|
|
7
|
+
* @returns A promise resolving to the model's status information (cache presence, loaded instances, size on disk, etc.).
|
|
8
|
+
* @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
|
|
9
|
+
*/
|
|
2
10
|
export declare function getModelInfo(params: GetModelInfoParams): Promise<{
|
|
3
11
|
name: string;
|
|
4
12
|
modelId: string;
|
|
5
13
|
expectedSize: number;
|
|
6
14
|
sha256Checksum: string;
|
|
7
|
-
addon: "
|
|
15
|
+
addon: "embeddings" | "llm" | "whisper" | "nmt" | "parakeet" | "tts" | "ocr" | "diffusion" | "vad" | "other";
|
|
8
16
|
isCached: boolean;
|
|
9
17
|
isLoaded: boolean;
|
|
10
18
|
cacheFiles: {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import {} from "../../schemas/index.js";
|
|
2
2
|
import { send } from "../rpc/rpc-client.js";
|
|
3
3
|
import { InvalidResponseError } from "../../utils/errors-client.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns status information for a catalog model, including cache state and loaded instances.
|
|
6
|
+
*
|
|
7
|
+
* @param params - Query parameters.
|
|
8
|
+
* @param params.name - The model's registry name (as found in the SDK's built-in catalog) to look up.
|
|
9
|
+
* @returns A promise resolving to the model's status information (cache presence, loaded instances, size on disk, etc.).
|
|
10
|
+
* @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
|
|
11
|
+
*/
|
|
4
12
|
export async function getModelInfo(params) {
|
|
5
13
|
const request = {
|
|
6
14
|
type: "getModelInfo",
|
|
@@ -5,7 +5,7 @@ import type { DelegateBase } from "../../schemas/delegate";
|
|
|
5
5
|
* Can also be used to check if the local SDK worker is responsive.
|
|
6
6
|
*
|
|
7
7
|
* @param params - Delegation target to check
|
|
8
|
-
* @param params.delegate - The provider to check (
|
|
8
|
+
* @param params.delegate - The provider to check (providerPublicKey + optional timeout)
|
|
9
9
|
* @returns A promise that resolves to a heartbeat response if the provider is reachable.
|
|
10
10
|
* @throws {QvacErrorBase} When the provider is unreachable or the response is invalid.
|
|
11
11
|
*
|
|
@@ -13,7 +13,7 @@ import type { DelegateBase } from "../../schemas/delegate";
|
|
|
13
13
|
* // Check if a delegated provider is online
|
|
14
14
|
* try {
|
|
15
15
|
* await heartbeat({
|
|
16
|
-
* delegate: {
|
|
16
|
+
* delegate: { providerPublicKey: "peerHex", timeout: 3000 },
|
|
17
17
|
* });
|
|
18
18
|
* console.log("Provider is online");
|
|
19
19
|
* } catch {
|
|
@@ -6,7 +6,7 @@ import { InvalidResponseError } from "../../utils/errors-client.js";
|
|
|
6
6
|
* Can also be used to check if the local SDK worker is responsive.
|
|
7
7
|
*
|
|
8
8
|
* @param params - Delegation target to check
|
|
9
|
-
* @param params.delegate - The provider to check (
|
|
9
|
+
* @param params.delegate - The provider to check (providerPublicKey + optional timeout)
|
|
10
10
|
* @returns A promise that resolves to a heartbeat response if the provider is reachable.
|
|
11
11
|
* @throws {QvacErrorBase} When the provider is unreachable or the response is invalid.
|
|
12
12
|
*
|
|
@@ -14,7 +14,7 @@ import { InvalidResponseError } from "../../utils/errors-client.js";
|
|
|
14
14
|
* // Check if a delegated provider is online
|
|
15
15
|
* try {
|
|
16
16
|
* await heartbeat({
|
|
17
|
-
* delegate: {
|
|
17
|
+
* delegate: { providerPublicKey: "peerHex", timeout: 3000 },
|
|
18
18
|
* });
|
|
19
19
|
* console.log("Provider is online");
|
|
20
20
|
* } catch {
|
|
@@ -13,12 +13,14 @@ export { cancel } from "./cancel";
|
|
|
13
13
|
export { startQVACProvider } from "./provide";
|
|
14
14
|
export { stopQVACProvider } from "./stop-provider";
|
|
15
15
|
export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, } from "./rag";
|
|
16
|
-
export { textToSpeech } from "./text-to-speech";
|
|
16
|
+
export { textToSpeech, textToSpeechStream } from "./text-to-speech";
|
|
17
17
|
export { getModelInfo } from "./get-model-info";
|
|
18
|
+
export { getLoadedModelInfo } from "./get-loaded-model-info";
|
|
18
19
|
export { ocr } from "./ocr";
|
|
19
20
|
export { invokePlugin, invokePluginStream } from "./invoke-plugin";
|
|
20
21
|
export { diffusion, type DiffusionProgressTick } from "./diffusion";
|
|
21
22
|
export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, type ModelRegistrySearchParams, } from "./registry";
|
|
22
23
|
export { suspend } from "./suspend";
|
|
23
24
|
export { resume } from "./resume";
|
|
25
|
+
export { state } from "./state";
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/client/api/index.js
CHANGED
|
@@ -13,11 +13,13 @@ export { cancel } from "./cancel.js";
|
|
|
13
13
|
export { startQVACProvider } from "./provide.js";
|
|
14
14
|
export { stopQVACProvider } from "./stop-provider.js";
|
|
15
15
|
export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, } from "./rag.js";
|
|
16
|
-
export { textToSpeech } from "./text-to-speech.js";
|
|
16
|
+
export { textToSpeech, textToSpeechStream } from "./text-to-speech.js";
|
|
17
17
|
export { getModelInfo } from "./get-model-info.js";
|
|
18
|
+
export { getLoadedModelInfo } from "./get-loaded-model-info.js";
|
|
18
19
|
export { ocr } from "./ocr.js";
|
|
19
20
|
export { invokePlugin, invokePluginStream } from "./invoke-plugin.js";
|
|
20
21
|
export { diffusion } from "./diffusion.js";
|
|
21
22
|
export { modelRegistryList, modelRegistrySearch, modelRegistryGetModel, } from "./registry.js";
|
|
22
23
|
export { suspend } from "./suspend.js";
|
|
23
24
|
export { resume } from "./resume.js";
|
|
25
|
+
export { state } from "./state.js";
|