@qvac/sdk 0.2.7-dev.1761566029.f834aa3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -3
- package/dist/client/api/cancel.d.ts +1 -1
- package/dist/client/api/cancel.js +4 -3
- package/dist/client/api/completion-stream.d.ts +24 -32
- package/dist/client/api/completion-stream.js +142 -50
- package/dist/client/api/delete-cache.js +3 -2
- package/dist/client/api/download-asset.d.ts +3 -3
- package/dist/client/api/download-asset.js +12 -17
- package/dist/client/api/embed.d.ts +1 -1
- package/dist/client/api/embed.js +4 -3
- package/dist/client/api/get-model-info.d.ts +29 -0
- package/dist/client/api/get-model-info.js +14 -0
- package/dist/client/api/index.d.ts +4 -0
- package/dist/client/api/index.js +4 -0
- package/dist/client/api/load-model.d.ts +3 -3
- package/dist/client/api/load-model.js +13 -22
- package/dist/client/api/logging-stream.d.ts +1 -1
- package/dist/client/api/logging-stream.js +3 -2
- package/dist/client/api/ping.d.ts +1 -1
- package/dist/client/api/ping.js +3 -2
- package/dist/client/api/provide.d.ts +1 -1
- package/dist/client/api/provide.js +4 -3
- package/dist/client/api/rag.d.ts +3 -3
- package/dist/client/api/rag.js +13 -12
- package/dist/client/api/set-config.d.ts +7 -0
- package/dist/client/api/set-config.js +20 -0
- package/dist/client/api/stop-provider.d.ts +15 -0
- package/dist/client/api/stop-provider.js +25 -0
- package/dist/client/api/text-to-speech.d.ts +7 -0
- package/dist/client/api/text-to-speech.js +58 -0
- package/dist/client/api/transcribe.d.ts +4 -2
- package/dist/client/api/transcribe.js +9 -5
- package/dist/client/api/translate.d.ts +1 -1
- package/dist/client/api/translate.js +3 -2
- package/dist/client/api/unload-model.d.ts +5 -1
- package/dist/client/api/unload-model.js +14 -4
- package/dist/client/config-manager.d.ts +4 -0
- package/dist/client/config-manager.js +8 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/init-hooks.d.ts +6 -0
- package/dist/client/init-hooks.js +37 -0
- package/dist/client/rpc/bare-client.d.ts +73 -0
- package/dist/client/rpc/bare-client.js +5 -4
- package/dist/client/rpc/bare-rpc-client.js +7 -3
- package/dist/client/rpc/expo-rpc-client.d.ts +1 -0
- package/dist/client/rpc/expo-rpc-client.js +9 -1
- package/dist/client/rpc/node-rpc-client.d.ts +1 -1
- package/dist/client/rpc/node-rpc-client.js +22 -9
- package/dist/client/rpc/rpc-client.d.ts +1 -0
- package/dist/client/rpc/rpc-client.js +27 -3
- package/dist/examples/cache-management.d.ts +2 -0
- package/dist/examples/cache-management.js +97 -0
- package/dist/examples/delegated-inference/consumer.js +2 -2
- package/dist/examples/download-with-blind-relays.d.ts +2 -0
- package/dist/examples/download-with-blind-relays.js +48 -0
- package/dist/examples/download-with-cancel.js +3 -4
- package/dist/examples/embed-hyperdrive.js +0 -1
- package/dist/examples/kv-cache-cleanup.js +0 -1
- package/dist/examples/kv-cache-custom-key.js +0 -1
- package/dist/examples/kv-cache-example.js +0 -1
- package/dist/examples/llamacpp-file-logging.js +0 -1
- package/dist/examples/llamacpp-filesystem.js +2 -2
- package/dist/examples/llamacpp-http.js +0 -1
- package/dist/examples/llamacpp-hyperdrive.js +0 -1
- package/dist/examples/llamacpp-multimodal.js +0 -1
- package/dist/examples/llamacpp-native-tools.js +118 -36
- package/dist/examples/llamacpp-sharded.d.ts +2 -0
- package/dist/examples/llamacpp-sharded.js +44 -0
- package/dist/examples/multi-model-demo.js +0 -1
- package/dist/examples/parallel-download.js +2 -2
- package/dist/examples/rag/rag-chromadb.js +0 -1
- package/dist/examples/rag/rag-hyperdb-workspaces.js +0 -1
- package/dist/examples/rag/rag-hyperdb.js +0 -1
- package/dist/examples/rag/rag-lancedb.js +0 -1
- package/dist/examples/rag/rag-sqlite.js +0 -1
- package/dist/examples/text-to-speech.d.ts +3 -0
- package/dist/examples/text-to-speech.js +137 -0
- package/dist/examples/translation/translation-indic.js +3 -1
- package/dist/examples/translation/translation-llm-context.js +0 -1
- package/dist/examples/translation/translation-llm.js +2 -2
- package/dist/examples/translation/translation-opus.js +3 -1
- package/dist/examples/translation/translation-stream.js +0 -1
- package/dist/examples/whispercpp-filesystem.js +32 -5
- package/dist/examples/whispercpp-microphone-record.js +9 -9
- package/dist/examples/whispercpp-prompt.d.ts +2 -0
- package/dist/examples/whispercpp-prompt.js +68 -0
- package/dist/expo/plugins/withMobileBundle.js +9 -3
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/models/hyperdrive/models.d.ts +1924 -100
- package/dist/models/hyperdrive/models.js +2051 -105
- package/dist/schemas/common.d.ts +420 -58
- package/dist/schemas/common.js +12 -0
- package/dist/schemas/completion-stream.d.ts +26 -22
- package/dist/schemas/completion-stream.js +9 -23
- package/dist/schemas/download-asset.d.ts +77 -2
- package/dist/schemas/download-asset.js +15 -4
- package/dist/schemas/get-model-info.d.ts +100 -0
- package/dist/schemas/get-model-info.js +40 -0
- package/dist/schemas/index.d.ts +8 -0
- package/dist/schemas/index.js +8 -0
- package/dist/schemas/llamacpp-config.d.ts +2 -1
- package/dist/schemas/llamacpp-config.js +3 -4
- package/dist/schemas/load-model.d.ts +2316 -266
- package/dist/schemas/load-model.js +157 -10
- package/dist/schemas/model-src-utils.d.ts +98 -0
- package/dist/schemas/model-src-utils.js +31 -0
- package/dist/schemas/sdk-errors-client.d.ts +25 -0
- package/dist/schemas/sdk-errors-client.js +111 -0
- package/dist/schemas/sdk-errors-server.d.ts +55 -0
- package/dist/schemas/sdk-errors-server.js +271 -0
- package/dist/schemas/set-config.d.ts +21 -0
- package/dist/schemas/set-config.js +14 -0
- package/dist/schemas/stop-provide.d.ts +17 -0
- package/dist/schemas/stop-provide.js +15 -0
- package/dist/schemas/text-to-speech.d.ts +34 -0
- package/dist/schemas/text-to-speech.js +25 -0
- package/dist/schemas/tools.d.ts +62 -0
- package/dist/schemas/tools.js +43 -0
- package/dist/schemas/transcription.d.ts +25 -2
- package/dist/schemas/transcription.js +12 -1
- package/dist/schemas/translation-config.d.ts +33 -5
- package/dist/schemas/translation-config.js +18 -1
- package/dist/schemas/unload-model.d.ts +2 -0
- package/dist/schemas/unload-model.js +2 -0
- package/dist/schemas/whispercpp-config.d.ts +55 -18
- package/dist/schemas/whispercpp-config.js +63 -15
- package/dist/server/bare/addons/cancel.js +2 -1
- package/dist/server/bare/addons/llamacpp/create-model.d.ts +9 -2
- package/dist/server/bare/addons/llamacpp/create-model.js +23 -23
- package/dist/server/bare/addons/llamacpp/handlers/completion-stream.d.ts +10 -2
- package/dist/server/bare/addons/llamacpp/handlers/completion-stream.js +62 -43
- package/dist/server/bare/addons/llamacpp/handlers/embed.js +3 -2
- package/dist/server/bare/addons/llamacpp/kv-cache-utils.d.ts +1 -1
- package/dist/server/bare/addons/llamacpp/kv-cache-utils.js +6 -2
- package/dist/server/bare/addons/load-model.js +59 -28
- package/dist/server/bare/addons/translation/create-model.d.ts +5 -1
- package/dist/server/bare/addons/translation/create-model.js +17 -25
- package/dist/server/bare/addons/translation/handlers/translate.js +10 -1
- package/dist/server/bare/addons/tts/create-model.d.ts +10 -0
- package/dist/server/bare/addons/tts/create-model.js +25 -0
- package/dist/server/bare/addons/tts/handlers/text-to-speech.d.ts +3 -0
- package/dist/server/bare/addons/tts/handlers/text-to-speech.js +87 -0
- 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 +21 -3
- package/dist/server/bare/addons/whispercpp/create-model.d.ts +5 -1
- package/dist/server/bare/addons/whispercpp/create-model.js +13 -32
- package/dist/server/bare/addons/whispercpp/handlers/transcribe-stream.js +41 -20
- package/dist/server/bare/delegate-rpc-client.js +3 -2
- package/dist/server/bare/hyperswarm.d.ts +3 -0
- package/dist/server/bare/hyperswarm.js +22 -1
- package/dist/server/bare/rag-hyperdb/rag-manager.js +16 -13
- package/dist/server/bare/registry/config-registry.d.ts +5 -0
- package/dist/server/bare/registry/config-registry.js +39 -0
- package/dist/server/bare/registry/logging-stream-registry.d.ts +1 -0
- package/dist/server/bare/registry/logging-stream-registry.js +7 -0
- package/dist/server/bare/registry/model-registry.d.ts +13 -0
- package/dist/server/bare/registry/model-registry.js +24 -7
- package/dist/server/rpc/handle-request.js +48 -3
- package/dist/server/rpc/handlers/completion-stream-delegated.js +2 -1
- package/dist/server/rpc/handlers/completion-stream.js +11 -4
- package/dist/server/rpc/handlers/download-asset.js +2 -3
- package/dist/server/rpc/handlers/get-model-info.d.ts +3 -0
- package/dist/server/rpc/handlers/get-model-info.js +148 -0
- package/dist/server/rpc/handlers/index.d.ts +6 -0
- package/dist/server/rpc/handlers/index.js +8 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +1 -0
- package/dist/server/rpc/handlers/load-model/download-manager.js +12 -31
- package/dist/server/rpc/handlers/load-model/http.js +51 -10
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +336 -156
- package/dist/server/rpc/handlers/load-model/index.js +1 -1
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +1 -1
- package/dist/server/rpc/handlers/load-model/resolve.js +17 -60
- package/dist/server/rpc/handlers/load-model-delegated.js +7 -4
- package/dist/server/rpc/handlers/load-model.js +19 -1
- package/dist/server/rpc/handlers/provideHandler/handler.js +2 -1
- package/dist/server/rpc/handlers/rag.js +0 -3
- package/dist/server/rpc/handlers/set-config.d.ts +3 -0
- package/dist/server/rpc/handlers/set-config.js +18 -0
- package/dist/server/rpc/handlers/stopProvideHandler.d.ts +3 -0
- package/dist/server/rpc/handlers/stopProvideHandler.js +22 -0
- package/dist/server/rpc/handlers/text-to-speech.d.ts +3 -0
- package/dist/server/rpc/handlers/text-to-speech.js +7 -0
- package/dist/server/rpc/handlers/transcribe-stream.js +6 -2
- package/dist/server/rpc/handlers/unload-model.js +7 -0
- package/dist/server/utils/cache.d.ts +13 -8
- package/dist/server/utils/cache.js +69 -14
- package/dist/server/utils/checksum.d.ts +2 -0
- package/dist/server/utils/checksum.js +24 -0
- package/dist/server/utils/index.d.ts +2 -0
- package/dist/server/utils/index.js +2 -0
- package/dist/server/utils/shard-utils.d.ts +22 -0
- package/dist/server/utils/shard-utils.js +37 -0
- package/dist/server/utils/tool-integration.d.ts +13 -0
- package/dist/server/utils/tool-integration.js +43 -0
- package/dist/server/utils/tool-parser.d.ts +7 -0
- package/dist/server/utils/tool-parser.js +244 -0
- package/dist/server/worker.js +28 -10
- package/dist/utils/errors-base.d.ts +3 -0
- package/dist/utils/errors-base.js +13 -0
- package/dist/utils/errors-client.d.ts +107 -0
- package/dist/utils/errors-client.js +186 -0
- package/dist/utils/errors-server.d.ts +146 -0
- package/dist/utils/errors-server.js +253 -0
- package/dist/utils/tool-helpers.d.ts +17 -0
- package/dist/utils/tool-helpers.js +99 -0
- package/package.json +15 -11
- package/dist/examples/llamacpp-tools-routing.d.ts +0 -2
- package/dist/examples/llamacpp-tools-routing.js +0 -364
- package/dist/examples/llamacpp-tools.d.ts +0 -2
- package/dist/examples/llamacpp-tools.js +0 -81
- package/dist/server/http-server.d.ts +0 -2
- package/dist/server/http-server.js +0 -189
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ npm i expo-file-system react-native-bare-kit
|
|
|
79
79
|
```js
|
|
80
80
|
export default {
|
|
81
81
|
expo: {
|
|
82
|
-
plugins: ["qvac
|
|
82
|
+
plugins: ["@qvac/sdk/expo-plugin"],
|
|
83
83
|
},
|
|
84
84
|
};
|
|
85
85
|
```
|
|
@@ -141,6 +141,7 @@ const cachedResponse = completion({
|
|
|
141
141
|
|
|
142
142
|
// Unload model to free up system resources
|
|
143
143
|
await unloadModel({ modelId });
|
|
144
|
+
process.exit();
|
|
144
145
|
```
|
|
145
146
|
|
|
146
147
|
**For more on how to use QVAC SDK, see [SDK at QVAC documentation](https://tether-2.gitbook.io/qvac-by-tether-or-reference/y2AsIh94H9DJ1pIBCNj9/sdk)**.
|
|
@@ -161,10 +162,10 @@ bun run build # or `watch` for hotreload
|
|
|
161
162
|
bun run build:pack
|
|
162
163
|
```
|
|
163
164
|
|
|
164
|
-
This outputs a tarball under `dist/
|
|
165
|
+
This outputs a tarball under `dist/qvac-sdk-{version}.tgz` that you can install in your project, e.g.:
|
|
165
166
|
|
|
166
167
|
```bash
|
|
167
|
-
npm i path/to/
|
|
168
|
+
npm i path/to/qvac-sdk-0.3.0.tgz
|
|
168
169
|
```
|
|
169
170
|
|
|
170
171
|
## Examples
|
|
@@ -271,6 +272,12 @@ This works for all model types (LLM, Whisper, NMT, Embeddings) and provides valu
|
|
|
271
272
|
- Indic language translation: [`examples/translation-indic.ts`](examples/translation-indic.ts)
|
|
272
273
|
- LLM-based translation: [`examples/translation-llm.ts`](examples/translation-llm.ts)
|
|
273
274
|
|
|
275
|
+
### Text to Speech
|
|
276
|
+
|
|
277
|
+
- Text to Speech: [`examples/text-to-speech.ts`](examples/text-to-speech.ts)
|
|
278
|
+
|
|
279
|
+
**Note**: To run the text-to-speech example, espeak data is required which can be obtained from [here](https://github.com/espeak-ng/espeak-ng).
|
|
280
|
+
|
|
274
281
|
### Multimodel
|
|
275
282
|
|
|
276
283
|
- Load multiple models simultaneously: [`examples/multi-model-demo.ts`](examples/multi-model-demo.ts)
|
|
@@ -287,6 +294,22 @@ This works for all model types (LLM, Whisper, NMT, Embeddings) and provides valu
|
|
|
287
294
|
|
|
288
295
|
- Pause and resume download: [`examples/download-with-cancel.ts`](examples/download-with-cancel.ts)
|
|
289
296
|
|
|
297
|
+
### Sharded Models
|
|
298
|
+
|
|
299
|
+
- Load sharded models from Hyperdrive: [`examples/llamacpp-sharded.ts`](examples/llamacpp-sharded.ts)
|
|
300
|
+
- Load models from local filesystem: [`examples/llamacpp-filesystem.ts`](examples/llamacpp-filesystem.ts)
|
|
301
|
+
|
|
302
|
+
**Note**: Sharded models automatically download all parts sequentially with detailed progress tracking per shard. For local sharded models, pass the path to the first shard file (e.g., `model-00001-of-00005.gguf`), and remaining shards will be loaded automatically.
|
|
303
|
+
|
|
304
|
+
### Blind Relays
|
|
305
|
+
|
|
306
|
+
Blind relays help establish peer connections through NAT/firewalls by routing traffic through relay nodes.
|
|
307
|
+
|
|
308
|
+
- Model downloads via Hyperdrive: [`examples/download-with-blind-relays.ts`](./examples/download-with-blind-relays.ts)
|
|
309
|
+
- Delegated inference: You can reuse the same pattern for delegated inference by calling `setConfig({ swarmRelays: [...relayPublicKeys] })` before starting your provider/consumer.
|
|
310
|
+
|
|
311
|
+
**Note**: The example uses mock relay keys. In real deployments, you **must** use your own relay servers or trusted public relays.
|
|
312
|
+
|
|
290
313
|
## Known issues
|
|
291
314
|
|
|
292
315
|
- **One off scripts don't terminate / hang**
|
|
@@ -7,7 +7,7 @@ import { type CancelParams } from "../../schemas/index";
|
|
|
7
7
|
* @param params.modelId - The model ID (required for inference cancellation)
|
|
8
8
|
* @param params.downloadKey - The download key (required for download cancellation)
|
|
9
9
|
* @param params.clearCache - If true, deletes the partial download file (default: false)
|
|
10
|
-
* @throws {
|
|
10
|
+
* @throws {QvacErrorBase} When the response type is invalid or when the cancellation fails
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* // Cancel inference
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { send } from "../rpc/rpc-client.js";
|
|
2
2
|
import {} from "../../schemas/index.js";
|
|
3
|
+
import { InvalidResponseError, CancelFailedError } from "../../utils/errors-client.js";
|
|
3
4
|
/**
|
|
4
5
|
* Cancels an ongoing operation.
|
|
5
6
|
*
|
|
@@ -8,7 +9,7 @@ import {} from "../../schemas/index.js";
|
|
|
8
9
|
* @param params.modelId - The model ID (required for inference cancellation)
|
|
9
10
|
* @param params.downloadKey - The download key (required for download cancellation)
|
|
10
11
|
* @param params.clearCache - If true, deletes the partial download file (default: false)
|
|
11
|
-
* @throws {
|
|
12
|
+
* @throws {QvacErrorBase} When the response type is invalid or when the cancellation fails
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* // Cancel inference
|
|
@@ -29,9 +30,9 @@ export async function cancel(params) {
|
|
|
29
30
|
};
|
|
30
31
|
const response = await send(request);
|
|
31
32
|
if (response.type !== "cancel") {
|
|
32
|
-
throw new
|
|
33
|
+
throw new InvalidResponseError("cancel");
|
|
33
34
|
}
|
|
34
35
|
if (!response.success) {
|
|
35
|
-
throw new
|
|
36
|
+
throw new CancelFailedError(response.error);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { type CompletionStats, type CompletionClientParams } from "../../schemas/index";
|
|
1
|
+
import { type CompletionStats, type CompletionClientParams, type ToolCall, type ToolCallEvent, type Tool } from "../../schemas/index";
|
|
2
|
+
import { type ToolInput } from "../../utils/tool-helpers";
|
|
3
|
+
type CompletionParams = Omit<CompletionClientParams, "tools"> & {
|
|
4
|
+
tools?: Tool[] | ToolInput[];
|
|
5
|
+
};
|
|
2
6
|
/**
|
|
3
7
|
* Generates completion from a language model based on conversation history.
|
|
4
8
|
*
|
|
@@ -6,7 +10,7 @@ import { type CompletionStats, type CompletionClientParams } from "../../schemas
|
|
|
6
10
|
* @param params.modelId - The identifier of the model to use for completion
|
|
7
11
|
* @param params.history - Array of conversation messages with role, content, and optional attachments
|
|
8
12
|
* @param params.stream - Whether to stream tokens (true) or return complete response (false). Defaults to true
|
|
9
|
-
* @param params.tools - Optional array of tools
|
|
13
|
+
* @param params.tools - Optional array of tools (can be simple ToolInput with Zod schemas or full Tool objects)
|
|
10
14
|
* @param params.kvCache - Optional KV cache configuration. Cache files are organized hierarchically:
|
|
11
15
|
* - Structure: `{kvCacheKey}/{modelId}/{configHash}.bin`
|
|
12
16
|
* - The configHash includes model config + system prompt to ensure cache isolation
|
|
@@ -15,51 +19,39 @@ import { type CompletionStats, type CompletionClientParams } from "../../schemas
|
|
|
15
19
|
* - `false` or `undefined`: No caching
|
|
16
20
|
* - ⚡ Performance: When cache exists, only the last message is sent to the model (includes multimodal attachments)
|
|
17
21
|
* - 🗑️ Cleanup: Use `deleteCache({ kvCacheKey })` to remove cached sessions
|
|
18
|
-
* @returns Object with tokenStream generator, text promise, and stats promise
|
|
22
|
+
* @returns Object with tokenStream generator, toolCallStream generator, text promise, toolCalls promise, and stats promise
|
|
19
23
|
* @example
|
|
20
24
|
* ```typescript
|
|
21
|
-
*
|
|
25
|
+
* import { z } from "zod";
|
|
26
|
+
*
|
|
27
|
+
* // Simple tool definition with Zod
|
|
22
28
|
* const result = completion({
|
|
23
29
|
* modelId: "llama-2",
|
|
24
30
|
* history: [
|
|
25
|
-
* { role: "user", content: "
|
|
31
|
+
* { role: "user", content: "What's the weather in Tokyo?" }
|
|
26
32
|
* ],
|
|
27
33
|
* stream: true,
|
|
28
|
-
*
|
|
34
|
+
* tools: [{
|
|
35
|
+
* name: "get_weather",
|
|
36
|
+
* description: "Get current weather",
|
|
37
|
+
* parameters: z.object({
|
|
38
|
+
* city: z.string().describe("City name"),
|
|
39
|
+
* country: z.string().describe("Country code").optional(),
|
|
40
|
+
* }),
|
|
41
|
+
* }]
|
|
29
42
|
* });
|
|
30
43
|
*
|
|
31
44
|
* for await (const token of result.tokenStream) {
|
|
32
|
-
*
|
|
45
|
+
* process.stdout.write(token);
|
|
33
46
|
* }
|
|
34
|
-
*
|
|
35
|
-
* // Custom session management with cache key
|
|
36
|
-
* const sessionResult = completion({
|
|
37
|
-
* modelId: "llama-2",
|
|
38
|
-
* history: [
|
|
39
|
-
* { role: "user", content: "Continue our conversation" }
|
|
40
|
-
* ],
|
|
41
|
-
* stream: true,
|
|
42
|
-
* kvCache: "user-session-123", // Custom cache key
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* // Non-streaming mode
|
|
46
|
-
* const response = completion({
|
|
47
|
-
* modelId: "llama-2",
|
|
48
|
-
* history: [
|
|
49
|
-
* { role: "user", content: "What is the capital of France?" }
|
|
50
|
-
* ],
|
|
51
|
-
* stream: false,
|
|
52
|
-
* });
|
|
53
|
-
*
|
|
54
|
-
* const text = await response.text;
|
|
55
|
-
* const stats = await response.stats;
|
|
56
|
-
* console.log(text);
|
|
57
|
-
* console.log(stats);
|
|
58
47
|
* ```
|
|
59
48
|
*/
|
|
60
|
-
export declare function completion(params:
|
|
49
|
+
export declare function completion(params: CompletionParams): {
|
|
61
50
|
tokenStream: AsyncGenerator<string>;
|
|
51
|
+
toolCallStream: AsyncGenerator<ToolCallEvent>;
|
|
62
52
|
stats: Promise<CompletionStats | undefined>;
|
|
63
53
|
text: Promise<string>;
|
|
54
|
+
toolCalls: Promise<ToolCall[]>;
|
|
64
55
|
};
|
|
56
|
+
export {};
|
|
65
57
|
//# sourceMappingURL=completion-stream.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { completionStreamResponseSchema, } from "../../schemas/index.js";
|
|
2
2
|
import { stream as streamRpc } from "../rpc/rpc-client.js";
|
|
3
|
+
import { validateTools } from "../../utils/tool-helpers.js";
|
|
3
4
|
/**
|
|
4
5
|
* Generates completion from a language model based on conversation history.
|
|
5
6
|
*
|
|
@@ -7,7 +8,7 @@ import { stream as streamRpc } from "../rpc/rpc-client.js";
|
|
|
7
8
|
* @param params.modelId - The identifier of the model to use for completion
|
|
8
9
|
* @param params.history - Array of conversation messages with role, content, and optional attachments
|
|
9
10
|
* @param params.stream - Whether to stream tokens (true) or return complete response (false). Defaults to true
|
|
10
|
-
* @param params.tools - Optional array of tools
|
|
11
|
+
* @param params.tools - Optional array of tools (can be simple ToolInput with Zod schemas or full Tool objects)
|
|
11
12
|
* @param params.kvCache - Optional KV cache configuration. Cache files are organized hierarchically:
|
|
12
13
|
* - Structure: `{kvCacheKey}/{modelId}/{configHash}.bin`
|
|
13
14
|
* - The configHash includes model config + system prompt to ensure cache isolation
|
|
@@ -16,103 +17,194 @@ import { stream as streamRpc } from "../rpc/rpc-client.js";
|
|
|
16
17
|
* - `false` or `undefined`: No caching
|
|
17
18
|
* - ⚡ Performance: When cache exists, only the last message is sent to the model (includes multimodal attachments)
|
|
18
19
|
* - 🗑️ Cleanup: Use `deleteCache({ kvCacheKey })` to remove cached sessions
|
|
19
|
-
* @returns Object with tokenStream generator, text promise, and stats promise
|
|
20
|
+
* @returns Object with tokenStream generator, toolCallStream generator, text promise, toolCalls promise, and stats promise
|
|
20
21
|
* @example
|
|
21
22
|
* ```typescript
|
|
22
|
-
*
|
|
23
|
+
* import { z } from "zod";
|
|
24
|
+
*
|
|
25
|
+
* // Simple tool definition with Zod
|
|
23
26
|
* const result = completion({
|
|
24
27
|
* modelId: "llama-2",
|
|
25
28
|
* history: [
|
|
26
|
-
* { role: "user", content: "
|
|
29
|
+
* { role: "user", content: "What's the weather in Tokyo?" }
|
|
27
30
|
* ],
|
|
28
31
|
* stream: true,
|
|
29
|
-
*
|
|
32
|
+
* tools: [{
|
|
33
|
+
* name: "get_weather",
|
|
34
|
+
* description: "Get current weather",
|
|
35
|
+
* parameters: z.object({
|
|
36
|
+
* city: z.string().describe("City name"),
|
|
37
|
+
* country: z.string().describe("Country code").optional(),
|
|
38
|
+
* }),
|
|
39
|
+
* }]
|
|
30
40
|
* });
|
|
31
41
|
*
|
|
32
42
|
* for await (const token of result.tokenStream) {
|
|
33
|
-
*
|
|
43
|
+
* process.stdout.write(token);
|
|
34
44
|
* }
|
|
35
|
-
*
|
|
36
|
-
* // Custom session management with cache key
|
|
37
|
-
* const sessionResult = completion({
|
|
38
|
-
* modelId: "llama-2",
|
|
39
|
-
* history: [
|
|
40
|
-
* { role: "user", content: "Continue our conversation" }
|
|
41
|
-
* ],
|
|
42
|
-
* stream: true,
|
|
43
|
-
* kvCache: "user-session-123", // Custom cache key
|
|
44
|
-
* });
|
|
45
|
-
*
|
|
46
|
-
* // Non-streaming mode
|
|
47
|
-
* const response = completion({
|
|
48
|
-
* modelId: "llama-2",
|
|
49
|
-
* history: [
|
|
50
|
-
* { role: "user", content: "What is the capital of France?" }
|
|
51
|
-
* ],
|
|
52
|
-
* stream: false,
|
|
53
|
-
* });
|
|
54
|
-
*
|
|
55
|
-
* const text = await response.text;
|
|
56
|
-
* const stats = await response.stats;
|
|
57
|
-
* console.log(text);
|
|
58
|
-
* console.log(stats);
|
|
59
45
|
* ```
|
|
60
46
|
*/
|
|
61
47
|
export function completion(params) {
|
|
48
|
+
const tools = params.tools ? validateTools(params.tools) : undefined;
|
|
62
49
|
const request = {
|
|
63
50
|
type: "completionStream",
|
|
64
51
|
...params,
|
|
52
|
+
tools,
|
|
65
53
|
stream: params.stream ?? true,
|
|
66
54
|
};
|
|
67
55
|
let stats;
|
|
68
56
|
let statsResolver = () => { };
|
|
69
|
-
|
|
57
|
+
let statsRejecter = () => { };
|
|
58
|
+
const statsPromise = new Promise((resolve, reject) => {
|
|
70
59
|
statsResolver = resolve;
|
|
60
|
+
statsRejecter = reject;
|
|
71
61
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
statsPromise.catch(() => { });
|
|
63
|
+
let toolCallsArray = [];
|
|
64
|
+
let toolCallsResolver = () => { };
|
|
65
|
+
let toolCallsRejecter = () => { };
|
|
66
|
+
const toolCallsPromise = new Promise((resolve, reject) => {
|
|
67
|
+
toolCallsResolver = resolve;
|
|
68
|
+
toolCallsRejecter = reject;
|
|
69
|
+
});
|
|
70
|
+
toolCallsPromise.catch(() => { });
|
|
71
|
+
const responses = streamRpc(request);
|
|
72
|
+
const tokenQueue = [];
|
|
73
|
+
const toolEventQueue = [];
|
|
74
|
+
let tokenDone = false;
|
|
75
|
+
let toolDone = false;
|
|
76
|
+
let tokenResolve = null;
|
|
77
|
+
let toolResolve = null;
|
|
78
|
+
let textBuffer = "";
|
|
79
|
+
let streamError = null;
|
|
80
|
+
const processResponses = async () => {
|
|
81
|
+
try {
|
|
82
|
+
for await (const response of responses) {
|
|
83
|
+
if (response &&
|
|
84
|
+
typeof response === "object" &&
|
|
85
|
+
"type" in response &&
|
|
86
|
+
response.type === "completionStream") {
|
|
76
87
|
const streamResponse = completionStreamResponseSchema.parse(response);
|
|
77
88
|
if (!streamResponse.done) {
|
|
78
|
-
|
|
89
|
+
const token = streamResponse.token;
|
|
90
|
+
if (token) {
|
|
91
|
+
textBuffer += token;
|
|
92
|
+
tokenQueue.push(token);
|
|
93
|
+
if (tokenResolve) {
|
|
94
|
+
tokenResolve();
|
|
95
|
+
tokenResolve = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (streamResponse.toolCallEvent) {
|
|
99
|
+
toolEventQueue.push(streamResponse.toolCallEvent);
|
|
100
|
+
if (toolResolve) {
|
|
101
|
+
toolResolve();
|
|
102
|
+
toolResolve = null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
79
105
|
}
|
|
80
106
|
else {
|
|
107
|
+
if (streamResponse.token) {
|
|
108
|
+
textBuffer += streamResponse.token;
|
|
109
|
+
}
|
|
81
110
|
stats = streamResponse.stats;
|
|
82
111
|
statsResolver(stats);
|
|
112
|
+
toolCallsArray = streamResponse.toolCalls || [];
|
|
113
|
+
toolCallsResolver(toolCallsArray);
|
|
114
|
+
tokenDone = true;
|
|
115
|
+
toolDone = true;
|
|
116
|
+
if (tokenResolve) {
|
|
117
|
+
tokenResolve();
|
|
118
|
+
tokenResolve = null;
|
|
119
|
+
}
|
|
120
|
+
if (toolResolve) {
|
|
121
|
+
toolResolve();
|
|
122
|
+
toolResolve = null;
|
|
123
|
+
}
|
|
83
124
|
}
|
|
84
125
|
}
|
|
85
126
|
}
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
streamError = error instanceof Error ? error : new Error(String(error));
|
|
130
|
+
statsRejecter(error);
|
|
131
|
+
toolCallsRejecter(error);
|
|
132
|
+
tokenDone = true;
|
|
133
|
+
toolDone = true;
|
|
134
|
+
if (tokenResolve) {
|
|
135
|
+
tokenResolve();
|
|
136
|
+
tokenResolve = null;
|
|
137
|
+
}
|
|
138
|
+
if (toolResolve) {
|
|
139
|
+
toolResolve();
|
|
140
|
+
toolResolve = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
void processResponses();
|
|
145
|
+
const textPromise = (async () => {
|
|
146
|
+
await statsPromise;
|
|
147
|
+
return textBuffer;
|
|
148
|
+
})();
|
|
149
|
+
textPromise.catch(() => { });
|
|
150
|
+
if (params.stream) {
|
|
151
|
+
const tokenStream = (async function* () {
|
|
152
|
+
while (true) {
|
|
153
|
+
if (tokenQueue.length > 0) {
|
|
154
|
+
yield tokenQueue.shift();
|
|
155
|
+
}
|
|
156
|
+
else if (tokenDone) {
|
|
157
|
+
if (streamError !== null) {
|
|
158
|
+
throw streamError;
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
await new Promise((resolve) => {
|
|
164
|
+
tokenResolve = resolve;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
})();
|
|
169
|
+
const toolCallStream = (async function* () {
|
|
170
|
+
while (true) {
|
|
171
|
+
if (toolEventQueue.length > 0) {
|
|
172
|
+
yield toolEventQueue.shift();
|
|
173
|
+
}
|
|
174
|
+
else if (toolDone) {
|
|
175
|
+
if (streamError !== null) {
|
|
176
|
+
throw streamError;
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
await new Promise((resolve) => {
|
|
182
|
+
toolResolve = resolve;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
86
186
|
})();
|
|
87
|
-
const textPromise = Promise.resolve("");
|
|
88
187
|
return {
|
|
89
188
|
tokenStream,
|
|
189
|
+
toolCallStream,
|
|
90
190
|
text: textPromise,
|
|
91
191
|
stats: statsPromise,
|
|
192
|
+
toolCalls: toolCallsPromise,
|
|
92
193
|
};
|
|
93
194
|
}
|
|
94
195
|
else {
|
|
95
196
|
const tokenStream = (async function* () {
|
|
96
197
|
//Empty generator for non-streaming mode
|
|
97
198
|
})();
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
for await (const response of streamRpc(request)) {
|
|
101
|
-
if (response.type === "completionStream") {
|
|
102
|
-
const streamResponse = completionStreamResponseSchema.parse(response);
|
|
103
|
-
buffer += streamResponse.token;
|
|
104
|
-
if (streamResponse.done) {
|
|
105
|
-
stats = streamResponse.stats;
|
|
106
|
-
statsResolver(stats);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return buffer;
|
|
199
|
+
const toolCallStream = (async function* () {
|
|
200
|
+
//Empty generator for non-streaming mode
|
|
111
201
|
})();
|
|
112
202
|
return {
|
|
113
203
|
tokenStream,
|
|
204
|
+
toolCallStream,
|
|
114
205
|
text: textPromise,
|
|
115
206
|
stats: statsPromise,
|
|
207
|
+
toolCalls: toolCallsPromise,
|
|
116
208
|
};
|
|
117
209
|
}
|
|
118
210
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { send } from "../rpc/rpc-client.js";
|
|
2
|
+
import { InvalidDeleteCacheParamsError, DeleteCacheFailedError, } from "../../utils/errors-client.js";
|
|
2
3
|
/**
|
|
3
4
|
* Deletes KV cache files.
|
|
4
5
|
*
|
|
@@ -35,11 +36,11 @@ export async function deleteCache(params) {
|
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
else {
|
|
38
|
-
throw new
|
|
39
|
+
throw new InvalidDeleteCacheParamsError();
|
|
39
40
|
}
|
|
40
41
|
const response = (await send(req));
|
|
41
42
|
if (!response.success && response.error) {
|
|
42
|
-
throw new
|
|
43
|
+
throw new DeleteCacheFailedError(response.error);
|
|
43
44
|
}
|
|
44
45
|
return {
|
|
45
46
|
success: response.success,
|
|
@@ -14,9 +14,9 @@ export type DownloadAssetOptions = BaseDownloadAssetOptions;
|
|
|
14
14
|
*
|
|
15
15
|
* @returns Promise that resolves to the asset ID (either the provided assetSrc or a generated ID)
|
|
16
16
|
*
|
|
17
|
-
* @throws {
|
|
18
|
-
* @throws {
|
|
19
|
-
* @throws {
|
|
17
|
+
* @throws {QvacErrorBase} When asset download fails, with details in the error message
|
|
18
|
+
* @throws {QvacErrorBase} When streaming ends unexpectedly (only when using onProgress)
|
|
19
|
+
* @throws {QvacErrorBase} When receiving an invalid response type from the server
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```typescript
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { send, stream } from "../rpc/rpc-client.js";
|
|
2
|
-
import {
|
|
2
|
+
import { downloadAssetOptionsToRequestSchema, } from "../../schemas/index.js";
|
|
3
|
+
import { DownloadAssetFailedError, StreamEndedError, InvalidResponseError, } from "../../utils/errors-client.js";
|
|
3
4
|
/**
|
|
4
5
|
* Downloads an asset (model file) without loading it into memory.
|
|
5
6
|
*
|
|
@@ -14,9 +15,9 @@ import { downloadAssetRequestSchema, } from "../../schemas/index.js";
|
|
|
14
15
|
*
|
|
15
16
|
* @returns Promise that resolves to the asset ID (either the provided assetSrc or a generated ID)
|
|
16
17
|
*
|
|
17
|
-
* @throws {
|
|
18
|
-
* @throws {
|
|
19
|
-
* @throws {
|
|
18
|
+
* @throws {QvacErrorBase} When asset download fails, with details in the error message
|
|
19
|
+
* @throws {QvacErrorBase} When streaming ends unexpectedly (only when using onProgress)
|
|
20
|
+
* @throws {QvacErrorBase} When receiving an invalid response type from the server
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
22
23
|
* ```typescript
|
|
@@ -36,13 +37,7 @@ import { downloadAssetRequestSchema, } from "../../schemas/index.js";
|
|
|
36
37
|
* ```
|
|
37
38
|
*/
|
|
38
39
|
export async function downloadAsset(options) {
|
|
39
|
-
const
|
|
40
|
-
const request = downloadAssetRequestSchema.parse({
|
|
41
|
-
type: "downloadAsset",
|
|
42
|
-
assetSrc: assetSrc,
|
|
43
|
-
withProgress: !!options.onProgress,
|
|
44
|
-
seed: options.seed,
|
|
45
|
-
});
|
|
40
|
+
const request = downloadAssetOptionsToRequestSchema.parse(options);
|
|
46
41
|
if (options.onProgress) {
|
|
47
42
|
// Use streaming for progress updates
|
|
48
43
|
for await (const response of stream(request)) {
|
|
@@ -51,22 +46,22 @@ export async function downloadAsset(options) {
|
|
|
51
46
|
}
|
|
52
47
|
else if (response.type === "downloadAsset") {
|
|
53
48
|
if (!response.success) {
|
|
54
|
-
throw new
|
|
49
|
+
throw new DownloadAssetFailedError(response.error);
|
|
55
50
|
}
|
|
56
|
-
return response.assetId
|
|
51
|
+
return response.assetId;
|
|
57
52
|
}
|
|
58
53
|
}
|
|
59
|
-
throw new
|
|
54
|
+
throw new StreamEndedError();
|
|
60
55
|
}
|
|
61
56
|
else {
|
|
62
57
|
// Use regular send for simple downloading
|
|
63
58
|
const response = await send(request);
|
|
64
59
|
if (response.type !== "downloadAsset") {
|
|
65
|
-
throw new
|
|
60
|
+
throw new InvalidResponseError("downloadAsset");
|
|
66
61
|
}
|
|
67
62
|
if (!response.success) {
|
|
68
|
-
throw new
|
|
63
|
+
throw new DownloadAssetFailedError(response.error);
|
|
69
64
|
}
|
|
70
|
-
return response.assetId
|
|
65
|
+
return response.assetId;
|
|
71
66
|
}
|
|
72
67
|
}
|
|
@@ -5,7 +5,7 @@ import { type EmbedParams } from "../../schemas/index";
|
|
|
5
5
|
* @param params - The parameters for the embedding
|
|
6
6
|
* @param params.modelId - The identifier of the embedding model to use
|
|
7
7
|
* @param params.text - The input text to embed
|
|
8
|
-
* @throws {
|
|
8
|
+
* @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
|
|
9
9
|
*/
|
|
10
10
|
export declare function embed(params: EmbedParams): Promise<number[]>;
|
|
11
11
|
//# sourceMappingURL=embed.d.ts.map
|
package/dist/client/api/embed.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { send } from "../rpc/rpc-client.js";
|
|
2
2
|
import {} from "../../schemas/index.js";
|
|
3
|
+
import { InvalidResponseError, EmbedFailedError } from "../../utils/errors-client.js";
|
|
3
4
|
/**
|
|
4
5
|
* Generates embeddings for a given text using a specified model.
|
|
5
6
|
*
|
|
6
7
|
* @param params - The parameters for the embedding
|
|
7
8
|
* @param params.modelId - The identifier of the embedding model to use
|
|
8
9
|
* @param params.text - The input text to embed
|
|
9
|
-
* @throws {
|
|
10
|
+
* @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
|
|
10
11
|
*/
|
|
11
12
|
export async function embed(params) {
|
|
12
13
|
const request = {
|
|
@@ -15,10 +16,10 @@ export async function embed(params) {
|
|
|
15
16
|
};
|
|
16
17
|
const response = await send(request);
|
|
17
18
|
if (response.type !== "embed") {
|
|
18
|
-
throw new
|
|
19
|
+
throw new InvalidResponseError("embed");
|
|
19
20
|
}
|
|
20
21
|
if (!response.success) {
|
|
21
|
-
throw new
|
|
22
|
+
throw new EmbedFailedError(response.error);
|
|
22
23
|
}
|
|
23
24
|
return response.embedding;
|
|
24
25
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type GetModelInfoParams } from "../../schemas/index";
|
|
2
|
+
export declare const getModelInfo: (params: GetModelInfoParams) => Promise<{
|
|
3
|
+
name: string;
|
|
4
|
+
modelId: string;
|
|
5
|
+
hyperdriveKey: string;
|
|
6
|
+
hyperbeeKey: string;
|
|
7
|
+
expectedSize: number;
|
|
8
|
+
sha256Checksum: string;
|
|
9
|
+
addon: "llm" | "whisper" | "embeddings" | "nmt" | "vad" | "tts";
|
|
10
|
+
isCached: boolean;
|
|
11
|
+
isLoaded: boolean;
|
|
12
|
+
cacheFiles: {
|
|
13
|
+
filename: string;
|
|
14
|
+
path: string;
|
|
15
|
+
expectedSize: number;
|
|
16
|
+
sha256Checksum: string;
|
|
17
|
+
isCached: boolean;
|
|
18
|
+
actualSize?: number | undefined;
|
|
19
|
+
cachedAt?: Date | undefined;
|
|
20
|
+
}[];
|
|
21
|
+
actualSize?: number | undefined;
|
|
22
|
+
cachedAt?: Date | undefined;
|
|
23
|
+
loadedInstances?: {
|
|
24
|
+
registryId: string;
|
|
25
|
+
loadedAt: Date;
|
|
26
|
+
config?: unknown;
|
|
27
|
+
}[] | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
//# sourceMappingURL=get-model-info.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {} from "../../schemas/index.js";
|
|
2
|
+
import { send } from "../rpc/rpc-client.js";
|
|
3
|
+
import { InvalidResponseError } from "../../utils/errors-client.js";
|
|
4
|
+
export const getModelInfo = async (params) => {
|
|
5
|
+
const request = {
|
|
6
|
+
type: "getModelInfo",
|
|
7
|
+
name: params.name,
|
|
8
|
+
};
|
|
9
|
+
const response = await send(request);
|
|
10
|
+
if (response.type !== "getModelInfo") {
|
|
11
|
+
throw new InvalidResponseError("getModelInfo");
|
|
12
|
+
}
|
|
13
|
+
return response.modelInfo;
|
|
14
|
+
};
|
|
@@ -10,5 +10,9 @@ export { embed } from "./embed";
|
|
|
10
10
|
export { translate } from "./translate";
|
|
11
11
|
export { cancel } from "./cancel";
|
|
12
12
|
export { startQVACProvider } from "./provide";
|
|
13
|
+
export { stopQVACProvider } from "./stop-provider";
|
|
13
14
|
export { ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings } from "./rag";
|
|
15
|
+
export { textToSpeech } from "./text-to-speech";
|
|
16
|
+
export { setConfig } from "./set-config";
|
|
17
|
+
export { getModelInfo } from "./get-model-info";
|
|
14
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/client/api/index.js
CHANGED
|
@@ -10,4 +10,8 @@ export { embed } from "./embed.js";
|
|
|
10
10
|
export { translate } from "./translate.js";
|
|
11
11
|
export { cancel } from "./cancel.js";
|
|
12
12
|
export { startQVACProvider } from "./provide.js";
|
|
13
|
+
export { stopQVACProvider } from "./stop-provider.js";
|
|
13
14
|
export { ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings } from "./rag.js";
|
|
15
|
+
export { textToSpeech } from "./text-to-speech.js";
|
|
16
|
+
export { setConfig } from "./set-config.js";
|
|
17
|
+
export { getModelInfo } from "./get-model-info.js";
|
|
@@ -21,9 +21,9 @@ export type LoadModelOptions = BaseLoadModelOptions & {
|
|
|
21
21
|
*
|
|
22
22
|
* @returns Promise that resolves to the model ID (either the provided modelSrc or a generated ID)
|
|
23
23
|
*
|
|
24
|
-
* @throws {
|
|
25
|
-
* @throws {
|
|
26
|
-
* @throws {
|
|
24
|
+
* @throws {QvacErrorBase} When model loading fails, with details in the error message
|
|
25
|
+
* @throws {QvacErrorBase} When streaming ends unexpectedly (only when using onProgress)
|
|
26
|
+
* @throws {QvacErrorBase} When receiving an invalid response type from the server
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* ```typescript
|