@qvac/sdk 0.4.1 → 0.6.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/README.md +365 -200
- package/bare-imports.json +35 -0
- package/dist/client/api/cancel.d.ts +12 -3
- package/dist/client/api/cancel.js +12 -3
- package/dist/client/api/completion-stream.d.ts +15 -5
- package/dist/client/api/completion-stream.js +50 -14
- package/dist/client/api/embed.d.ts +17 -3
- package/dist/client/api/embed.js +0 -8
- package/dist/client/api/get-model-info.d.ts +2 -2
- package/dist/client/api/get-model-info.js +2 -2
- package/dist/client/api/index.d.ts +2 -2
- package/dist/client/api/index.js +2 -2
- package/dist/client/api/load-model.d.ts +37 -11
- package/dist/client/api/load-model.js +34 -117
- package/dist/client/api/logging-stream.d.ts +6 -3
- package/dist/client/api/logging-stream.js +6 -3
- package/dist/client/api/ocr.d.ts +31 -0
- package/dist/client/api/ocr.js +88 -0
- package/dist/client/api/rag.d.ts +215 -20
- package/dist/client/api/rag.js +382 -23
- package/dist/client/api/translate.js +10 -11
- package/dist/client/api/unload-model.js +6 -3
- package/dist/client/config-loader/config-utils.d.ts +5 -0
- package/dist/client/config-loader/config-utils.js +20 -0
- package/dist/client/config-loader/resolve-config.bare.d.ts +9 -0
- package/dist/client/config-loader/resolve-config.bare.js +87 -0
- package/dist/client/config-loader/resolve-config.expo.d.ts +11 -0
- package/dist/client/config-loader/resolve-config.expo.js +62 -0
- package/dist/client/config-loader/resolve-config.node.d.ts +9 -0
- package/dist/client/config-loader/resolve-config.node.js +118 -0
- package/dist/client/init-hooks.d.ts +18 -3
- package/dist/client/init-hooks.js +57 -29
- package/dist/client/logging-stream-registry.d.ts +1 -1
- package/dist/client/logging-stream-registry.js +14 -13
- package/dist/client/rpc/bare-client.d.ts +3 -184
- package/dist/client/rpc/bare-client.js +67 -8
- package/dist/client/rpc/expo-rpc-client.d.ts +2 -2
- package/dist/client/rpc/expo-rpc-client.js +70 -12
- package/dist/client/rpc/node-rpc-client.d.ts +1 -1
- package/dist/client/rpc/node-rpc-client.js +14 -7
- package/dist/client/rpc/rpc-client.d.ts +1 -1
- package/dist/client/rpc/rpc-client.js +13 -58
- package/dist/examples/config/blind-relay/blind-relay.config.d.ts +5 -0
- package/dist/examples/config/blind-relay/blind-relay.config.js +7 -0
- package/dist/examples/config/default/default.config.d.ts +8 -0
- package/dist/examples/config/default/default.config.js +6 -0
- package/dist/examples/config-reload.d.ts +2 -0
- package/dist/examples/config-reload.js +49 -0
- package/dist/examples/default-config-usage.d.ts +17 -0
- package/dist/examples/default-config-usage.js +47 -0
- package/dist/examples/delegated-inference/consumer.js +1 -0
- package/dist/examples/download-with-blind-relays.js +22 -21
- package/dist/examples/embed-hyperdrive.js +39 -3
- package/dist/examples/kv-cache-cleanup.js +1 -1
- package/dist/examples/kv-cache-custom-key.js +16 -1
- package/dist/examples/kv-cache-example.js +1 -1
- package/dist/examples/llamacpp-hyperdrive.js +1 -1
- package/dist/examples/llamacpp-sharded.js +13 -4
- package/dist/examples/logging-file-transport.d.ts +2 -0
- package/dist/examples/{llamacpp-file-logging.js → logging-file-transport.js} +3 -7
- package/dist/examples/logging-streaming.d.ts +2 -0
- package/dist/examples/logging-streaming.js +75 -0
- package/dist/examples/mcp-websearch.d.ts +13 -0
- package/dist/examples/mcp-websearch.js +176 -0
- package/dist/examples/ocr-fasttext.d.ts +2 -0
- package/dist/examples/ocr-fasttext.js +52 -0
- package/dist/examples/quickstart.d.ts +2 -0
- package/dist/examples/quickstart.js +28 -0
- package/dist/examples/rag/rag-hyperdb/cancellation.d.ts +2 -0
- package/dist/examples/rag/rag-hyperdb/cancellation.js +75 -0
- package/dist/examples/rag/rag-hyperdb/ingest.d.ts +2 -0
- package/dist/examples/rag/{rag-hyperdb.js → rag-hyperdb/ingest.js} +10 -4
- package/dist/examples/rag/rag-hyperdb/pipeline.d.ts +2 -0
- package/dist/examples/rag/rag-hyperdb/pipeline.js +74 -0
- package/dist/examples/rag/rag-hyperdb/workspaces.d.ts +2 -0
- package/dist/examples/rag/rag-hyperdb/workspaces.js +178 -0
- package/dist/examples/translation/translation-bergamot-batch.d.ts +2 -0
- package/dist/examples/translation/translation-bergamot-batch.js +49 -0
- package/dist/examples/translation/translation-bergamot.d.ts +2 -0
- package/dist/examples/translation/translation-bergamot.js +39 -0
- package/dist/examples/translation/translation-indic.js +1 -0
- package/dist/examples/translation/translation-opus.js +1 -0
- package/dist/examples/translation/translation-stream.js +1 -0
- package/dist/expo/plugins/withMobileBundle.js +29 -10
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -2
- package/dist/logging/addon.d.ts +6 -0
- package/dist/logging/addon.js +75 -0
- package/dist/logging/base-logger.js +26 -16
- package/dist/logging/client-logger.d.ts +3 -0
- package/dist/logging/client-logger.js +24 -0
- package/dist/logging/index.d.ts +7 -1
- package/dist/logging/index.js +7 -1
- package/dist/logging/logger.d.ts +0 -2
- package/dist/logging/logger.js +11 -6
- package/dist/logging/namespaces.d.ts +12 -0
- package/dist/logging/namespaces.js +12 -0
- package/dist/logging/registry.d.ts +31 -0
- package/dist/logging/registry.js +48 -0
- package/dist/logging/server-logger.d.ts +3 -0
- package/dist/logging/server-logger.js +16 -0
- package/dist/logging/stream-logger.d.ts +1 -1
- package/dist/logging/stream-logger.js +6 -3
- package/dist/logging/transport.js +2 -2
- package/dist/logging/types.d.ts +2 -0
- package/dist/logging/utils.d.ts +2 -0
- package/dist/logging/utils.js +62 -0
- package/dist/models/hyperdrive/models.d.ts +1886 -230
- package/dist/models/hyperdrive/models.js +2191 -443
- package/dist/schemas/archive.d.ts +9 -0
- package/dist/schemas/archive.js +17 -0
- package/dist/schemas/cancel.d.ts +6 -0
- package/dist/schemas/cancel.js +5 -0
- package/dist/schemas/common.d.ts +660 -92
- package/dist/schemas/common.js +6 -4
- package/dist/schemas/delegate.d.ts +1 -0
- package/dist/schemas/delegate.js +1 -0
- package/dist/schemas/download-asset.d.ts +21 -9
- package/dist/schemas/embed.d.ts +3 -3
- package/dist/schemas/embed.js +9 -2
- package/dist/schemas/get-model-info.d.ts +12 -10
- package/dist/schemas/get-model-info.js +9 -1
- package/dist/schemas/index.d.ts +9 -1
- package/dist/schemas/index.js +12 -1
- package/dist/schemas/json-schema.d.ts +16 -0
- package/dist/schemas/json-schema.js +2 -0
- package/dist/schemas/llamacpp-config.d.ts +117 -12
- package/dist/schemas/llamacpp-config.js +46 -12
- package/dist/schemas/load-model.d.ts +3669 -481
- package/dist/schemas/load-model.js +95 -34
- package/dist/schemas/logging-stream.d.ts +11 -4
- package/dist/schemas/logging-stream.js +4 -3
- package/dist/schemas/mcp-adapter.d.ts +47 -0
- package/dist/schemas/mcp-adapter.js +1 -0
- package/dist/schemas/model-src-utils.d.ts +38 -14
- package/dist/schemas/model-src-utils.js +4 -3
- package/dist/schemas/model-types.d.ts +154 -0
- package/dist/schemas/model-types.js +140 -0
- package/dist/schemas/ocr.d.ts +88 -0
- package/dist/schemas/ocr.js +52 -0
- package/dist/schemas/rag.d.ts +183 -52
- package/dist/schemas/rag.js +148 -23
- package/dist/schemas/reload-config.d.ts +356 -0
- package/dist/schemas/reload-config.js +44 -0
- package/dist/schemas/runtime-context.d.ts +19 -0
- package/dist/schemas/runtime-context.js +7 -0
- package/dist/schemas/sdk-config.d.ts +717 -0
- package/dist/schemas/sdk-config.js +131 -0
- package/dist/schemas/sdk-errors-client.d.ts +5 -0
- package/dist/schemas/sdk-errors-client.js +25 -0
- package/dist/schemas/sdk-errors-server.d.ts +17 -0
- package/dist/schemas/sdk-errors-server.js +85 -0
- package/dist/schemas/shard.d.ts +21 -0
- package/dist/schemas/shard.js +17 -0
- package/dist/schemas/tools.d.ts +3 -0
- package/dist/schemas/translate.d.ts +68 -23
- package/dist/schemas/translate.js +37 -11
- package/dist/schemas/translation-config.d.ts +337 -13
- package/dist/schemas/translation-config.js +65 -9
- package/dist/schemas/whispercpp-config.d.ts +9 -1
- package/dist/schemas/whispercpp-config.js +2 -1
- package/dist/scripts/run-unit-tests.d.ts +2 -0
- package/dist/scripts/run-unit-tests.js +17 -0
- package/dist/server/bare/addons/llamacpp-completion/cache-logger.d.ts +6 -0
- package/dist/server/bare/addons/llamacpp-completion/cache-logger.js +34 -0
- package/dist/server/bare/addons/{llamacpp → llamacpp-completion}/create-model.d.ts +1 -5
- package/dist/server/bare/addons/{llamacpp → llamacpp-completion}/create-model.js +6 -20
- package/dist/server/bare/addons/{llamacpp → llamacpp-completion}/handlers/completion-stream.js +26 -7
- package/dist/server/bare/addons/llamacpp-completion/index.d.ts +4 -0
- package/dist/server/bare/addons/llamacpp-completion/index.js +3 -0
- package/dist/server/bare/addons/{llamacpp → llamacpp-completion}/kv-cache-utils.d.ts +4 -1
- package/dist/server/bare/addons/{llamacpp → llamacpp-completion}/kv-cache-utils.js +49 -14
- package/dist/server/bare/addons/llamacpp-embedding/create-model.d.ts +8 -0
- package/dist/server/bare/addons/llamacpp-embedding/create-model.js +38 -0
- package/dist/server/bare/addons/llamacpp-embedding/handlers/embed.d.ts +12 -0
- package/dist/server/bare/addons/{llamacpp → llamacpp-embedding}/handlers/embed.js +18 -4
- package/dist/server/bare/addons/llamacpp-embedding/index.d.ts +3 -0
- package/dist/server/bare/addons/llamacpp-embedding/index.js +2 -0
- package/dist/server/bare/addons/load-model.js +38 -28
- package/dist/server/bare/addons/{translation → nmtcpp-translation}/create-model.js +23 -8
- package/dist/server/bare/addons/{translation → nmtcpp-translation}/handlers/translate.js +35 -11
- package/dist/server/bare/addons/onnx-ocr/create-model.d.ts +10 -0
- package/dist/server/bare/addons/onnx-ocr/create-model.js +39 -0
- package/dist/server/bare/addons/onnx-ocr/handlers/ocr-stream.d.ts +10 -0
- package/dist/server/bare/addons/onnx-ocr/handlers/ocr-stream.js +109 -0
- package/dist/server/bare/addons/onnx-ocr/index.d.ts +3 -0
- package/dist/server/bare/addons/onnx-ocr/index.js +2 -0
- package/dist/server/bare/addons/unload-model.js +6 -3
- package/dist/server/bare/addons/{whispercpp → whispercpp-transcription}/create-model.js +2 -1
- package/dist/server/bare/addons/whispercpp-transcription/handlers/transcribe-stream.js +82 -0
- package/dist/server/bare/delegate-rpc-client.js +31 -11
- package/dist/server/bare/hyperswarm.js +7 -5
- package/dist/server/bare/rag-hyperdb/handlers/chunk.d.ts +3 -0
- package/dist/server/bare/rag-hyperdb/handlers/chunk.js +7 -0
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.d.ts +3 -0
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.js +9 -0
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.js +9 -10
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.d.ts +3 -0
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.js +14 -0
- package/dist/server/bare/rag-hyperdb/handlers/ingest.d.ts +9 -0
- package/dist/server/bare/rag-hyperdb/handlers/ingest.js +18 -0
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.d.ts +3 -0
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.js +4 -0
- package/dist/server/bare/rag-hyperdb/handlers/reindex.d.ts +9 -0
- package/dist/server/bare/rag-hyperdb/handlers/reindex.js +16 -0
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.d.ts +7 -4
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.js +13 -14
- package/dist/server/bare/rag-hyperdb/handlers/search.js +10 -10
- package/dist/server/bare/rag-hyperdb/index.d.ts +8 -1
- package/dist/server/bare/rag-hyperdb/index.js +8 -1
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +7 -0
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +39 -0
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.d.ts +15 -0
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +135 -0
- package/dist/server/bare/registry/config-registry.d.ts +13 -4
- package/dist/server/bare/registry/config-registry.js +53 -10
- package/dist/server/bare/registry/logging-stream-registry.d.ts +24 -7
- package/dist/server/bare/registry/logging-stream-registry.js +99 -20
- package/dist/server/bare/registry/model-config-registry.d.ts +4 -0
- package/dist/server/bare/registry/model-config-registry.js +15 -0
- package/dist/server/bare/registry/model-config-utils.d.ts +15 -0
- package/dist/server/bare/registry/model-config-utils.js +121 -0
- package/dist/server/bare/registry/model-registry.d.ts +6 -26
- package/dist/server/bare/registry/model-registry.js +9 -6
- package/dist/server/bare/registry/runtime-context-registry.d.ts +7 -0
- package/dist/server/bare/registry/runtime-context-registry.js +26 -0
- package/dist/server/bare/utils/loader-adapter.d.ts +7 -0
- package/dist/server/bare/utils/loader-adapter.js +9 -0
- package/dist/server/error-handlers.js +4 -2
- package/dist/server/rpc/create-server.js +5 -3
- package/dist/server/rpc/handle-request.js +115 -19
- package/dist/server/rpc/handlers/cancelHandler.js +13 -2
- package/dist/server/rpc/handlers/completion-stream-delegated.js +4 -2
- package/dist/server/rpc/handlers/completion-stream.js +1 -1
- package/dist/server/rpc/handlers/delete-cache.js +4 -2
- package/dist/server/rpc/handlers/download-asset.js +3 -1
- package/dist/server/rpc/handlers/embed.js +4 -2
- package/dist/server/rpc/handlers/get-model-info.d.ts +1 -1
- package/dist/server/rpc/handlers/get-model-info.js +22 -10
- package/dist/server/rpc/handlers/index.d.ts +4 -2
- package/dist/server/rpc/handlers/index.js +2 -2
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +11 -11
- package/dist/server/rpc/handlers/load-model/download-manager.js +40 -28
- package/dist/server/rpc/handlers/{load-model.d.ts → load-model/handler.d.ts} +2 -2
- package/dist/server/rpc/handlers/load-model/handler.js +179 -0
- package/dist/server/rpc/handlers/load-model/http.js +361 -50
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +26 -22
- package/dist/server/rpc/handlers/load-model/index.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model/index.js +2 -2
- package/dist/server/rpc/handlers/load-model/resolve.js +39 -8
- package/dist/server/rpc/handlers/load-model-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model-delegated.js +15 -10
- package/dist/server/rpc/handlers/logging-stream.js +4 -4
- package/dist/server/rpc/handlers/ocr-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/ocr-stream.js +39 -0
- package/dist/server/rpc/handlers/provideHandler/connection.js +12 -10
- package/dist/server/rpc/handlers/provideHandler/handler.js +18 -16
- package/dist/server/rpc/handlers/provideHandler/proxy.js +8 -6
- package/dist/server/rpc/handlers/rag.d.ts +2 -2
- package/dist/server/rpc/handlers/rag.js +107 -41
- package/dist/server/rpc/handlers/stopProvideHandler.js +3 -1
- package/dist/server/rpc/handlers/text-to-speech.js +1 -1
- package/dist/server/rpc/handlers/transcribe-stream.js +4 -2
- package/dist/server/rpc/handlers/translate.js +9 -16
- package/dist/server/rpc/handlers/unload-model.js +4 -2
- package/dist/server/utils/archive.d.ts +3 -0
- package/dist/server/utils/archive.js +171 -0
- package/dist/server/utils/audio/decoder.d.ts +2 -1
- package/dist/server/utils/audio/decoder.js +48 -11
- package/dist/server/utils/cache.d.ts +5 -5
- package/dist/server/utils/cache.js +13 -11
- package/dist/server/utils/config-transform.d.ts +3 -0
- package/dist/server/utils/config-transform.js +23 -0
- package/dist/server/utils/formatting.d.ts +13 -0
- package/dist/server/utils/formatting.js +26 -0
- package/dist/server/utils/gguf-tensor-extractor.d.ts +15 -0
- package/dist/server/utils/gguf-tensor-extractor.js +314 -0
- package/dist/server/utils/index.d.ts +4 -1
- package/dist/server/utils/index.js +4 -1
- package/dist/server/utils/shard-utils.d.ts +42 -16
- package/dist/server/utils/shard-utils.js +95 -7
- package/dist/server/worker.js +49 -19
- package/dist/utils/errors-base.d.ts +1 -1
- package/dist/utils/errors-base.js +2 -2
- package/dist/utils/errors-client.d.ts +24 -0
- package/dist/utils/errors-client.js +40 -0
- package/dist/utils/errors-server.d.ts +42 -0
- package/dist/utils/errors-server.js +71 -0
- package/dist/utils/mcp-adapter.d.ts +12 -0
- package/dist/utils/mcp-adapter.js +103 -0
- package/dist/utils/object.d.ts +2 -0
- package/dist/utils/object.js +3 -0
- package/dist/utils/tool-helpers.d.ts +10 -2
- package/dist/utils/tool-helpers.js +24 -11
- package/package.json +74 -36
- package/dist/client/api/set-config.d.ts +0 -7
- package/dist/client/api/set-config.js +0 -20
- package/dist/client/config-manager.d.ts +0 -4
- package/dist/client/config-manager.js +0 -8
- package/dist/client/rpc/bare-rpc-client.d.ts +0 -4
- package/dist/client/rpc/bare-rpc-client.js +0 -91
- package/dist/examples/llamacpp-file-logging.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb-workspaces.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb-workspaces.js +0 -106
- package/dist/examples/rag/rag-hyperdb.d.ts +0 -2
- package/dist/schemas/set-config.d.ts +0 -21
- package/dist/schemas/set-config.js +0 -14
- package/dist/server/bare/addons/llamacpp/handlers/embed.d.ts +0 -4
- package/dist/server/bare/addons/llamacpp/index.d.ts +0 -4
- package/dist/server/bare/addons/llamacpp/index.js +0 -3
- package/dist/server/bare/addons/whispercpp/handlers/transcribe-stream.js +0 -63
- package/dist/server/bare/rag-hyperdb/rag-manager.d.ts +0 -5
- package/dist/server/bare/rag-hyperdb/rag-manager.js +0 -64
- package/dist/server/rpc/handlers/load-model.js +0 -59
- package/dist/server/rpc/handlers/set-config.d.ts +0 -3
- package/dist/server/rpc/handlers/set-config.js +0 -18
- package/dist/server/utils/hash.d.ts +0 -5
- package/dist/server/utils/hash.js +0 -11
- /package/dist/server/bare/addons/{llamacpp → llamacpp-completion}/handlers/completion-stream.d.ts +0 -0
- /package/dist/server/bare/addons/{translation → nmtcpp-translation}/create-model.d.ts +0 -0
- /package/dist/server/bare/addons/{translation → nmtcpp-translation}/handlers/translate.d.ts +0 -0
- /package/dist/server/bare/addons/{translation → nmtcpp-translation}/index.d.ts +0 -0
- /package/dist/server/bare/addons/{translation → nmtcpp-translation}/index.js +0 -0
- /package/dist/server/bare/addons/{tts → onnx-tts}/create-model.d.ts +0 -0
- /package/dist/server/bare/addons/{tts → onnx-tts}/create-model.js +0 -0
- /package/dist/server/bare/addons/{tts → onnx-tts}/handlers/text-to-speech.d.ts +0 -0
- /package/dist/server/bare/addons/{tts → onnx-tts}/handlers/text-to-speech.js +0 -0
- /package/dist/server/bare/addons/{tts → onnx-tts}/index.d.ts +0 -0
- /package/dist/server/bare/addons/{tts → onnx-tts}/index.js +0 -0
- /package/dist/server/bare/addons/{whispercpp → whispercpp-transcription}/create-model.d.ts +0 -0
- /package/dist/server/bare/addons/{whispercpp → whispercpp-transcription}/handlers/transcribe-stream.d.ts +0 -0
- /package/dist/server/bare/addons/{whispercpp → whispercpp-transcription}/index.d.ts +0 -0
- /package/dist/server/bare/addons/{whispercpp → whispercpp-transcription}/index.js +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"#rpc": {
|
|
3
|
+
"react-native": "./dist/client/rpc/expo-rpc-client.js",
|
|
4
|
+
"bare": "./dist/client/rpc/bare-client.js",
|
|
5
|
+
"default": "./dist/client/rpc/node-rpc-client.js"
|
|
6
|
+
},
|
|
7
|
+
"child_process": {
|
|
8
|
+
"bare": "bare-subprocess",
|
|
9
|
+
"default": "child_process"
|
|
10
|
+
},
|
|
11
|
+
"crypto": {
|
|
12
|
+
"bare": "bare-crypto",
|
|
13
|
+
"default": "crypto"
|
|
14
|
+
},
|
|
15
|
+
"fs": {
|
|
16
|
+
"bare": "bare-fs",
|
|
17
|
+
"default": "fs"
|
|
18
|
+
},
|
|
19
|
+
"os": {
|
|
20
|
+
"bare": "bare-os",
|
|
21
|
+
"default": "os"
|
|
22
|
+
},
|
|
23
|
+
"path": {
|
|
24
|
+
"bare": "bare-path",
|
|
25
|
+
"default": "path"
|
|
26
|
+
},
|
|
27
|
+
"process": {
|
|
28
|
+
"bare": "bare-process",
|
|
29
|
+
"default": "process"
|
|
30
|
+
},
|
|
31
|
+
"readline": {
|
|
32
|
+
"bare": "bare-readline",
|
|
33
|
+
"default": "readline"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -3,10 +3,11 @@ import { type CancelParams } from "../../schemas/index";
|
|
|
3
3
|
* Cancels an ongoing operation.
|
|
4
4
|
*
|
|
5
5
|
* @param params - The parameters for the cancellation
|
|
6
|
-
* @param params.operation - The type of operation to cancel ("inference" or "
|
|
6
|
+
* @param params.operation - The type of operation to cancel ("inference", "downloadAsset", or "rag")
|
|
7
7
|
* @param params.modelId - The model ID (required for inference cancellation)
|
|
8
8
|
* @param params.downloadKey - The download key (required for download cancellation)
|
|
9
9
|
* @param params.clearCache - If true, deletes the partial download file (default: false)
|
|
10
|
+
* @param params.workspace - The RAG workspace to cancel (optional, defaults to "default")
|
|
10
11
|
* @throws {QvacErrorBase} When the response type is invalid or when the cancellation fails
|
|
11
12
|
*
|
|
12
13
|
* @example
|
|
@@ -15,11 +16,19 @@ import { type CancelParams } from "../../schemas/index";
|
|
|
15
16
|
*
|
|
16
17
|
* @example
|
|
17
18
|
* // Pause download (preserves partial file for automatic resume)
|
|
18
|
-
* await cancel({ operation: "
|
|
19
|
+
* await cancel({ operation: "downloadAsset", downloadKey: "download-key" });
|
|
19
20
|
*
|
|
20
21
|
* @example
|
|
21
22
|
* // Cancel download completely (deletes partial file)
|
|
22
|
-
* await cancel({ operation: "
|
|
23
|
+
* await cancel({ operation: "downloadAsset", downloadKey: "download-key", clearCache: true });
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Cancel RAG operation on default workspace
|
|
27
|
+
* await cancel({ operation: "rag" });
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Cancel RAG operation on specific workspace
|
|
31
|
+
* await cancel({ operation: "rag", workspace: "my-workspace" });
|
|
23
32
|
*/
|
|
24
33
|
export declare function cancel(params: CancelParams): Promise<void>;
|
|
25
34
|
//# sourceMappingURL=cancel.d.ts.map
|
|
@@ -5,10 +5,11 @@ import { InvalidResponseError, CancelFailedError } from "../../utils/errors-clie
|
|
|
5
5
|
* Cancels an ongoing operation.
|
|
6
6
|
*
|
|
7
7
|
* @param params - The parameters for the cancellation
|
|
8
|
-
* @param params.operation - The type of operation to cancel ("inference" or "
|
|
8
|
+
* @param params.operation - The type of operation to cancel ("inference", "downloadAsset", or "rag")
|
|
9
9
|
* @param params.modelId - The model ID (required for inference cancellation)
|
|
10
10
|
* @param params.downloadKey - The download key (required for download cancellation)
|
|
11
11
|
* @param params.clearCache - If true, deletes the partial download file (default: false)
|
|
12
|
+
* @param params.workspace - The RAG workspace to cancel (optional, defaults to "default")
|
|
12
13
|
* @throws {QvacErrorBase} When the response type is invalid or when the cancellation fails
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
@@ -17,11 +18,19 @@ import { InvalidResponseError, CancelFailedError } from "../../utils/errors-clie
|
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
19
20
|
* // Pause download (preserves partial file for automatic resume)
|
|
20
|
-
* await cancel({ operation: "
|
|
21
|
+
* await cancel({ operation: "downloadAsset", downloadKey: "download-key" });
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
23
24
|
* // Cancel download completely (deletes partial file)
|
|
24
|
-
* await cancel({ operation: "
|
|
25
|
+
* await cancel({ operation: "downloadAsset", downloadKey: "download-key", clearCache: true });
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Cancel RAG operation on default workspace
|
|
29
|
+
* await cancel({ operation: "rag" });
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Cancel RAG operation on specific workspace
|
|
33
|
+
* await cancel({ operation: "rag", workspace: "my-workspace" });
|
|
25
34
|
*/
|
|
26
35
|
export async function cancel(params) {
|
|
27
36
|
const request = {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type CompletionStats, type
|
|
1
|
+
import { type CompletionClientParams, type CompletionStats, type McpClientInput, type Tool, type ToolCallEvent, type ToolCallWithCall } 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
|
+
mcp?: McpClientInput[];
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* Generates completion from a language model based on conversation history.
|
|
@@ -11,6 +12,7 @@ type CompletionParams = Omit<CompletionClientParams, "tools"> & {
|
|
|
11
12
|
* @param params.history - Array of conversation messages with role, content, and optional attachments
|
|
12
13
|
* @param params.stream - Whether to stream tokens (true) or return complete response (false). Defaults to true
|
|
13
14
|
* @param params.tools - Optional array of tools (can be simple ToolInput with Zod schemas or full Tool objects)
|
|
15
|
+
* @param params.mcp - Optional array of MCP client inputs for tool integration
|
|
14
16
|
* @param params.kvCache - Optional KV cache configuration. Cache files are organized hierarchically:
|
|
15
17
|
* - Structure: `{kvCacheKey}/{modelId}/{configHash}.bin`
|
|
16
18
|
* - The configHash includes model config + system prompt to ensure cache isolation
|
|
@@ -19,12 +21,11 @@ type CompletionParams = Omit<CompletionClientParams, "tools"> & {
|
|
|
19
21
|
* - `false` or `undefined`: No caching
|
|
20
22
|
* - ⚡ Performance: When cache exists, only the last message is sent to the model (includes multimodal attachments)
|
|
21
23
|
* - 🗑️ Cleanup: Use `deleteCache({ kvCacheKey })` to remove cached sessions
|
|
22
|
-
* @returns Object with tokenStream generator, toolCallStream generator, text promise, toolCalls promise, and stats promise
|
|
24
|
+
* @returns Object with tokenStream generator, toolCallStream generator, text promise, toolCalls promise (with call() method), and stats promise
|
|
23
25
|
* @example
|
|
24
26
|
* ```typescript
|
|
25
27
|
* import { z } from "zod";
|
|
26
28
|
*
|
|
27
|
-
* // Simple tool definition with Zod
|
|
28
29
|
* const result = completion({
|
|
29
30
|
* modelId: "llama-2",
|
|
30
31
|
* history: [
|
|
@@ -36,14 +37,23 @@ type CompletionParams = Omit<CompletionClientParams, "tools"> & {
|
|
|
36
37
|
* description: "Get current weather",
|
|
37
38
|
* parameters: z.object({
|
|
38
39
|
* city: z.string().describe("City name"),
|
|
39
|
-
* country: z.string().describe("Country code").optional(),
|
|
40
40
|
* }),
|
|
41
|
+
* handler: async (args) => {
|
|
42
|
+
* return { temperature: 22, condition: "sunny" };
|
|
43
|
+
* }
|
|
41
44
|
* }]
|
|
42
45
|
* });
|
|
43
46
|
*
|
|
44
47
|
* for await (const token of result.tokenStream) {
|
|
45
48
|
* process.stdout.write(token);
|
|
46
49
|
* }
|
|
50
|
+
*
|
|
51
|
+
* for (const toolCall of await result.toolCalls) {
|
|
52
|
+
* if (toolCall.invoke) {
|
|
53
|
+
* const toolResult = await toolCall.invoke();
|
|
54
|
+
* console.log(toolResult);
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
47
57
|
* ```
|
|
48
58
|
*/
|
|
49
59
|
export declare function completion(params: CompletionParams): {
|
|
@@ -51,7 +61,7 @@ export declare function completion(params: CompletionParams): {
|
|
|
51
61
|
toolCallStream: AsyncGenerator<ToolCallEvent>;
|
|
52
62
|
stats: Promise<CompletionStats | undefined>;
|
|
53
63
|
text: Promise<string>;
|
|
54
|
-
toolCalls: Promise<
|
|
64
|
+
toolCalls: Promise<ToolCallWithCall[]>;
|
|
55
65
|
};
|
|
56
66
|
export {};
|
|
57
67
|
//# sourceMappingURL=completion-stream.d.ts.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { completionStreamResponseSchema, } from "../../schemas/index.js";
|
|
2
1
|
import { stream as streamRpc } from "../rpc/rpc-client.js";
|
|
3
|
-
import {
|
|
2
|
+
import { getClientLogger } from "../../logging/index.js";
|
|
3
|
+
import { completionStreamResponseSchema, } from "../../schemas/index.js";
|
|
4
|
+
import { getMcpToolsWithHandlers } from "../../utils/mcp-adapter.js";
|
|
5
|
+
import { attachHandlersToToolCalls, validateTools, } from "../../utils/tool-helpers.js";
|
|
6
|
+
const logger = getClientLogger();
|
|
4
7
|
/**
|
|
5
8
|
* Generates completion from a language model based on conversation history.
|
|
6
9
|
*
|
|
@@ -9,6 +12,7 @@ import { validateTools } from "../../utils/tool-helpers.js";
|
|
|
9
12
|
* @param params.history - Array of conversation messages with role, content, and optional attachments
|
|
10
13
|
* @param params.stream - Whether to stream tokens (true) or return complete response (false). Defaults to true
|
|
11
14
|
* @param params.tools - Optional array of tools (can be simple ToolInput with Zod schemas or full Tool objects)
|
|
15
|
+
* @param params.mcp - Optional array of MCP client inputs for tool integration
|
|
12
16
|
* @param params.kvCache - Optional KV cache configuration. Cache files are organized hierarchically:
|
|
13
17
|
* - Structure: `{kvCacheKey}/{modelId}/{configHash}.bin`
|
|
14
18
|
* - The configHash includes model config + system prompt to ensure cache isolation
|
|
@@ -17,12 +21,11 @@ import { validateTools } from "../../utils/tool-helpers.js";
|
|
|
17
21
|
* - `false` or `undefined`: No caching
|
|
18
22
|
* - ⚡ Performance: When cache exists, only the last message is sent to the model (includes multimodal attachments)
|
|
19
23
|
* - 🗑️ Cleanup: Use `deleteCache({ kvCacheKey })` to remove cached sessions
|
|
20
|
-
* @returns Object with tokenStream generator, toolCallStream generator, text promise, toolCalls promise, and stats promise
|
|
24
|
+
* @returns Object with tokenStream generator, toolCallStream generator, text promise, toolCalls promise (with call() method), and stats promise
|
|
21
25
|
* @example
|
|
22
26
|
* ```typescript
|
|
23
27
|
* import { z } from "zod";
|
|
24
28
|
*
|
|
25
|
-
* // Simple tool definition with Zod
|
|
26
29
|
* const result = completion({
|
|
27
30
|
* modelId: "llama-2",
|
|
28
31
|
* history: [
|
|
@@ -34,24 +37,26 @@ import { validateTools } from "../../utils/tool-helpers.js";
|
|
|
34
37
|
* description: "Get current weather",
|
|
35
38
|
* parameters: z.object({
|
|
36
39
|
* city: z.string().describe("City name"),
|
|
37
|
-
* country: z.string().describe("Country code").optional(),
|
|
38
40
|
* }),
|
|
41
|
+
* handler: async (args) => {
|
|
42
|
+
* return { temperature: 22, condition: "sunny" };
|
|
43
|
+
* }
|
|
39
44
|
* }]
|
|
40
45
|
* });
|
|
41
46
|
*
|
|
42
47
|
* for await (const token of result.tokenStream) {
|
|
43
48
|
* process.stdout.write(token);
|
|
44
49
|
* }
|
|
50
|
+
*
|
|
51
|
+
* for (const toolCall of await result.toolCalls) {
|
|
52
|
+
* if (toolCall.invoke) {
|
|
53
|
+
* const toolResult = await toolCall.invoke();
|
|
54
|
+
* console.log(toolResult);
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
45
57
|
* ```
|
|
46
58
|
*/
|
|
47
59
|
export function completion(params) {
|
|
48
|
-
const tools = params.tools ? validateTools(params.tools) : undefined;
|
|
49
|
-
const request = {
|
|
50
|
-
type: "completionStream",
|
|
51
|
-
...params,
|
|
52
|
-
tools,
|
|
53
|
-
stream: params.stream ?? true,
|
|
54
|
-
};
|
|
55
60
|
let stats;
|
|
56
61
|
let statsResolver = () => { };
|
|
57
62
|
let statsRejecter = () => { };
|
|
@@ -68,7 +73,6 @@ export function completion(params) {
|
|
|
68
73
|
toolCallsRejecter = reject;
|
|
69
74
|
});
|
|
70
75
|
toolCallsPromise.catch(() => { });
|
|
71
|
-
const responses = streamRpc(request);
|
|
72
76
|
const tokenQueue = [];
|
|
73
77
|
const toolEventQueue = [];
|
|
74
78
|
let tokenDone = false;
|
|
@@ -79,6 +83,37 @@ export function completion(params) {
|
|
|
79
83
|
let streamError = null;
|
|
80
84
|
const processResponses = async () => {
|
|
81
85
|
try {
|
|
86
|
+
let allTools = [];
|
|
87
|
+
const allHandlers = new Map();
|
|
88
|
+
if (params.tools) {
|
|
89
|
+
const { tools, handlers } = validateTools(params.tools);
|
|
90
|
+
allTools = tools;
|
|
91
|
+
for (const [name, handler] of handlers) {
|
|
92
|
+
if (allHandlers.has(name)) {
|
|
93
|
+
logger.warn(`Duplicate tool handler for "${name}", overwriting`);
|
|
94
|
+
}
|
|
95
|
+
allHandlers.set(name, handler);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (params.mcp && params.mcp.length > 0) {
|
|
99
|
+
const { tools: mcpTools, handlers: mcpHandlers } = await getMcpToolsWithHandlers(params.mcp);
|
|
100
|
+
allTools = [...mcpTools, ...allTools];
|
|
101
|
+
for (const [name, handler] of mcpHandlers) {
|
|
102
|
+
if (allHandlers.has(name)) {
|
|
103
|
+
logger.warn(`Duplicate tool handler for "${name}", overwriting`);
|
|
104
|
+
}
|
|
105
|
+
allHandlers.set(name, handler);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const request = {
|
|
109
|
+
type: "completionStream",
|
|
110
|
+
modelId: params.modelId,
|
|
111
|
+
history: params.history,
|
|
112
|
+
kvCache: params.kvCache,
|
|
113
|
+
tools: allTools.length > 0 ? allTools : undefined,
|
|
114
|
+
stream: params.stream ?? true,
|
|
115
|
+
};
|
|
116
|
+
const responses = streamRpc(request);
|
|
82
117
|
for await (const response of responses) {
|
|
83
118
|
if (response &&
|
|
84
119
|
typeof response === "object" &&
|
|
@@ -109,7 +144,8 @@ export function completion(params) {
|
|
|
109
144
|
}
|
|
110
145
|
stats = streamResponse.stats;
|
|
111
146
|
statsResolver(stats);
|
|
112
|
-
|
|
147
|
+
const rawToolCalls = streamResponse.toolCalls || [];
|
|
148
|
+
toolCallsArray = attachHandlersToToolCalls(rawToolCalls, allHandlers);
|
|
113
149
|
toolCallsResolver(toolCallsArray);
|
|
114
150
|
tokenDone = true;
|
|
115
151
|
toolDone = true;
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import { type EmbedParams } from "../../schemas/index";
|
|
2
1
|
/**
|
|
3
|
-
* Generates embeddings for a
|
|
2
|
+
* Generates embeddings for a single text using a specified model.
|
|
4
3
|
*
|
|
5
4
|
* @param params - The parameters for the embedding
|
|
6
5
|
* @param params.modelId - The identifier of the embedding model to use
|
|
7
6
|
* @param params.text - The input text to embed
|
|
8
7
|
* @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
|
|
9
8
|
*/
|
|
10
|
-
export declare function embed(params:
|
|
9
|
+
export declare function embed(params: {
|
|
10
|
+
modelId: string;
|
|
11
|
+
text: string;
|
|
12
|
+
}): Promise<number[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Generates embeddings for multiple texts using a specified model.
|
|
15
|
+
*
|
|
16
|
+
* @param params - The parameters for the embedding
|
|
17
|
+
* @param params.modelId - The identifier of the embedding model to use
|
|
18
|
+
* @param params.text - The input texts to embed
|
|
19
|
+
* @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
|
|
20
|
+
*/
|
|
21
|
+
export declare function embed(params: {
|
|
22
|
+
modelId: string;
|
|
23
|
+
text: string[];
|
|
24
|
+
}): Promise<number[][]>;
|
|
11
25
|
//# sourceMappingURL=embed.d.ts.map
|
package/dist/client/api/embed.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { send } from "../rpc/rpc-client.js";
|
|
2
2
|
import {} from "../../schemas/index.js";
|
|
3
3
|
import { InvalidResponseError, EmbedFailedError } from "../../utils/errors-client.js";
|
|
4
|
-
/**
|
|
5
|
-
* Generates embeddings for a given text using a specified model.
|
|
6
|
-
*
|
|
7
|
-
* @param params - The parameters for the embedding
|
|
8
|
-
* @param params.modelId - The identifier of the embedding model to use
|
|
9
|
-
* @param params.text - The input text to embed
|
|
10
|
-
* @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
|
|
11
|
-
*/
|
|
12
4
|
export async function embed(params) {
|
|
13
5
|
const request = {
|
|
14
6
|
type: "embed",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type GetModelInfoParams } from "../../schemas/index";
|
|
2
|
-
export declare
|
|
2
|
+
export declare function getModelInfo(params: GetModelInfoParams): Promise<{
|
|
3
3
|
name: string;
|
|
4
4
|
modelId: string;
|
|
5
5
|
hyperdriveKey: string;
|
|
6
6
|
hyperbeeKey: string;
|
|
7
7
|
expectedSize: number;
|
|
8
8
|
sha256Checksum: string;
|
|
9
|
-
addon: "
|
|
9
|
+
addon: "llamacpp-completion" | "whispercpp-transcription" | "llamacpp-embedding" | "nmtcpp-translation" | "onnx-tts" | "onnx-ocr" | "vad";
|
|
10
10
|
isCached: boolean;
|
|
11
11
|
isLoaded: boolean;
|
|
12
12
|
cacheFiles: {
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
export
|
|
4
|
+
export async function getModelInfo(params) {
|
|
5
5
|
const request = {
|
|
6
6
|
type: "getModelInfo",
|
|
7
7
|
name: params.name,
|
|
@@ -11,4 +11,4 @@ export const getModelInfo = async (params) => {
|
|
|
11
11
|
throw new InvalidResponseError("getModelInfo");
|
|
12
12
|
}
|
|
13
13
|
return response.modelInfo;
|
|
14
|
-
}
|
|
14
|
+
}
|
|
@@ -11,8 +11,8 @@ export { translate } from "./translate";
|
|
|
11
11
|
export { cancel } from "./cancel";
|
|
12
12
|
export { startQVACProvider } from "./provide";
|
|
13
13
|
export { stopQVACProvider } from "./stop-provider";
|
|
14
|
-
export { ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings } from "./rag";
|
|
14
|
+
export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, } from "./rag";
|
|
15
15
|
export { textToSpeech } from "./text-to-speech";
|
|
16
|
-
export { setConfig } from "./set-config";
|
|
17
16
|
export { getModelInfo } from "./get-model-info";
|
|
17
|
+
export { ocr } from "./ocr";
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/client/api/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export { translate } from "./translate.js";
|
|
|
11
11
|
export { cancel } from "./cancel.js";
|
|
12
12
|
export { startQVACProvider } from "./provide.js";
|
|
13
13
|
export { stopQVACProvider } from "./stop-provider.js";
|
|
14
|
-
export { ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings } from "./rag.js";
|
|
14
|
+
export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, } from "./rag.js";
|
|
15
15
|
export { textToSpeech } from "./text-to-speech.js";
|
|
16
|
-
export { setConfig } from "./set-config.js";
|
|
17
16
|
export { getModelInfo } from "./get-model-info.js";
|
|
17
|
+
export { ocr } from "./ocr.js";
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type LoadModelOptions as BaseLoadModelOptions } from "../../schemas/index";
|
|
3
|
-
export type LoadModelOptions = BaseLoadModelOptions & {
|
|
4
|
-
logger?: Logger;
|
|
5
|
-
};
|
|
1
|
+
import { type LoadModelOptions, type ReloadConfigOptions } from "../../schemas/index";
|
|
6
2
|
/**
|
|
7
3
|
* Loads a machine learning model from a local path, remote URL, or Hyperdrive key.
|
|
8
4
|
*
|
|
9
|
-
* This function supports
|
|
10
|
-
* and
|
|
5
|
+
* This function supports multiple model types: LLM (Large Language Model), Whisper (speech recognition),
|
|
6
|
+
* embeddings, NMT (translation), and TTS. It can handle both local file paths and Hyperdrive URLs (pear://).
|
|
11
7
|
*
|
|
12
8
|
* When `onProgress` is provided, the function uses streaming to provide real-time download progress.
|
|
13
9
|
* Otherwise, it uses a simple request-response pattern for faster execution.
|
|
14
10
|
*
|
|
15
11
|
* @param options - An object that defines all configuration parameters required for loading the model, including:
|
|
16
12
|
* - modelSrc: The location from which the model weights are fetched (local path, remote URL, or Hyperdrive URL)
|
|
17
|
-
* - modelType: The type of model ("llm", "whisper", "embeddings", or "
|
|
13
|
+
* - modelType: The type of model ("llm", "whisper", "embeddings", "nmt", or "tts")
|
|
18
14
|
* - modelConfig: Model-specific configuration options
|
|
19
15
|
* - projectionModelSrc: (LLM only) Projection model source for multimodal models
|
|
20
16
|
* - vadModelSrc: (Whisper only) VAD model source for voice activity detection
|
|
17
|
+
* - onProgress: Callback for download progress updates
|
|
18
|
+
* - logger: Logger instance for model operation logs
|
|
21
19
|
*
|
|
22
20
|
* @returns Promise that resolves to the model ID (either the provided modelSrc or a generated ID)
|
|
23
21
|
*
|
|
@@ -89,10 +87,38 @@ export type LoadModelOptions = BaseLoadModelOptions & {
|
|
|
89
87
|
* modelType: "llm",
|
|
90
88
|
* logger // Pass logger in options
|
|
91
89
|
* });
|
|
92
|
-
*
|
|
93
|
-
* // Now any logs from the model operations will appear in your logger automatically
|
|
94
|
-
* // No need to manually manage logging streams!
|
|
95
90
|
* ```
|
|
96
91
|
*/
|
|
97
92
|
export declare function loadModel(options: LoadModelOptions): Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Hot-reloads configuration on an already loaded model.
|
|
95
|
+
*
|
|
96
|
+
* @param options - Configuration for reloading config on an existing model:
|
|
97
|
+
* - modelId: The ID of an existing loaded model
|
|
98
|
+
* - modelType: The type of model (must match the loaded model)
|
|
99
|
+
* - modelConfig: New configuration to apply
|
|
100
|
+
*
|
|
101
|
+
* @returns Promise that resolves to the model ID
|
|
102
|
+
*
|
|
103
|
+
* @throws {QvacErrorBase} When model reload fails, with details in the error message
|
|
104
|
+
* @throws {QvacErrorBase} When receiving an invalid response type from the server
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* // Load new model
|
|
109
|
+
* const modelId = await loadModel({
|
|
110
|
+
* modelSrc: "pear://<hyperdrive-key>/whisper-tiny.gguf",
|
|
111
|
+
* modelType: "whisper",
|
|
112
|
+
* modelConfig: { language: "en" },
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* // Later, update the config without reloading the model
|
|
116
|
+
* await loadModel({
|
|
117
|
+
* modelId,
|
|
118
|
+
* modelType: "whisper",
|
|
119
|
+
* modelConfig: { language: "es" },
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare function loadModel(options: ReloadConfigOptions): Promise<string>;
|
|
98
124
|
//# sourceMappingURL=load-model.d.ts.map
|
|
@@ -1,107 +1,26 @@
|
|
|
1
1
|
import { send, stream } from "../rpc/rpc-client.js";
|
|
2
|
-
import {} from "../../logging/index.js";
|
|
3
2
|
import { startLoggingStreamForModel } from "../logging-stream-registry.js";
|
|
4
|
-
import { loadModelOptionsToRequestSchema, } from "../../schemas/index.js";
|
|
3
|
+
import { loadModelOptionsToRequestSchema, reloadConfigOptionsToRequestSchema, isModelTypeAlias, normalizeModelType, } from "../../schemas/index.js";
|
|
5
4
|
import { ModelLoadFailedError, StreamEndedError, InvalidResponseError, } from "../../utils/errors-client.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* This function supports three model types: LLM (Large Language Model), Whisper (speech recognition),
|
|
10
|
-
* and embeddings. It can handle both local file paths and Hyperdrive URLs (pear://).
|
|
11
|
-
*
|
|
12
|
-
* When `onProgress` is provided, the function uses streaming to provide real-time download progress.
|
|
13
|
-
* Otherwise, it uses a simple request-response pattern for faster execution.
|
|
14
|
-
*
|
|
15
|
-
* @param options - An object that defines all configuration parameters required for loading the model, including:
|
|
16
|
-
* - modelSrc: The location from which the model weights are fetched (local path, remote URL, or Hyperdrive URL)
|
|
17
|
-
* - modelType: The type of model ("llm", "whisper", "embeddings", or "nmt")
|
|
18
|
-
* - modelConfig: Model-specific configuration options
|
|
19
|
-
* - projectionModelSrc: (LLM only) Projection model source for multimodal models
|
|
20
|
-
* - vadModelSrc: (Whisper only) VAD model source for voice activity detection
|
|
21
|
-
*
|
|
22
|
-
* @returns Promise that resolves to the model ID (either the provided modelSrc or a generated ID)
|
|
23
|
-
*
|
|
24
|
-
* @throws {QvacErrorBase} When model loading fails, with details in the error message
|
|
25
|
-
* @throws {QvacErrorBase} When streaming ends unexpectedly (only when using onProgress)
|
|
26
|
-
* @throws {QvacErrorBase} When receiving an invalid response type from the server
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* // Local file path - absolute path
|
|
31
|
-
* const localModelId = await loadModel({
|
|
32
|
-
* modelSrc: "/home/user/models/llama-7b.gguf",
|
|
33
|
-
* modelType: "llm",
|
|
34
|
-
* modelConfig: { contextSize: 2048 }
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* // Local file path - relative path
|
|
38
|
-
* const relativeModelId = await loadModel({
|
|
39
|
-
* modelSrc: "./models/whisper-base.gguf",
|
|
40
|
-
* modelType: "whisper"
|
|
41
|
-
* });
|
|
42
|
-
*
|
|
43
|
-
* // Hyperdrive URL with key and path
|
|
44
|
-
* const hyperdriveId = await loadModel({
|
|
45
|
-
* modelSrc: "pear://<hyperdrive-key>/llama-7b.gguf",
|
|
46
|
-
* modelType: "llm",
|
|
47
|
-
* modelConfig: { contextSize: 2048 }
|
|
48
|
-
* });
|
|
49
|
-
*
|
|
50
|
-
* // Remote HTTP/HTTPS URL with progress tracking
|
|
51
|
-
* const remoteId = await loadModel({
|
|
52
|
-
* modelSrc: "https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q4_K_M.gguf",
|
|
53
|
-
* modelType: "llm",
|
|
54
|
-
* onProgress: (progress) => {
|
|
55
|
-
* console.log(`Downloaded: ${progress.percentage}%`);
|
|
56
|
-
* }
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* // Multimodal model with projection
|
|
60
|
-
* const multimodalId = await loadModel({
|
|
61
|
-
* modelSrc: "https://huggingface.co/.../main-model.gguf",
|
|
62
|
-
* modelType: "llm",
|
|
63
|
-
* projectionModelSrc: "https://huggingface.co/.../projection-model.gguf",
|
|
64
|
-
* modelConfig: { ctx_size: 512 },
|
|
65
|
-
* onProgress: (progress) => {
|
|
66
|
-
* console.log(`Loading: ${progress.percentage}%`);
|
|
67
|
-
* }
|
|
68
|
-
* });
|
|
69
|
-
*
|
|
70
|
-
* // Whisper with VAD model
|
|
71
|
-
* const whisperId = await loadModel({
|
|
72
|
-
* modelSrc: "https://huggingface.co/.../whisper-model.gguf",
|
|
73
|
-
* modelType: "whisper",
|
|
74
|
-
* vadModelSrc: "https://huggingface.co/.../vad-model.bin",
|
|
75
|
-
* modelConfig: {
|
|
76
|
-
* mode: "caption",
|
|
77
|
-
* output_format: "plaintext",
|
|
78
|
-
* min_seconds: 2,
|
|
79
|
-
* max_seconds: 6
|
|
80
|
-
* }
|
|
81
|
-
* });
|
|
82
|
-
*
|
|
83
|
-
* // Load with automatic logging - logs from the model will be forwarded to your logger
|
|
84
|
-
* import { getLogger } from "../../logging/index.js";
|
|
85
|
-
* const logger = getLogger("my-app");
|
|
86
|
-
*
|
|
87
|
-
* const modelId = await loadModel({
|
|
88
|
-
* modelSrc: "/path/to/model.gguf",
|
|
89
|
-
* modelType: "llm",
|
|
90
|
-
* logger // Pass logger in options
|
|
91
|
-
* });
|
|
92
|
-
*
|
|
93
|
-
* // Now any logs from the model operations will appear in your logger automatically
|
|
94
|
-
* // No need to manually manage logging streams!
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
5
|
+
import { getClientLogger } from "../../logging/index.js";
|
|
6
|
+
const logger = getClientLogger();
|
|
97
7
|
export async function loadModel(options) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
if (options.
|
|
8
|
+
const isReloadConfig = "modelId" in options && !("modelSrc" in options);
|
|
9
|
+
// Warn about deprecated alias usage
|
|
10
|
+
if (!isReloadConfig && isModelTypeAlias(options.modelType)) {
|
|
11
|
+
const canonical = normalizeModelType(options.modelType);
|
|
12
|
+
logger.warn(`Model type "${options.modelType}" is an alias and will be deprecated. Use "${canonical}" instead.`);
|
|
13
|
+
}
|
|
14
|
+
const request = isReloadConfig
|
|
15
|
+
? reloadConfigOptionsToRequestSchema.parse(options)
|
|
16
|
+
: loadModelOptionsToRequestSchema.parse(options);
|
|
17
|
+
const modelLogger = isReloadConfig ? undefined : options.logger;
|
|
18
|
+
const onProgress = isReloadConfig ? undefined : options.onProgress;
|
|
19
|
+
if (onProgress) {
|
|
101
20
|
// Use streaming for progress updates
|
|
102
21
|
for await (const response of stream(request)) {
|
|
103
22
|
if (response.type === "modelProgress") {
|
|
104
|
-
|
|
23
|
+
onProgress(response);
|
|
105
24
|
}
|
|
106
25
|
else if (response.type === "loadModel") {
|
|
107
26
|
if (!response.success) {
|
|
@@ -109,12 +28,12 @@ export async function loadModel(options) {
|
|
|
109
28
|
}
|
|
110
29
|
const modelId = response.modelId;
|
|
111
30
|
// Start logging stream in the background if logger is provided, catch to avoid failing the entire loadModel operation
|
|
112
|
-
if (
|
|
31
|
+
if (modelLogger) {
|
|
113
32
|
try {
|
|
114
|
-
startLoggingStreamForModel(modelId,
|
|
33
|
+
startLoggingStreamForModel(modelId, modelLogger);
|
|
115
34
|
}
|
|
116
35
|
catch (error) {
|
|
117
|
-
|
|
36
|
+
logger.warn(`Failed to start logging stream for model ${modelId}:`, error);
|
|
118
37
|
}
|
|
119
38
|
}
|
|
120
39
|
return modelId;
|
|
@@ -122,24 +41,22 @@ export async function loadModel(options) {
|
|
|
122
41
|
}
|
|
123
42
|
throw new StreamEndedError();
|
|
124
43
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
44
|
+
// Use regular send for simple loading
|
|
45
|
+
const response = await send(request);
|
|
46
|
+
if (response.type !== "loadModel") {
|
|
47
|
+
throw new InvalidResponseError("loadModel");
|
|
48
|
+
}
|
|
49
|
+
if (!response.success) {
|
|
50
|
+
throw new ModelLoadFailedError(response.error);
|
|
51
|
+
}
|
|
52
|
+
const modelId = response.modelId;
|
|
53
|
+
if (modelLogger) {
|
|
54
|
+
try {
|
|
55
|
+
startLoggingStreamForModel(modelId, modelLogger);
|
|
133
56
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
startLoggingStreamForModel(modelId, logger);
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
console.warn(`Failed to start logging stream for model ${modelId}:`, error);
|
|
141
|
-
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
logger.warn(`Failed to start logging stream for model ${modelId}:`, error);
|
|
142
59
|
}
|
|
143
|
-
return modelId;
|
|
144
60
|
}
|
|
61
|
+
return modelId;
|
|
145
62
|
}
|