@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
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { loadModel, unloadModel, GTE_LARGE_FP16,
|
|
1
|
+
import { loadModel, unloadModel, GTE_LARGE_FP16, ragIngest, ragSearch, ragCloseWorkspace, } from "@qvac/sdk";
|
|
2
2
|
try {
|
|
3
3
|
// Get query from command line or use default
|
|
4
4
|
const query = process.argv[2] || "machine learning algorithms";
|
|
5
|
+
const workspace = "ingest-example";
|
|
5
6
|
console.log(`🔍 Query: "${query}"`);
|
|
6
7
|
const modelId = await loadModel({
|
|
7
8
|
modelSrc: GTE_LARGE_FP16,
|
|
@@ -20,16 +21,18 @@ try {
|
|
|
20
21
|
"Cloud computing delivers computing services over the internet, allowing users to access resources like storage, processing power, and applications on-demand from anywhere.",
|
|
21
22
|
"Cybersecurity protects digital systems, networks, and data from malicious attacks, unauthorized access, and various forms of cyber threats through multiple layers of defense.",
|
|
22
23
|
];
|
|
23
|
-
console.log("📚
|
|
24
|
-
const
|
|
24
|
+
console.log("📚 Ingesting documents...");
|
|
25
|
+
const result = await ragIngest({
|
|
25
26
|
modelId,
|
|
27
|
+
workspace,
|
|
26
28
|
documents: samples,
|
|
27
29
|
chunk: false,
|
|
28
30
|
});
|
|
29
|
-
console.log(
|
|
31
|
+
console.log(`✅ Ingested ${result.processed.length} documents`);
|
|
30
32
|
console.log("🔎 Searching for similar documents...");
|
|
31
33
|
const results = await ragSearch({
|
|
32
34
|
modelId,
|
|
35
|
+
workspace,
|
|
33
36
|
query,
|
|
34
37
|
topK: 3,
|
|
35
38
|
});
|
|
@@ -41,6 +44,9 @@ try {
|
|
|
41
44
|
console.log("=".repeat(100));
|
|
42
45
|
console.log();
|
|
43
46
|
});
|
|
47
|
+
// Cleanup: close and delete workspace
|
|
48
|
+
await ragCloseWorkspace({ workspace, deleteOnClose: true });
|
|
49
|
+
console.log(`\n🗑️ Deleted '${workspace}' workspace`);
|
|
44
50
|
await unloadModel({ modelId });
|
|
45
51
|
}
|
|
46
52
|
catch (error) {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { loadModel, unloadModel, embed, GTE_LARGE_FP16, ragChunk, ragSaveEmbeddings, ragSearch, ragCloseWorkspace, } from "@qvac/sdk";
|
|
2
|
+
try {
|
|
3
|
+
// Get query from command line or use default
|
|
4
|
+
const query = process.argv[2] || "machine learning algorithms";
|
|
5
|
+
console.log("🔧 RAG Pipeline Example (Segregated Flow)\n");
|
|
6
|
+
console.log(`🔍 Query: "${query}"`);
|
|
7
|
+
const workspace = "pipeline-example";
|
|
8
|
+
const modelId = await loadModel({
|
|
9
|
+
modelSrc: GTE_LARGE_FP16,
|
|
10
|
+
modelType: "embeddings",
|
|
11
|
+
onProgress: (progress) => {
|
|
12
|
+
console.log(`Loading model... ${progress.percentage.toFixed(1)}%`);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
const samples = [
|
|
16
|
+
"Machine learning is a subset of artificial intelligence that focuses on algorithms that can learn and make predictions from data without being explicitly programmed for every task.",
|
|
17
|
+
"Deep learning uses neural networks with multiple layers to process and learn from complex data patterns, enabling breakthroughs in image recognition and natural language processing.",
|
|
18
|
+
"Natural language processing combines computational linguistics with machine learning to help computers understand, interpret, and generate human language in a meaningful way.",
|
|
19
|
+
"Computer vision enables machines to interpret and understand visual information from the world, using techniques like image classification, object detection, and facial recognition.",
|
|
20
|
+
"Quantum computing leverages quantum mechanical phenomena to process information in fundamentally different ways than classical computers, potentially solving certain problems exponentially faster.",
|
|
21
|
+
"Blockchain technology creates decentralized, immutable ledgers that enable secure peer-to-peer transactions without requiring a central authority or intermediary.",
|
|
22
|
+
"Cloud computing delivers computing services over the internet, allowing users to access resources like storage, processing power, and applications on-demand from anywhere.",
|
|
23
|
+
"Cybersecurity protects digital systems, networks, and data from malicious attacks, unauthorized access, and various forms of cyber threats through multiple layers of defense.",
|
|
24
|
+
];
|
|
25
|
+
console.log("\n📝 Step 1: Chunking documents...");
|
|
26
|
+
const chunks = await ragChunk({
|
|
27
|
+
documents: samples,
|
|
28
|
+
chunkOpts: {
|
|
29
|
+
chunkSize: 128,
|
|
30
|
+
chunkOverlap: 20,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
console.log(` Created ${chunks.length} chunks`);
|
|
34
|
+
console.log("\n🧠 Step 2: Generating embeddings (batch)...");
|
|
35
|
+
const texts = chunks.map((chunk) => chunk.content);
|
|
36
|
+
const embeddings = await embed({ modelId, text: texts });
|
|
37
|
+
const embeddedDocs = chunks.map((chunk, i) => ({
|
|
38
|
+
id: chunk.id,
|
|
39
|
+
content: chunk.content,
|
|
40
|
+
embedding: embeddings[i],
|
|
41
|
+
embeddingModelId: modelId,
|
|
42
|
+
}));
|
|
43
|
+
console.log(` Generated ${embeddedDocs.length} embeddings`);
|
|
44
|
+
console.log("\n💾 Step 3: Saving to vector database...");
|
|
45
|
+
const saveResult = await ragSaveEmbeddings({
|
|
46
|
+
workspace,
|
|
47
|
+
documents: embeddedDocs,
|
|
48
|
+
});
|
|
49
|
+
const saved = saveResult.filter((r) => r.status === "fulfilled").length;
|
|
50
|
+
console.log(` Saved ${saved}/${saveResult.length} documents`);
|
|
51
|
+
console.log("\n🔎 Step 4: Searching...");
|
|
52
|
+
const results = await ragSearch({
|
|
53
|
+
workspace,
|
|
54
|
+
modelId,
|
|
55
|
+
query,
|
|
56
|
+
topK: 3,
|
|
57
|
+
});
|
|
58
|
+
console.log("\n📋 Top 3 most similar documents:");
|
|
59
|
+
results.forEach((result, index) => {
|
|
60
|
+
console.log("=".repeat(50) + " Top result:");
|
|
61
|
+
console.log(`\n${index + 1}. (Score: ${result.score})`);
|
|
62
|
+
console.log(` ${result.content}`);
|
|
63
|
+
console.log("=".repeat(100));
|
|
64
|
+
console.log();
|
|
65
|
+
});
|
|
66
|
+
// Cleanup: close and delete workspace
|
|
67
|
+
await ragCloseWorkspace({ workspace, deleteOnClose: true });
|
|
68
|
+
console.log(`🗑️ Deleted '${workspace}' workspace`);
|
|
69
|
+
await unloadModel({ modelId });
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error("❌ Error:", error);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { loadModel, unloadModel, GTE_LARGE_FP16, ragIngest, ragSearch, ragDeleteEmbeddings, ragListWorkspaces, ragCloseWorkspace, ragReindex, } from "@qvac/sdk";
|
|
2
|
+
try {
|
|
3
|
+
console.log("🚀 RAG Workspaces with Chunking Example\n");
|
|
4
|
+
// Load model
|
|
5
|
+
const modelId = await loadModel({
|
|
6
|
+
modelSrc: GTE_LARGE_FP16,
|
|
7
|
+
modelType: "embeddings",
|
|
8
|
+
onProgress: (p) => process.stdout.write(`\rLoading: ${Math.round(p.percentage * 100)}%`),
|
|
9
|
+
});
|
|
10
|
+
console.log("\n");
|
|
11
|
+
// Medical articles (will be chunked)
|
|
12
|
+
const medicalArticles = [
|
|
13
|
+
`COVID-19: A Comprehensive Overview
|
|
14
|
+
|
|
15
|
+
COVID-19 is a respiratory illness caused by the SARS-CoV-2 virus, first identified in December 2019
|
|
16
|
+
in Wuhan, China. The virus spreads primarily through respiratory droplets when an infected person
|
|
17
|
+
coughs, sneezes, or talks.
|
|
18
|
+
|
|
19
|
+
Common symptoms include fever, cough, fatigue, and loss of taste or smell. Some patients may
|
|
20
|
+
experience shortness of breath, muscle aches, sore throat, and headaches. Symptoms typically
|
|
21
|
+
appear 2-14 days after exposure to the virus.
|
|
22
|
+
|
|
23
|
+
Vaccines have been developed using various technologies including mRNA, viral vector, and
|
|
24
|
+
inactivated virus approaches. These vaccines have proven effective in preventing severe illness,
|
|
25
|
+
hospitalization, and death. Booster doses are recommended to maintain immunity.
|
|
26
|
+
|
|
27
|
+
Treatment options vary based on severity. Mild cases often require only supportive care including
|
|
28
|
+
rest and hydration. Severe cases may require hospitalization, oxygen therapy, and antiviral
|
|
29
|
+
medications such as remdesivir or Paxlovid.`,
|
|
30
|
+
`Diabetes Management and Prevention
|
|
31
|
+
|
|
32
|
+
Diabetes is a chronic condition affecting how your body processes blood sugar. Type 1 diabetes
|
|
33
|
+
occurs when the immune system attacks insulin-producing cells. Type 2 diabetes develops when
|
|
34
|
+
the body becomes resistant to insulin or doesn't produce enough.
|
|
35
|
+
|
|
36
|
+
Prevention strategies for Type 2 diabetes include maintaining a healthy weight, regular physical
|
|
37
|
+
activity, and a balanced diet rich in whole grains, vegetables, and lean proteins. Regular
|
|
38
|
+
monitoring of blood glucose levels is essential for managing the condition.
|
|
39
|
+
|
|
40
|
+
Treatment may include lifestyle modifications, oral medications, and insulin therapy. Complications
|
|
41
|
+
can affect the heart, kidneys, eyes, and nervous system if blood sugar is not well controlled.`,
|
|
42
|
+
`Heart Disease: Risk Factors and Prevention
|
|
43
|
+
|
|
44
|
+
Cardiovascular disease remains the leading cause of death worldwide. Risk factors include high
|
|
45
|
+
blood pressure, high cholesterol, smoking, obesity, diabetes, and physical inactivity.
|
|
46
|
+
|
|
47
|
+
Prevention involves adopting a heart-healthy lifestyle: regular exercise, a diet low in saturated
|
|
48
|
+
fats and sodium, maintaining a healthy weight, and avoiding tobacco. Regular check-ups can help
|
|
49
|
+
detect problems early.
|
|
50
|
+
|
|
51
|
+
Treatment options range from lifestyle changes and medications to surgical interventions like
|
|
52
|
+
angioplasty, stent placement, or bypass surgery depending on severity.`,
|
|
53
|
+
`Mental Health and Wellness
|
|
54
|
+
|
|
55
|
+
Mental health encompasses emotional, psychological, and social well-being. Common conditions
|
|
56
|
+
include anxiety disorders, depression, bipolar disorder, and schizophrenia. These affect
|
|
57
|
+
thinking, mood, and behavior.
|
|
58
|
+
|
|
59
|
+
Treatment typically involves a combination of psychotherapy, medication, and lifestyle changes.
|
|
60
|
+
Cognitive behavioral therapy has proven effective for many conditions. Support systems and
|
|
61
|
+
stress management techniques are crucial components of recovery.
|
|
62
|
+
|
|
63
|
+
Early intervention improves outcomes significantly. Reducing stigma around mental health
|
|
64
|
+
encourages people to seek help when needed.`,
|
|
65
|
+
];
|
|
66
|
+
// Tech documents (shorter, won't be chunked)
|
|
67
|
+
const techDocs = [
|
|
68
|
+
"Artificial intelligence is transforming industries through automation and advanced data analysis capabilities.",
|
|
69
|
+
"Deep learning neural networks enable breakthroughs in computer vision and natural language processing.",
|
|
70
|
+
];
|
|
71
|
+
// Ingest medical articles with chunking
|
|
72
|
+
console.log("📚 Ingesting medical articles with chunking...");
|
|
73
|
+
const medicalResult = await ragIngest({
|
|
74
|
+
modelId,
|
|
75
|
+
workspace: "medical",
|
|
76
|
+
documents: medicalArticles,
|
|
77
|
+
chunk: true,
|
|
78
|
+
chunkOpts: {
|
|
79
|
+
chunkSize: 50,
|
|
80
|
+
chunkOverlap: 10,
|
|
81
|
+
chunkStrategy: "paragraph",
|
|
82
|
+
splitStrategy: "token",
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
console.log(`✅ Created ${medicalResult.processed.length} chunks from medical articles`);
|
|
86
|
+
// Ingest tech docs without chunking
|
|
87
|
+
console.log("\n📚 Ingesting tech documents...");
|
|
88
|
+
const techResult = await ragIngest({
|
|
89
|
+
modelId,
|
|
90
|
+
workspace: "technology",
|
|
91
|
+
documents: techDocs,
|
|
92
|
+
chunk: false,
|
|
93
|
+
});
|
|
94
|
+
console.log(`✅ Ingested ${techResult.processed.length} tech documents`);
|
|
95
|
+
// Test searches
|
|
96
|
+
const searches = [
|
|
97
|
+
{ workspace: "medical", query: "COVID symptoms fever", label: "Medical" },
|
|
98
|
+
{ workspace: "medical", query: "vaccine technology", label: "Medical" },
|
|
99
|
+
{ workspace: "technology", query: "neural networks", label: "Tech" },
|
|
100
|
+
{ workspace: "technology", query: "COVID", label: "Tech (isolation test)" },
|
|
101
|
+
];
|
|
102
|
+
console.log("\n🔍 Running searches:");
|
|
103
|
+
for (const { workspace, query, label } of searches) {
|
|
104
|
+
const results = await ragSearch({ modelId, workspace, query, topK: 1 });
|
|
105
|
+
console.log(`\n${label}: "${query}"`);
|
|
106
|
+
if (results.length > 0 && results[0]) {
|
|
107
|
+
console.log(` ✓ Score: ${results[0].score.toFixed(3)}`);
|
|
108
|
+
console.log(` ✓ Match: ${results[0].content.substring(0, 80)}...`);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
console.log(` ✗ No results (workspace isolation working correctly)`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Test a third workspace
|
|
115
|
+
console.log("\n📁 Testing 'general' workspace...");
|
|
116
|
+
await ragIngest({
|
|
117
|
+
modelId,
|
|
118
|
+
workspace: "general",
|
|
119
|
+
documents: ["General workspace content for testing"],
|
|
120
|
+
chunk: false,
|
|
121
|
+
});
|
|
122
|
+
const generalSearch = await ragSearch({
|
|
123
|
+
modelId,
|
|
124
|
+
workspace: "general",
|
|
125
|
+
query: "general workspace",
|
|
126
|
+
});
|
|
127
|
+
console.log(`General workspace: ${generalSearch?.[0]?.content === "General workspace content for testing" ? "✅ Working" : "❌ Failed"}`);
|
|
128
|
+
// Reindexing - regenerate embeddings for an existing workspace
|
|
129
|
+
console.log("\n🔄 Reindexing medical workspace...");
|
|
130
|
+
const reindexResult = await ragReindex({
|
|
131
|
+
workspace: "medical",
|
|
132
|
+
modelId,
|
|
133
|
+
onProgress: (stage, current, total) => {
|
|
134
|
+
const pct = total > 0 ? Math.round((current / total) * 100) : 0;
|
|
135
|
+
console.log(` [${stage}] ${current}/${total} (${pct}%)`);
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
console.log(`${reindexResult.reindexed ? "✅ Reindex completed" : "⚠️ Reindex returned false"} for medical workspace`);
|
|
139
|
+
if (reindexResult.details) {
|
|
140
|
+
console.log(" Details:", reindexResult.details);
|
|
141
|
+
}
|
|
142
|
+
// Verify reindexed data still works
|
|
143
|
+
const reindexVerify = await ragSearch({
|
|
144
|
+
modelId,
|
|
145
|
+
workspace: "medical",
|
|
146
|
+
query: "COVID symptoms",
|
|
147
|
+
topK: 1,
|
|
148
|
+
});
|
|
149
|
+
console.log(` Verification search: ${reindexVerify.length > 0 ? "✅ Working" : "❌ Failed"}`);
|
|
150
|
+
// Cleanup example
|
|
151
|
+
const firstChunk = medicalResult.processed.find((p) => p.status === "fulfilled" && p.id);
|
|
152
|
+
if (firstChunk?.id) {
|
|
153
|
+
await ragDeleteEmbeddings({
|
|
154
|
+
workspace: "medical",
|
|
155
|
+
ids: [firstChunk.id],
|
|
156
|
+
});
|
|
157
|
+
console.log("\n🗑️ Deleted one medical chunk");
|
|
158
|
+
}
|
|
159
|
+
// List all workspaces
|
|
160
|
+
console.log("\n📂 Listing workspaces...");
|
|
161
|
+
const workspaces = await ragListWorkspaces();
|
|
162
|
+
workspaces.forEach((ws) => {
|
|
163
|
+
console.log(` • ${ws.name} (${ws.open ? "open" : "closed"})`);
|
|
164
|
+
});
|
|
165
|
+
// Close and delete all workspaces created in this example
|
|
166
|
+
console.log("\n🗑️ Closing and deleting workspaces...");
|
|
167
|
+
await ragCloseWorkspace({ workspace: "medical", deleteOnClose: true });
|
|
168
|
+
console.log("Deleted 'medical' workspace");
|
|
169
|
+
await ragCloseWorkspace({ workspace: "technology", deleteOnClose: true });
|
|
170
|
+
console.log("Deleted 'technology' workspace");
|
|
171
|
+
await ragCloseWorkspace({ workspace: "general", deleteOnClose: true });
|
|
172
|
+
console.log("Deleted 'general' workspace");
|
|
173
|
+
await unloadModel({ modelId });
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
console.error("❌ Error:", error);
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { loadModel, translate, unloadModel, BERGAMOT_ENFR } from "@qvac/sdk";
|
|
2
|
+
try {
|
|
3
|
+
const modelId = await loadModel({
|
|
4
|
+
modelSrc: BERGAMOT_ENFR,
|
|
5
|
+
modelType: "nmt",
|
|
6
|
+
modelConfig: {
|
|
7
|
+
engine: "Bergamot",
|
|
8
|
+
from: "en",
|
|
9
|
+
to: "fr",
|
|
10
|
+
beamsize: 1,
|
|
11
|
+
normalize: 1,
|
|
12
|
+
temperature: 0.2,
|
|
13
|
+
norepeatngramsize: 3,
|
|
14
|
+
lengthpenalty: 1.2,
|
|
15
|
+
},
|
|
16
|
+
onProgress: (progress) => {
|
|
17
|
+
console.log(progress);
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
console.log(`✅ Bergamot model loaded: ${modelId}`);
|
|
21
|
+
// Test with array of texts for batch processing
|
|
22
|
+
const texts = [
|
|
23
|
+
"Hello world",
|
|
24
|
+
"How are you today?",
|
|
25
|
+
"This is a test of batch translation",
|
|
26
|
+
"The weather is nice",
|
|
27
|
+
];
|
|
28
|
+
console.log("\n📝 Translating batch of texts:");
|
|
29
|
+
texts.forEach((text, i) => console.log(` ${i + 1}. ${text}`));
|
|
30
|
+
const result = translate({
|
|
31
|
+
modelId,
|
|
32
|
+
text: texts, // Pass array for batch processing
|
|
33
|
+
modelType: "nmt",
|
|
34
|
+
stream: false,
|
|
35
|
+
});
|
|
36
|
+
const translatedText = await result.text;
|
|
37
|
+
const translations = translatedText.split("\n");
|
|
38
|
+
console.log("\n✅ Translations:");
|
|
39
|
+
translations.forEach((translation, i) => {
|
|
40
|
+
if (i < texts.length) {
|
|
41
|
+
console.log(` ${i + 1}. ${texts[i]} -> "${translation}"`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
await unloadModel({ modelId });
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
console.error("❌ Error:", error);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { loadModel, translate, unloadModel, BERGAMOT_ENFR } from "@qvac/sdk";
|
|
2
|
+
try {
|
|
3
|
+
// Bergamot models automatically derive vocabulary files from the model source
|
|
4
|
+
// when using pear:// URLs. You can still override them explicitly if needed:
|
|
5
|
+
// - srcVocabSrc: source vocabulary file (optional)
|
|
6
|
+
// - dstVocabSrc: target vocabulary file (optional)
|
|
7
|
+
const modelId = await loadModel({
|
|
8
|
+
modelSrc: BERGAMOT_ENFR,
|
|
9
|
+
modelType: "nmt",
|
|
10
|
+
modelConfig: {
|
|
11
|
+
engine: "Bergamot",
|
|
12
|
+
from: "en",
|
|
13
|
+
to: "fr",
|
|
14
|
+
beamsize: 1,
|
|
15
|
+
normalize: 1,
|
|
16
|
+
temperature: 0.2,
|
|
17
|
+
norepeatngramsize: 3,
|
|
18
|
+
lengthpenalty: 1.2,
|
|
19
|
+
},
|
|
20
|
+
onProgress: (progress) => {
|
|
21
|
+
console.log(progress);
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
console.log(`✅ Bergamot model loaded: ${modelId}`);
|
|
25
|
+
const text = "This is a test of the Bergamot translation model.";
|
|
26
|
+
const result = translate({
|
|
27
|
+
modelId,
|
|
28
|
+
text,
|
|
29
|
+
modelType: "nmt",
|
|
30
|
+
stream: false,
|
|
31
|
+
});
|
|
32
|
+
const translatedText = await result.text;
|
|
33
|
+
console.log(`Translated text EN -> FR: ${text} -> "${translatedText}"`);
|
|
34
|
+
await unloadModel({ modelId });
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error("❌ Error:", error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
@@ -24,12 +24,9 @@ function withMobileBundle(config) {
|
|
|
24
24
|
throw new WorkerFileNotFoundError(workerPath);
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
|
-
// Truncate incompatible RPC clients for mobile
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"bare-rpc-client.js",
|
|
31
|
-
"bare-client.js",
|
|
32
|
-
];
|
|
27
|
+
// Truncate incompatible RPC clients for mobile
|
|
28
|
+
// Keep: rpc-client.js, expo-rpc-client.js, bare-client.js (needed for worker bundle)
|
|
29
|
+
const rpcClientsToTruncate = ["node-rpc-client.js"];
|
|
33
30
|
const truncatedContent = "// This RPC client is not available in mobile environments";
|
|
34
31
|
for (const clientFile of rpcClientsToTruncate) {
|
|
35
32
|
const clientPath = path.join(qvacSdkPath, "dist", "client", "rpc", clientFile);
|
|
@@ -38,9 +35,15 @@ function withMobileBundle(config) {
|
|
|
38
35
|
console.log(`🔧 QVAC: Truncated ${clientFile} for mobile compatibility`);
|
|
39
36
|
}
|
|
40
37
|
}
|
|
38
|
+
// Copy bare imports configuration for bare-pack
|
|
39
|
+
const bareImportsSource = path.join(qvacSdkPath, "bare-imports.json");
|
|
40
|
+
const importsMapPath = path.join(qvacSdkPath, "dist", "imports.json");
|
|
41
|
+
if (fs.existsSync(bareImportsSource)) {
|
|
42
|
+
fs.copyFileSync(bareImportsSource, importsMapPath);
|
|
43
|
+
console.log("🔧 QVAC: Copied bare-imports.json for mobile bundle");
|
|
44
|
+
}
|
|
41
45
|
// Remove optional modules from the bundle
|
|
42
46
|
const optionalModules = [
|
|
43
|
-
"crypto",
|
|
44
47
|
"expo-file-system",
|
|
45
48
|
"react-native-bare-kit",
|
|
46
49
|
"@qvac/sdk/worker.mobile.bundle",
|
|
@@ -48,9 +51,25 @@ function withMobileBundle(config) {
|
|
|
48
51
|
const deferFlags = optionalModules
|
|
49
52
|
.map((mod) => `--defer "${mod}"`)
|
|
50
53
|
.join(" ");
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
// Detect bare-pack version (v1.x uses --target, v2.x uses --host)
|
|
55
|
+
let platformFlag = "--host";
|
|
56
|
+
try {
|
|
57
|
+
const versionOutput = execSync(`npx bare-pack --version "${workerPath}"`, { cwd: projectRoot, encoding: "utf-8" }).trim();
|
|
58
|
+
const versionMatch = versionOutput.match(/v?(\d+)\./);
|
|
59
|
+
const majorVersion = versionMatch && versionMatch[1] ? parseInt(versionMatch[1], 10) : 2;
|
|
60
|
+
if (majorVersion < 2) {
|
|
61
|
+
platformFlag = "--target";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
throw new Error(`Failed to detect bare-pack version. Ensure bare-pack is installed: npm install bare-pack`, { cause: error });
|
|
66
|
+
}
|
|
67
|
+
const platforms = ["android-arm64", "ios-arm64", "ios-arm64-simulator"];
|
|
68
|
+
const platformFlags = platforms
|
|
69
|
+
.map((p) => `${platformFlag} ${p}`)
|
|
70
|
+
.join(" ");
|
|
71
|
+
// Generate the bundle using bare-pack with the current project's dependencies
|
|
72
|
+
execSync(`cd "${projectRoot}" && npx bare-pack ${platformFlags} --linked --imports "${importsMapPath}" ${deferFlags} --out "${outputPath}" "${workerPath}"`, { stdio: "inherit", cwd: projectRoot });
|
|
54
73
|
console.log("🫡 QVAC: Mobile worker bundle generated successfully");
|
|
55
74
|
}
|
|
56
75
|
catch (error) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings,
|
|
1
|
+
export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, } from "./client/api/index";
|
|
2
2
|
export { close } from "./client/index";
|
|
3
|
-
export { type ModelProgressUpdate, type LoadModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallError, type ToolCallEvent, type CompletionStats, VERBOSITY, type Attachment, type CompletionParams, type RagSearchResult, type RagSaveEmbeddingsResult, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, type
|
|
4
|
-
export { type ToolInput } from "./utils/tool-helpers";
|
|
3
|
+
export { type ModelProgressUpdate, type LoadModelOptions, type DownloadAssetOptions, type Tool, type ToolCall, type ToolCallWithCall, type ToolCallError, type ToolCallEvent, type CompletionStats, VERBOSITY, type Attachment, type CompletionParams, type RagSearchResult, type RagSaveEmbeddingsResult, type RagReindexResult, type RagEmbeddedDoc, type RagDoc, type RagWorkspaceInfo, type RagCloseWorkspaceParams, type RagDeleteWorkspaceParams, type RagIngestStage, type RagReindexStage, type RagSaveStage, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, type QvacConfig, type ModelInfo, type GetModelInfoParams, type LoadedInstance, type CacheFileInfo, toolSchema, type McpClient, type McpClientInput, type OCRClientParams, type OCRTextBlock, type OCROptions, } from "./schemas/index";
|
|
4
|
+
export { type ToolInput, type ToolHandler } from "./utils/tool-helpers";
|
|
5
|
+
export { PUBLIC_MODEL_TYPES as MODEL_TYPES } from "./schemas/index";
|
|
5
6
|
export * from "./models/hyperdrive/index";
|
|
6
7
|
export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio";
|
|
7
|
-
export { getLogger,
|
|
8
|
+
export { getLogger, SDK_LOG_ID } from "./logging/index";
|
|
8
9
|
export type { Logger, LogTransport, LoggerOptions } from "./logging/index";
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// Public API exports only
|
|
2
|
-
export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings,
|
|
2
|
+
export { completion, deleteCache, loadModel, downloadAsset, ping, startQVACProvider, stopQVACProvider, unloadModel, transcribe, transcribeStream, embed, translate, cancel, ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace, textToSpeech, getModelInfo, loggingStream, ocr, } from "./client/api/index.js";
|
|
3
3
|
export { close } from "./client/index.js";
|
|
4
4
|
export { VERBOSITY, SDK_CLIENT_ERROR_CODES, SDK_SERVER_ERROR_CODES, toolSchema, } from "./schemas/index.js";
|
|
5
5
|
export {} from "./utils/tool-helpers.js";
|
|
6
|
+
// Model types - canonical naming with backward-compatible aliases
|
|
7
|
+
export { PUBLIC_MODEL_TYPES as MODEL_TYPES } from "./schemas/index.js";
|
|
6
8
|
// Hyperdrive model constants
|
|
7
9
|
export * from "./models/hyperdrive/index.js";
|
|
8
10
|
export { SUPPORTED_AUDIO_FORMATS } from "./constants/audio.js";
|
|
9
11
|
// Logging exports
|
|
10
|
-
export { getLogger,
|
|
12
|
+
export { getLogger, SDK_LOG_ID } from "./logging/index.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Logger } from "./index";
|
|
2
|
+
export declare function registerAddonLogger(modelId: string, namespace: string, logger: Logger): void;
|
|
3
|
+
export declare function unregisterAddonLogger(modelId: string): void;
|
|
4
|
+
export declare function createAddonLoggerCallback(namespace: string): (priority: number, message: string) => void;
|
|
5
|
+
export declare function clearAllAddonLoggers(): void;
|
|
6
|
+
//# sourceMappingURL=addon.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { unregisterLogger } from "./registry.js";
|
|
2
|
+
// Map C++ addon priority (0-4) to SDK LogLevel
|
|
3
|
+
const PRIORITY_TO_LEVEL = {
|
|
4
|
+
0: "error",
|
|
5
|
+
1: "warn",
|
|
6
|
+
2: "info",
|
|
7
|
+
3: "debug",
|
|
8
|
+
4: "debug",
|
|
9
|
+
};
|
|
10
|
+
const ADDON_LOGGERS_KEY = Symbol.for("@qvac/sdk:addon-loggers");
|
|
11
|
+
const MODEL_LOGGERS_KEY = Symbol.for("@qvac/sdk:model-loggers");
|
|
12
|
+
function getAddonLoggers() {
|
|
13
|
+
const global = globalThis;
|
|
14
|
+
if (!global[ADDON_LOGGERS_KEY]) {
|
|
15
|
+
global[ADDON_LOGGERS_KEY] = new Map();
|
|
16
|
+
}
|
|
17
|
+
return global[ADDON_LOGGERS_KEY];
|
|
18
|
+
}
|
|
19
|
+
function getModelLoggers() {
|
|
20
|
+
const global = globalThis;
|
|
21
|
+
if (!global[MODEL_LOGGERS_KEY]) {
|
|
22
|
+
global[MODEL_LOGGERS_KEY] = new Map();
|
|
23
|
+
}
|
|
24
|
+
return global[MODEL_LOGGERS_KEY];
|
|
25
|
+
}
|
|
26
|
+
export function registerAddonLogger(modelId, namespace, logger) {
|
|
27
|
+
const addonLoggers = getAddonLoggers();
|
|
28
|
+
const modelLoggers = getModelLoggers();
|
|
29
|
+
if (!addonLoggers.has(namespace)) {
|
|
30
|
+
addonLoggers.set(namespace, new Set());
|
|
31
|
+
}
|
|
32
|
+
addonLoggers.get(namespace).add(logger);
|
|
33
|
+
modelLoggers.set(modelId, { namespace, logger });
|
|
34
|
+
}
|
|
35
|
+
export function unregisterAddonLogger(modelId) {
|
|
36
|
+
const addonLoggers = getAddonLoggers();
|
|
37
|
+
const modelLoggers = getModelLoggers();
|
|
38
|
+
const entry = modelLoggers.get(modelId);
|
|
39
|
+
if (entry) {
|
|
40
|
+
addonLoggers.get(entry.namespace)?.delete(entry.logger);
|
|
41
|
+
unregisterLogger(entry.logger);
|
|
42
|
+
modelLoggers.delete(modelId);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function routeLog(logger, level, message) {
|
|
46
|
+
switch (level) {
|
|
47
|
+
case "error":
|
|
48
|
+
logger.error(message);
|
|
49
|
+
break;
|
|
50
|
+
case "warn":
|
|
51
|
+
logger.warn(message);
|
|
52
|
+
break;
|
|
53
|
+
case "info":
|
|
54
|
+
logger.info(message);
|
|
55
|
+
break;
|
|
56
|
+
case "debug":
|
|
57
|
+
logger.debug(message);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function createAddonLoggerCallback(namespace) {
|
|
62
|
+
return (priority, message) => {
|
|
63
|
+
const loggers = getAddonLoggers().get(namespace);
|
|
64
|
+
if (!loggers || loggers.size === 0)
|
|
65
|
+
return;
|
|
66
|
+
const level = PRIORITY_TO_LEVEL[priority] ?? "debug";
|
|
67
|
+
for (const logger of loggers) {
|
|
68
|
+
routeLog(logger, level, message);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function clearAllAddonLoggers() {
|
|
73
|
+
getAddonLoggers().clear();
|
|
74
|
+
getModelLoggers().clear();
|
|
75
|
+
}
|