@qvac/sdk 0.8.1 → 1.0.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/LICENSE +24 -1
- package/README.md +191 -373
- package/dist/client/api/cancel.d.ts +4 -22
- package/dist/client/api/cancel.js +6 -25
- package/dist/client/api/completion-stream.d.ts +30 -24
- package/dist/client/api/completion-stream.js +70 -121
- package/dist/client/api/delete-cache.js +2 -3
- package/dist/client/api/download-asset.d.ts +5 -6
- package/dist/client/api/download-asset.js +20 -16
- package/dist/client/api/embed.d.ts +4 -21
- package/dist/client/api/embed.js +14 -4
- package/dist/client/api/index.d.ts +2 -6
- package/dist/client/api/index.js +2 -6
- package/dist/client/api/load-model.d.ts +21 -49
- package/dist/client/api/load-model.js +134 -40
- package/dist/client/api/logging-stream.d.ts +4 -7
- package/dist/client/api/logging-stream.js +5 -9
- package/dist/client/api/ping.d.ts +11 -0
- package/dist/client/api/ping.js +18 -0
- package/dist/client/api/provide.d.ts +1 -1
- package/dist/client/api/provide.js +3 -4
- package/dist/client/api/rag.d.ts +21 -216
- package/dist/client/api/rag.js +36 -396
- package/dist/client/api/stop-provider.d.ts +1 -1
- package/dist/client/api/stop-provider.js +3 -4
- package/dist/client/api/text-to-speech.d.ts +2 -2
- package/dist/client/api/text-to-speech.js +3 -3
- package/dist/client/api/transcribe.d.ts +5 -9
- package/dist/client/api/transcribe.js +9 -11
- package/dist/client/api/translate.d.ts +3 -3
- package/dist/client/api/translate.js +15 -15
- package/dist/client/api/unload-model.d.ts +1 -5
- package/dist/client/api/unload-model.js +4 -17
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/logging-stream-registry.d.ts +1 -1
- package/dist/client/logging-stream-registry.js +13 -14
- package/dist/client/rpc/bare-client.d.ts +139 -3
- package/dist/client/rpc/bare-client.js +16 -117
- package/dist/client/rpc/bare-rpc-client.d.ts +4 -0
- package/dist/client/rpc/bare-rpc-client.js +87 -0
- package/dist/client/rpc/expo-rpc-client.d.ts +1 -2
- package/dist/client/rpc/expo-rpc-client.js +14 -57
- package/dist/client/rpc/node-rpc-client.d.ts +8 -3
- package/dist/client/rpc/node-rpc-client.js +62 -218
- package/dist/client/rpc/rpc-client.d.ts +2 -3
- package/dist/client/rpc/rpc-client.js +49 -184
- package/dist/constants/audio.d.ts +2 -1
- package/dist/constants/audio.js +17 -1
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.js +0 -1
- package/dist/examples/delegated-inference/consumer.js +2 -3
- package/dist/examples/download-with-cancel.js +4 -3
- package/dist/examples/embed-hyperdrive.d.ts +2 -0
- package/dist/examples/embed-hyperdrive.js +19 -0
- package/dist/examples/kv-cache-cleanup.js +2 -1
- package/dist/examples/kv-cache-custom-key.js +2 -16
- package/dist/examples/kv-cache-example.js +2 -1
- package/dist/examples/llamacpp-file-logging.d.ts +2 -0
- package/dist/examples/{logging-file-transport.js → llamacpp-file-logging.js} +8 -3
- package/dist/examples/llamacpp-filesystem.js +2 -2
- package/dist/examples/llamacpp-http.js +1 -0
- package/dist/examples/llamacpp-hyperdrive.d.ts +2 -0
- package/dist/examples/{llamacpp-p2p.js → llamacpp-hyperdrive.js} +2 -1
- package/dist/examples/llamacpp-multimodal.js +4 -3
- package/dist/examples/llamacpp-native-tools.js +30 -72
- package/dist/examples/multi-model-demo.js +3 -2
- package/dist/examples/parallel-download.js +14 -46
- package/dist/examples/rag/rag-chromadb.js +1 -0
- package/dist/examples/rag/rag-hyperdb-workspaces.d.ts +2 -0
- package/dist/examples/rag/rag-hyperdb-workspaces.js +107 -0
- package/dist/examples/rag/rag-hyperdb.d.ts +2 -0
- package/dist/examples/rag/{rag-hyperdb/ingest.js → rag-hyperdb.js} +5 -10
- package/dist/examples/rag/rag-lancedb.js +1 -0
- package/dist/examples/rag/rag-sqlite.js +1 -0
- package/dist/examples/seed-hyperdrive.d.ts +2 -0
- package/dist/examples/text-to-speech.d.ts +3 -0
- package/dist/examples/{tts/utils.js → text-to-speech.js} +63 -18
- package/dist/examples/translation/translation-indic.js +1 -4
- package/dist/examples/translation/translation-llm-context.js +1 -0
- package/dist/examples/translation/translation-llm.js +2 -2
- package/dist/examples/translation/translation-opus.js +3 -6
- package/dist/examples/translation/translation-stream.js +3 -3
- package/dist/examples/whispercpp-filesystem.js +43 -0
- package/dist/examples/{transcription/whispercpp-microphone-record.js → whispercpp-microphone-record.js} +9 -8
- package/dist/expo/plugins/index.d.ts +0 -3
- package/dist/expo/plugins/index.js +0 -3
- package/dist/expo/plugins/withMobileBundle.d.ts +2 -5
- package/dist/expo/plugins/withMobileBundle.js +40 -121
- package/dist/expo/plugins/withQvacSDK.d.ts +0 -4
- package/dist/expo/plugins/withQvacSDK.js +1 -26
- package/dist/index.d.ts +4 -9
- package/dist/index.js +5 -11
- package/dist/logging/base-logger.js +16 -26
- package/dist/logging/index.d.ts +1 -7
- package/dist/logging/index.js +1 -7
- package/dist/logging/logger.d.ts +2 -0
- package/dist/logging/logger.js +6 -11
- package/dist/logging/stream-logger.d.ts +1 -1
- package/dist/logging/stream-logger.js +3 -6
- package/dist/logging/transport.js +2 -2
- package/dist/logging/types.d.ts +0 -2
- package/dist/logging/utils.d.ts +0 -2
- package/dist/logging/utils.js +0 -62
- package/dist/models/{registry → hyperdrive}/index.js +1 -1
- package/dist/models/hyperdrive/models.d.ts +619 -0
- package/dist/models/hyperdrive/models.js +693 -0
- package/dist/schemas/cancel.d.ts +0 -18
- package/dist/schemas/cancel.js +0 -7
- package/dist/schemas/common.d.ts +166 -3012
- package/dist/schemas/common.js +4 -27
- package/dist/schemas/completion-stream.d.ts +60 -31
- package/dist/schemas/completion-stream.js +44 -20
- package/dist/schemas/delegate.d.ts +0 -9
- package/dist/schemas/delegate.js +2 -6
- package/dist/schemas/download-asset.d.ts +3 -125
- package/dist/schemas/download-asset.js +5 -22
- package/dist/schemas/embed.d.ts +3 -3
- package/dist/schemas/embed.js +2 -9
- package/dist/schemas/index.d.ts +2 -20
- package/dist/schemas/index.js +2 -20
- package/dist/schemas/llamacpp-config.d.ts +12 -243
- package/dist/schemas/llamacpp-config.js +14 -50
- package/dist/schemas/load-model.d.ts +893 -14471
- package/dist/schemas/load-model.js +72 -325
- package/dist/schemas/logging-stream.d.ts +4 -11
- package/dist/schemas/logging-stream.js +3 -4
- package/dist/schemas/ping.d.ts +11 -0
- package/dist/schemas/ping.js +8 -0
- package/dist/schemas/rag.d.ts +52 -183
- package/dist/schemas/rag.js +23 -152
- package/dist/schemas/text-to-speech.d.ts +1 -692
- package/dist/schemas/text-to-speech.js +3 -35
- package/dist/schemas/transcription.d.ts +0 -3
- package/dist/schemas/transcription.js +0 -1
- package/dist/schemas/translate.d.ts +23 -68
- package/dist/schemas/translate.js +11 -37
- package/dist/schemas/translation-config.d.ts +7 -810
- package/dist/schemas/translation-config.js +7 -113
- package/dist/schemas/unload-model.d.ts +0 -2
- package/dist/schemas/unload-model.js +0 -2
- package/dist/schemas/whispercpp-config.d.ts +25 -0
- package/dist/schemas/whispercpp-config.js +18 -0
- package/dist/server/bare/{ops → addons}/cancel.js +1 -2
- package/dist/server/bare/addons/index.d.ts +4 -0
- package/dist/server/bare/addons/index.js +3 -0
- package/dist/server/bare/addons/llamacpp/create-model.d.ts +5 -0
- package/dist/server/bare/addons/llamacpp/create-model.js +67 -0
- package/dist/server/bare/{plugins/llamacpp-completion/ops → addons/llamacpp/handlers}/completion-stream.d.ts +1 -2
- package/dist/server/bare/{plugins/llamacpp-completion/ops → addons/llamacpp/handlers}/completion-stream.js +87 -54
- package/dist/server/bare/addons/llamacpp/handlers/embed.d.ts +4 -0
- package/dist/server/bare/{ops → addons/llamacpp/handlers}/embed.js +7 -22
- package/dist/server/bare/addons/llamacpp/index.d.ts +4 -0
- package/dist/server/bare/addons/llamacpp/index.js +3 -0
- package/dist/server/bare/{ops → addons/llamacpp}/kv-cache-utils.d.ts +1 -4
- package/dist/server/bare/{ops → addons/llamacpp}/kv-cache-utils.js +19 -54
- package/dist/server/bare/addons/load-model.d.ts +3 -0
- package/dist/server/bare/addons/load-model.js +62 -0
- package/dist/server/bare/addons/translation/create-model.d.ts +4 -0
- package/dist/server/bare/addons/translation/create-model.js +45 -0
- package/dist/server/bare/addons/translation/handlers/translate.d.ts +3 -0
- package/dist/server/bare/{ops → addons/translation/handlers}/translate.js +14 -47
- package/dist/server/bare/addons/translation/index.d.ts +3 -0
- package/dist/server/bare/addons/translation/index.js +2 -0
- package/dist/server/bare/addons/tts/create-model.d.ts +6 -0
- package/dist/server/bare/addons/tts/create-model.js +40 -0
- package/dist/server/bare/{plugins/onnx-tts/ops → addons/tts/handlers}/text-to-speech.js +3 -25
- package/dist/server/bare/addons/tts/index.d.ts +3 -0
- package/dist/server/bare/addons/tts/index.js +2 -0
- package/dist/server/bare/addons/unload-model.js +20 -0
- package/dist/server/bare/addons/whispercpp/create-model.d.ts +6 -0
- package/dist/server/bare/addons/whispercpp/create-model.js +55 -0
- package/dist/server/bare/addons/whispercpp/handlers/transcribe-stream.d.ts +3 -0
- package/dist/server/bare/addons/whispercpp/handlers/transcribe-stream.js +48 -0
- package/dist/server/bare/addons/whispercpp/index.d.ts +3 -0
- package/dist/server/bare/addons/whispercpp/index.js +2 -0
- package/dist/server/bare/delegate-rpc-client.d.ts +0 -6
- package/dist/server/bare/delegate-rpc-client.js +45 -187
- package/dist/server/bare/hyperswarm.d.ts +0 -3
- package/dist/server/bare/hyperswarm.js +6 -29
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.js +10 -9
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.d.ts +4 -7
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.js +14 -13
- package/dist/server/bare/rag-hyperdb/handlers/search.js +10 -10
- package/dist/server/bare/rag-hyperdb/index.d.ts +1 -8
- package/dist/server/bare/rag-hyperdb/index.js +1 -8
- package/dist/server/bare/rag-hyperdb/rag-manager.d.ts +5 -0
- package/dist/server/bare/rag-hyperdb/rag-manager.js +65 -0
- package/dist/server/bare/registry/logging-stream-registry.d.ts +7 -24
- package/dist/server/bare/registry/logging-stream-registry.js +20 -99
- package/dist/server/bare/registry/model-registry.d.ts +26 -16
- package/dist/server/bare/registry/model-registry.js +13 -34
- package/dist/server/error-handlers.d.ts +2 -3
- package/dist/server/error-handlers.js +10 -15
- package/dist/server/http-server.d.ts +2 -0
- package/dist/server/http-server.js +189 -0
- package/dist/server/rpc/create-server.js +3 -5
- package/dist/server/rpc/handle-request.d.ts +9 -0
- package/dist/server/rpc/handle-request.js +242 -92
- package/dist/server/rpc/handlers/cancelHandler.js +3 -14
- package/dist/server/rpc/handlers/completion-stream-delegated.d.ts +1 -3
- package/dist/server/rpc/handlers/completion-stream-delegated.js +8 -20
- package/dist/server/rpc/handlers/completion-stream.js +41 -2
- package/dist/server/rpc/handlers/delete-cache.js +2 -4
- package/dist/server/rpc/handlers/download-asset.js +6 -59
- package/dist/server/rpc/handlers/embed.js +19 -2
- package/dist/server/rpc/handlers/index.d.ts +0 -13
- package/dist/server/rpc/handlers/index.js +0 -13
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +11 -12
- package/dist/server/rpc/handlers/load-model/download-manager.js +28 -43
- package/dist/server/rpc/handlers/load-model/http.d.ts +1 -2
- package/dist/server/rpc/handlers/load-model/http.js +55 -424
- package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +1 -2
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +171 -364
- 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.d.ts +1 -3
- package/dist/server/rpc/handlers/load-model/resolve.js +29 -110
- package/dist/server/rpc/handlers/load-model-delegated.d.ts +2 -6
- package/dist/server/rpc/handlers/load-model-delegated.js +20 -60
- package/dist/server/rpc/handlers/{load-model/handler.d.ts → load-model.d.ts} +2 -2
- package/dist/server/rpc/handlers/load-model.js +57 -0
- package/dist/server/rpc/handlers/logging-stream.js +4 -4
- package/dist/server/rpc/handlers/provideHandler/connection.js +10 -12
- package/dist/server/rpc/handlers/provideHandler/handler.js +17 -20
- package/dist/server/rpc/handlers/provideHandler/proxy.js +6 -8
- package/dist/server/rpc/handlers/rag.d.ts +2 -2
- package/dist/server/rpc/handlers/rag.js +43 -130
- package/dist/server/rpc/handlers/stopProvideHandler.js +2 -6
- package/dist/server/rpc/handlers/text-to-speech.js +5 -2
- package/dist/server/rpc/handlers/transcribe-stream.js +24 -2
- package/dist/server/rpc/handlers/translate.js +49 -2
- package/dist/server/rpc/handlers/unload-model.js +3 -12
- package/dist/server/rpc/index.d.ts +1 -1
- package/dist/server/utils/audio/decoder.d.ts +1 -2
- package/dist/server/utils/audio/decoder.js +12 -49
- package/dist/server/utils/cache.d.ts +8 -19
- package/dist/server/utils/cache.js +15 -100
- package/dist/server/utils/hash.d.ts +5 -0
- package/dist/server/utils/hash.js +11 -0
- package/dist/server/utils/index.d.ts +2 -7
- package/dist/server/utils/index.js +2 -7
- package/dist/server/utils/tool-parser.js +14 -28
- package/dist/server/worker.d.ts +5 -4
- package/dist/server/worker.js +89 -22
- package/package.json +41 -148
- package/NOTICE +0 -695
- package/bare-imports.json +0 -44
- package/dist/client/api/get-model-info.d.ts +0 -36
- package/dist/client/api/get-model-info.js +0 -14
- package/dist/client/api/heartbeat.d.ts +0 -30
- package/dist/client/api/heartbeat.js +0 -38
- package/dist/client/api/invoke-plugin.d.ts +0 -15
- package/dist/client/api/invoke-plugin.js +0 -38
- package/dist/client/api/ocr.d.ts +0 -31
- package/dist/client/api/ocr.js +0 -88
- package/dist/client/api/registry.d.ts +0 -14
- package/dist/client/api/registry.js +0 -37
- package/dist/client/config-loader/config-utils.d.ts +0 -5
- package/dist/client/config-loader/config-utils.js +0 -20
- package/dist/client/config-loader/resolve-config.bare.d.ts +0 -9
- package/dist/client/config-loader/resolve-config.bare.js +0 -87
- package/dist/client/config-loader/resolve-config.expo.d.ts +0 -11
- package/dist/client/config-loader/resolve-config.expo.js +0 -62
- package/dist/client/config-loader/resolve-config.node.d.ts +0 -10
- package/dist/client/config-loader/resolve-config.node.js +0 -145
- package/dist/client/init-hooks.d.ts +0 -21
- package/dist/client/init-hooks.js +0 -66
- package/dist/client/rpc/expo-device-info.d.ts +0 -6
- package/dist/client/rpc/expo-device-info.js +0 -32
- package/dist/client/rpc/profiling/index.d.ts +0 -2
- package/dist/client/rpc/profiling/index.js +0 -1
- package/dist/client/rpc/profiling/profiler.d.ts +0 -27
- package/dist/client/rpc/profiling/profiler.js +0 -139
- package/dist/constants/registry.d.ts +0 -2
- package/dist/constants/registry.js +0 -1
- package/dist/examples/cache-management.d.ts +0 -2
- package/dist/examples/cache-management.js +0 -97
- package/dist/examples/config/blind-relay/blind-relay.config.d.ts +0 -5
- package/dist/examples/config/blind-relay/blind-relay.config.js +0 -7
- package/dist/examples/config/default/default.config.d.ts +0 -8
- package/dist/examples/config/default/default.config.js +0 -6
- package/dist/examples/config/plugins/plugins.config.d.ts +0 -5
- package/dist/examples/config/plugins/plugins.config.js +0 -4
- package/dist/examples/config-reload.d.ts +0 -2
- package/dist/examples/config-reload.js +0 -49
- package/dist/examples/default-config-usage.d.ts +0 -17
- package/dist/examples/default-config-usage.js +0 -47
- package/dist/examples/delegated-inference/consumer-profiled.d.ts +0 -2
- package/dist/examples/delegated-inference/consumer-profiled.js +0 -67
- package/dist/examples/download-with-blind-relays.d.ts +0 -2
- package/dist/examples/download-with-blind-relays.js +0 -49
- package/dist/examples/embed-p2p.d.ts +0 -2
- package/dist/examples/embed-p2p.js +0 -54
- package/dist/examples/llamacpp-p2p.d.ts +0 -2
- package/dist/examples/llamacpp-sharded.d.ts +0 -2
- package/dist/examples/llamacpp-sharded.js +0 -53
- package/dist/examples/logging-file-transport.d.ts +0 -2
- package/dist/examples/logging-streaming.d.ts +0 -2
- package/dist/examples/logging-streaming.js +0 -75
- package/dist/examples/mcp-websearch.d.ts +0 -13
- package/dist/examples/mcp-websearch.js +0 -176
- package/dist/examples/ocr-fasttext.d.ts +0 -2
- package/dist/examples/ocr-fasttext.js +0 -52
- package/dist/examples/plugins.d.ts +0 -14
- package/dist/examples/plugins.js +0 -129
- package/dist/examples/profiling/basic.d.ts +0 -2
- package/dist/examples/profiling/basic.js +0 -71
- package/dist/examples/profiling/per-call.d.ts +0 -2
- package/dist/examples/profiling/per-call.js +0 -30
- package/dist/examples/quickstart.d.ts +0 -2
- package/dist/examples/quickstart.js +0 -28
- package/dist/examples/rag/rag-hyperdb/cancellation.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb/cancellation.js +0 -75
- package/dist/examples/rag/rag-hyperdb/ingest.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb/pipeline.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb/pipeline.js +0 -74
- package/dist/examples/rag/rag-hyperdb/workspaces.d.ts +0 -2
- package/dist/examples/rag/rag-hyperdb/workspaces.js +0 -178
- package/dist/examples/registry-query.d.ts +0 -2
- package/dist/examples/registry-query.js +0 -87
- package/dist/examples/seed-p2p.d.ts +0 -2
- package/dist/examples/transcription/parakeet-ctc-filesystem.d.ts +0 -2
- package/dist/examples/transcription/parakeet-ctc-filesystem.js +0 -40
- package/dist/examples/transcription/parakeet-microphone-record.d.ts +0 -2
- package/dist/examples/transcription/parakeet-microphone-record.js +0 -95
- package/dist/examples/transcription/parakeet-sortformer.d.ts +0 -2
- package/dist/examples/transcription/parakeet-sortformer.js +0 -115
- package/dist/examples/transcription/parakeet-tdt-filesystem.d.ts +0 -2
- package/dist/examples/transcription/parakeet-tdt-filesystem.js +0 -44
- package/dist/examples/transcription/whispercpp-filesystem.js +0 -69
- package/dist/examples/transcription/whispercpp-prompt.d.ts +0 -2
- package/dist/examples/transcription/whispercpp-prompt.js +0 -67
- package/dist/examples/translation/translation-bergamot-batch.d.ts +0 -2
- package/dist/examples/translation/translation-bergamot-batch.js +0 -49
- package/dist/examples/translation/translation-bergamot-pivot.d.ts +0 -2
- package/dist/examples/translation/translation-bergamot-pivot.js +0 -73
- package/dist/examples/translation/translation-bergamot.d.ts +0 -2
- package/dist/examples/translation/translation-bergamot.js +0 -39
- package/dist/examples/translation/translation-llm-afriquegemma.d.ts +0 -2
- package/dist/examples/translation/translation-llm-afriquegemma.js +0 -39
- package/dist/examples/tts/chatterbox.d.ts +0 -2
- package/dist/examples/tts/chatterbox.js +0 -59
- package/dist/examples/tts/supertonic.d.ts +0 -2
- package/dist/examples/tts/supertonic.js +0 -51
- package/dist/examples/tts/utils.d.ts +0 -17
- package/dist/expo/plugins/resolve-sdk-package-dir.d.ts +0 -15
- package/dist/expo/plugins/resolve-sdk-package-dir.js +0 -31
- package/dist/expo/plugins/withAndroidArchitecture.d.ts +0 -8
- package/dist/expo/plugins/withAndroidArchitecture.js +0 -52
- package/dist/expo/plugins/withAndroidNdkVersion.d.ts +0 -8
- package/dist/expo/plugins/withAndroidNdkVersion.js +0 -31
- package/dist/expo/plugins/withDeviceInfo.d.ts +0 -10
- package/dist/expo/plugins/withDeviceInfo.js +0 -48
- package/dist/logging/addon.d.ts +0 -6
- package/dist/logging/addon.js +0 -75
- package/dist/logging/client-logger.d.ts +0 -3
- package/dist/logging/client-logger.js +0 -24
- package/dist/logging/namespaces.d.ts +0 -6
- package/dist/logging/namespaces.js +0 -6
- package/dist/logging/registry.d.ts +0 -31
- package/dist/logging/registry.js +0 -62
- package/dist/logging/server-logger.d.ts +0 -3
- package/dist/logging/server-logger.js +0 -16
- package/dist/models/registry/models.d.ts +0 -10417
- package/dist/models/registry/models.js +0 -10757
- package/dist/models/update-models/codegen.d.ts +0 -3
- package/dist/models/update-models/codegen.js +0 -135
- package/dist/models/update-models/history.d.ts +0 -24
- package/dist/models/update-models/history.js +0 -107
- package/dist/models/update-models/index.d.ts +0 -2
- package/dist/models/update-models/index.js +0 -125
- package/dist/models/update-models/naming.d.ts +0 -4
- package/dist/models/update-models/naming.js +0 -370
- package/dist/models/update-models/processing.d.ts +0 -8
- package/dist/models/update-models/processing.js +0 -67
- package/dist/models/update-models/registry.d.ts +0 -4
- package/dist/models/update-models/registry.js +0 -67
- package/dist/models/update-models/shards.d.ts +0 -4
- package/dist/models/update-models/shards.js +0 -57
- package/dist/models/update-models/types.d.ts +0 -60
- package/dist/models/update-models/types.js +0 -1
- package/dist/models/update-models/utils.d.ts +0 -3
- package/dist/models/update-models/utils.js +0 -21
- package/dist/pear/pre.d.ts +0 -18
- package/dist/pear/pre.js +0 -433
- package/dist/profiling/aggregator.d.ts +0 -15
- package/dist/profiling/aggregator.js +0 -100
- package/dist/profiling/clock.d.ts +0 -12
- package/dist/profiling/clock.js +0 -51
- package/dist/profiling/controller.d.ts +0 -33
- package/dist/profiling/controller.js +0 -123
- package/dist/profiling/envelope.d.ts +0 -10
- package/dist/profiling/envelope.js +0 -36
- package/dist/profiling/events.d.ts +0 -20
- package/dist/profiling/events.js +0 -37
- package/dist/profiling/exporters.d.ts +0 -10
- package/dist/profiling/exporters.js +0 -236
- package/dist/profiling/index.d.ts +0 -36
- package/dist/profiling/index.js +0 -31
- package/dist/profiling/ring-buffer.d.ts +0 -19
- package/dist/profiling/ring-buffer.js +0 -83
- package/dist/profiling/types.d.ts +0 -47
- package/dist/profiling/types.js +0 -1
- package/dist/schemas/archive.d.ts +0 -9
- package/dist/schemas/archive.js +0 -17
- package/dist/schemas/engine-addon-map.d.ts +0 -5
- package/dist/schemas/engine-addon-map.js +0 -52
- package/dist/schemas/get-model-info.d.ts +0 -120
- package/dist/schemas/get-model-info.js +0 -58
- package/dist/schemas/heartbeat.d.ts +0 -17
- package/dist/schemas/heartbeat.js +0 -10
- package/dist/schemas/json-schema.d.ts +0 -16
- package/dist/schemas/json-schema.js +0 -2
- package/dist/schemas/mcp-adapter.d.ts +0 -47
- package/dist/schemas/mcp-adapter.js +0 -1
- package/dist/schemas/model-src-utils.d.ts +0 -148
- package/dist/schemas/model-src-utils.js +0 -35
- package/dist/schemas/model-types.d.ts +0 -183
- package/dist/schemas/model-types.js +0 -168
- package/dist/schemas/ocr.d.ts +0 -125
- package/dist/schemas/ocr.js +0 -57
- package/dist/schemas/path-validation.d.ts +0 -10
- package/dist/schemas/path-validation.js +0 -22
- package/dist/schemas/plugin.d.ts +0 -226
- package/dist/schemas/plugin.js +0 -158
- package/dist/schemas/profiling.d.ts +0 -105
- package/dist/schemas/profiling.js +0 -66
- package/dist/schemas/registry.d.ts +0 -356
- package/dist/schemas/registry.js +0 -93
- package/dist/schemas/reload-config.d.ts +0 -476
- package/dist/schemas/reload-config.js +0 -44
- package/dist/schemas/runtime-context.d.ts +0 -19
- package/dist/schemas/runtime-context.js +0 -7
- package/dist/schemas/sdk-config.d.ts +0 -2973
- package/dist/schemas/sdk-config.js +0 -136
- package/dist/schemas/sdk-errors-client.d.ts +0 -31
- package/dist/schemas/sdk-errors-client.js +0 -143
- package/dist/schemas/sdk-errors-registry.d.ts +0 -6
- package/dist/schemas/sdk-errors-registry.js +0 -8
- package/dist/schemas/sdk-errors-server.d.ts +0 -89
- package/dist/schemas/sdk-errors-server.js +0 -451
- package/dist/schemas/shard.d.ts +0 -21
- package/dist/schemas/shard.js +0 -17
- package/dist/schemas/tools.d.ts +0 -65
- package/dist/schemas/tools.js +0 -43
- package/dist/schemas/transcription-config.d.ts +0 -383
- package/dist/schemas/transcription-config.js +0 -95
- package/dist/scripts/run-security-tests-bare.d.ts +0 -2
- package/dist/scripts/run-security-tests-bare.js +0 -78
- package/dist/scripts/run-security-tests.d.ts +0 -2
- package/dist/scripts/run-security-tests.js +0 -22
- package/dist/scripts/run-unit-tests.d.ts +0 -2
- package/dist/scripts/run-unit-tests.js +0 -17
- package/dist/server/bare/ops/embed.d.ts +0 -12
- package/dist/server/bare/ops/load-model.d.ts +0 -9
- package/dist/server/bare/ops/load-model.js +0 -85
- package/dist/server/bare/ops/transcribe.d.ts +0 -3
- package/dist/server/bare/ops/transcribe.js +0 -75
- package/dist/server/bare/ops/translate.d.ts +0 -5
- package/dist/server/bare/ops/unload-model.js +0 -41
- package/dist/server/bare/plugins/index.d.ts +0 -8
- package/dist/server/bare/plugins/index.js +0 -7
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.d.ts +0 -6
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +0 -34
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +0 -220
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +0 -155
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +0 -54
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +0 -87
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +0 -367
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +0 -201
- package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.d.ts +0 -10
- package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.js +0 -110
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +0 -86
- package/dist/server/bare/plugins/onnx-ocr/plugin.js +0 -117
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +0 -373
- package/dist/server/bare/plugins/onnx-tts/plugin.js +0 -182
- package/dist/server/bare/plugins/onnx-tts/wav-helper.d.ts +0 -14
- package/dist/server/bare/plugins/onnx-tts/wav-helper.js +0 -107
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +0 -317
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +0 -154
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +0 -237
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +0 -86
- package/dist/server/bare/rag-hyperdb/handlers/chunk.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/chunk.js +0 -7
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/close-workspace.js +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/delete-workspace.js +0 -14
- package/dist/server/bare/rag-hyperdb/handlers/ingest.d.ts +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/ingest.js +0 -18
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.d.ts +0 -3
- package/dist/server/bare/rag-hyperdb/handlers/list-workspaces.js +0 -4
- package/dist/server/bare/rag-hyperdb/handlers/reindex.d.ts +0 -9
- package/dist/server/bare/rag-hyperdb/handlers/reindex.js +0 -16
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +0 -7
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +0 -39
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.d.ts +0 -15
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +0 -136
- package/dist/server/bare/registry/config-registry.d.ts +0 -14
- package/dist/server/bare/registry/config-registry.js +0 -82
- package/dist/server/bare/registry/model-config-registry.d.ts +0 -4
- package/dist/server/bare/registry/model-config-registry.js +0 -15
- package/dist/server/bare/registry/model-config-utils.d.ts +0 -15
- package/dist/server/bare/registry/model-config-utils.js +0 -112
- package/dist/server/bare/registry/registry-client.d.ts +0 -5
- package/dist/server/bare/registry/registry-client.js +0 -37
- package/dist/server/bare/registry/runtime-context-registry.d.ts +0 -7
- package/dist/server/bare/registry/runtime-context-registry.js +0 -26
- package/dist/server/bare/utils/audio-input.d.ts +0 -10
- package/dist/server/bare/utils/audio-input.js +0 -33
- package/dist/server/bare/utils/loader-adapter.d.ts +0 -7
- package/dist/server/bare/utils/loader-adapter.js +0 -9
- package/dist/server/env.d.ts +0 -22
- package/dist/server/env.js +0 -57
- package/dist/server/plugins/index.d.ts +0 -2
- package/dist/server/plugins/index.js +0 -1
- package/dist/server/plugins/registry.d.ts +0 -9
- package/dist/server/plugins/registry.js +0 -79
- package/dist/server/rpc/delegate-transport.d.ts +0 -19
- package/dist/server/rpc/delegate-transport.js +0 -236
- package/dist/server/rpc/delegate-utils.d.ts +0 -2
- package/dist/server/rpc/delegate-utils.js +0 -5
- package/dist/server/rpc/handler-registry.d.ts +0 -3
- package/dist/server/rpc/handler-registry.js +0 -113
- package/dist/server/rpc/handler-utils.d.ts +0 -23
- package/dist/server/rpc/handler-utils.js +0 -170
- package/dist/server/rpc/handlers/cancel-delegated.d.ts +0 -4
- package/dist/server/rpc/handlers/cancel-delegated.js +0 -71
- package/dist/server/rpc/handlers/get-model-info.d.ts +0 -3
- package/dist/server/rpc/handlers/get-model-info.js +0 -164
- package/dist/server/rpc/handlers/heartbeat-delegated.d.ts +0 -4
- package/dist/server/rpc/handlers/heartbeat-delegated.js +0 -32
- package/dist/server/rpc/handlers/heartbeat.d.ts +0 -3
- package/dist/server/rpc/handlers/heartbeat.js +0 -3
- package/dist/server/rpc/handlers/load-model/download-stats.d.ts +0 -6
- package/dist/server/rpc/handlers/load-model/download-stats.js +0 -87
- package/dist/server/rpc/handlers/load-model/handler.js +0 -187
- package/dist/server/rpc/handlers/load-model/registry.d.ts +0 -11
- package/dist/server/rpc/handlers/load-model/registry.js +0 -548
- package/dist/server/rpc/handlers/load-model/types.d.ts +0 -29
- package/dist/server/rpc/handlers/load-model/types.js +0 -1
- package/dist/server/rpc/handlers/ocr-stream.d.ts +0 -3
- package/dist/server/rpc/handlers/ocr-stream.js +0 -4
- package/dist/server/rpc/handlers/plugin-dispatch.d.ts +0 -15
- package/dist/server/rpc/handlers/plugin-dispatch.js +0 -59
- package/dist/server/rpc/handlers/plugin-invoke.d.ts +0 -4
- package/dist/server/rpc/handlers/plugin-invoke.js +0 -92
- package/dist/server/rpc/handlers/registry.d.ts +0 -5
- package/dist/server/rpc/handlers/registry.js +0 -157
- package/dist/server/rpc/handlers/unload-model-delegated.d.ts +0 -3
- package/dist/server/rpc/handlers/unload-model-delegated.js +0 -32
- package/dist/server/rpc/profiling/context.d.ts +0 -18
- package/dist/server/rpc/profiling/context.js +0 -38
- package/dist/server/rpc/profiling/delegation-profiler.d.ts +0 -32
- package/dist/server/rpc/profiling/delegation-profiler.js +0 -154
- package/dist/server/rpc/profiling/index.d.ts +0 -5
- package/dist/server/rpc/profiling/index.js +0 -4
- package/dist/server/rpc/profiling/operation-metrics.d.ts +0 -25
- package/dist/server/rpc/profiling/operation-metrics.js +0 -199
- package/dist/server/rpc/profiling/operation-wrappers.d.ts +0 -18
- package/dist/server/rpc/profiling/operation-wrappers.js +0 -124
- package/dist/server/rpc/profiling/profiler.d.ts +0 -13
- package/dist/server/rpc/profiling/profiler.js +0 -97
- package/dist/server/utils/archive.d.ts +0 -4
- package/dist/server/utils/archive.js +0 -179
- package/dist/server/utils/checksum.d.ts +0 -4
- package/dist/server/utils/checksum.js +0 -31
- package/dist/server/utils/config-transform.d.ts +0 -3
- package/dist/server/utils/config-transform.js +0 -23
- package/dist/server/utils/formatting.d.ts +0 -19
- package/dist/server/utils/formatting.js +0 -61
- package/dist/server/utils/gguf-tensor-extractor.d.ts +0 -15
- package/dist/server/utils/gguf-tensor-extractor.js +0 -314
- package/dist/server/utils/path-security.d.ts +0 -12
- package/dist/server/utils/path-security.js +0 -25
- package/dist/server/utils/shard-utils.d.ts +0 -48
- package/dist/server/utils/shard-utils.js +0 -125
- package/dist/server/utils/tool-integration.d.ts +0 -13
- package/dist/server/utils/tool-integration.js +0 -43
- package/dist/server/worker-core.d.ts +0 -6
- package/dist/server/worker-core.js +0 -88
- package/dist/utils/errors-base.d.ts +0 -3
- package/dist/utils/errors-base.js +0 -13
- package/dist/utils/errors-client.d.ts +0 -137
- package/dist/utils/errors-client.js +0 -240
- package/dist/utils/errors-server.d.ts +0 -236
- package/dist/utils/errors-server.js +0 -412
- package/dist/utils/global-singleton.d.ts +0 -2
- package/dist/utils/global-singleton.js +0 -10
- package/dist/utils/mcp-adapter.d.ts +0 -12
- package/dist/utils/mcp-adapter.js +0 -103
- package/dist/utils/object.d.ts +0 -2
- package/dist/utils/object.js +0 -3
- package/dist/utils/path-sanitize.d.ts +0 -17
- package/dist/utils/path-sanitize.js +0 -54
- package/dist/utils/tool-helpers.d.ts +0 -25
- package/dist/utils/tool-helpers.js +0 -112
- package/expo/plugins/patches/android-link.mjs +0 -63
- package/expo/plugins/patches/ios-link.mjs +0 -63
- /package/dist/examples/{seed-p2p.js → seed-hyperdrive.js} +0 -0
- /package/dist/examples/{transcription/whispercpp-filesystem.d.ts → whispercpp-filesystem.d.ts} +0 -0
- /package/dist/examples/{transcription/whispercpp-microphone-record.d.ts → whispercpp-microphone-record.d.ts} +0 -0
- /package/dist/models/{registry → hyperdrive}/index.d.ts +0 -0
- /package/dist/server/bare/{ops → addons}/cancel.d.ts +0 -0
- /package/dist/server/bare/{plugins/onnx-tts/ops → addons/tts/handlers}/text-to-speech.d.ts +0 -0
- /package/dist/server/bare/{ops → addons}/unload-model.d.ts +0 -0
package/dist/examples/plugins.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin Selection Example
|
|
3
|
-
*
|
|
4
|
-
* Config: examples/config/plugins/plugins.config.json
|
|
5
|
-
* Selected: llamacpp-completion (LLM), nmtcpp-translation (NMT)
|
|
6
|
-
*
|
|
7
|
-
* Demonstrates:
|
|
8
|
-
* 1. LLM completion -> works (plugin selected)
|
|
9
|
-
* 2. NMT translation -> works (plugin selected)
|
|
10
|
-
* 3. Embeddings -> fails (plugin not selected)
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
import { execSync } from "child_process";
|
|
14
|
-
import { existsSync, rmSync } from "fs";
|
|
15
|
-
import path from "path";
|
|
16
|
-
const configDir = import.meta.dirname ?? process.cwd();
|
|
17
|
-
const configPath = `${configDir}/config/plugins/plugins.config.json`;
|
|
18
|
-
const projectRoot = path.resolve(configDir, "..");
|
|
19
|
-
const qvacOutputDir = path.join(projectRoot, "qvac");
|
|
20
|
-
// ─── Generate the worker bundle from the plugins config ─────────────────────
|
|
21
|
-
console.log(`🔍 Config: ${configPath}`);
|
|
22
|
-
console.log(`⚠️ This example will generate a worker bundle in ${qvacOutputDir} and delete it on exit.`);
|
|
23
|
-
console.log(" If you have an existing qvac/ folder with bundled files, they will be overwritten and removed.\n");
|
|
24
|
-
console.log("🔨 Generating worker bundle from plugins config...\n");
|
|
25
|
-
try {
|
|
26
|
-
execSync(`npx @qvac/cli bundle sdk --config "${configPath}" --quiet`, {
|
|
27
|
-
cwd: projectRoot,
|
|
28
|
-
stdio: "inherit",
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
console.error("❌ Failed to generate worker bundle. Ensure @qvac/cli is installed:");
|
|
33
|
-
console.error(" npm install -D @qvac/cli");
|
|
34
|
-
console.error("❌ Error:", error);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
console.log("");
|
|
38
|
-
// Cleanup generated qvac/ folder on exit
|
|
39
|
-
function cleanup() {
|
|
40
|
-
if (existsSync(qvacOutputDir)) {
|
|
41
|
-
rmSync(qvacOutputDir, { recursive: true, force: true });
|
|
42
|
-
console.log(`\n🧹 Cleaned up ${qvacOutputDir}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
process.on("exit", cleanup);
|
|
46
|
-
// Point config before importing the SDK.
|
|
47
|
-
// In a real app, place qvac.config.json (or .js/.ts) in your project root (auto-discovered).
|
|
48
|
-
process.env["QVAC_CONFIG_PATH"] = configPath;
|
|
49
|
-
const { completion, translate, embed, loadModel, unloadModel, LLAMA_3_2_1B_INST_Q4_0, MARIAN_OPUS_EN_IT_Q4_0, GTE_LARGE_FP16, } = await import("@qvac/sdk");
|
|
50
|
-
console.log("1. LLM Completion (llamacpp-completion plugin)");
|
|
51
|
-
try {
|
|
52
|
-
const llmModelId = await loadModel({
|
|
53
|
-
modelSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
54
|
-
modelType: "llm",
|
|
55
|
-
modelConfig: { ctx_size: 2048 },
|
|
56
|
-
onProgress: (p) => console.log(` Loading LLM: ${p.percentage.toFixed(1)}%`),
|
|
57
|
-
});
|
|
58
|
-
console.log(` Model loaded: ${llmModelId}`);
|
|
59
|
-
const question = "What is 2 + 2? Answer in one word.";
|
|
60
|
-
console.log(` Question: ${question}`);
|
|
61
|
-
const result = completion({
|
|
62
|
-
modelId: llmModelId,
|
|
63
|
-
history: [{ role: "user", content: question }],
|
|
64
|
-
stream: true,
|
|
65
|
-
});
|
|
66
|
-
process.stdout.write(" Response: ");
|
|
67
|
-
for await (const token of result.tokenStream) {
|
|
68
|
-
process.stdout.write(token);
|
|
69
|
-
}
|
|
70
|
-
console.log("\n");
|
|
71
|
-
await unloadModel({ modelId: llmModelId });
|
|
72
|
-
console.log(" ✅ LLM unloaded\n");
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error(" ❌ LLM failed:", error);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
console.log("2. Translation (nmtcpp-translation plugin)");
|
|
79
|
-
try {
|
|
80
|
-
const nmtModelId = await loadModel({
|
|
81
|
-
modelSrc: MARIAN_OPUS_EN_IT_Q4_0,
|
|
82
|
-
modelType: "nmt",
|
|
83
|
-
modelConfig: {
|
|
84
|
-
engine: "Opus",
|
|
85
|
-
from: "en",
|
|
86
|
-
to: "it",
|
|
87
|
-
},
|
|
88
|
-
onProgress: (p) => console.log(` Loading NMT: ${p.percentage.toFixed(1)}%`),
|
|
89
|
-
});
|
|
90
|
-
console.log(` Model loaded: ${nmtModelId}`);
|
|
91
|
-
const text = "Hello, how are you?";
|
|
92
|
-
const result = translate({
|
|
93
|
-
modelId: nmtModelId,
|
|
94
|
-
text,
|
|
95
|
-
modelType: "nmt",
|
|
96
|
-
stream: false,
|
|
97
|
-
});
|
|
98
|
-
const translated = await result.text;
|
|
99
|
-
console.log(` "${text}" -> "${translated}"\n`);
|
|
100
|
-
await unloadModel({ modelId: nmtModelId });
|
|
101
|
-
console.log(" ✅ NMT unloaded\n");
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
console.error(" ❌ Translation failed:", error);
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
console.log("3. Embeddings (llamacpp-embedding plugin NOT in config)");
|
|
108
|
-
console.log(" Attempting to load an embeddings model...\n");
|
|
109
|
-
try {
|
|
110
|
-
const embedModelId = await loadModel({
|
|
111
|
-
modelSrc: GTE_LARGE_FP16,
|
|
112
|
-
modelType: "embeddings",
|
|
113
|
-
});
|
|
114
|
-
await embed({ modelId: embedModelId, text: "test" });
|
|
115
|
-
console.error(" ❌ Unexpected: embed succeeded without the plugin!");
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
120
|
-
if (message.includes("Plugin not found")) {
|
|
121
|
-
console.log(" ✅ Expected PLUGIN_NOT_FOUND error:");
|
|
122
|
-
console.log(` ${message}\n`);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
console.error(" ❌ Unexpected error:", error);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
console.log("Done! Only the selected plugins were available.");
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { completion, loadModel, unloadModel, LLAMA_3_2_1B_INST_Q4_0, profiler, } from "@qvac/sdk";
|
|
2
|
-
try {
|
|
3
|
-
// Enable profiling globally
|
|
4
|
-
profiler.enable({
|
|
5
|
-
mode: "verbose",
|
|
6
|
-
includeServerBreakdown: true,
|
|
7
|
-
});
|
|
8
|
-
console.log("Profiler enabled:", profiler.isEnabled());
|
|
9
|
-
const modelId = await loadModel({
|
|
10
|
-
modelSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
11
|
-
modelType: "llm",
|
|
12
|
-
onProgress: (p) => console.log(` ${p.percentage.toFixed(1)}%`),
|
|
13
|
-
});
|
|
14
|
-
console.log("Model loaded:", modelId);
|
|
15
|
-
console.log("\n→ Running completion...");
|
|
16
|
-
const result = completion({
|
|
17
|
-
modelId,
|
|
18
|
-
history: [{ role: "user", content: "Say hello in one sentence." }],
|
|
19
|
-
stream: true,
|
|
20
|
-
});
|
|
21
|
-
for await (const token of result.tokenStream) {
|
|
22
|
-
process.stdout.write(token);
|
|
23
|
-
}
|
|
24
|
-
console.log();
|
|
25
|
-
await unloadModel({ modelId });
|
|
26
|
-
// Export profiling data
|
|
27
|
-
console.log("\n=== Profiler Summary ===");
|
|
28
|
-
console.log(profiler.exportSummary());
|
|
29
|
-
console.log("\n=== Profiler Table ===");
|
|
30
|
-
console.log(profiler.exportTable());
|
|
31
|
-
const json = profiler.exportJSON();
|
|
32
|
-
console.log("\n=== Load Model Metrics ===");
|
|
33
|
-
// Filter for operation-level event (kind: "handler"), not RPC phase events
|
|
34
|
-
const loadModelEvent = json.recentEvents?.find((e) => e.op === "loadModel" && e.kind === "handler");
|
|
35
|
-
if (loadModelEvent) {
|
|
36
|
-
const tags = loadModelEvent.tags ?? {};
|
|
37
|
-
const gauges = loadModelEvent.gauges ?? {};
|
|
38
|
-
console.log(" sourceType:", tags["sourceType"] ?? "(not set)");
|
|
39
|
-
console.log(" cacheHit:", tags["cacheHit"] ?? "(not set)");
|
|
40
|
-
console.log(" totalLoadTime:", gauges["totalLoadTime"], "ms");
|
|
41
|
-
console.log(" modelInitializationTime:", gauges["modelInitializationTime"], "ms");
|
|
42
|
-
if (tags["cacheHit"] !== "true") {
|
|
43
|
-
console.log(" downloadTime:", gauges["downloadTime"] ?? "(cached)", "ms");
|
|
44
|
-
console.log(" totalBytesDownloaded:", gauges["totalBytesDownloaded"] ?? "(cached)");
|
|
45
|
-
console.log(" downloadSpeedBps:", gauges["downloadSpeedBps"] ?? "(cached)");
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
console.log(" (download metrics omitted - cache hit)");
|
|
49
|
-
}
|
|
50
|
-
if (gauges["checksumValidationTime"] !== undefined) {
|
|
51
|
-
console.log(" checksumValidationTime:", gauges["checksumValidationTime"], "ms");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
console.log(" (no loadModel handler event captured)");
|
|
56
|
-
// Debug: show what ops are available
|
|
57
|
-
const ops = [...new Set(json.recentEvents?.map((e) => `${e.op}:${e.kind}`) ?? [])];
|
|
58
|
-
console.log(" Available ops:", ops.join(", "));
|
|
59
|
-
}
|
|
60
|
-
console.log("\n=== Profiler JSON (structure) ===");
|
|
61
|
-
console.log(" aggregates:", Object.keys(json.aggregates).length, "metrics");
|
|
62
|
-
console.log(" recentEvents:", json.recentEvents?.length ?? 0, "events");
|
|
63
|
-
console.log(" config:", json.config);
|
|
64
|
-
// Disable profiling
|
|
65
|
-
profiler.disable();
|
|
66
|
-
console.log("\nProfiler disabled:", !profiler.isEnabled());
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
console.error("Error:", error);
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { embed, loadModel, unloadModel, GTE_LARGE_FP16, profiler, } from "@qvac/sdk";
|
|
2
|
-
try {
|
|
3
|
-
profiler.disable();
|
|
4
|
-
console.log("Profiler globally enabled:", profiler.isEnabled());
|
|
5
|
-
const modelId = await loadModel({
|
|
6
|
-
modelSrc: GTE_LARGE_FP16,
|
|
7
|
-
modelType: "embeddings",
|
|
8
|
-
onProgress: (p) => console.log(` ${p.percentage.toFixed(1)}%`),
|
|
9
|
-
});
|
|
10
|
-
console.log("Model loaded:", modelId);
|
|
11
|
-
console.log("\n=== Embed with per-call profiling ===");
|
|
12
|
-
const embedding1 = await embed({ modelId, text: "Profile this specific call" }, { profiling: { enabled: true, includeServerBreakdown: true } });
|
|
13
|
-
console.log("Embedding dimensions:", embedding1.length);
|
|
14
|
-
console.log("\n=== Embed without profiling ===");
|
|
15
|
-
const embedding2 = await embed({
|
|
16
|
-
modelId,
|
|
17
|
-
text: "This call is not profiled",
|
|
18
|
-
});
|
|
19
|
-
console.log("Embedding dimensions:", embedding2.length);
|
|
20
|
-
console.log("\n=== Embed with profiling explicitly disabled ===");
|
|
21
|
-
const embedding3 = await embed({ modelId, text: "Profiling explicitly disabled for this call" }, { profiling: { enabled: false } });
|
|
22
|
-
console.log("Embedding dimensions:", embedding3.length);
|
|
23
|
-
await unloadModel({ modelId });
|
|
24
|
-
console.log("\n=== Profiler Summary (per-call data only) ===");
|
|
25
|
-
console.log(profiler.exportSummary());
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
console.error("Error:", error);
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { loadModel, LLAMA_3_2_1B_INST_Q4_0, completion, unloadModel, } from "@qvac/sdk";
|
|
2
|
-
try {
|
|
3
|
-
// Load a model into memory
|
|
4
|
-
const modelId = await loadModel({
|
|
5
|
-
modelSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
6
|
-
modelType: "llm",
|
|
7
|
-
onProgress: (progress) => {
|
|
8
|
-
console.log(progress);
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
// You can use the loaded model multiple times
|
|
12
|
-
const history = [
|
|
13
|
-
{
|
|
14
|
-
role: "user",
|
|
15
|
-
content: "Explain quantum computing in one sentence",
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
const result = completion({ modelId, history, stream: true });
|
|
19
|
-
for await (const token of result.tokenStream) {
|
|
20
|
-
process.stdout.write(token);
|
|
21
|
-
}
|
|
22
|
-
// Unload model to free up system resources
|
|
23
|
-
await unloadModel({ modelId });
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
console.error("❌ Error:", error);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { loadModel, unloadModel, GTE_LARGE_FP16, ragIngest, ragCloseWorkspace, cancel, } from "@qvac/sdk";
|
|
2
|
-
const WORKSPACE = "cancellation-demo";
|
|
3
|
-
// Generate sample documents
|
|
4
|
-
function generateDocuments(count) {
|
|
5
|
-
const topics = [
|
|
6
|
-
"Machine learning algorithms process data to identify patterns and make decisions.",
|
|
7
|
-
"Deep neural networks consist of multiple layers that extract higher-level features.",
|
|
8
|
-
"Natural language processing enables computers to understand human language.",
|
|
9
|
-
"Computer vision systems analyze visual information from images and videos.",
|
|
10
|
-
"Reinforcement learning trains agents through trial and error using rewards.",
|
|
11
|
-
];
|
|
12
|
-
return Array.from({ length: count }, (_, i) => {
|
|
13
|
-
const topic = topics[i % topics.length];
|
|
14
|
-
return `Document ${i + 1}: ${topic} Extended content for document ${i + 1}.`;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
console.log("RAG Cancellation Example\n");
|
|
19
|
-
// Load embedding model
|
|
20
|
-
console.log("Loading embedding model...");
|
|
21
|
-
const modelId = await loadModel({
|
|
22
|
-
modelSrc: GTE_LARGE_FP16,
|
|
23
|
-
modelType: "embeddings",
|
|
24
|
-
onProgress: (progress) => {
|
|
25
|
-
process.stdout.write(`\r ${progress.percentage.toFixed(1)}%`);
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
console.log("\n✅ Model loaded\n");
|
|
29
|
-
// Generate documents
|
|
30
|
-
const documents = generateDocuments(200);
|
|
31
|
-
console.log(`📄 Processing ${documents.length} documents...\n`);
|
|
32
|
-
let progressCount = 0;
|
|
33
|
-
let cancelled = false;
|
|
34
|
-
try {
|
|
35
|
-
await ragIngest({
|
|
36
|
-
modelId,
|
|
37
|
-
workspace: WORKSPACE,
|
|
38
|
-
documents,
|
|
39
|
-
progressInterval: 50,
|
|
40
|
-
onProgress: (stage, current, total) => {
|
|
41
|
-
progressCount++;
|
|
42
|
-
const pct = total > 0 ? Math.round((current / total) * 100) : 0;
|
|
43
|
-
console.log(` [${stage}] ${current}/${total} (${pct}%)`);
|
|
44
|
-
// Cancel during embedding stage after a few updates
|
|
45
|
-
if (!cancelled && stage === "embedding" && current > 10) {
|
|
46
|
-
console.log("\n🛑 Triggering cancellation...\n");
|
|
47
|
-
cancelled = true;
|
|
48
|
-
void cancel({ operation: "rag", workspace: WORKSPACE });
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
console.log("\n⚠️ Ingest completed (cancellation didn't interrupt in time)");
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
56
|
-
const wasCancelled = msg.toLowerCase().includes("cancel") ||
|
|
57
|
-
msg.toLowerCase().includes("abort");
|
|
58
|
-
if (wasCancelled) {
|
|
59
|
-
console.log("✅ Operation cancelled successfully!");
|
|
60
|
-
console.log(` Progress updates received: ${progressCount}`);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// Cleanup (workspace may not exist if cancelled early)
|
|
67
|
-
await ragCloseWorkspace({ workspace: WORKSPACE, deleteOnClose: true }).catch(() => { });
|
|
68
|
-
await unloadModel({ modelId });
|
|
69
|
-
console.log("✅ Done");
|
|
70
|
-
process.exit(0);
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
console.error("❌ Error:", error);
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
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
|
-
}
|