@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
package/README.md
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
[](https://qvac.tether.dev)
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
**QVAC** is an open-source, cross-platform
|
|
5
|
+
**QVAC** is an open-source, cross-platform **ecosystem** for local-first, peer-to-peer **AI**. QVAC runs on [**Bare**](https://bare.pears.com) by [Holepunch](https://holepunch.to), a lightweight, cross-platform JavaScript runtime.
|
|
6
6
|
|
|
7
7
|
# QVAC SDK
|
|
8
8
|
|
|
9
|
-
**QVAC SDK** is the canonical entry point to
|
|
9
|
+
**QVAC SDK** is the canonical entry point to develop AI applications with QVAC.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
> _Part of **QVAC** ecosystem_
|
|
12
|
+
> <br>
|
|
13
|
+
> <sup>
|
|
14
|
+
> <a href="https://qvac.tether.dev" >Home</a> •
|
|
15
|
+
> <a href="https://qvac.tether.dev/docs" >Docs</a> •
|
|
16
|
+
> <a href="https://qvacbytether.featurebase.app" >Support</a> •
|
|
17
|
+
> <a href="https://discord.com/invite/tetherdev" >Discord</a>
|
|
18
|
+
> </sup>
|
|
19
|
+
|
|
20
|
+
Written in TypeScript, it provides all QVAC capabilities through a unified interface while also abstracting away the complexity of running your application in a JS environment other than Bare.
|
|
21
|
+
|
|
22
|
+
For the comprehensive reference, [see official QVAC documentation](https://qvac.tether.dev/docs).
|
|
12
23
|
|
|
13
24
|
## Requirements
|
|
14
25
|
|
|
@@ -16,65 +27,29 @@ Supported JS environments: Bare, Node.js, Expo and Bun.
|
|
|
16
27
|
|
|
17
28
|
## Installation
|
|
18
29
|
|
|
19
|
-
### Steps
|
|
20
|
-
|
|
21
|
-
1. [Authenticate to Tether’s GitHub packages](#step-1-authenticate-to-tethers-github-packages)
|
|
22
|
-
2. [Install package and dependencies](#step-2-install-package-and-dependencies)
|
|
23
|
-
|
|
24
|
-
### Step 1: authenticate to Tether’s GitHub packages
|
|
25
|
-
|
|
26
|
-
1. [Create a GitHub personal access token (classic) with scope `read:packages`](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic).
|
|
27
|
-
|
|
28
|
-
2. Add the token to your environment variables. For example, on macOS/Linux:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
export NPM_TOKEN=<token_generated_in_previous_step>
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
3. In the root of your project, create file `.npmrc` with the following content:
|
|
35
|
-
|
|
36
|
-
```ini
|
|
37
|
-
@qvac:registry=https://registry.npmjs.org
|
|
38
|
-
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
_Alternatively, you can create the `.npmrc` file in your home directory, for user-level (global) configuration._
|
|
42
|
-
|
|
43
|
-
4. Confirm authentication to Tether’s GitHub packages:
|
|
44
|
-
|
|
45
30
|
```bash
|
|
46
|
-
npm
|
|
31
|
+
npm install @qvac/sdk
|
|
47
32
|
```
|
|
48
33
|
|
|
49
|
-
|
|
34
|
+
### Linux
|
|
50
35
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
1. Install in your project using the package manager of your choice:
|
|
36
|
+
OS peer dependency:
|
|
54
37
|
|
|
55
38
|
```bash
|
|
56
|
-
|
|
39
|
+
apt install vulkan-sdk
|
|
57
40
|
```
|
|
58
41
|
|
|
59
|
-
|
|
60
|
-
> If you can't get the package via Tether's private GitHub package registry, see section [Build from source](#build-from-source).
|
|
61
|
-
|
|
62
|
-
#### On Linux
|
|
63
|
-
|
|
64
|
-
> [!IMPORTANT]
|
|
65
|
-
> If you're on Linux ensure that the Vulkan SDK is installed (e.g. `apt install vulkan-sdk` on Ubuntu)
|
|
66
|
-
|
|
67
|
-
#### On Expo
|
|
42
|
+
### Expo
|
|
68
43
|
|
|
69
|
-
1.
|
|
44
|
+
1. Peer dependencies:
|
|
70
45
|
|
|
71
46
|
```bash
|
|
72
47
|
npm i expo-file-system react-native-bare-kit
|
|
73
48
|
```
|
|
74
49
|
|
|
75
|
-
2.
|
|
50
|
+
2. On Android, bump `minSdkVersion` to 29, by adding `ext { minSdkVersion=29 }` to `android/build.gradle` or using `expo-build-properties`.
|
|
76
51
|
|
|
77
|
-
3. Add the QVAC Expo plugin to
|
|
52
|
+
3. Add the QVAC Expo plugin to `app.json`:
|
|
78
53
|
|
|
79
54
|
```js
|
|
80
55
|
export default {
|
|
@@ -101,78 +76,81 @@ npx expo run:android --device
|
|
|
101
76
|
> [!IMPORTANT]
|
|
102
77
|
> Due to limitations with `llamacpp`, QVAC currently does not run on emulators. You **must** use a physical device.
|
|
103
78
|
|
|
104
|
-
##
|
|
105
|
-
|
|
106
|
-
You can run the self-contained example below:
|
|
79
|
+
## Usage
|
|
107
80
|
|
|
108
81
|
```js
|
|
109
|
-
import {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
82
|
+
import {
|
|
83
|
+
completion,
|
|
84
|
+
LLAMA_3_2_1B_INST_Q4_0,
|
|
85
|
+
loadModel,
|
|
86
|
+
downloadAsset,
|
|
87
|
+
unloadModel,
|
|
88
|
+
VERBOSITY,
|
|
89
|
+
} from "@qvac/sdk";
|
|
90
|
+
try {
|
|
91
|
+
// First just cache the model
|
|
92
|
+
await downloadAsset({
|
|
93
|
+
assetSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
94
|
+
onProgress: (progress) => {
|
|
95
|
+
console.log(progress);
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
// Then load it in memory from cache
|
|
99
|
+
const modelId = await loadModel({
|
|
100
|
+
modelSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
115
101
|
modelType: "llm",
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
history
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
// You can use the loaded model multiple times
|
|
141
|
-
|
|
142
|
-
// Unload model to free up system resources
|
|
143
|
-
await unloadModel({ modelId });
|
|
144
|
-
process.exit();
|
|
102
|
+
modelConfig: {
|
|
103
|
+
device: "gpu",
|
|
104
|
+
ctx_size: 2048,
|
|
105
|
+
verbosity: VERBOSITY.ERROR,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
const history = [
|
|
109
|
+
{
|
|
110
|
+
role: "user",
|
|
111
|
+
content: "Explain quantum computing in one sentence, use lots of emojis",
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
const result = completion({ modelId, history, stream: true });
|
|
115
|
+
for await (const token of result.tokenStream) {
|
|
116
|
+
process.stdout.write(token);
|
|
117
|
+
}
|
|
118
|
+
const stats = await result.stats;
|
|
119
|
+
console.log("\n📊 Performance Stats:", stats);
|
|
120
|
+
// Change `clearStorage: true` to delete cached model files
|
|
121
|
+
await unloadModel({ modelId, clearStorage: false });
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error("❌ Error:", error);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
145
126
|
```
|
|
146
127
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
## Build from source
|
|
150
|
-
|
|
151
|
-
Use the [Bun](https://bun.sh/) package manager:
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
bun i
|
|
155
|
-
```
|
|
128
|
+
## Functionalities
|
|
156
129
|
|
|
157
|
-
|
|
158
|
-
bun run build # or `watch` for hotreload
|
|
159
|
-
```
|
|
130
|
+
### AI tasks
|
|
160
131
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
132
|
+
- Completion: LLM inference via [`llama.cpp`](https://github.com/ggml-org/llama.cpp).
|
|
133
|
+
- Transcription: speech-to-text (ASR) via [`whisper.cpp`](https://github.com/ggml-org/whisper.cpp).
|
|
134
|
+
- Text embeddings: via `llama.cpp`, for RAG.
|
|
135
|
+
- Translation: between different languages.
|
|
136
|
+
- Text-to-Speech: TTS via ONNX.
|
|
137
|
+
- Multimodal: via [`llama.cpp`] — i.e., process and understand multiple types of media within the same conversation context.
|
|
138
|
+
- RAG: retrieval-augmented generation with progress streaming, cancellation, and workspace management.
|
|
139
|
+
- Delegated inference: perform peer-to-peer edge inference via Holepunch stack.
|
|
164
140
|
|
|
165
|
-
|
|
141
|
+
### Utilities
|
|
166
142
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
143
|
+
- Configuration: customize SDK behavior via config files (`qvac.config.json`, `.js`, or `.ts`).
|
|
144
|
+
- Logging: visibility into what's happening inside your models during loading, inference, and other operations.
|
|
145
|
+
- Download Lifecycle: pause and resume model downloads.
|
|
146
|
+
- Blind Relays: establish peer connections through NAT/firewalls by routing traffic through relay nodes.
|
|
147
|
+
- Sharded models: download a model that is sharded into multiple parts.
|
|
170
148
|
|
|
171
149
|
## Examples
|
|
172
150
|
|
|
173
|
-
In the `./examples` subdirectory, you will find scripts demonstrating SDK
|
|
151
|
+
In the `./examples` subdirectory, you will find scripts demonstrating how to use all SDK functionalities. To try any of them:
|
|
174
152
|
|
|
175
|
-
1.
|
|
153
|
+
1. Build the SDK from source (see [Build](#build) section).
|
|
176
154
|
2. Run using Bare, Node.js, or Bun as the runtime:
|
|
177
155
|
|
|
178
156
|
```bash
|
|
@@ -186,139 +164,326 @@ node dist/examples/path/to/example.js
|
|
|
186
164
|
bun run examples/path/to/example.ts
|
|
187
165
|
```
|
|
188
166
|
|
|
189
|
-
|
|
167
|
+
### Completion
|
|
168
|
+
|
|
169
|
+
- `llama.cpp` with local files: [`examples/llamacpp-filesystem.ts`](examples/llamacpp-filesystem.ts)
|
|
170
|
+
- `llama.cpp` with Hyperdrive: [`examples/llamacpp-hyperdrive.ts`](examples/llamacpp-hyperdrive.ts)
|
|
171
|
+
- `llama.cpp` with HTTP: [`examples/llamacpp-http.ts`](examples/llamacpp-http.ts)
|
|
172
|
+
- `llama.cpp` with tools/function calls: [`examples/llamacpp-native-tools.ts`](examples/llamacpp-native-tools.ts)
|
|
173
|
+
- `llama.cpp` with multimodal inference: [`examples/llamacpp-multimodal.ts`](examples/llamacpp-multimodal.ts)
|
|
174
|
+
- `llama.cpp` with KV cache: [`examples/kv-cache-example.ts`](examples/kv-cache-example.ts)
|
|
190
175
|
|
|
191
|
-
|
|
176
|
+
### Transcription
|
|
192
177
|
|
|
193
|
-
|
|
178
|
+
- `whisper.cpp` transcription: [`examples/whispercpp-filesystem.ts`](examples/whispercpp-filesystem.ts)
|
|
179
|
+
- Microphone recording: [`examples/whispercpp-microphone-record.ts`](examples/whispercpp-microphone-record.ts)
|
|
194
180
|
|
|
195
|
-
|
|
181
|
+
### Embeddings
|
|
196
182
|
|
|
197
|
-
|
|
198
|
-
import { getLogger, loadModel, completion, unloadModel } from "@qvac/sdk";
|
|
199
|
-
|
|
200
|
-
// Create a logger for your application
|
|
201
|
-
const logger = getLogger("my-app", {
|
|
202
|
-
level: "debug", // Set log level
|
|
203
|
-
transports: [
|
|
204
|
-
// Optional: add custom log handlers
|
|
205
|
-
(level, namespace, message) => {
|
|
206
|
-
console.log(`[${level.toUpperCase()}] ${namespace}: ${message}`);
|
|
207
|
-
},
|
|
208
|
-
],
|
|
209
|
-
});
|
|
183
|
+
- Single and batch embeddings: [`examples/embed-hyperdrive.ts`](examples/embed-hyperdrive.ts)
|
|
210
184
|
|
|
211
|
-
|
|
212
|
-
const modelId = await loadModel(
|
|
213
|
-
"pear://afa79ee07c0a138bb9f11bfaee771fb1bdfca8c82d961cff0474e49827bd1de3/Llama-3.2-1B-Instruct-Q4_0.gguf",
|
|
214
|
-
{
|
|
215
|
-
modelType: "llm",
|
|
216
|
-
logger, // Enable log streaming
|
|
217
|
-
},
|
|
218
|
-
);
|
|
185
|
+
**RAG with HyperDB** (cross-platform):
|
|
219
186
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}).tokenStream) {
|
|
225
|
-
process.stdout.write(token);
|
|
226
|
-
}
|
|
187
|
+
- Ingest (full pipeline): [`examples/rag/rag-hyperdb/ingest.ts`](examples/rag/rag-hyperdb/ingest.ts)
|
|
188
|
+
- Segregated pipeline: [`examples/rag/rag-hyperdb/pipeline.ts`](examples/rag/rag-hyperdb/pipeline.ts) _(Segregated flow: chunk → embed → save)_
|
|
189
|
+
- Workspaces: [`examples/rag/rag-hyperdb/workspaces.ts`](examples/rag/rag-hyperdb/workspaces.ts) _(Workspace lifecycle: list, close, delete)_
|
|
190
|
+
- Cancellation: [`examples/rag/rag-hyperdb/cancellation.ts`](examples/rag/rag-hyperdb/cancellation.ts) _(progress + cancel)_
|
|
227
191
|
|
|
228
|
-
|
|
229
|
-
```
|
|
192
|
+
**RAG with other backends** (desktop only):
|
|
230
193
|
|
|
231
|
-
|
|
194
|
+
- LanceDB: [`examples/rag/rag-lancedb.ts`](examples/rag/rag-lancedb.ts)
|
|
195
|
+
- ChromaDB: [`examples/rag/rag-chromadb.ts`](examples/rag/rag-chromadb.ts) _(requires ChromaDB server)_
|
|
196
|
+
- SQLite-Vector: [`examples/rag/rag-sqlite.ts`](examples/rag/rag-sqlite.ts) _(SQLite-Vector WASM)_
|
|
232
197
|
|
|
233
|
-
|
|
198
|
+
### Translation
|
|
234
199
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
[DEBUG] llamacpp:llm: Starting inference...
|
|
239
|
-
[DEBUG] llamacpp:llm: Inference completed, tokens=12
|
|
240
|
-
```
|
|
200
|
+
- Marian OPUS translation: [`examples/translation/translation-opus.ts`](examples/translation/translation-opus.ts)
|
|
201
|
+
- Indic language translation: [`examples/translation/translation-indic.ts`](examples/translation/translation-indic.ts)
|
|
202
|
+
- LLM-based translation: [`examples/translation/translation-llm.ts`](examples/translation/translation-llm.ts)
|
|
241
203
|
|
|
242
|
-
|
|
204
|
+
### Text-to-Speech
|
|
243
205
|
|
|
244
|
-
|
|
206
|
+
- TTS with [eSpeak](https://github.com/espeak-ng/espeak-ng): [`examples/text-to-speech.ts`](examples/text-to-speech.ts)
|
|
245
207
|
|
|
246
|
-
|
|
247
|
-
- `llama.cpp` with Hyperdrive: [`examples/llamacpp-hyperdrive.ts`](examples/llamacpp-hyperdrive.ts)
|
|
248
|
-
- `llama.cpp` with HTTP: [`examples/llamacpp-http.ts`](examples/llamacpp-http.ts)
|
|
249
|
-
- `llama.cpp` with file logging: [`examples/llamacpp-file-logging.ts`](examples/llamacpp-file-logging.ts)
|
|
250
|
-
- `llama.cpp` with tools/function calls: [`examples/llamacpp-tools.ts`](examples/llamacpp-tools.ts)
|
|
251
|
-
- `llama.cpp` with tools and routing: [`examples/llamacpp-tools-routing.ts`](examples/llamacpp-tools-routing.ts)
|
|
252
|
-
- `llama.cpp` with multimodal inference: [`examples/llamacpp-multimodal.ts`](examples/llamacpp-multimodal.ts)
|
|
253
|
-
- `llama.cpp` with KV cache: [`examples/kv-cache-example.ts`](examples/kv-cache-example.ts)
|
|
208
|
+
### Multimodel
|
|
254
209
|
|
|
255
|
-
|
|
210
|
+
- Load multiple models simultaneously: [`examples/multi-model-demo.ts`](examples/multi-model-demo.ts)
|
|
256
211
|
|
|
257
|
-
|
|
258
|
-
- Microphone recording: [`examples/microphone-record-transcription.ts`](examples/microphone-record-transcription.ts)
|
|
212
|
+
### Delegated inference
|
|
259
213
|
|
|
260
|
-
|
|
214
|
+
- Provider: [`examples/delegated-inference/provider.ts`](examples/delegated-inference/provider.ts)
|
|
215
|
+
- Consumer: [`examples/delegated-inference/consumer.ts`](examples/delegated-inference/consumer.ts)
|
|
261
216
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
- RAG with workspaces: [`examples/rag-hyperdb-workspaces.ts`](examples/rag-hyperdb-workspaces.ts) _(Demonstrates workspace isolation and chunking)_
|
|
265
|
-
- RAG example with LanceDB (desktop only): [`examples/rag-lancedb.ts`](examples/rag-lancedb.ts)
|
|
266
|
-
- RAG example with ChromaDB (desktop only): [`examples/rag-chromadb.ts`](examples/rag-chromadb.ts) _(Note: Requires ChromaDB server running)_
|
|
267
|
-
- RAG example with SQLite-Vector (desktop only): [`examples/rag-sqlite.ts`](examples/rag-sqlite.ts) _(Note: Uses SQLite-Vector WASM)_
|
|
217
|
+
> [!TIP]
|
|
218
|
+
> Set `QVAC_HYPERSWARM_SEED` env var to ensure that the provider uses the same keypair (i.e., public key doesn't change on every run).
|
|
268
219
|
|
|
269
|
-
|
|
220
|
+
> [!NOTE]
|
|
221
|
+
> Consumer does not handle reconnection yet.
|
|
270
222
|
|
|
271
|
-
|
|
272
|
-
- Indic language translation: [`examples/translation-indic.ts`](examples/translation-indic.ts)
|
|
273
|
-
- LLM-based translation: [`examples/translation-llm.ts`](examples/translation-llm.ts)
|
|
223
|
+
### Logging
|
|
274
224
|
|
|
275
|
-
|
|
225
|
+
Stream real-time logs from the SDK server and native addons:
|
|
276
226
|
|
|
277
|
-
|
|
227
|
+
```ts
|
|
228
|
+
import { loggingStream, SDK_LOG_ID } from "@qvac/sdk";
|
|
278
229
|
|
|
279
|
-
|
|
230
|
+
// SDK server logs (general operations)
|
|
231
|
+
for await (const log of loggingStream({ id: SDK_LOG_ID })) {
|
|
232
|
+
console.log(`[${log.level}] ${log.namespace}: ${log.message}`);
|
|
233
|
+
}
|
|
280
234
|
|
|
281
|
-
|
|
235
|
+
// Addon logs per model (llamacpp, whispercpp, etc.)
|
|
236
|
+
for await (const log of loggingStream({ id: modelId })) {
|
|
237
|
+
console.log(`[${log.level}] ${log.namespace}: ${log.message}`);
|
|
238
|
+
}
|
|
239
|
+
```
|
|
282
240
|
|
|
283
|
-
-
|
|
241
|
+
- Log streaming: [`examples/logging-streaming.ts`](examples/logging-streaming.ts)
|
|
242
|
+
- Log with custom file transport: [`examples/logging-file-transport.ts`](examples/logging-file-transport.ts)
|
|
284
243
|
|
|
285
|
-
###
|
|
244
|
+
### Configuration
|
|
286
245
|
|
|
287
|
-
|
|
288
|
-
- Consumer example: [`examples/delegated-inference/consumer.ts`](examples/delegated-inference/consumer.ts)
|
|
246
|
+
Customize SDK behavior using a config file. The SDK auto-discovers `qvac.config.{json,js,ts}` in your project root, or you can specify a path via `QVAC_CONFIG_PATH` environment variable.
|
|
289
247
|
|
|
290
|
-
**
|
|
291
|
-
**Note**: ⚠️ Consumer does not handle reconnection yet.
|
|
248
|
+
**Supported formats:**
|
|
292
249
|
|
|
293
|
-
|
|
250
|
+
- `qvac.config.json` - JSON format
|
|
251
|
+
- `qvac.config.js` - JavaScript with `export default`
|
|
252
|
+
- `qvac.config.ts` - TypeScript with `export default`
|
|
294
253
|
|
|
295
|
-
|
|
254
|
+
**Available options:**
|
|
296
255
|
|
|
297
|
-
|
|
256
|
+
| Option | Type | Default | Description |
|
|
257
|
+
| ------------------------- | ---------- | ---------------- | --------------------------------------------------- |
|
|
258
|
+
| `cacheDirectory` | `string` | `~/.qvac/models` | Where models and assets are stored |
|
|
259
|
+
| `swarmRelays` | `string[]` | `[]` | Hyperswarm relay public keys for P2P |
|
|
260
|
+
| `loggerLevel` | `string` | `"info"` | Log level: `"error"`, `"warn"`, `"info"`, `"debug"` |
|
|
261
|
+
| `loggerConsoleOutput` | `boolean` | `true` | Enable/disable console output |
|
|
262
|
+
| `httpDownloadConcurrency` | `number` | `3` | Max concurrent HTTP downloads for sharded models |
|
|
263
|
+
| `httpConnectionTimeoutMs` | `number` | `10000` | HTTP connection timeout in milliseconds |
|
|
264
|
+
|
|
265
|
+
- Config usage example: [`examples/default-config-usage.ts`](examples/default-config-usage.ts)
|
|
298
266
|
|
|
299
|
-
|
|
300
|
-
- Load models from local filesystem: [`examples/llamacpp-filesystem.ts`](examples/llamacpp-filesystem.ts)
|
|
267
|
+
### Download Lifecycle
|
|
301
268
|
|
|
302
|
-
|
|
269
|
+
- Pause and resume download: [`examples/download-with-cancel.ts`](examples/download-with-cancel.ts)
|
|
303
270
|
|
|
304
271
|
### Blind Relays
|
|
305
272
|
|
|
306
273
|
Blind relays help establish peer connections through NAT/firewalls by routing traffic through relay nodes.
|
|
307
274
|
|
|
308
275
|
- Model downloads via Hyperdrive: [`examples/download-with-blind-relays.ts`](./examples/download-with-blind-relays.ts)
|
|
309
|
-
- Delegated inference: You can reuse the same pattern for delegated inference by
|
|
276
|
+
- Delegated inference: You can reuse the same pattern for delegated inference by adding `swarmRelays` to your config file before starting your provider/consumer.
|
|
277
|
+
|
|
278
|
+
> [!NOTE]
|
|
279
|
+
> The examples use mock relay keys. For real deployments, you **must** use your own relay servers or trusted public relays.
|
|
280
|
+
|
|
281
|
+
### Sharded Models
|
|
282
|
+
|
|
283
|
+
Sharded models are split into multiple files following the pattern: `<name>-00001-of-0000X.<ext>`. The SDK automatically downloads and loads all parts with detailed progress tracking.
|
|
284
|
+
|
|
285
|
+
**Supported formats:**
|
|
286
|
+
|
|
287
|
+
- Archives (`.tar`, `.tar.gz`, `.tgz`): HTTP or local with automatic extraction
|
|
288
|
+
- HTTP sharded URL: pass the download URL of any shard and the SDK will fetch the remaining shards
|
|
289
|
+
- Hyperdrive: use any sharded Hyperdrive model source
|
|
290
|
+
- Local shards: pass the path to any shard file. _(Note: All shards must be in the same directory)_
|
|
291
|
+
|
|
292
|
+
See: [`examples/llamacpp-sharded.ts`](examples/llamacpp-sharded.ts)
|
|
293
|
+
|
|
294
|
+
## Basic flow
|
|
295
|
+
|
|
296
|
+
```mermaid
|
|
297
|
+
sequenceDiagram
|
|
298
|
+
participant User as User
|
|
299
|
+
participant SDK as QVAC SDK
|
|
300
|
+
participant RPC as RPC Client (singleton)
|
|
301
|
+
participant Worker as Bare Worker (singleton)
|
|
302
|
+
|
|
303
|
+
User->>SDK: Call loadModel("llama-3", options)
|
|
304
|
+
SDK->>RPC: Create runtime-specific RPC client
|
|
305
|
+
RPC->>Worker: Spawn worker (if needed) and send loadModel request
|
|
306
|
+
Worker->>Worker: Download and load model into memory
|
|
307
|
+
Worker->>RPC: Return success response
|
|
308
|
+
RPC->>SDK: Model loaded successfully
|
|
309
|
+
SDK->>User: loadModel() resolves with modelId
|
|
310
|
+
```
|
|
310
311
|
|
|
311
312
|
**Note**: The example uses mock relay keys. In real deployments, you **must** use your own relay servers or trusted public relays.
|
|
312
313
|
|
|
313
|
-
|
|
314
|
+
### Hot Config Reload
|
|
315
|
+
|
|
316
|
+
Hot config reload allows you to update model configurations on-the-fly without unloading the model. Pass `modelId` (instead of `modelSrc`) to `loadModel` with the `modelType` and new `modelConfig` to apply changes instantly.
|
|
317
|
+
|
|
318
|
+
- Config reload using whisper: [`examples/config-reload.ts`](examples/config-reload.ts)
|
|
319
|
+
|
|
320
|
+
**Note**: Config reload is currently supported for Whisper models. All config parameters except `contextParams` (GPU settings, flash attention) can be hot reloaded. `contextParams` are load-time only and require full model reload. More model types coming soon.
|
|
321
|
+
|
|
322
|
+
## Contributing
|
|
323
|
+
|
|
324
|
+
### Commit Message and PR Title Format
|
|
325
|
+
|
|
326
|
+
This repository enforces structured commit messages and PR titles to maintain consistency and generate changelogs automatically.
|
|
327
|
+
|
|
328
|
+
#### Format
|
|
329
|
+
|
|
330
|
+
**Commit messages:**
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
prefix[tags]?: subject
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**PR titles:**
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
TICKET prefix[tags]: subject
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
#### Allowed Prefixes
|
|
343
|
+
|
|
344
|
+
- `feat` - New features or capabilities
|
|
345
|
+
- `fix` - Bug fixes
|
|
346
|
+
- `doc` - Documentation changes
|
|
347
|
+
- `test` - Test additions or modifications
|
|
348
|
+
- `mod` - Model-related changes
|
|
349
|
+
- `chore` - Maintenance tasks
|
|
350
|
+
- `infra` - CI/CD, tooling, infrastructure
|
|
351
|
+
|
|
352
|
+
#### Allowed Tags
|
|
353
|
+
|
|
354
|
+
Tags are optional:
|
|
355
|
+
|
|
356
|
+
- `[api]` - API changes (non-breaking)
|
|
357
|
+
- `[bc]` - Breaking changes (including breaking API changes)
|
|
358
|
+
|
|
359
|
+
#### Examples
|
|
360
|
+
|
|
361
|
+
**Valid commit messages:**
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
feat: add RAG support for LanceDB
|
|
365
|
+
fix[api]: fix completion stream error handling
|
|
366
|
+
doc: update installation instructions
|
|
367
|
+
feat[bc]: redesign loadModel signature
|
|
368
|
+
chore: update dependencies
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Valid PR titles:**
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
QVAC-123 feat: add RAG support for LanceDB
|
|
375
|
+
QVAC-456 fix[api]: fix completion stream error handling
|
|
376
|
+
QVAC-789 doc: update installation instructions
|
|
377
|
+
QVAC-101 feat[bc]: redesign loadModel signature
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
#### Code Examples Requirements
|
|
381
|
+
|
|
382
|
+
When creating PRs with specific tags, you must include code examples in the PR description:
|
|
383
|
+
|
|
384
|
+
**`[bc]` tag requirements:**
|
|
385
|
+
|
|
386
|
+
Must include BEFORE/AFTER code examples showing the migration path:
|
|
387
|
+
|
|
388
|
+
````markdown
|
|
389
|
+
## BC Changes
|
|
390
|
+
|
|
391
|
+
**BEFORE:**
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
const model = await loadModel("model-path");
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**AFTER:**
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
const modelId = await loadModel("model-path", { modelType: "llm" });
|
|
401
|
+
```
|
|
402
|
+
````
|
|
403
|
+
|
|
404
|
+
Or using inline comments:
|
|
405
|
+
|
|
406
|
+
````markdown
|
|
407
|
+
```typescript
|
|
408
|
+
// old
|
|
409
|
+
const model = await loadModel("model-path");
|
|
410
|
+
|
|
411
|
+
// new
|
|
412
|
+
const modelId = await loadModel("model-path", { modelType: "llm" });
|
|
413
|
+
```
|
|
414
|
+
````
|
|
415
|
+
|
|
416
|
+
**`[api]` tag requirements (non-breaking):**
|
|
417
|
+
|
|
418
|
+
Must include at least one fenced code block showing the new API usage:
|
|
419
|
+
|
|
420
|
+
````markdown
|
|
421
|
+
## New API
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
// New completion API with streaming support
|
|
425
|
+
for await (const token of completion({
|
|
426
|
+
modelId,
|
|
427
|
+
history: [{ role: "user", content: "Hello!" }],
|
|
428
|
+
}).tokenStream) {
|
|
429
|
+
process.stdout.write(token);
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
````
|
|
433
|
+
|
|
434
|
+
#### Validation
|
|
435
|
+
|
|
436
|
+
- **Commit messages** are validated automatically via Husky commit-msg hook
|
|
437
|
+
- **PR titles and descriptions** are validated via GitHub Actions on PR creation/update
|
|
438
|
+
- Invalid commits or PRs will be rejected with helpful error messages
|
|
439
|
+
- **Auto-skipped commits:** The following Git-generated commits bypass validation:
|
|
440
|
+
- Merge commits (e.g., `Merge pull request #123`)
|
|
441
|
+
- Version bumps (e.g., `1.0.0`, `v1.0.0`)
|
|
442
|
+
- Revert commits (e.g., `Revert "feat: add feature"`)
|
|
443
|
+
- Squash commits (e.g., `squash! fix: bug fix`)
|
|
444
|
+
|
|
445
|
+
#### Generating Changelogs
|
|
446
|
+
|
|
447
|
+
Once your PRs are merged into `dev`, you can generate a changelog:
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
npm run changelog:generate
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
This will:
|
|
454
|
+
|
|
455
|
+
1. Compare versions between `dev` and `main` branches
|
|
456
|
+
2. Collect all merged PRs
|
|
457
|
+
3. Parse and classify each PR by prefix
|
|
458
|
+
4. Generate `changelog/<version>/CHANGELOG.md`
|
|
459
|
+
5. Generate `changelog/<version>/breaking.md` for BC changes (with code examples)
|
|
460
|
+
6. Generate `changelog/<version>/api.md` for API changes (with code examples)
|
|
461
|
+
|
|
462
|
+
**Note:** Requires a GitHub token (`GITHUB_TOKEN` or `GH_TOKEN` environment variable) to fetch PR metadata.
|
|
463
|
+
|
|
464
|
+
## Build
|
|
465
|
+
|
|
466
|
+
Use the [Bun](https://bun.sh/) package manager:
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
bun i
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
bun run build # or `watch` for hotreload
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
```bash
|
|
477
|
+
bun run build:pack
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
This outputs a tarball under `dist/qvac-sdk-{version}.tgz` that you can install in your project, e.g.:
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
npm i path/to/qvac-sdk-0.3.0.tgz
|
|
484
|
+
```
|
|
314
485
|
|
|
315
|
-
|
|
316
|
-
- Add a `process.exit()` call at the end, we're working on it.
|
|
486
|
+
## More Resources
|
|
317
487
|
|
|
318
|
-
-
|
|
319
|
-
|
|
320
|
-
- Open the `ios` folder in Xcode
|
|
321
|
-
- Start the app with the play ▶️ button
|
|
322
|
-
- View -> Debug area -> Activate console
|
|
323
|
-
- You should see the system logs on the right pane
|
|
324
|
-
- ⚠️ This only works when starting the app from Xcode
|
|
488
|
+
- [Comprehensive documentation of this SDK](https://qvac.tether.dev/docs/sdk)
|
|
489
|
+
- [Package at NPM](https://www.npmjs.com/package/@qvac/sdk)
|