@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/client/api/rag.js
CHANGED
|
@@ -1,226 +1,52 @@
|
|
|
1
|
-
import { send
|
|
2
|
-
|
|
3
|
-
// ============== Chunk ==============
|
|
1
|
+
import { send } from "../rpc/rpc-client.js";
|
|
2
|
+
// ============== Save Embeddings ==============
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Part of the segregated flow: ragChunk() → embed() → ragSaveEmbeddings()
|
|
4
|
+
* Saves document embeddings in the RAG vector database.
|
|
7
5
|
*
|
|
8
|
-
* @param params - The parameters for
|
|
9
|
-
* @param params.
|
|
10
|
-
* @param params.
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
14
|
-
* @
|
|
15
|
-
*
|
|
16
|
-
* const chunks = await ragChunk({
|
|
17
|
-
* documents: ["Long document text here..."],
|
|
18
|
-
* chunkOpts: {
|
|
19
|
-
* chunkSize: 256,
|
|
20
|
-
* chunkOverlap: 50,
|
|
21
|
-
* chunkStrategy: "paragraph",
|
|
22
|
-
* },
|
|
23
|
-
* });
|
|
24
|
-
* ```
|
|
6
|
+
* @param params - The parameters for saving embeddings
|
|
7
|
+
* @param params.modelId - The identifier of the embedding model to use
|
|
8
|
+
* @param params.documents - The documents to embed and save (string or array of strings)
|
|
9
|
+
* @param params.chunk - Whether to chunk the documents before embedding (default: false)
|
|
10
|
+
* @param params.chunkOpts - Options for chunking documents
|
|
11
|
+
* @param params.workspace - Optional workspace for isolated storage
|
|
12
|
+
* @throws {Error} When the response type is invalid or when the operation fails
|
|
13
|
+
* @returns The processed results and dropped indices
|
|
25
14
|
*/
|
|
26
|
-
export async function
|
|
15
|
+
export async function ragSaveEmbeddings(params) {
|
|
27
16
|
const request = {
|
|
28
17
|
type: "rag",
|
|
29
|
-
operation: "
|
|
18
|
+
operation: "saveEmbeddings",
|
|
30
19
|
...params,
|
|
31
20
|
};
|
|
32
|
-
const response = await send(request
|
|
33
|
-
if (response.type !== "rag") {
|
|
34
|
-
throw new InvalidResponseError("rag");
|
|
35
|
-
}
|
|
36
|
-
if (!response.success) {
|
|
37
|
-
throw new RAGChunkFailedError(response.error);
|
|
38
|
-
}
|
|
39
|
-
if (response.operation !== "chunk") {
|
|
40
|
-
throw new InvalidOperationError();
|
|
41
|
-
}
|
|
42
|
-
return response.chunks;
|
|
43
|
-
}
|
|
44
|
-
// ============== Ingest ==============
|
|
45
|
-
/**
|
|
46
|
-
* Ingests documents into the RAG vector database.
|
|
47
|
-
* Full pipeline: chunk → embed → save
|
|
48
|
-
*
|
|
49
|
-
* **Workspace lifecycle:** This operation implicitly opens (or creates) the workspace.
|
|
50
|
-
* The workspace remains open until closed.
|
|
51
|
-
*
|
|
52
|
-
* @param params - The parameters for ingestion
|
|
53
|
-
* @param params.modelId - The embedding model identifier
|
|
54
|
-
* @param params.documents - Documents to ingest (string or array)
|
|
55
|
-
* @param params.chunk - Whether to chunk documents (default: true)
|
|
56
|
-
* @param params.chunkOpts - Chunking options
|
|
57
|
-
* @param params.workspace - Workspace for isolated storage (default: "default"). Created if it doesn't exist.
|
|
58
|
-
* @param params.onProgress - Progress callback (stage, current, total)
|
|
59
|
-
* @param params.progressInterval - Minimum interval between progress updates in ms
|
|
60
|
-
* @returns Processing results and dropped indices
|
|
61
|
-
* @throws {RAGSaveFailedError} When the operation fails
|
|
62
|
-
* @throws {StreamEndedError} When streaming ends unexpectedly (only when using onProgress)
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```typescript
|
|
66
|
-
* // Simple ingest
|
|
67
|
-
* const result = await ragIngest({
|
|
68
|
-
* modelId,
|
|
69
|
-
* documents: ["Document 1", "Document 2"],
|
|
70
|
-
* });
|
|
71
|
-
*
|
|
72
|
-
* // With progress tracking
|
|
73
|
-
* const result = await ragIngest({
|
|
74
|
-
* modelId,
|
|
75
|
-
* documents: ["Document 1", "Document 2"],
|
|
76
|
-
* workspace: "my-docs",
|
|
77
|
-
* onProgress: (stage, current, total) => {
|
|
78
|
-
* console.log(`[${stage}] ${current}/${total}`);
|
|
79
|
-
* },
|
|
80
|
-
* });
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
export async function ragIngest(params, options) {
|
|
84
|
-
const { onProgress, ...requestParams } = params;
|
|
85
|
-
const request = {
|
|
86
|
-
type: "rag",
|
|
87
|
-
operation: "ingest",
|
|
88
|
-
...requestParams,
|
|
89
|
-
chunk: requestParams.chunk ?? true,
|
|
90
|
-
withProgress: onProgress ? true : undefined,
|
|
91
|
-
};
|
|
92
|
-
if (onProgress) {
|
|
93
|
-
// Use streaming for progress updates
|
|
94
|
-
for await (const event of stream(request, options)) {
|
|
95
|
-
if (event.type === "rag:progress" && event.operation === "ingest") {
|
|
96
|
-
const progress = event;
|
|
97
|
-
onProgress(progress.stage, progress.current, progress.total);
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
if (event.type === "rag" && event.operation === "ingest") {
|
|
101
|
-
if (!event.success) {
|
|
102
|
-
throw new RAGSaveFailedError(event.error);
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
processed: event.processed,
|
|
106
|
-
droppedIndices: event.droppedIndices,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
throw new StreamEndedError();
|
|
111
|
-
}
|
|
112
|
-
const response = await send(request, options);
|
|
21
|
+
const response = await send(request);
|
|
113
22
|
if (response.type !== "rag") {
|
|
114
|
-
throw new
|
|
23
|
+
throw new Error("Invalid response type");
|
|
115
24
|
}
|
|
116
25
|
if (!response.success) {
|
|
117
|
-
throw new
|
|
26
|
+
throw new Error(response.error ?? "Failed to save embeddings");
|
|
118
27
|
}
|
|
119
|
-
if (response.operation !== "
|
|
120
|
-
throw new
|
|
28
|
+
if (response.operation !== "saveEmbeddings") {
|
|
29
|
+
throw new Error("Invalid operation in response");
|
|
121
30
|
}
|
|
122
31
|
return {
|
|
123
32
|
processed: response.processed,
|
|
124
33
|
droppedIndices: response.droppedIndices,
|
|
125
34
|
};
|
|
126
35
|
}
|
|
127
|
-
// ============== SaveEmbeddings ==============
|
|
128
|
-
/**
|
|
129
|
-
* Saves pre-embedded documents to the RAG vector database.
|
|
130
|
-
* Part of the segregated flow: chunk() → embed() → saveEmbeddings()
|
|
131
|
-
*
|
|
132
|
-
* **Workspace lifecycle:** This operation implicitly opens (or creates) the workspace.
|
|
133
|
-
* The workspace remains open until closed.
|
|
134
|
-
*
|
|
135
|
-
* @param params - The parameters for saving
|
|
136
|
-
* @param params.documents - Pre-embedded documents (must have id, content, embedding, embeddingModelId)
|
|
137
|
-
* @param params.workspace - Workspace for isolated storage (default: "default"). Created if it doesn't exist.
|
|
138
|
-
* @param params.onProgress - Progress callback (stage, current, total)
|
|
139
|
-
* @param params.progressInterval - Minimum interval between progress updates in ms
|
|
140
|
-
* @returns Array of save results
|
|
141
|
-
* @throws {RAGSaveFailedError} When the operation fails
|
|
142
|
-
* @throws {StreamEndedError} When streaming ends unexpectedly (only when using onProgress)
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* ```typescript
|
|
146
|
-
* // Segregated flow
|
|
147
|
-
* const chunks = await ragChunk({ documents: ["text1", "text2"] });
|
|
148
|
-
* const embeddings = await embed({ modelId, text: chunks.map(c => c.content) });
|
|
149
|
-
* const embeddedDocs = chunks.map((chunk, i) => ({
|
|
150
|
-
* ...chunk,
|
|
151
|
-
* embedding: embeddings[i],
|
|
152
|
-
* embeddingModelId: modelId,
|
|
153
|
-
* }));
|
|
154
|
-
* const result = await ragSaveEmbeddings({
|
|
155
|
-
* documents: embeddedDocs,
|
|
156
|
-
* workspace: "my-workspace",
|
|
157
|
-
* });
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
export async function ragSaveEmbeddings(params, options) {
|
|
161
|
-
const { onProgress, ...requestParams } = params;
|
|
162
|
-
const request = {
|
|
163
|
-
type: "rag",
|
|
164
|
-
operation: "saveEmbeddings",
|
|
165
|
-
...requestParams,
|
|
166
|
-
withProgress: onProgress ? true : undefined,
|
|
167
|
-
};
|
|
168
|
-
if (onProgress) {
|
|
169
|
-
for await (const event of stream(request, options)) {
|
|
170
|
-
if (event.type === "rag:progress" &&
|
|
171
|
-
event.operation === "saveEmbeddings") {
|
|
172
|
-
const progress = event;
|
|
173
|
-
onProgress(progress.stage, progress.current, progress.total);
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
if (event.type === "rag" && event.operation === "saveEmbeddings") {
|
|
177
|
-
if (!event.success) {
|
|
178
|
-
throw new RAGSaveFailedError(event.error);
|
|
179
|
-
}
|
|
180
|
-
return event.processed;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
throw new StreamEndedError();
|
|
184
|
-
}
|
|
185
|
-
const response = await send(request, options);
|
|
186
|
-
if (response.type !== "rag") {
|
|
187
|
-
throw new InvalidResponseError("rag");
|
|
188
|
-
}
|
|
189
|
-
if (!response.success) {
|
|
190
|
-
throw new RAGSaveFailedError(response.error);
|
|
191
|
-
}
|
|
192
|
-
if (response.operation !== "saveEmbeddings") {
|
|
193
|
-
throw new InvalidOperationError();
|
|
194
|
-
}
|
|
195
|
-
return response.processed;
|
|
196
|
-
}
|
|
197
36
|
// ============== Search ==============
|
|
198
37
|
/**
|
|
199
38
|
* Searches for similar documents in the RAG vector database.
|
|
200
39
|
*
|
|
201
|
-
* **Workspace lifecycle:** This operation requires an existing workspace. If the workspace
|
|
202
|
-
* doesn't exist, returns an empty array.
|
|
203
|
-
*
|
|
204
40
|
* @param params - The parameters for searching
|
|
205
41
|
* @param params.modelId - The identifier of the embedding model to use
|
|
206
42
|
* @param params.query - The search query text
|
|
207
43
|
* @param params.topK - Number of top results to retrieve (default: 5)
|
|
208
44
|
* @param params.n - Number of centroids to use for IVF index search (default: 3)
|
|
209
|
-
* @param params.workspace -
|
|
210
|
-
* @
|
|
211
|
-
* @
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```typescript
|
|
215
|
-
* const results = await ragSearch({
|
|
216
|
-
* modelId,
|
|
217
|
-
* query: "AI and machine learning",
|
|
218
|
-
* topK: 5,
|
|
219
|
-
* workspace: "my-docs",
|
|
220
|
-
* });
|
|
221
|
-
* ```
|
|
45
|
+
* @param params.workspace - Optional workspace for isolated storage
|
|
46
|
+
* @throws {Error} When the response type is invalid or when the operation fails
|
|
47
|
+
* @returns Array of search results with id, content, and score
|
|
222
48
|
*/
|
|
223
|
-
export async function ragSearch(params
|
|
49
|
+
export async function ragSearch(params) {
|
|
224
50
|
const request = {
|
|
225
51
|
type: "rag",
|
|
226
52
|
operation: "search",
|
|
@@ -228,15 +54,15 @@ export async function ragSearch(params, options) {
|
|
|
228
54
|
topK: params.topK ?? 5,
|
|
229
55
|
n: params.n ?? 3,
|
|
230
56
|
};
|
|
231
|
-
const response = await send(request
|
|
57
|
+
const response = await send(request);
|
|
232
58
|
if (response.type !== "rag") {
|
|
233
|
-
throw new
|
|
59
|
+
throw new Error("Invalid response type");
|
|
234
60
|
}
|
|
235
61
|
if (!response.success) {
|
|
236
|
-
throw new
|
|
62
|
+
throw new Error(response.error ?? "Failed to search");
|
|
237
63
|
}
|
|
238
64
|
if (response.operation !== "search") {
|
|
239
|
-
throw new
|
|
65
|
+
throw new Error("Invalid operation in response");
|
|
240
66
|
}
|
|
241
67
|
return response.results;
|
|
242
68
|
}
|
|
@@ -244,214 +70,28 @@ export async function ragSearch(params, options) {
|
|
|
244
70
|
/**
|
|
245
71
|
* Deletes document embeddings from the RAG vector database.
|
|
246
72
|
*
|
|
247
|
-
* **Workspace lifecycle:** This operation requires an existing workspace.
|
|
248
|
-
*
|
|
249
73
|
* @param params - The parameters for deleting embeddings
|
|
74
|
+
* @param params.modelId - The identifier of the embedding model (must match workspace model)
|
|
250
75
|
* @param params.ids - Array of document IDs to delete
|
|
251
|
-
* @param params.workspace -
|
|
252
|
-
* @throws {
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```typescript
|
|
256
|
-
* await ragDeleteEmbeddings({
|
|
257
|
-
* ids: ["doc-1", "doc-2"],
|
|
258
|
-
* workspace: "my-docs",
|
|
259
|
-
* });
|
|
260
|
-
* ```
|
|
76
|
+
* @param params.workspace - Optional workspace for isolated storage
|
|
77
|
+
* @throws {Error} When the response type is invalid or when the operation fails
|
|
78
|
+
* @returns boolean indicating success
|
|
261
79
|
*/
|
|
262
|
-
export async function ragDeleteEmbeddings(params
|
|
80
|
+
export async function ragDeleteEmbeddings(params) {
|
|
263
81
|
const request = {
|
|
264
82
|
type: "rag",
|
|
265
83
|
operation: "deleteEmbeddings",
|
|
266
84
|
...params,
|
|
267
85
|
};
|
|
268
|
-
const response = await send(request
|
|
86
|
+
const response = await send(request);
|
|
269
87
|
if (response.type !== "rag") {
|
|
270
|
-
throw new
|
|
88
|
+
throw new Error("Invalid response type");
|
|
271
89
|
}
|
|
272
90
|
if (!response.success) {
|
|
273
|
-
throw new
|
|
91
|
+
throw new Error(response.error ?? "Failed to delete embeddings");
|
|
274
92
|
}
|
|
275
93
|
if (response.operation !== "deleteEmbeddings") {
|
|
276
|
-
throw new
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// ============== Reindex ==============
|
|
280
|
-
/**
|
|
281
|
-
* Reindexes the RAG database to optimize search performance.
|
|
282
|
-
* For HyperDB, this rebalances centroids using k-means clustering.
|
|
283
|
-
*
|
|
284
|
-
* **Workspace lifecycle:** This operation requires an existing workspace.
|
|
285
|
-
*
|
|
286
|
-
* **Note:** Reindex requires a minimum number of documents to perform clustering.
|
|
287
|
-
* For HyperDB, this is 16 documents by default. If there are insufficient documents,
|
|
288
|
-
* `reindexed` will be `false` with `details` explaining the reason.
|
|
289
|
-
*
|
|
290
|
-
* @param params - The parameters for reindexing
|
|
291
|
-
* @param params.workspace - Workspace to reindex (default: "default"). Must already exist.
|
|
292
|
-
* @param params.onProgress - Progress callback (stage, current, total)
|
|
293
|
-
* @returns Reindex result with `reindexed` boolean and optional `details`
|
|
294
|
-
* @throws {RAGSaveFailedError} When the operation fails or workspace doesn't exist
|
|
295
|
-
* @throws {StreamEndedError} When streaming ends unexpectedly (only when using onProgress)
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* ```typescript
|
|
299
|
-
* // Simple reindex
|
|
300
|
-
* const result = await ragReindex({
|
|
301
|
-
* workspace: "my-docs",
|
|
302
|
-
* });
|
|
303
|
-
*
|
|
304
|
-
* // Check result
|
|
305
|
-
* if (!result.reindexed) {
|
|
306
|
-
* console.log("Reindex skipped:", result.details?.reason);
|
|
307
|
-
* }
|
|
308
|
-
*
|
|
309
|
-
* // With progress tracking
|
|
310
|
-
* const result = await ragReindex({
|
|
311
|
-
* workspace: "my-docs",
|
|
312
|
-
* onProgress: (stage, current, total) => {
|
|
313
|
-
* console.log(`[${stage}] ${current}/${total}`);
|
|
314
|
-
* },
|
|
315
|
-
* });
|
|
316
|
-
* ```
|
|
317
|
-
*/
|
|
318
|
-
export async function ragReindex(params, options) {
|
|
319
|
-
const { onProgress, ...requestParams } = params;
|
|
320
|
-
const request = {
|
|
321
|
-
type: "rag",
|
|
322
|
-
operation: "reindex",
|
|
323
|
-
...requestParams,
|
|
324
|
-
withProgress: onProgress ? true : undefined,
|
|
325
|
-
};
|
|
326
|
-
if (onProgress) {
|
|
327
|
-
for await (const event of stream(request, options)) {
|
|
328
|
-
if (event.type === "rag:progress" && event.operation === "reindex") {
|
|
329
|
-
const progress = event;
|
|
330
|
-
onProgress(progress.stage, progress.current, progress.total);
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
if (event.type === "rag" && event.operation === "reindex") {
|
|
334
|
-
if (!event.success) {
|
|
335
|
-
throw new RAGSaveFailedError(event.error);
|
|
336
|
-
}
|
|
337
|
-
return event.result;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
throw new StreamEndedError();
|
|
341
|
-
}
|
|
342
|
-
const response = await send(request, options);
|
|
343
|
-
if (response.type !== "rag") {
|
|
344
|
-
throw new InvalidResponseError("rag");
|
|
345
|
-
}
|
|
346
|
-
if (!response.success) {
|
|
347
|
-
throw new RAGSaveFailedError(response.error);
|
|
348
|
-
}
|
|
349
|
-
if (response.operation !== "reindex") {
|
|
350
|
-
throw new InvalidOperationError();
|
|
351
|
-
}
|
|
352
|
-
return response.result;
|
|
353
|
-
}
|
|
354
|
-
// ============== List Workspaces ==============
|
|
355
|
-
/**
|
|
356
|
-
* Lists all RAG workspaces with their open status.
|
|
357
|
-
*
|
|
358
|
-
* Returns all workspaces that exist on disk. The `open` field indicates whether
|
|
359
|
-
* the workspace is currently loaded in memory and holding active resources
|
|
360
|
-
* (Corestore, HyperDB adapter, and possibly a RAG instance).
|
|
361
|
-
*
|
|
362
|
-
* @returns Array of workspace info with name and open status
|
|
363
|
-
* @throws {RAGListWorkspacesFailedError} When the operation fails
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* ```typescript
|
|
367
|
-
* const workspaces = await ragListWorkspaces();
|
|
368
|
-
* // [{ name: "default", open: true }, { name: "my-docs", open: false }]
|
|
369
|
-
* ```
|
|
370
|
-
*/
|
|
371
|
-
export async function ragListWorkspaces(options) {
|
|
372
|
-
const request = {
|
|
373
|
-
type: "rag",
|
|
374
|
-
operation: "listWorkspaces",
|
|
375
|
-
};
|
|
376
|
-
const response = await send(request, options);
|
|
377
|
-
if (response.type !== "rag") {
|
|
378
|
-
throw new InvalidResponseError("rag");
|
|
379
|
-
}
|
|
380
|
-
if (!response.success) {
|
|
381
|
-
throw new RAGListWorkspacesFailedError(response.error);
|
|
382
|
-
}
|
|
383
|
-
if (response.operation !== "listWorkspaces") {
|
|
384
|
-
throw new InvalidOperationError();
|
|
385
|
-
}
|
|
386
|
-
return response.workspaces;
|
|
387
|
-
}
|
|
388
|
-
// ============== Close Workspace ==============
|
|
389
|
-
/**
|
|
390
|
-
* Closes a RAG workspace, releasing in-memory resources (Corestore, HyperDB adapter, RAG instance).
|
|
391
|
-
*
|
|
392
|
-
* **Workspace lifecycle:** Workspaces are implicitly opened.
|
|
393
|
-
* This function explicitly closes them, releasing memory and file locks. The workspace data
|
|
394
|
-
* remains on disk unless `deleteOnClose` is set to true.
|
|
395
|
-
*
|
|
396
|
-
* @param params - The parameters for closing
|
|
397
|
-
* @param params.workspace - Name of the workspace to close (default: "default")
|
|
398
|
-
* @param params.deleteOnClose - If true, deletes the workspace data from disk after closing (default: false)
|
|
399
|
-
* @throws {RAGCloseWorkspaceFailedError} When the operation fails
|
|
400
|
-
*
|
|
401
|
-
* @example
|
|
402
|
-
* ```typescript
|
|
403
|
-
* // Close a specific workspace
|
|
404
|
-
* await ragCloseWorkspace({ workspace: "my-docs" });
|
|
405
|
-
*
|
|
406
|
-
* // Close and delete in one call
|
|
407
|
-
* await ragCloseWorkspace({ workspace: "my-docs", deleteOnClose: true });
|
|
408
|
-
* ```
|
|
409
|
-
*/
|
|
410
|
-
export async function ragCloseWorkspace(params, options) {
|
|
411
|
-
const request = {
|
|
412
|
-
type: "rag",
|
|
413
|
-
operation: "closeWorkspace",
|
|
414
|
-
...params,
|
|
415
|
-
};
|
|
416
|
-
const response = await send(request, options);
|
|
417
|
-
if (response.type !== "rag") {
|
|
418
|
-
throw new InvalidResponseError("rag");
|
|
419
|
-
}
|
|
420
|
-
if (!response.success) {
|
|
421
|
-
throw new RAGCloseWorkspaceFailedError(response.error);
|
|
422
|
-
}
|
|
423
|
-
if (response.operation !== "closeWorkspace") {
|
|
424
|
-
throw new InvalidOperationError();
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
// ============== Delete Workspace ==============
|
|
428
|
-
/**
|
|
429
|
-
* Deletes a RAG workspace and all its data.
|
|
430
|
-
* The workspace must not be currently loaded/in-use.
|
|
431
|
-
*
|
|
432
|
-
* @param params - The parameters for deletion
|
|
433
|
-
* @param params.workspace - Name of the workspace to delete
|
|
434
|
-
* @throws {RAGDeleteFailedError} When the workspace doesn't exist or is currently loaded
|
|
435
|
-
*
|
|
436
|
-
* @example
|
|
437
|
-
* ```typescript
|
|
438
|
-
* await ragDeleteWorkspace({ workspace: "my-docs" });
|
|
439
|
-
* ```
|
|
440
|
-
*/
|
|
441
|
-
export async function ragDeleteWorkspace(params, options) {
|
|
442
|
-
const request = {
|
|
443
|
-
type: "rag",
|
|
444
|
-
operation: "deleteWorkspace",
|
|
445
|
-
...params,
|
|
446
|
-
};
|
|
447
|
-
const response = await send(request, options);
|
|
448
|
-
if (response.type !== "rag") {
|
|
449
|
-
throw new InvalidResponseError("rag");
|
|
450
|
-
}
|
|
451
|
-
if (!response.success) {
|
|
452
|
-
throw new RAGDeleteFailedError(response.error);
|
|
453
|
-
}
|
|
454
|
-
if (response.operation !== "deleteWorkspace") {
|
|
455
|
-
throw new InvalidOperationError();
|
|
94
|
+
throw new Error("Invalid operation in response");
|
|
456
95
|
}
|
|
96
|
+
return response.success;
|
|
457
97
|
}
|
|
@@ -5,7 +5,7 @@ import { type StopProvideParams } from "../../schemas/index";
|
|
|
5
5
|
* @param options - Options object with required topic
|
|
6
6
|
* @param options.topic - Topic hex string to leave
|
|
7
7
|
* @returns A promise that resolves to the stop provide response containing success status
|
|
8
|
-
* @throws {
|
|
8
|
+
* @throws {Error} When the response type is not "stopProvide" or the request fails
|
|
9
9
|
*/
|
|
10
10
|
export declare function stopQVACProvider(params: StopProvideParams): Promise<{
|
|
11
11
|
type: "stopProvide";
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import {} from "../../schemas/index.js";
|
|
2
2
|
import { send } from "../rpc/rpc-client.js";
|
|
3
|
-
import { InvalidResponseError, ProviderStopFailedError, } from "../../utils/errors-client.js";
|
|
4
3
|
/**
|
|
5
4
|
* Stops a running provider service and leaves the specified topic.
|
|
6
5
|
*
|
|
7
6
|
* @param options - Options object with required topic
|
|
8
7
|
* @param options.topic - Topic hex string to leave
|
|
9
8
|
* @returns A promise that resolves to the stop provide response containing success status
|
|
10
|
-
* @throws {
|
|
9
|
+
* @throws {Error} When the response type is not "stopProvide" or the request fails
|
|
11
10
|
*/
|
|
12
11
|
export async function stopQVACProvider(params) {
|
|
13
12
|
const request = {
|
|
@@ -16,10 +15,10 @@ export async function stopQVACProvider(params) {
|
|
|
16
15
|
};
|
|
17
16
|
const response = await send(request);
|
|
18
17
|
if (response.type !== "stopProvide") {
|
|
19
|
-
throw new
|
|
18
|
+
throw new Error("Invalid response type");
|
|
20
19
|
}
|
|
21
20
|
if (response.error) {
|
|
22
|
-
throw new
|
|
21
|
+
throw new Error(response.error);
|
|
23
22
|
}
|
|
24
23
|
return response;
|
|
25
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type TtsClientParams
|
|
2
|
-
export declare function textToSpeech(params: TtsClientParams
|
|
1
|
+
import { type TtsClientParams } from "../../schemas/index";
|
|
2
|
+
export declare function textToSpeech(params: TtsClientParams): {
|
|
3
3
|
bufferStream: AsyncGenerator<number>;
|
|
4
4
|
buffer: Promise<number[]>;
|
|
5
5
|
done: Promise<boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ttsResponseSchema, } from "../../schemas/index.js";
|
|
2
2
|
import { stream as streamRpc } from "../rpc/rpc-client.js";
|
|
3
|
-
export function textToSpeech(params
|
|
3
|
+
export function textToSpeech(params) {
|
|
4
4
|
const request = {
|
|
5
5
|
type: "textToSpeech",
|
|
6
6
|
modelId: params.modelId,
|
|
@@ -14,7 +14,7 @@ export function textToSpeech(params, options) {
|
|
|
14
14
|
});
|
|
15
15
|
if (params.stream) {
|
|
16
16
|
const bufferStream = (async function* () {
|
|
17
|
-
for await (const response of streamRpc(request
|
|
17
|
+
for await (const response of streamRpc(request)) {
|
|
18
18
|
if (response.type === "textToSpeech") {
|
|
19
19
|
const streamResponse = ttsResponseSchema.parse(response);
|
|
20
20
|
if (streamResponse.buffer.length > 0) {
|
|
@@ -38,7 +38,7 @@ export function textToSpeech(params, options) {
|
|
|
38
38
|
})();
|
|
39
39
|
const bufferPromise = (async () => {
|
|
40
40
|
let buffer = [];
|
|
41
|
-
for await (const response of streamRpc(request
|
|
41
|
+
for await (const response of streamRpc(request)) {
|
|
42
42
|
if (response.type === "textToSpeech") {
|
|
43
43
|
const streamResponse = ttsResponseSchema.parse(response);
|
|
44
44
|
buffer = buffer.concat(streamResponse.buffer);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TranscribeClientParams
|
|
1
|
+
import { type TranscribeClientParams } from "../../schemas/index";
|
|
2
2
|
/**
|
|
3
3
|
* This function streams audio transcription results in real-time, yielding
|
|
4
4
|
* text chunks as they become available from the model.
|
|
@@ -6,12 +6,10 @@ import { type TranscribeClientParams, type RPCOptions } from "../../schemas/inde
|
|
|
6
6
|
* @param params - The arguments for the transcription
|
|
7
7
|
* @param params.modelId - The identifier of the transcription model to use
|
|
8
8
|
* @param params.audioChunk - Audio input as either a file path (string) or audio buffer
|
|
9
|
-
* @param params.prompt - Optional initial prompt to guide the transcription
|
|
10
|
-
* @param options - Optional RPC options including per-call profiling
|
|
11
9
|
* @yields {string} Text chunks as they are transcribed
|
|
12
|
-
* @throws {
|
|
10
|
+
* @throws {Error} When transcription fails with an error message
|
|
13
11
|
*/
|
|
14
|
-
export declare function transcribeStream(params: TranscribeClientParams
|
|
12
|
+
export declare function transcribeStream(params: TranscribeClientParams): AsyncGenerator<string, void, unknown>;
|
|
15
13
|
/**
|
|
16
14
|
* This function provides a simple interface for transcribing audio by
|
|
17
15
|
* collecting all streaming results into a single string response.
|
|
@@ -19,10 +17,8 @@ export declare function transcribeStream(params: TranscribeClientParams, options
|
|
|
19
17
|
* @param params - The arguments for the transcription
|
|
20
18
|
* @param params.modelId - The identifier of the transcription model to use
|
|
21
19
|
* @param params.audioChunk - Audio input as either a file path (string) or audio buffer
|
|
22
|
-
* @param params.prompt - Optional initial prompt to guide the transcription
|
|
23
|
-
* @param options - Optional RPC options including per-call profiling
|
|
24
20
|
* @returns {Promise<string>} The complete transcribed text
|
|
25
|
-
* @throws {
|
|
21
|
+
* @throws {Error} When transcription fails (propagated from transcribeStream)
|
|
26
22
|
*/
|
|
27
|
-
export declare function transcribe(params: TranscribeClientParams
|
|
23
|
+
export declare function transcribe(params: TranscribeClientParams): Promise<string>;
|
|
28
24
|
//# sourceMappingURL=transcribe.d.ts.map
|
|
@@ -7,23 +7,23 @@ import { stream } from "../rpc/rpc-client.js";
|
|
|
7
7
|
* @param params - The arguments for the transcription
|
|
8
8
|
* @param params.modelId - The identifier of the transcription model to use
|
|
9
9
|
* @param params.audioChunk - Audio input as either a file path (string) or audio buffer
|
|
10
|
-
* @param params.prompt - Optional initial prompt to guide the transcription
|
|
11
|
-
* @param options - Optional RPC options including per-call profiling
|
|
12
10
|
* @yields {string} Text chunks as they are transcribed
|
|
13
|
-
* @throws {
|
|
11
|
+
* @throws {Error} When transcription fails with an error message
|
|
14
12
|
*/
|
|
15
|
-
export async function* transcribeStream(params
|
|
13
|
+
export async function* transcribeStream(params) {
|
|
16
14
|
const request = {
|
|
17
15
|
type: "transcribeStream",
|
|
18
16
|
modelId: params.modelId,
|
|
19
17
|
audioChunk: typeof params.audioChunk === "string"
|
|
20
18
|
? { type: "filePath", value: params.audioChunk }
|
|
21
19
|
: { type: "base64", value: params.audioChunk.toString("base64") },
|
|
22
|
-
...(params.prompt && { prompt: params.prompt }),
|
|
23
20
|
};
|
|
24
|
-
for await (const response of stream(request
|
|
21
|
+
for await (const response of stream(request)) {
|
|
25
22
|
if (response.type === "transcribeStream") {
|
|
26
23
|
const streamResponse = transcribeStreamResponseSchema.parse(response);
|
|
24
|
+
if (streamResponse.error) {
|
|
25
|
+
throw new Error(`Transcription failed: ${streamResponse.error}`);
|
|
26
|
+
}
|
|
27
27
|
if (streamResponse.text) {
|
|
28
28
|
yield streamResponse.text;
|
|
29
29
|
}
|
|
@@ -40,14 +40,12 @@ export async function* transcribeStream(params, options) {
|
|
|
40
40
|
* @param params - The arguments for the transcription
|
|
41
41
|
* @param params.modelId - The identifier of the transcription model to use
|
|
42
42
|
* @param params.audioChunk - Audio input as either a file path (string) or audio buffer
|
|
43
|
-
* @param params.prompt - Optional initial prompt to guide the transcription
|
|
44
|
-
* @param options - Optional RPC options including per-call profiling
|
|
45
43
|
* @returns {Promise<string>} The complete transcribed text
|
|
46
|
-
* @throws {
|
|
44
|
+
* @throws {Error} When transcription fails (propagated from transcribeStream)
|
|
47
45
|
*/
|
|
48
|
-
export async function transcribe(params
|
|
46
|
+
export async function transcribe(params) {
|
|
49
47
|
let fullText = "";
|
|
50
|
-
for await (const textChunk of transcribeStream(params
|
|
48
|
+
for await (const textChunk of transcribeStream(params)) {
|
|
51
49
|
fullText += textChunk;
|
|
52
50
|
}
|
|
53
51
|
return fullText;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TranslateClientParams, type TranslationStats
|
|
1
|
+
import { type TranslateClientParams, type TranslationStats } from "../../schemas/index";
|
|
2
2
|
/**
|
|
3
3
|
* Translates text from one language to another using a specified translation model.
|
|
4
4
|
* Supports both NMT (Neural Machine Translation) and LLM models.
|
|
@@ -10,7 +10,7 @@ import { type TranslateClientParams, type TranslationStats, type RPCOptions } fr
|
|
|
10
10
|
* @param params.to - Target language code
|
|
11
11
|
* @param params.stream - Whether to stream tokens (true) or return complete response (false). Defaults to true.
|
|
12
12
|
* @returns Object with tokenStream generator and text/stats properties
|
|
13
|
-
* @throws {
|
|
13
|
+
* @throws {Error} When translation fails with an error message or when language detection fails
|
|
14
14
|
* @example
|
|
15
15
|
* ```typescript
|
|
16
16
|
* // Streaming mode (default)
|
|
@@ -39,7 +39,7 @@ import { type TranslateClientParams, type TranslationStats, type RPCOptions } fr
|
|
|
39
39
|
* console.log(await response.text);
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
export declare function translate(params: TranslateClientParams
|
|
42
|
+
export declare function translate(params: TranslateClientParams): {
|
|
43
43
|
tokenStream: AsyncGenerator<string>;
|
|
44
44
|
stats: Promise<TranslationStats | undefined>;
|
|
45
45
|
text: Promise<string>;
|