@qvac/sdk 0.9.1 → 0.10.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 +15 -68
- 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-native-tools.js +2 -8
- package/dist/examples/llamacpp-structured-output.d.ts +2 -0
- package/dist/examples/llamacpp-structured-output.js +106 -0
- package/dist/examples/llamacpp-tools-pythonic.d.ts +2 -0
- package/dist/examples/llamacpp-tools-pythonic.js +69 -0
- package/dist/examples/plugins.js +4 -4
- package/dist/examples/suspend-resume.js +21 -4
- 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 +6620 -6185
- package/dist/models/registry/models.js +6296 -5318
- 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.js +4 -2
- 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 +361 -279
- 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 +122 -31
- package/dist/schemas/completion-stream.js +137 -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/finetune.d.ts +16 -16
- package/dist/schemas/finetune.js +8 -8
- 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 +83 -26
- 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 +113 -94
- 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 +301 -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 +12 -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 +40 -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 +15 -19
- 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/NOTICE
CHANGED
|
@@ -83,46 +83,6 @@ Third-Party Model Licenses
|
|
|
83
83
|
https://huggingface.co/personalizedrefrigerator/whisper-base-fr
|
|
84
84
|
fr-tiny-ggml-model-f16
|
|
85
85
|
https://huggingface.co/JaepaX/whisper-tiny-fr
|
|
86
|
-
ggml-opus-ar-en
|
|
87
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-ar-en
|
|
88
|
-
ggml-opus-de-en
|
|
89
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-de-en
|
|
90
|
-
ggml-opus-de-fr
|
|
91
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-de-fr
|
|
92
|
-
ggml-opus-en-ar
|
|
93
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-en-ar
|
|
94
|
-
ggml-opus-en-es
|
|
95
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-en-es
|
|
96
|
-
ggml-opus-en-fr
|
|
97
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-en-fr
|
|
98
|
-
ggml-opus-en-it
|
|
99
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-en-it
|
|
100
|
-
ggml-opus-en-roa
|
|
101
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-en-roa
|
|
102
|
-
ggml-opus-en-ru
|
|
103
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-en-ru
|
|
104
|
-
ggml-opus-en-zh
|
|
105
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-en-zh
|
|
106
|
-
ggml-opus-es-en
|
|
107
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-es-en
|
|
108
|
-
ggml-opus-es-fr
|
|
109
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-es-fr
|
|
110
|
-
ggml-opus-fr-de
|
|
111
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-fr-de
|
|
112
|
-
ggml-opus-fr-en
|
|
113
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-fr-en
|
|
114
|
-
ggml-opus-fr-es
|
|
115
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-fr-es
|
|
116
|
-
ggml-opus-it-en
|
|
117
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-it-en
|
|
118
|
-
ggml-opus-ja-en
|
|
119
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-ja-en
|
|
120
|
-
ggml-opus-mt-en-roa-f16
|
|
121
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-en-roa
|
|
122
|
-
ggml-opus-mt-roa-en-f16
|
|
123
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-roa-en
|
|
124
|
-
ggml-opus-roa-en
|
|
125
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-roa-en
|
|
126
86
|
gpt-oss-120b-Q4_K_M-00001-of-00002
|
|
127
87
|
https://huggingface.co/unsloth/gpt-oss-120b-GGUF
|
|
128
88
|
gpt-oss-20b-GGUF
|
|
@@ -216,14 +176,6 @@ Third-Party Model Licenses
|
|
|
216
176
|
https://huggingface.co/nasedkinpv/parakeet-tdt-0.6b-v3-onnx-int8
|
|
217
177
|
encoder-model
|
|
218
178
|
https://huggingface.co/istupakov/parakeet-tdt-0.6b-v3-onnx
|
|
219
|
-
ggml-opus-en-de
|
|
220
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-en-de
|
|
221
|
-
ggml-opus-en-pt
|
|
222
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-tc-big-en-pt
|
|
223
|
-
ggml-opus-ru-en
|
|
224
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-ru-en
|
|
225
|
-
ggml-opus-zh-en
|
|
226
|
-
https://huggingface.co/Helsinki-NLP/opus-mt-zh-en
|
|
227
179
|
parakeet-ctc-0.6b-ONNX
|
|
228
180
|
https://huggingface.co/onnx-community/parakeet-ctc-0.6b-ONNX
|
|
229
181
|
parakeet-rs
|
|
@@ -376,7 +328,7 @@ Third-Party Model Licenses
|
|
|
376
328
|
model.enis.intgemm.alphas
|
|
377
329
|
https://github.com/mozilla/firefox-translations-models/tree/main/models/base-memory/enis
|
|
378
330
|
model.enit.intgemm.alphas
|
|
379
|
-
https://github.com/mozilla/firefox-translations-models/tree/main/models/
|
|
331
|
+
https://github.com/mozilla/firefox-translations-models/tree/main/models/base-memory/enit
|
|
380
332
|
model.enja.intgemm.alphas
|
|
381
333
|
https://github.com/mozilla/firefox-translations-models/tree/main/models/base-memory/enja
|
|
382
334
|
model.enkn.intgemm.alphas
|
|
@@ -420,7 +372,7 @@ Third-Party Model Licenses
|
|
|
420
372
|
model.enzh.intgemm.alphas
|
|
421
373
|
https://github.com/mozilla/firefox-translations-models/tree/main/models/base-memory/enzh
|
|
422
374
|
model.esen.intgemm.alphas
|
|
423
|
-
https://github.com/mozilla/firefox-translations-models/tree/main/models/
|
|
375
|
+
https://github.com/mozilla/firefox-translations-models/tree/main/models/base-memory/esen
|
|
424
376
|
model.eten.intgemm.alphas
|
|
425
377
|
https://github.com/mozilla/firefox-translations-models/tree/main/models/base-memory/eten
|
|
426
378
|
model.faen.intgemm.alphas
|
|
@@ -542,26 +494,21 @@ JavaScript Dependencies
|
|
|
542
494
|
@qvac/decoder-audio@0.3.7
|
|
543
495
|
https://github.com/tetherto/qvac
|
|
544
496
|
@qvac/diagnostics@0.1.1
|
|
545
|
-
@qvac/diffusion-cpp@0.
|
|
497
|
+
@qvac/diffusion-cpp@0.3.0
|
|
546
498
|
https://github.com/tetherto/qvac
|
|
547
|
-
@qvac/dl-base@0.
|
|
548
|
-
|
|
549
|
-
@qvac/
|
|
550
|
-
https://github.com/tetherto/qvac
|
|
551
|
-
@qvac/dl-hyperdrive@0.2.1
|
|
552
|
-
https://github.com/tetherto/qvac
|
|
553
|
-
@qvac/embed-llamacpp@0.13.4
|
|
499
|
+
@qvac/dl-base@0.1.1
|
|
500
|
+
@qvac/dl-hyperdrive@0.1.1
|
|
501
|
+
@qvac/embed-llamacpp@0.14.0
|
|
554
502
|
https://github.com/tetherto/qvac
|
|
555
503
|
@qvac/error@0.1.1
|
|
556
504
|
@qvac/infer-base@0.1.1
|
|
557
|
-
@qvac/infer-base@0.2.2
|
|
558
|
-
@qvac/infer-base@0.3.1
|
|
559
|
-
https://github.com/tetherto/qvac
|
|
560
505
|
@qvac/infer-base@0.4.0
|
|
561
506
|
https://github.com/tetherto/qvac
|
|
507
|
+
@qvac/infer-base@0.4.1
|
|
508
|
+
https://github.com/tetherto/qvac
|
|
562
509
|
@qvac/langdetect-text@0.1.2
|
|
563
510
|
https://github.com/tetherto/qvac
|
|
564
|
-
@qvac/llm-llamacpp@0.
|
|
511
|
+
@qvac/llm-llamacpp@0.17.3
|
|
565
512
|
https://github.com/tetherto/qvac
|
|
566
513
|
@qvac/logging@0.1.0
|
|
567
514
|
@qvac/ocr-onnx@0.4.2
|
|
@@ -570,7 +517,7 @@ JavaScript Dependencies
|
|
|
570
517
|
https://github.com/tetherto/qvac
|
|
571
518
|
@qvac/rag@0.4.4
|
|
572
519
|
https://github.com/tetherto/qvac
|
|
573
|
-
@qvac/registry-client@0.4.
|
|
520
|
+
@qvac/registry-client@0.4.1
|
|
574
521
|
https://github.com/tetherto/qvac
|
|
575
522
|
@qvac/registry-schema@0.1.2
|
|
576
523
|
@qvac/response@0.1.2
|
|
@@ -578,9 +525,9 @@ JavaScript Dependencies
|
|
|
578
525
|
https://github.com/tetherto/qvac
|
|
579
526
|
@qvac/transcription-whispercpp@0.6.1
|
|
580
527
|
https://github.com/tetherto/qvac
|
|
581
|
-
@qvac/translation-nmtcpp@
|
|
582
|
-
https://github.com/tetherto/qvac
|
|
583
|
-
@qvac/tts-onnx@0.8.
|
|
528
|
+
@qvac/translation-nmtcpp@2.1.0
|
|
529
|
+
https://github.com/tetherto/qvac
|
|
530
|
+
@qvac/tts-onnx@0.8.5
|
|
584
531
|
https://github.com/tetherto/qvac
|
|
585
532
|
adaptive-timeout@1.0.1
|
|
586
533
|
https://github.com/holepunchto/adaptive-timeout
|
|
@@ -630,9 +577,9 @@ JavaScript Dependencies
|
|
|
630
577
|
https://github.com/holepunchto/bare-https
|
|
631
578
|
bare-inspect@3.1.4
|
|
632
579
|
https://github.com/holepunchto/bare-inspect
|
|
633
|
-
bare-lief@0.
|
|
580
|
+
bare-lief@0.2.3
|
|
634
581
|
https://github.com/holepunchto/bare-lief
|
|
635
|
-
bare-link@2.1
|
|
582
|
+
bare-link@3.2.1
|
|
636
583
|
https://github.com/holepunchto/bare-link
|
|
637
584
|
bare-module@6.1.3
|
|
638
585
|
https://github.com/holepunchto/bare-module
|
|
@@ -28,7 +28,7 @@ import { type CancelParams } from "../../schemas/index";
|
|
|
28
28
|
* await cancel({
|
|
29
29
|
* operation: "downloadAsset",
|
|
30
30
|
* downloadKey: "download-key",
|
|
31
|
-
* delegate: {
|
|
31
|
+
* delegate: { providerPublicKey: "peerHex" },
|
|
32
32
|
* });
|
|
33
33
|
*
|
|
34
34
|
* @example
|
|
@@ -30,7 +30,7 @@ import { InvalidResponseError, CancelFailedError } from "../../utils/errors-clie
|
|
|
30
30
|
* await cancel({
|
|
31
31
|
* operation: "downloadAsset",
|
|
32
32
|
* downloadKey: "download-key",
|
|
33
|
-
* delegate: {
|
|
33
|
+
* delegate: { providerPublicKey: "peerHex" },
|
|
34
34
|
* });
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
@@ -1,19 +1,50 @@
|
|
|
1
|
-
import { type CompletionClientParams, type
|
|
1
|
+
import { type CompletionClientParams, type CompletionRun, type McpClientInput, type Tool, type RPCOptions } from "../../schemas/index";
|
|
2
2
|
import { type ToolInput } from "../../utils/tool-helpers";
|
|
3
3
|
type CompletionParams = Omit<CompletionClientParams, "tools"> & {
|
|
4
4
|
tools?: Tool[] | ToolInput[];
|
|
5
5
|
mcp?: McpClientInput[];
|
|
6
6
|
rpcOptions?: RPCOptions;
|
|
7
|
+
captureThinking?: boolean;
|
|
8
|
+
emitRawDeltas?: boolean;
|
|
7
9
|
};
|
|
8
10
|
/**
|
|
9
11
|
* Generates completion from a language model based on conversation history.
|
|
10
12
|
*
|
|
13
|
+
* Returns a `CompletionRun` whose canonical surfaces are:
|
|
14
|
+
*
|
|
15
|
+
* - `events` — `AsyncIterable<CompletionEvent>` of ordered, typed events.
|
|
16
|
+
* - `final` — `Promise<CompletionFinal>` with aggregated results once the
|
|
17
|
+
* stream ends (content, thinking, tool calls, stats, raw text).
|
|
18
|
+
*
|
|
19
|
+
* Legacy convenience fields (`tokenStream`, `text`, `toolCallStream`,
|
|
20
|
+
* `toolCalls`, `stats`) are still available but deprecated — they derive
|
|
21
|
+
* from `events` / `final` internally.
|
|
22
|
+
*
|
|
11
23
|
* @param params - The completion parameters
|
|
12
24
|
* @param params.modelId - The identifier of the model to use for completion
|
|
13
25
|
* @param params.history - Array of conversation messages with role, content, and optional attachments
|
|
14
26
|
* @param params.stream - Whether to stream tokens (true) or return complete response (false). Defaults to true
|
|
15
27
|
* @param params.tools - Optional array of tools (can be simple ToolInput with Zod schemas or full Tool objects)
|
|
16
28
|
* @param params.mcp - Optional array of MCP client inputs for tool integration
|
|
29
|
+
* @param params.captureThinking - Best-effort parsing of `<think>` blocks into `thinkingDelta` events; `final.raw.fullText` always preserves the original output
|
|
30
|
+
* @param params.emitRawDeltas - When true, every raw model token is also emitted as a `rawDelta` event
|
|
31
|
+
* @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.
|
|
32
|
+
* 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|>`).
|
|
33
|
+
* @param params.responseFormat - Optional structured-output constraint applied to the model's output:
|
|
34
|
+
* - `{ type: "text" }` — no constraint (default behavior)
|
|
35
|
+
* - `{ type: "json_object" }` — output must be a JSON object
|
|
36
|
+
* - `{ type: "json_schema", json_schema: { name, schema, description?, strict? } }` — output must validate against `schema`
|
|
37
|
+
*
|
|
38
|
+
* The schema is converted to GBNF natively by llama.cpp and applied for the
|
|
39
|
+
* duration of the request only. `json_schema.name` and `json_schema.description`
|
|
40
|
+
* are accepted for OpenAI compatibility but only used at the API boundary —
|
|
41
|
+
* they do not affect generation. **`json_schema.strict` is currently accepted
|
|
42
|
+
* for compatibility but does NOT trigger OpenAI's auto-tightening semantics**
|
|
43
|
+
* (implicit `additionalProperties: false`, all properties required). The
|
|
44
|
+
* schema is forwarded to the addon as-is, so callers who want strict
|
|
45
|
+
* validation must encode it explicitly in `schema`.
|
|
46
|
+
*
|
|
47
|
+
* Cannot be combined with `tools` (tools already constrain output via their parameter schema).
|
|
17
48
|
* @param params.kvCache - Optional KV cache configuration. Cache files are organized hierarchically:
|
|
18
49
|
* - Structure: `{kvCacheKey}/{modelId}/{configHash}.bin`
|
|
19
50
|
* - The configHash includes model config + system prompt to ensure cache isolation
|
|
@@ -22,17 +53,29 @@ type CompletionParams = Omit<CompletionClientParams, "tools"> & {
|
|
|
22
53
|
* - `false` or `undefined`: No caching
|
|
23
54
|
* - ⚡ Performance: When cache exists, only the last message is sent to the model (includes multimodal attachments)
|
|
24
55
|
* - 🗑️ Cleanup: Use `deleteCache({ kvCacheKey })` to remove cached sessions
|
|
25
|
-
*
|
|
56
|
+
*
|
|
57
|
+
* **Auto-cache (`kvCache: true`) — assistant turn contract.** When
|
|
58
|
+
* pushing the assistant turn back into `history` for the next call,
|
|
59
|
+
* use `(await run.final).cacheableAssistantContent`. That's the exact
|
|
60
|
+
* string the SDK persisted to the cache key on this turn, so re-using
|
|
61
|
+
* it verbatim guarantees the next-turn lookup hits.
|
|
62
|
+
* - Any post-processing of the assistant text (rewriting, summarizing,
|
|
63
|
+
* stripping model stop tokens like `<|im_end|>`) before pushing it
|
|
64
|
+
* back will miss the cache. Push the canonical string unchanged.
|
|
65
|
+
* - `cacheableAssistantContent` is omitted on tool-call turns - those
|
|
66
|
+
* can't be auto-cached today.
|
|
67
|
+
* @returns A CompletionRun — consume via `events` / `final`.
|
|
26
68
|
* @example
|
|
27
69
|
* ```typescript
|
|
28
70
|
* import { z } from "zod";
|
|
29
71
|
*
|
|
30
|
-
* const
|
|
72
|
+
* const run = completion({
|
|
31
73
|
* modelId: "llama-2",
|
|
32
74
|
* history: [
|
|
33
75
|
* { role: "user", content: "What's the weather in Tokyo?" }
|
|
34
76
|
* ],
|
|
35
77
|
* stream: true,
|
|
78
|
+
* captureThinking: true,
|
|
36
79
|
* tools: [{
|
|
37
80
|
* name: "get_weather",
|
|
38
81
|
* description: "Get current weather",
|
|
@@ -45,10 +88,12 @@ type CompletionParams = Omit<CompletionClientParams, "tools"> & {
|
|
|
45
88
|
* }]
|
|
46
89
|
* });
|
|
47
90
|
*
|
|
48
|
-
* for await (const
|
|
49
|
-
* process.stdout.write(
|
|
91
|
+
* for await (const event of run.events) {
|
|
92
|
+
* if (event.type === "contentDelta") process.stdout.write(event.text);
|
|
93
|
+
* if (event.type === "toolCall") console.log(event.call.name, event.call.arguments);
|
|
50
94
|
* }
|
|
51
95
|
*
|
|
96
|
+
* const result = await run.final;
|
|
52
97
|
* for (const toolCall of await result.toolCalls) {
|
|
53
98
|
* if (toolCall.invoke) {
|
|
54
99
|
* const toolResult = await toolCall.invoke();
|
|
@@ -57,12 +102,6 @@ type CompletionParams = Omit<CompletionClientParams, "tools"> & {
|
|
|
57
102
|
* }
|
|
58
103
|
* ```
|
|
59
104
|
*/
|
|
60
|
-
export declare function completion(params: CompletionParams):
|
|
61
|
-
tokenStream: AsyncGenerator<string>;
|
|
62
|
-
toolCallStream: AsyncGenerator<ToolCallEvent>;
|
|
63
|
-
stats: Promise<CompletionStats | undefined>;
|
|
64
|
-
text: Promise<string>;
|
|
65
|
-
toolCalls: Promise<ToolCallWithCall[]>;
|
|
66
|
-
};
|
|
105
|
+
export declare function completion(params: CompletionParams): CompletionRun;
|
|
67
106
|
export {};
|
|
68
107
|
//# sourceMappingURL=completion-stream.d.ts.map
|
|
@@ -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) {
|