@qvac/sdk 0.23.0 → 0.24.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/NOTICE +115 -58
- package/README.md +10 -13
- package/dist/examples/asr/parakeet-sortformer.js +24 -14
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +40 -11
- package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
- package/dist/examples/asr/whispercpp-prompt.js +9 -5
- package/dist/examples/assess-model-fit.d.ts +7 -9
- package/dist/examples/assess-model-fit.js +22 -43
- package/dist/examples/calc-tokens.d.ts +2 -0
- package/dist/examples/calc-tokens.js +21 -0
- package/dist/examples/classification/classify-image.js +11 -5
- package/dist/examples/completion-stop-reason.d.ts +3 -3
- package/dist/examples/completion-stop-reason.js +4 -4
- package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
- package/dist/examples/diffusion-flux3-klein.js +102 -0
- package/dist/examples/diffusion-moss-image.d.ts +2 -0
- package/dist/examples/diffusion-moss-image.js +126 -0
- package/dist/examples/diffusion-qwen-image-21.js +15 -4
- package/dist/examples/embed-multimodal.d.ts +2 -0
- package/dist/examples/embed-multimodal.js +80 -0
- package/dist/examples/embed-p2p.js +2 -2
- package/dist/examples/image/megaloc.d.ts +2 -0
- package/dist/examples/image/megaloc.js +37 -0
- package/dist/examples/llamacpp-multimodal.js +18 -0
- package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
- package/dist/examples/rag/rag-turbovec.js +2 -2
- package/dist/examples/sessions.d.ts +17 -0
- package/dist/examples/sessions.js +63 -0
- package/dist/examples/tools/llamacpp-deferred-tools.js +8 -4
- package/dist/scripts/check-resource-collectors-packaging.js +7 -6
- package/dist/scripts/contract/build-contract.d.ts +2 -1
- package/dist/scripts/contract/build-contract.js +13 -1
- package/dist/scripts/contract/constants-registry.d.ts +17 -0
- package/dist/scripts/contract/constants-registry.js +8 -2
- package/dist/scripts/contract/method-shapes.d.ts +4 -0
- package/dist/scripts/contract/method-shapes.js +4 -0
- package/dist/scripts/enforce-inference-versions.d.ts +1 -1
- package/dist/scripts/enforce-inference-versions.js +28 -18
- package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
- package/dist/src/client/api/assess-model-fit.d.ts +17 -17
- package/dist/src/client/api/assess-model-fit.js +18 -31
- package/dist/src/client/api/audio-edit.d.ts +5 -3
- package/dist/src/client/api/audio-edit.js +5 -3
- package/dist/src/client/api/audio-gen-result.js +134 -45
- package/dist/src/client/api/audio-gen.d.ts +40 -3
- package/dist/src/client/api/audio-gen.js +40 -3
- package/dist/src/client/api/audio-understand.d.ts +2 -2
- package/dist/src/client/api/audio-understand.js +2 -2
- package/dist/src/client/api/batch-completion.js +2 -1
- package/dist/src/client/api/calc-tokens.d.ts +33 -0
- package/dist/src/client/api/calc-tokens.js +44 -0
- package/dist/src/client/api/cancel.d.ts +2 -2
- package/dist/src/client/api/cancel.js +2 -2
- package/dist/src/client/api/classify.d.ts +12 -5
- package/dist/src/client/api/classify.js +17 -5
- package/dist/src/client/api/client-request-id.d.ts +0 -15
- package/dist/src/client/api/client-request-id.js +15 -12
- package/dist/src/client/api/completion-stream.d.ts +8 -1
- package/dist/src/client/api/completion-stream.js +10 -1
- package/dist/src/client/api/delete-cache.d.ts +9 -2
- package/dist/src/client/api/delete-cache.js +13 -3
- package/dist/src/client/api/diffusion.d.ts +20 -4
- package/dist/src/client/api/diffusion.js +23 -5
- package/dist/src/client/api/embed.d.ts +82 -29
- package/dist/src/client/api/embed.js +64 -19
- package/dist/src/client/api/get-model-info.d.ts +2 -2
- package/dist/src/client/api/get-model-info.js +2 -2
- package/dist/src/client/api/get-system-resources.d.ts +2 -2
- package/dist/src/client/api/get-system-resources.js +2 -2
- package/dist/src/client/api/heartbeat.d.ts +3 -2
- package/dist/src/client/api/heartbeat.js +3 -2
- package/dist/src/client/api/index.d.ts +4 -3
- package/dist/src/client/api/index.js +2 -1
- package/dist/src/client/api/invoke-plugin.d.ts +8 -2
- package/dist/src/client/api/invoke-plugin.js +17 -2
- package/dist/src/client/api/load-model.js +5 -2
- package/dist/src/client/api/ocr.d.ts +5 -3
- package/dist/src/client/api/ocr.js +44 -21
- package/dist/src/client/api/rag.d.ts +1 -1
- package/dist/src/client/api/rag.js +1 -1
- package/dist/src/client/api/registry.d.ts +17 -7
- package/dist/src/client/api/registry.js +37 -12
- package/dist/src/client/api/resume.d.ts +2 -1
- package/dist/src/client/api/resume.js +2 -2
- package/dist/src/client/api/rpc-server.d.ts +4 -4
- package/dist/src/client/api/rpc-server.js +10 -10
- package/dist/src/client/api/state.d.ts +2 -2
- package/dist/src/client/api/state.js +2 -2
- package/dist/src/client/api/subscribe-logs.d.ts +2 -2
- package/dist/src/client/api/subscribe-logs.js +2 -2
- package/dist/src/client/api/suspend.d.ts +4 -2
- package/dist/src/client/api/suspend.js +4 -3
- package/dist/src/client/api/text-to-speech.d.ts +14 -5
- package/dist/src/client/api/text-to-speech.js +83 -29
- package/dist/src/client/api/transcribe.d.ts +6 -2
- package/dist/src/client/api/transcribe.js +7 -1
- package/dist/src/client/api/unload-model.d.ts +19 -7
- package/dist/src/client/api/unload-model.js +29 -11
- package/dist/src/client/api/upscale.d.ts +6 -3
- package/dist/src/client/api/upscale.js +9 -4
- package/dist/src/client/api/vector-index.d.ts +50 -16
- package/dist/src/client/api/vector-index.js +100 -48
- package/dist/src/client/api/video-request.d.ts +5 -5
- package/dist/src/client/api/video.d.ts +3 -2
- package/dist/src/client/api/video.js +3 -2
- package/dist/src/client/api/vla.d.ts +9 -5
- package/dist/src/client/api/vla.js +17 -8
- package/dist/src/client/api/world.d.ts +5 -5
- package/dist/src/client/api/world.js +4 -4
- package/dist/src/client/init-hooks.d.ts +6 -4
- package/dist/src/client/init-hooks.js +12 -15
- package/dist/src/client/logging-stream-registry.d.ts +6 -3
- package/dist/src/client/logging-stream-registry.js +31 -12
- package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
- package/dist/src/client/rpc/bundle-stamp.js +75 -0
- package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
- package/dist/src/client/rpc/expo-home-dir.js +4 -0
- package/dist/src/client/rpc/expo-rpc-client.js +189 -135
- package/dist/src/client/rpc/node-rpc-client.js +322 -413
- package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
- package/dist/src/client/rpc/pear-runtime.js +12 -0
- package/dist/src/client/rpc/rpc-client.d.ts +5 -4
- package/dist/src/client/rpc/rpc-client.js +126 -23
- package/dist/src/client/rpc/rpc-error.js +21 -2
- package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
- package/dist/src/client/rpc/unbundled-harness.js +27 -0
- package/dist/src/client/rpc/worker-failure.d.ts +27 -0
- package/dist/src/client/rpc/worker-failure.js +61 -0
- package/dist/src/client/session-registry.d.ts +75 -0
- package/dist/src/client/session-registry.js +149 -0
- package/dist/src/client/session.d.ts +125 -0
- package/dist/src/client/session.js +148 -0
- package/dist/src/commands/bundle/addons.d.ts +14 -0
- package/dist/src/commands/bundle/addons.js +65 -0
- package/dist/src/commands/bundle/constants.js +1 -0
- package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
- package/dist/src/commands/bundle/entry-gen.js +17 -50
- package/dist/src/commands/bundle/index.d.ts +59 -13
- package/dist/src/commands/bundle/index.js +345 -121
- package/dist/src/commands/bundle/link.d.ts +58 -0
- package/dist/src/commands/bundle/link.js +135 -0
- package/dist/src/commands/bundle/node-support.d.ts +13 -0
- package/dist/src/commands/bundle/node-support.js +23 -0
- package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
- package/dist/src/commands/bundle/read-bundle.js +27 -0
- package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
- package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
- package/dist/src/commands/bundle/scratch.d.ts +35 -0
- package/dist/src/commands/bundle/scratch.js +178 -0
- package/dist/src/commands/bundle/targets.d.ts +14 -0
- package/dist/src/commands/bundle/targets.js +37 -0
- package/dist/src/commands/host-prebuilds/index.d.ts +5 -4
- package/dist/src/commands/host-prebuilds/index.js +9 -7
- package/dist/src/commands/index.d.ts +4 -3
- package/dist/src/commands/verify/abi.d.ts +20 -14
- package/dist/src/commands/verify/abi.js +11 -79
- package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
- package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
- package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
- package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
- package/dist/src/commands/verify/bundle-source.js +25 -21
- package/dist/src/commands/verify/engines-advice.d.ts +2 -8
- package/dist/src/commands/verify/engines-advice.js +7 -54
- package/dist/src/commands/verify/index.d.ts +30 -29
- package/dist/src/commands/verify/index.js +92 -200
- package/dist/src/commands/verify/prebuilds.d.ts +3 -5
- package/dist/src/commands/verify/prebuilds.js +1 -2
- package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
- package/dist/src/commands/verify/resource-collectors.js +1 -50
- package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
- package/dist/src/commands/verify/sidecar-runtime.js +51 -0
- package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
- package/dist/src/expo/plugins/withBareKit.js +204 -0
- package/dist/src/expo/plugins/withMobileBundle.d.ts +4 -11
- package/dist/src/expo/plugins/withMobileBundle.js +36 -57
- package/dist/src/expo/plugins/withQvacSDK.d.ts +1 -0
- package/dist/src/expo/plugins/withQvacSDK.js +3 -0
- package/dist/src/index.d.ts +6 -5
- package/dist/src/index.js +10 -14
- package/dist/src/logging/utils.js +10 -2
- package/dist/src/plugin-ids.d.ts +2 -1
- package/dist/src/plugin-ids.js +2 -0
- package/dist/src/schemas/public.d.ts +1 -1
- package/dist/src/schemas/public.js +1 -1
- package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
- package/dist/src/schemas/sdk-errors-client.js +30 -36
- package/dist/src/schemas/sdk-errors-server.d.ts +11 -1
- package/dist/src/schemas/sdk-errors-server.js +60 -2
- package/dist/src/server/rpc/rpc-utils.d.ts +25 -4
- package/dist/src/server/rpc/rpc-utils.js +39 -5
- package/dist/src/utils/errors-client.d.ts +37 -29
- package/dist/src/utils/errors-client.js +50 -41
- package/dist/src/utils/errors-server.d.ts +59 -1
- package/dist/src/utils/errors-server.js +110 -1
- package/dist/src/utils/withTimeout.js +34 -17
- package/dist/src/worker/handle-request.js +25 -22
- package/dist/src/worker/handler-utils.d.ts +2 -6
- package/dist/src/worker/handler-utils.js +2 -20
- package/dist/src/worker/index.d.ts +2 -4
- package/dist/src/worker/index.js +23 -35
- package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
- package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
- package/dist/src/worker/shim.d.ts +4 -0
- package/dist/src/worker/shim.js +7 -0
- package/dist/src/worker/start.d.ts +9 -0
- package/dist/src/worker/start.js +16 -0
- package/dist/src/worker/unbundled-shim.d.ts +2 -0
- package/dist/src/worker/unbundled-shim.js +4 -0
- package/docs/system-resources-support-matrix.md +27 -19
- package/package.json +62 -51
- package/src/electron-forge/index.cjs +65 -91
- package/dist/examples/model-fit-ui/server.d.ts +0 -24
- package/dist/examples/model-fit-ui/server.js +0 -221
- package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
- package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
- package/dist/src/client/rpc/init-timeout.d.ts +0 -26
- package/dist/src/client/rpc/init-timeout.js +0 -25
- package/dist/src/client/rpc/ipc-socket-path.d.ts +0 -11
- package/dist/src/client/rpc/ipc-socket-path.js +0 -30
- package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
- package/dist/src/client/rpc/worker-startup-error.js +0 -13
- package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
- package/dist/src/commands/bundle/bare-pack.js +0 -77
- package/dist/src/commands/bundle/manifest.d.ts +0 -25
- package/dist/src/commands/bundle/manifest.js +0 -192
- package/dist/src/expo/plugins/link-addons.d.ts +0 -18
- package/dist/src/expo/plugins/link-addons.js +0 -65
- package/dist/src/pear/pre.d.ts +0 -21
- package/dist/src/pear/pre.js +0 -450
- package/dist/src/server/env.d.ts +0 -22
- package/dist/src/server/env.js +0 -59
- package/dist/src/server/utils/qvac-paths.d.ts +0 -2
- package/dist/src/server/utils/qvac-paths.js +0 -5
- package/dist/src/server/utils/worker-lock.d.ts +0 -3
- package/dist/src/server/utils/worker-lock.js +0 -67
- package/dist/src/worker/create-server.d.ts +0 -8
- package/dist/src/worker/create-server.js +0 -51
- package/dist/src/worker/lifecycle.d.ts +0 -23
- package/dist/src/worker/lifecycle.js +0 -149
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { type DiffusionClientParams, type DiffusionStats } from '@qvac/inference/surface';
|
|
1
|
+
import { type DiffusionClientParams, type DiffusionStats, type RPCOptions } from '@qvac/inference/surface';
|
|
2
2
|
export interface DiffusionProgressTick {
|
|
3
3
|
step: number;
|
|
4
4
|
totalSteps: number;
|
|
5
5
|
elapsedMs: number;
|
|
6
6
|
}
|
|
7
7
|
interface DiffusionResult {
|
|
8
|
+
/** Stable id of this generation; pass to `cancel({ requestId })` to stop it. */
|
|
9
|
+
requestId: string;
|
|
8
10
|
progressStream: AsyncGenerator<DiffusionProgressTick>;
|
|
9
11
|
outputs: Promise<Uint8Array[]>;
|
|
10
12
|
stats: Promise<DiffusionStats | undefined>;
|
|
@@ -13,7 +15,8 @@ interface DiffusionResult {
|
|
|
13
15
|
* Generates images using a loaded diffusion model.
|
|
14
16
|
*
|
|
15
17
|
* @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
|
|
16
|
-
* @
|
|
18
|
+
* @param options - Optional RPC options (timeout, profiling, force new connection).
|
|
19
|
+
* @returns A result object exposing `requestId` (stable identifier for this generation, for `cancel({ requestId })`), `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
|
|
17
20
|
* @throws {InferenceCancelledError} The run's promises reject and progress stream throws when an active generation is cancelled.
|
|
18
21
|
* @throws {RequestRejectedByPolicyError} The run rejects when another image or video generation owns the model.
|
|
19
22
|
*
|
|
@@ -32,7 +35,7 @@ interface DiffusionResult {
|
|
|
32
35
|
* const { outputs } = diffusion({ modelId, prompt: "oil painting style", init_image: initImage, strength: 0.7 });
|
|
33
36
|
*
|
|
34
37
|
* // img2img (FLUX.2 — in-context conditioning)
|
|
35
|
-
* // IMPORTANT: FLUX img2img requires `prediction: "flux2_flow"` to be set on the
|
|
38
|
+
* // IMPORTANT: FLUX.2 img2img requires `prediction: "flux2_flow"` to be set on the
|
|
36
39
|
* // model config at loadModel time (e.g. `loadModel(src, { modelType: "diffusion",
|
|
37
40
|
* // modelConfig: { prediction: "flux2_flow" } })`).
|
|
38
41
|
* const { outputs } = diffusion({ modelId, prompt: "turn into watercolor", init_image: initImage });
|
|
@@ -52,6 +55,19 @@ interface DiffusionResult {
|
|
|
52
55
|
* height: 768,
|
|
53
56
|
* });
|
|
54
57
|
*
|
|
58
|
+
* // FLUX.3 Image Klein reference editing. Load the Qwen3-VL 4B encoder and the
|
|
59
|
+
* // FLUX.2 VAE; the engine detects FLUX.3 from the weights, so leave `prediction` unset.
|
|
60
|
+
* const { outputs: flux3Edit } = diffusion({
|
|
61
|
+
* modelId,
|
|
62
|
+
* prompt: "Place the subject in a lush garden, preserving its appearance.",
|
|
63
|
+
* init_images: [refA],
|
|
64
|
+
* width: 512,
|
|
65
|
+
* height: 512,
|
|
66
|
+
* steps: 16,
|
|
67
|
+
* cfg_scale: 1,
|
|
68
|
+
* sampling_method: "euler",
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
55
71
|
* // Qwen-Image-2.1 reference editing. Load the matching Qwen3-VL encoder,
|
|
56
72
|
* // vision projector, and 2.1 VAE from your local files first.
|
|
57
73
|
* const { outputs: edited } = diffusion({
|
|
@@ -105,6 +121,6 @@ interface DiffusionResult {
|
|
|
105
121
|
* const buffers = await outputs;
|
|
106
122
|
* ```
|
|
107
123
|
*/
|
|
108
|
-
export declare function diffusion(params: DiffusionClientParams): DiffusionResult;
|
|
124
|
+
export declare function diffusion(params: DiffusionClientParams, options?: RPCOptions): DiffusionResult;
|
|
109
125
|
export {};
|
|
110
126
|
//# sourceMappingURL=diffusion.d.ts.map
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { diffusionStreamResponseSchema } from '@qvac/inference/surface';
|
|
2
2
|
import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
|
|
3
|
+
import { generateClientRequestId } from '../../client/api/client-request-id.js';
|
|
3
4
|
import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
|
|
4
5
|
/**
|
|
5
6
|
* Generates images using a loaded diffusion model.
|
|
6
7
|
*
|
|
7
8
|
* @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
|
|
8
|
-
* @
|
|
9
|
+
* @param options - Optional RPC options (timeout, profiling, force new connection).
|
|
10
|
+
* @returns A result object exposing `requestId` (stable identifier for this generation, for `cancel({ requestId })`), `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
|
|
9
11
|
* @throws {InferenceCancelledError} The run's promises reject and progress stream throws when an active generation is cancelled.
|
|
10
12
|
* @throws {RequestRejectedByPolicyError} The run rejects when another image or video generation owns the model.
|
|
11
13
|
*
|
|
@@ -24,7 +26,7 @@ import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
|
|
|
24
26
|
* const { outputs } = diffusion({ modelId, prompt: "oil painting style", init_image: initImage, strength: 0.7 });
|
|
25
27
|
*
|
|
26
28
|
* // img2img (FLUX.2 — in-context conditioning)
|
|
27
|
-
* // IMPORTANT: FLUX img2img requires `prediction: "flux2_flow"` to be set on the
|
|
29
|
+
* // IMPORTANT: FLUX.2 img2img requires `prediction: "flux2_flow"` to be set on the
|
|
28
30
|
* // model config at loadModel time (e.g. `loadModel(src, { modelType: "diffusion",
|
|
29
31
|
* // modelConfig: { prediction: "flux2_flow" } })`).
|
|
30
32
|
* const { outputs } = diffusion({ modelId, prompt: "turn into watercolor", init_image: initImage });
|
|
@@ -44,6 +46,19 @@ import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
|
|
|
44
46
|
* height: 768,
|
|
45
47
|
* });
|
|
46
48
|
*
|
|
49
|
+
* // FLUX.3 Image Klein reference editing. Load the Qwen3-VL 4B encoder and the
|
|
50
|
+
* // FLUX.2 VAE; the engine detects FLUX.3 from the weights, so leave `prediction` unset.
|
|
51
|
+
* const { outputs: flux3Edit } = diffusion({
|
|
52
|
+
* modelId,
|
|
53
|
+
* prompt: "Place the subject in a lush garden, preserving its appearance.",
|
|
54
|
+
* init_images: [refA],
|
|
55
|
+
* width: 512,
|
|
56
|
+
* height: 512,
|
|
57
|
+
* steps: 16,
|
|
58
|
+
* cfg_scale: 1,
|
|
59
|
+
* sampling_method: "euler",
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
47
62
|
* // Qwen-Image-2.1 reference editing. Load the matching Qwen3-VL encoder,
|
|
48
63
|
* // vision projector, and 2.1 VAE from your local files first.
|
|
49
64
|
* const { outputs: edited } = diffusion({
|
|
@@ -97,15 +112,17 @@ import { decodeBase64, encodeBase64 } from '../../utils/encoding.js';
|
|
|
97
112
|
* const buffers = await outputs;
|
|
98
113
|
* ```
|
|
99
114
|
*/
|
|
100
|
-
export function diffusion(params) {
|
|
115
|
+
export function diffusion(params, options) {
|
|
101
116
|
const { init_image, init_images, ...rest } = params;
|
|
117
|
+
const requestId = generateClientRequestId();
|
|
102
118
|
const request = {
|
|
103
119
|
...rest,
|
|
104
120
|
...(init_image !== undefined && { init_image: encodeBase64(init_image) }),
|
|
105
121
|
...(init_images !== undefined && {
|
|
106
122
|
init_images: init_images.map(encodeBase64)
|
|
107
123
|
}),
|
|
108
|
-
type: 'diffusionStream'
|
|
124
|
+
type: 'diffusionStream',
|
|
125
|
+
requestId
|
|
109
126
|
};
|
|
110
127
|
let statsResolver = () => { };
|
|
111
128
|
let statsRejecter = () => { };
|
|
@@ -128,7 +145,7 @@ export function diffusion(params) {
|
|
|
128
145
|
outputsPromise.catch(() => { });
|
|
129
146
|
const processResponses = async () => {
|
|
130
147
|
try {
|
|
131
|
-
for await (const response of streamRpc(request)) {
|
|
148
|
+
for await (const response of streamRpc(request, options)) {
|
|
132
149
|
if (response &&
|
|
133
150
|
typeof response === 'object' &&
|
|
134
151
|
'type' in response &&
|
|
@@ -187,6 +204,7 @@ export function diffusion(params) {
|
|
|
187
204
|
}
|
|
188
205
|
})();
|
|
189
206
|
return {
|
|
207
|
+
requestId,
|
|
190
208
|
progressStream,
|
|
191
209
|
outputs: outputsPromise,
|
|
192
210
|
stats: statsPromise
|
|
@@ -1,42 +1,95 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { send } from '../../client/rpc/rpc-client.js';
|
|
2
|
+
import { type EmbedClientParams, type EmbedBatchClientParams, type EmbedClientInput, type EmbedInput, type EmbedStats, type RPCOptions } from '@qvac/inference/surface';
|
|
3
|
+
type EmbedResult<T> = Promise<{
|
|
4
|
+
embedding: T;
|
|
5
|
+
stats?: EmbedStats;
|
|
6
|
+
}> & {
|
|
7
|
+
requestId: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Embeds one input supported by the loaded model.
|
|
11
|
+
*
|
|
12
|
+
* @overloadLabel "Single input"
|
|
13
|
+
* @param params - Model identifier and text, ordered text/media parts, or image bytes.
|
|
14
|
+
* @param options - Optional RPC options.
|
|
15
|
+
* @returns One vector, optional statistics, and a synchronous requestId for cancellation.
|
|
16
|
+
* @throws {QvacErrorBase} When validation or inference fails.
|
|
17
|
+
*/
|
|
18
|
+
export declare function embed(params: {
|
|
19
|
+
modelId: string;
|
|
20
|
+
input: EmbedClientInput;
|
|
21
|
+
text?: never;
|
|
22
|
+
inputs?: never;
|
|
23
|
+
}, options?: RPCOptions): EmbedResult<number[]>;
|
|
2
24
|
/**
|
|
3
|
-
*
|
|
25
|
+
* Embeds one text string.
|
|
4
26
|
*
|
|
5
27
|
* @overloadLabel "Single text"
|
|
6
|
-
* @param params -
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @returns A promise (decorated with `requestId`) resolving to an object with `embedding` (a single `number[]` vector) and optional `stats` performance data.
|
|
11
|
-
* @throws {QvacErrorBase} When the response type is invalid or when the embedding fails
|
|
28
|
+
* @param params - Model identifier and text.
|
|
29
|
+
* @param options - Optional RPC options.
|
|
30
|
+
* @returns One vector with optional statistics and a requestId for cancellation.
|
|
31
|
+
* @throws {QvacErrorBase} When validation or inference fails.
|
|
12
32
|
*/
|
|
13
33
|
export declare function embed(params: {
|
|
14
34
|
modelId: string;
|
|
15
35
|
text: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}> & {
|
|
20
|
-
requestId: string;
|
|
21
|
-
};
|
|
36
|
+
inputs?: never;
|
|
37
|
+
input?: never;
|
|
38
|
+
}, options?: RPCOptions): EmbedResult<number[]>;
|
|
22
39
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
29
|
-
* @param
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
40
|
+
* @deprecated Use `embedBatch({ modelId, inputs })` instead. This overload will be
|
|
41
|
+
* removed in the next major version.
|
|
42
|
+
*
|
|
43
|
+
* Embeds each string in a text array.
|
|
44
|
+
*
|
|
45
|
+
* @overloadLabel "Legacy text batch (deprecated)"
|
|
46
|
+
* @param params - Model identifier and text strings.
|
|
47
|
+
* @param options - Optional RPC options.
|
|
48
|
+
* @returns One vector per string, optional statistics, and a requestId.
|
|
49
|
+
* @throws {QvacErrorBase} When validation or inference fails.
|
|
32
50
|
*/
|
|
33
51
|
export declare function embed(params: {
|
|
34
52
|
modelId: string;
|
|
35
53
|
text: string[];
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
inputs?: never;
|
|
55
|
+
input?: never;
|
|
56
|
+
}, options?: RPCOptions): EmbedResult<number[][]>;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use `embedBatch({ modelId, inputs })` instead. This overload will be
|
|
59
|
+
* removed in the next major version.
|
|
60
|
+
*
|
|
61
|
+
* Embeds each text or ordered text/media input.
|
|
62
|
+
*
|
|
63
|
+
* @overloadLabel "Legacy inputs batch (deprecated)"
|
|
64
|
+
* @param params - Model identifier and text or ordered text/media inputs. Images go through embedBatch.
|
|
65
|
+
* @param options - Optional RPC options.
|
|
66
|
+
* @returns One vector per input, optional statistics, and a requestId.
|
|
67
|
+
* @throws {QvacErrorBase} When validation or inference fails.
|
|
68
|
+
*/
|
|
69
|
+
export declare function embed(params: {
|
|
70
|
+
modelId: string;
|
|
71
|
+
inputs: EmbedInput[];
|
|
72
|
+
text?: never;
|
|
73
|
+
input?: never;
|
|
74
|
+
}, options?: RPCOptions): EmbedResult<number[][]>;
|
|
75
|
+
/**
|
|
76
|
+
* Embeds a single input or a legacy batch supported by the loaded model.
|
|
77
|
+
*
|
|
78
|
+
* @param params - Model identifier and input.
|
|
79
|
+
* @param options - Optional RPC options.
|
|
80
|
+
* @returns Embeddings, optional statistics, and a requestId for cancellation.
|
|
81
|
+
* @throws {QvacErrorBase} When validation or inference fails.
|
|
82
|
+
*/
|
|
83
|
+
export declare function embed(params: EmbedClientParams, options?: RPCOptions): EmbedResult<number[] | number[][]>;
|
|
84
|
+
/**
|
|
85
|
+
* Embeds a batch of inputs supported by the loaded model, in input order.
|
|
86
|
+
*
|
|
87
|
+
* @param params - Model identifier and a non-empty list of inputs.
|
|
88
|
+
* @param options - Optional RPC options.
|
|
89
|
+
* @returns One vector per input, including one-item batches, optional statistics, and a requestId.
|
|
90
|
+
* @throws {QvacErrorBase} When validation or inference fails.
|
|
91
|
+
*/
|
|
92
|
+
export declare function embedBatch(params: EmbedBatchClientParams, options?: RPCOptions): EmbedResult<number[][]>;
|
|
93
|
+
export declare function createEmbedCall(params: EmbedClientParams, options?: RPCOptions, sendRequest?: typeof send): EmbedResult<number[] | number[][]>;
|
|
94
|
+
export {};
|
|
42
95
|
//# sourceMappingURL=embed.d.ts.map
|
|
@@ -1,30 +1,75 @@
|
|
|
1
1
|
import { send } from '../../client/rpc/rpc-client.js';
|
|
2
|
-
import {} from '@qvac/inference/surface';
|
|
2
|
+
import { embedClientParamsSchema, embedBatchClientParamsSchema, embedResponseSchema, embedBatchResponseSchema } from '@qvac/inference/surface';
|
|
3
3
|
import { InvalidResponseError } from '../../utils/errors-client.js';
|
|
4
|
+
import { parseClientInput } from '../../client/parse-input.js';
|
|
5
|
+
import { encodeBase64 } from '../../utils/encoding.js';
|
|
4
6
|
import { decoratePromise } from '../../utils/decorate-promise.js';
|
|
5
7
|
import { generateClientRequestId } from '../../client/api/client-request-id.js';
|
|
8
|
+
import { getClientLogger } from '../../logging/index.js';
|
|
9
|
+
const logger = getClientLogger();
|
|
6
10
|
export function embed(params, options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
return createEmbedCall(params, options);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Embeds a batch of inputs supported by the loaded model, in input order.
|
|
15
|
+
*
|
|
16
|
+
* @param params - Model identifier and a non-empty list of inputs.
|
|
17
|
+
* @param options - Optional RPC options.
|
|
18
|
+
* @returns One vector per input, including one-item batches, optional statistics, and a requestId.
|
|
19
|
+
* @throws {QvacErrorBase} When validation or inference fails.
|
|
20
|
+
*/
|
|
21
|
+
export function embedBatch(params, options) {
|
|
12
22
|
const requestId = generateClientRequestId();
|
|
13
|
-
|
|
14
|
-
return decoratePromise(inner, { requestId });
|
|
23
|
+
return decoratePromise(runEmbedBatch(params, requestId, options), { requestId });
|
|
15
24
|
}
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
export function createEmbedCall(params, options, sendRequest = send) {
|
|
26
|
+
const requestId = generateClientRequestId();
|
|
27
|
+
return decoratePromise(runEmbed(params, requestId, options, sendRequest), { requestId });
|
|
28
|
+
}
|
|
29
|
+
function encodeInput(input) {
|
|
30
|
+
return typeof input === 'object' && !Array.isArray(input)
|
|
31
|
+
? { ...input, image: encodeBase64(input.image) }
|
|
32
|
+
: input;
|
|
33
|
+
}
|
|
34
|
+
async function runEmbed(params, requestId, options, sendRequest) {
|
|
35
|
+
const parsed = parseClientInput(embedClientParamsSchema, params);
|
|
36
|
+
if (parsed.inputs !== undefined) {
|
|
37
|
+
logger.warn('embed() with inputs is deprecated. Use embedBatch() instead.');
|
|
25
38
|
}
|
|
39
|
+
else if (Array.isArray(parsed.text)) {
|
|
40
|
+
logger.warn('embed() with a text array is deprecated. Use embedBatch() instead.');
|
|
41
|
+
}
|
|
42
|
+
const request = parsed.input !== undefined
|
|
43
|
+
? { modelId: parsed.modelId, input: encodeInput(parsed.input) }
|
|
44
|
+
: parsed.inputs !== undefined
|
|
45
|
+
? { modelId: parsed.modelId, inputs: parsed.inputs }
|
|
46
|
+
: { modelId: parsed.modelId, text: parsed.text };
|
|
47
|
+
const response = await sendRequest({ ...request, type: 'embed', requestId }, options);
|
|
48
|
+
if (response.type !== 'embed')
|
|
49
|
+
throw new InvalidResponseError('embed');
|
|
50
|
+
const result = embedResponseSchema.safeParse(response);
|
|
51
|
+
if (!result.success)
|
|
52
|
+
throw new InvalidResponseError('embed', result.error);
|
|
53
|
+
return {
|
|
54
|
+
embedding: result.data.embedding,
|
|
55
|
+
...(result.data.stats !== undefined && { stats: result.data.stats })
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function runEmbedBatch(params, requestId, options) {
|
|
59
|
+
const parsed = parseClientInput(embedBatchClientParamsSchema, params);
|
|
60
|
+
const response = await send({
|
|
61
|
+
modelId: parsed.modelId,
|
|
62
|
+
inputs: parsed.inputs.map(encodeInput),
|
|
63
|
+
type: 'embedBatch',
|
|
64
|
+
requestId
|
|
65
|
+
}, options);
|
|
66
|
+
if (response.type !== 'embedBatch')
|
|
67
|
+
throw new InvalidResponseError('embedBatch');
|
|
68
|
+
const result = embedBatchResponseSchema.safeParse(response);
|
|
69
|
+
if (!result.success)
|
|
70
|
+
throw new InvalidResponseError('embedBatch', result.error);
|
|
26
71
|
return {
|
|
27
|
-
embedding:
|
|
28
|
-
...(
|
|
72
|
+
embedding: result.data.embedding,
|
|
73
|
+
...(result.data.stats !== undefined && { stats: result.data.stats })
|
|
29
74
|
};
|
|
30
75
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type GetModelInfoParams, type ModelInfo } from '@qvac/inference/surface';
|
|
1
|
+
import { type GetModelInfoParams, type ModelInfo, type RPCOptions } from '@qvac/inference/surface';
|
|
2
2
|
/**
|
|
3
3
|
* Returns status information for a catalog model, including cache state and loaded instances.
|
|
4
4
|
*
|
|
@@ -7,5 +7,5 @@ import { type GetModelInfoParams, type ModelInfo } from '@qvac/inference/surface
|
|
|
7
7
|
* @returns A promise resolving to the model's status information (cache presence, loaded instances, size on disk, etc.).
|
|
8
8
|
* @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
|
|
9
9
|
*/
|
|
10
|
-
export declare function getModelInfo(params: GetModelInfoParams): Promise<ModelInfo>;
|
|
10
|
+
export declare function getModelInfo(params: GetModelInfoParams, options?: RPCOptions): Promise<ModelInfo>;
|
|
11
11
|
//# sourceMappingURL=get-model-info.d.ts.map
|
|
@@ -9,12 +9,12 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
|
|
|
9
9
|
* @returns A promise resolving to the model's status information (cache presence, loaded instances, size on disk, etc.).
|
|
10
10
|
* @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
|
|
11
11
|
*/
|
|
12
|
-
export async function getModelInfo(params) {
|
|
12
|
+
export async function getModelInfo(params, options) {
|
|
13
13
|
const request = {
|
|
14
14
|
type: 'getModelInfo',
|
|
15
15
|
name: params.name
|
|
16
16
|
};
|
|
17
|
-
const response = await send(request);
|
|
17
|
+
const response = await send(request, options);
|
|
18
18
|
if (response.type !== 'getModelInfo') {
|
|
19
19
|
throw new InvalidResponseError('getModelInfo');
|
|
20
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type GetSystemResourcesInput, type SystemResources } from '@qvac/inference/surface';
|
|
1
|
+
import { type GetSystemResourcesInput, type SystemResources, type RPCOptions } from '@qvac/inference/surface';
|
|
2
2
|
/**
|
|
3
3
|
* Read the worker's system capabilities and optional resource sample.
|
|
4
4
|
*
|
|
@@ -7,5 +7,5 @@ import { type GetSystemResourcesInput, type SystemResources } from '@qvac/infere
|
|
|
7
7
|
* @throws {InvalidResponseError} If the worker returns a different response type.
|
|
8
8
|
* @throws {Error} If the RPC request fails.
|
|
9
9
|
*/
|
|
10
|
-
export declare function getSystemResources(input?: GetSystemResourcesInput): Promise<SystemResources>;
|
|
10
|
+
export declare function getSystemResources(input?: GetSystemResourcesInput, options?: RPCOptions): Promise<SystemResources>;
|
|
11
11
|
//# sourceMappingURL=get-system-resources.d.ts.map
|
|
@@ -9,12 +9,12 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
|
|
|
9
9
|
* @throws {InvalidResponseError} If the worker returns a different response type.
|
|
10
10
|
* @throws {Error} If the RPC request fails.
|
|
11
11
|
*/
|
|
12
|
-
export async function getSystemResources(input) {
|
|
12
|
+
export async function getSystemResources(input, options) {
|
|
13
13
|
const request = {
|
|
14
14
|
type: 'getSystemResources',
|
|
15
15
|
...(input?.sample !== undefined && { sample: input.sample })
|
|
16
16
|
};
|
|
17
|
-
const response = await send(request);
|
|
17
|
+
const response = await send(request, options);
|
|
18
18
|
if (response.type !== 'getSystemResources') {
|
|
19
19
|
throw new InvalidResponseError('getSystemResources');
|
|
20
20
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { type HeartbeatResponse } from '@qvac/inference/surface';
|
|
1
|
+
import { type HeartbeatResponse, type RPCOptions } from '@qvac/inference/surface';
|
|
2
2
|
/**
|
|
3
3
|
* Checks whether the local SDK worker is responsive by sending a heartbeat
|
|
4
4
|
* round-trip.
|
|
5
5
|
*
|
|
6
|
+
* @param options - Optional RPC options (timeout, profiling, force new connection).
|
|
6
7
|
* @returns A promise that resolves to a heartbeat response.
|
|
7
8
|
* @throws {QvacErrorBase} When the response is invalid.
|
|
8
9
|
*
|
|
9
10
|
* @example
|
|
10
11
|
* await heartbeat();
|
|
11
12
|
*/
|
|
12
|
-
export declare function heartbeat(): Promise<HeartbeatResponse>;
|
|
13
|
+
export declare function heartbeat(options?: RPCOptions): Promise<HeartbeatResponse>;
|
|
13
14
|
//# sourceMappingURL=heartbeat.d.ts.map
|
|
@@ -5,15 +5,16 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
|
|
|
5
5
|
* Checks whether the local SDK worker is responsive by sending a heartbeat
|
|
6
6
|
* round-trip.
|
|
7
7
|
*
|
|
8
|
+
* @param options - Optional RPC options (timeout, profiling, force new connection).
|
|
8
9
|
* @returns A promise that resolves to a heartbeat response.
|
|
9
10
|
* @throws {QvacErrorBase} When the response is invalid.
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* await heartbeat();
|
|
13
14
|
*/
|
|
14
|
-
export async function heartbeat() {
|
|
15
|
+
export async function heartbeat(options) {
|
|
15
16
|
const request = { type: 'heartbeat' };
|
|
16
|
-
const response = await send(request);
|
|
17
|
+
const response = await send(request, options);
|
|
17
18
|
if (response.type !== 'heartbeat') {
|
|
18
19
|
throw new InvalidResponseError('heartbeat');
|
|
19
20
|
}
|
|
@@ -3,18 +3,19 @@ export { downloadAsset } from './download-asset.js';
|
|
|
3
3
|
export { batchCompletion } from './batch-completion.js';
|
|
4
4
|
export { completion } from './completion-stream.js';
|
|
5
5
|
export { deleteCache } from './delete-cache.js';
|
|
6
|
-
export {
|
|
6
|
+
export { calcTokens, type CalcTokensClientParams } from './calc-tokens.js';
|
|
7
|
+
export { unloadModel, type UnloadModelResult } from './unload-model.js';
|
|
7
8
|
export { loggingStream } from './logging-stream.js';
|
|
8
9
|
export { subscribeServerLogs, type ServerLogHandler } from './subscribe-logs.js';
|
|
9
10
|
export { heartbeat } from './heartbeat.js';
|
|
10
11
|
export { transcribe, transcribeStream } from './transcribe.js';
|
|
11
12
|
export { bciTranscribe, bciTranscribeStream } from './bci-transcribe.js';
|
|
12
|
-
export { embed } from './embed.js';
|
|
13
|
+
export { embed, embedBatch } from './embed.js';
|
|
13
14
|
export { finetune, type FinetuneHandle } from './finetune.js';
|
|
14
15
|
export { translate } from './translate.js';
|
|
15
16
|
export { cancel } from './cancel.js';
|
|
16
17
|
export { ragChunk, ragIngest, ragSaveEmbeddings, ragSearch, ragDeleteEmbeddings, ragReindex, ragListWorkspaces, ragCloseWorkspace, ragDeleteWorkspace } from './rag.js';
|
|
17
|
-
export { createVectorIndex, loadVectorIndex, type VectorIndex } from './vector-index.js';
|
|
18
|
+
export { createVectorIndex, loadVectorIndex, type VectorIndex, type VectorIndexOperation } from './vector-index.js';
|
|
18
19
|
export { textToSpeech, textToSpeechStream } from './text-to-speech.js';
|
|
19
20
|
export { getModelInfo } from './get-model-info.js';
|
|
20
21
|
export { getLoadedModelInfo } from './get-loaded-model-info.js';
|
|
@@ -3,13 +3,14 @@ export { downloadAsset } from './download-asset.js';
|
|
|
3
3
|
export { batchCompletion } from './batch-completion.js';
|
|
4
4
|
export { completion } from './completion-stream.js';
|
|
5
5
|
export { deleteCache } from './delete-cache.js';
|
|
6
|
+
export { calcTokens } from './calc-tokens.js';
|
|
6
7
|
export { unloadModel } from './unload-model.js';
|
|
7
8
|
export { loggingStream } from './logging-stream.js';
|
|
8
9
|
export { subscribeServerLogs } from './subscribe-logs.js';
|
|
9
10
|
export { heartbeat } from './heartbeat.js';
|
|
10
11
|
export { transcribe, transcribeStream } from './transcribe.js';
|
|
11
12
|
export { bciTranscribe, bciTranscribeStream } from './bci-transcribe.js';
|
|
12
|
-
export { embed } from './embed.js';
|
|
13
|
+
export { embed, embedBatch } from './embed.js';
|
|
13
14
|
export { finetune } from './finetune.js';
|
|
14
15
|
export { translate } from './translate.js';
|
|
15
16
|
export { cancel } from './cancel.js';
|
|
@@ -3,6 +3,8 @@ export interface InvokePluginOptions<TParams = unknown> {
|
|
|
3
3
|
modelId: string;
|
|
4
4
|
handler: string;
|
|
5
5
|
params: TParams;
|
|
6
|
+
/** Caller-minted id for `cancel({ requestId })`; generated when omitted. */
|
|
7
|
+
requestId?: string;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
10
|
* Invoke a non-streaming plugin handler.
|
|
@@ -15,7 +17,9 @@ export interface InvokePluginOptions<TParams = unknown> {
|
|
|
15
17
|
* @returns A promise resolving to the handler's result payload (typed via the `TResponse` generic).
|
|
16
18
|
* @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
|
|
17
19
|
*/
|
|
18
|
-
export declare function invokePlugin<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): Promise<TResponse
|
|
20
|
+
export declare function invokePlugin<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): Promise<TResponse> & {
|
|
21
|
+
requestId: string;
|
|
22
|
+
};
|
|
19
23
|
/**
|
|
20
24
|
* Invoke a streaming plugin handler.
|
|
21
25
|
*
|
|
@@ -27,5 +31,7 @@ export declare function invokePlugin<TResponse = unknown, TParams = unknown>(opt
|
|
|
27
31
|
* @returns An async generator yielding chunk payloads (typed via the `TResponse` generic) until the stream completes.
|
|
28
32
|
* @throws {QvacErrorBase} When an intermediate response has the wrong type (`InvalidResponseError`) or the RPC layer fails.
|
|
29
33
|
*/
|
|
30
|
-
export declare function invokePluginStream<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): AsyncGenerator<TResponse
|
|
34
|
+
export declare function invokePluginStream<TResponse = unknown, TParams = unknown>(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): AsyncGenerator<TResponse> & {
|
|
35
|
+
requestId: string;
|
|
36
|
+
};
|
|
31
37
|
//# sourceMappingURL=invoke-plugin.d.ts.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { send, stream } from '../../client/rpc/rpc-client.js';
|
|
2
2
|
import { InvalidResponseError } from '../../utils/errors-client.js';
|
|
3
|
+
import { decoratePromise } from '../../utils/decorate-promise.js';
|
|
4
|
+
import { generateClientRequestId } from '../../client/api/client-request-id.js';
|
|
3
5
|
/**
|
|
4
6
|
* Invoke a non-streaming plugin handler.
|
|
5
7
|
*
|
|
@@ -11,9 +13,16 @@ import { InvalidResponseError } from '../../utils/errors-client.js';
|
|
|
11
13
|
* @returns A promise resolving to the handler's result payload (typed via the `TResponse` generic).
|
|
12
14
|
* @throws {QvacErrorBase} When the response type is invalid (`InvalidResponseError`) or the RPC layer fails.
|
|
13
15
|
*/
|
|
14
|
-
export
|
|
16
|
+
export function invokePlugin(options, rpcOptions) {
|
|
17
|
+
const requestId = options.requestId ?? generateClientRequestId();
|
|
18
|
+
return decoratePromise(runInvokePlugin(options, requestId, rpcOptions), {
|
|
19
|
+
requestId
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function runInvokePlugin(options, requestId, rpcOptions) {
|
|
15
23
|
const request = {
|
|
16
24
|
type: 'pluginInvoke',
|
|
25
|
+
requestId,
|
|
17
26
|
modelId: options.modelId,
|
|
18
27
|
handler: options.handler,
|
|
19
28
|
params: options.params
|
|
@@ -35,9 +44,15 @@ export async function invokePlugin(options, rpcOptions) {
|
|
|
35
44
|
* @returns An async generator yielding chunk payloads (typed via the `TResponse` generic) until the stream completes.
|
|
36
45
|
* @throws {QvacErrorBase} When an intermediate response has the wrong type (`InvalidResponseError`) or the RPC layer fails.
|
|
37
46
|
*/
|
|
38
|
-
export
|
|
47
|
+
export function invokePluginStream(options, rpcOptions) {
|
|
48
|
+
const requestId = options.requestId ?? generateClientRequestId();
|
|
49
|
+
const generator = runInvokePluginStream(options, requestId, rpcOptions);
|
|
50
|
+
return Object.assign(generator, { requestId });
|
|
51
|
+
}
|
|
52
|
+
async function* runInvokePluginStream(options, requestId, rpcOptions) {
|
|
39
53
|
const request = {
|
|
40
54
|
type: 'pluginInvokeStream',
|
|
55
|
+
requestId,
|
|
41
56
|
modelId: options.modelId,
|
|
42
57
|
handler: options.handler,
|
|
43
58
|
params: options.params
|
|
@@ -7,6 +7,7 @@ import { parseClientInput } from '../../client/parse-input.js';
|
|
|
7
7
|
import { getClientLogger } from '../../logging/index.js';
|
|
8
8
|
import { decoratePromise } from '../../utils/decorate-promise.js';
|
|
9
9
|
import { generateClientRequestId } from '../../client/api/client-request-id.js';
|
|
10
|
+
import { recordHeldModel } from '../../client/session-registry.js';
|
|
10
11
|
const logger = getClientLogger();
|
|
11
12
|
function isReactNativeRuntime() {
|
|
12
13
|
const runtime = globalThis;
|
|
@@ -93,10 +94,11 @@ async function runLoadModel(options, requestId, rpcOptions) {
|
|
|
93
94
|
throw new ModelLoadFailedError(response.error);
|
|
94
95
|
}
|
|
95
96
|
const modelId = response.modelId;
|
|
97
|
+
recordHeldModel(rpcOptions, modelId);
|
|
96
98
|
// Start logging stream in the background if logger is provided, catch to avoid failing the entire loadModel operation
|
|
97
99
|
if (modelLogger) {
|
|
98
100
|
try {
|
|
99
|
-
startLoggingStreamForModel(modelId, modelLogger);
|
|
101
|
+
startLoggingStreamForModel(modelId, modelLogger, rpcOptions);
|
|
100
102
|
}
|
|
101
103
|
catch (error) {
|
|
102
104
|
logger.warn(`Failed to start logging stream for model ${modelId}:`, error);
|
|
@@ -116,9 +118,10 @@ async function runLoadModel(options, requestId, rpcOptions) {
|
|
|
116
118
|
throw new ModelLoadFailedError(response.error);
|
|
117
119
|
}
|
|
118
120
|
const modelId = response.modelId;
|
|
121
|
+
recordHeldModel(rpcOptions, modelId);
|
|
119
122
|
if (modelLogger) {
|
|
120
123
|
try {
|
|
121
|
-
startLoggingStreamForModel(modelId, modelLogger);
|
|
124
|
+
startLoggingStreamForModel(modelId, modelLogger, rpcOptions);
|
|
122
125
|
}
|
|
123
126
|
catch (error) {
|
|
124
127
|
logger.warn(`Failed to start logging stream for model ${modelId}:`, error);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type OCRClientParams, type OCRTextBlock, type OCRStats } from '@qvac/inference/surface';
|
|
1
|
+
import { type OCRClientParams, type OCRTextBlock, type OCRStats, type RPCOptions } from '@qvac/inference/surface';
|
|
2
2
|
/**
|
|
3
3
|
* Performs Optical Character Recognition (OCR) on an image to extract text.
|
|
4
4
|
*
|
|
@@ -7,7 +7,8 @@ import { type OCRClientParams, type OCRTextBlock, type OCRStats } from '@qvac/in
|
|
|
7
7
|
* @param params.image - Image input as either a file path (string) or image buffer
|
|
8
8
|
* @param params.options - Optional OCR options (e.g., paragraph mode)
|
|
9
9
|
* @param params.stream - Whether to stream blocks as they're detected (true) or return all at once (false). Defaults to false
|
|
10
|
-
* @
|
|
10
|
+
* @param options - Optional RPC options (timeout, profiling, force new connection).
|
|
11
|
+
* @returns Object with `requestId` (pass to `cancel({ requestId })`), blockStream generator, blocks promise, and stats promise
|
|
11
12
|
* @example
|
|
12
13
|
* ```typescript
|
|
13
14
|
* // Load an OCR model first. Registry GGUF models resolve their pipeline
|
|
@@ -32,7 +33,8 @@ import { type OCRClientParams, type OCRTextBlock, type OCRStats } from '@qvac/in
|
|
|
32
33
|
* }
|
|
33
34
|
* ```
|
|
34
35
|
*/
|
|
35
|
-
export declare function ocr(params: OCRClientParams): {
|
|
36
|
+
export declare function ocr(params: OCRClientParams, options?: RPCOptions): {
|
|
37
|
+
requestId: string;
|
|
36
38
|
blockStream: AsyncGenerator<OCRTextBlock[]>;
|
|
37
39
|
blocks: Promise<OCRTextBlock[]>;
|
|
38
40
|
stats: Promise<OCRStats | undefined>;
|