@qvac/sdk 0.8.2 → 0.9.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 +267 -63
- package/README.md +2 -0
- package/dist/client/api/diffusion.d.ts +32 -0
- package/dist/client/api/diffusion.js +103 -0
- package/dist/client/api/embed.d.ts +9 -3
- package/dist/client/api/embed.js +4 -1
- package/dist/client/api/finetune.d.ts +69 -0
- package/dist/client/api/finetune.js +139 -0
- package/dist/client/api/get-model-info.d.ts +1 -1
- package/dist/client/api/index.d.ts +4 -0
- package/dist/client/api/index.js +4 -0
- package/dist/client/api/rag.d.ts +1 -1
- package/dist/client/api/rag.js +1 -1
- package/dist/client/api/resume.d.ts +14 -0
- package/dist/client/api/resume.js +20 -0
- package/dist/client/api/suspend.d.ts +13 -0
- package/dist/client/api/suspend.js +19 -0
- package/dist/client/api/transcribe.d.ts +25 -17
- package/dist/client/api/transcribe.js +115 -35
- package/dist/client/rpc/bare-client.d.ts +5 -1
- package/dist/client/rpc/bare-client.js +70 -57
- package/dist/client/rpc/expo-rpc-client.d.ts +4 -0
- package/dist/client/rpc/expo-rpc-client.js +8 -0
- package/dist/client/rpc/node-rpc-client.d.ts +4 -0
- package/dist/client/rpc/node-rpc-client.js +8 -0
- package/dist/client/rpc/rpc-client.d.ts +13 -0
- package/dist/client/rpc/rpc-client.js +131 -1
- package/dist/examples/delegated-inference/composite.d.ts +2 -0
- package/dist/examples/delegated-inference/composite.js +99 -0
- package/dist/examples/diffusion-flux2-klein.d.ts +2 -0
- package/dist/examples/diffusion-flux2-klein.js +46 -0
- package/dist/examples/diffusion-simple.d.ts +2 -0
- package/dist/examples/diffusion-simple.js +17 -0
- package/dist/examples/diffusion-txt2img.d.ts +2 -0
- package/dist/examples/diffusion-txt2img.js +40 -0
- package/dist/examples/embed-p2p.js +2 -2
- package/dist/examples/finetune/llamacpp-finetune.d.ts +2 -0
- package/dist/examples/finetune/llamacpp-finetune.js +78 -0
- package/dist/examples/logging-streaming.js +1 -1
- package/dist/examples/mcp-websearch.js +2 -0
- package/dist/examples/ocr-fasttext.js +11 -0
- package/dist/examples/profiling/per-call.js +3 -3
- package/dist/examples/rag/rag-chromadb.js +2 -2
- package/dist/examples/rag/rag-hyperdb/pipeline.js +1 -1
- package/dist/examples/rag/rag-lancedb.js +2 -2
- package/dist/examples/rag/rag-sqlite.js +2 -2
- package/dist/examples/suspend-resume.d.ts +2 -0
- package/dist/examples/suspend-resume.js +52 -0
- package/dist/examples/transcription/parakeet-ctc-filesystem.js +3 -5
- package/dist/examples/transcription/parakeet-microphone-record.js +42 -33
- package/dist/examples/transcription/parakeet-sortformer.js +13 -3
- package/dist/examples/transcription/parakeet-tdt-filesystem.js +5 -7
- package/dist/examples/transcription/whispercpp-filesystem-streaming.d.ts +2 -0
- package/dist/examples/transcription/whispercpp-filesystem-streaming.js +99 -0
- package/dist/examples/transcription/whispercpp-microphone-record.js +78 -299
- package/dist/examples/transcription/whispercpp-prompt.js +11 -0
- package/dist/examples/translation/translation-llm.js +2 -2
- package/dist/examples/tts/supertonic-multilingual.d.ts +2 -0
- package/dist/examples/tts/supertonic-multilingual.js +56 -0
- package/dist/examples/tts/supertonic.js +12 -7
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/logging/utils.js +1 -1
- package/dist/models/registry/models.d.ts +15176 -4264
- package/dist/models/registry/models.js +18657 -7404
- package/dist/models/update-models/codegen.js +2 -2
- package/dist/models/update-models/naming.js +26 -0
- package/dist/pear/pre.js +2 -0
- package/dist/polyfills/bare-globals.d.ts +2 -0
- package/dist/polyfills/bare-globals.js +4 -0
- package/dist/polyfills/bare-globals.noop.d.ts +2 -0
- package/dist/polyfills/bare-globals.noop.js +1 -0
- package/dist/profiling/exporters.js +16 -11
- package/dist/profiling/model-execution.d.ts +16 -0
- package/dist/profiling/model-execution.js +33 -0
- package/dist/schemas/common.d.ts +967 -198
- package/dist/schemas/common.js +16 -1
- package/dist/schemas/completion-stream.d.ts +14 -6
- package/dist/schemas/completion-stream.js +4 -3
- package/dist/schemas/download-asset.d.ts +7 -3
- package/dist/schemas/embed.d.ts +19 -0
- package/dist/schemas/embed.js +7 -0
- package/dist/schemas/engine-addon-map.js +4 -1
- package/dist/schemas/finetune.d.ts +620 -0
- package/dist/schemas/finetune.js +161 -0
- package/dist/schemas/get-model-info.d.ts +2 -0
- package/dist/schemas/get-model-info.js +1 -0
- package/dist/schemas/index.d.ts +5 -1
- package/dist/schemas/index.js +5 -1
- package/dist/schemas/llamacpp-config.d.ts +26 -6
- package/dist/schemas/llamacpp-config.js +12 -0
- package/dist/schemas/load-model.d.ts +4005 -1400
- package/dist/schemas/load-model.js +34 -1
- package/dist/schemas/model-src-utils.d.ts +10 -2
- package/dist/schemas/model-types.d.ts +19 -1
- package/dist/schemas/model-types.js +11 -0
- package/dist/schemas/ocr.d.ts +2 -0
- package/dist/schemas/plugin.d.ts +24 -3
- package/dist/schemas/plugin.js +14 -0
- package/dist/schemas/profiling.d.ts +4 -0
- package/dist/schemas/profiling.js +4 -0
- package/dist/schemas/registry.d.ts +18 -0
- package/dist/schemas/registry.js +2 -0
- package/dist/schemas/reload-config.d.ts +9 -1
- package/dist/schemas/resume.d.ts +10 -0
- package/dist/schemas/resume.js +7 -0
- package/dist/schemas/sdcpp-config.d.ts +327 -0
- package/dist/schemas/sdcpp-config.js +102 -0
- package/dist/schemas/sdk-config.d.ts +1225 -235
- package/dist/schemas/sdk-config.js +4 -0
- package/dist/schemas/sdk-errors-server.d.ts +2 -0
- package/dist/schemas/sdk-errors-server.js +12 -0
- package/dist/schemas/suspend.d.ts +10 -0
- package/dist/schemas/suspend.js +7 -0
- package/dist/schemas/text-to-speech.d.ts +187 -10
- package/dist/schemas/text-to-speech.js +12 -4
- package/dist/schemas/transcription-config.d.ts +16 -56
- package/dist/schemas/transcription-config.js +0 -2
- package/dist/schemas/transcription.d.ts +66 -6
- package/dist/schemas/transcription.js +29 -7
- package/dist/schemas/translate.d.ts +14 -4
- package/dist/schemas/translate.js +10 -2
- package/dist/schemas/translation-config.d.ts +30 -10
- package/dist/server/bare/delegate-rpc-client.js +3 -3
- package/dist/server/bare/hyperswarm.js +15 -3
- package/dist/server/bare/ops/embed.d.ts +8 -4
- package/dist/server/bare/ops/embed.js +15 -4
- package/dist/server/bare/ops/transcribe.d.ts +6 -2
- package/dist/server/bare/ops/transcribe.js +53 -1
- package/dist/server/bare/ops/translate.d.ts +4 -1
- package/dist/server/bare/ops/translate.js +28 -65
- package/dist/server/bare/ops/unload-model.js +2 -0
- package/dist/server/bare/plugins/index.d.ts +1 -0
- package/dist/server/bare/plugins/index.js +1 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.d.ts +1 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/cache-logger.js +3 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +3 -1
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +57 -11
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.d.ts +11 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +112 -0
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +175 -5
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +45 -35
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +11 -1
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +9 -4
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +17 -2
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +16 -15
- package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.d.ts +5 -7
- package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.js +11 -3
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +2 -0
- package/dist/server/bare/plugins/onnx-ocr/plugin.js +24 -19
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.d.ts +7 -2
- package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.js +22 -97
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +98 -9
- package/dist/server/bare/plugins/onnx-tts/plugin.js +85 -46
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +30 -60
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +49 -37
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.d.ts +3 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +51 -0
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +278 -0
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +70 -0
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +38 -2
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +43 -22
- package/dist/server/bare/rag-hyperdb/handlers/ingest.js +2 -1
- package/dist/server/bare/rag-hyperdb/handlers/search.js +2 -1
- package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +7 -0
- package/dist/server/bare/registry/model-config-utils.js +3 -0
- package/dist/server/bare/registry/model-registry.d.ts +2 -2
- package/dist/server/bare/registry/model-registry.js +1 -1
- package/dist/server/bare/registry/registry-client.js +21 -0
- package/dist/server/bare/runtime-lifecycle.d.ts +28 -0
- package/dist/server/bare/runtime-lifecycle.js +132 -0
- package/dist/server/bare/types/addon-responses.d.ts +62 -0
- package/dist/server/bare/types/addon-responses.js +1 -0
- package/dist/server/env.js +3 -1
- package/dist/server/rpc/delegate-transport.js +1 -1
- package/dist/server/rpc/handle-request.js +50 -4
- package/dist/server/rpc/handler-registry.js +20 -1
- package/dist/server/rpc/handler-utils.d.ts +5 -3
- package/dist/server/rpc/handler-utils.js +52 -50
- package/dist/server/rpc/handlers/delete-cache.js +3 -0
- package/dist/server/rpc/handlers/diffusion-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/diffusion-stream.js +4 -0
- package/dist/server/rpc/handlers/finetune.d.ts +3 -0
- package/dist/server/rpc/handlers/finetune.js +16 -0
- package/dist/server/rpc/handlers/index.d.ts +10 -0
- package/dist/server/rpc/handlers/index.js +10 -0
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +24 -9
- package/dist/server/rpc/handlers/load-model/registry.d.ts +11 -0
- package/dist/server/rpc/handlers/load-model/registry.js +31 -4
- package/dist/server/rpc/handlers/plugin-dispatch.d.ts +1 -13
- package/dist/server/rpc/handlers/plugin-dispatch.js +21 -21
- package/dist/server/rpc/handlers/resume.d.ts +3 -0
- package/dist/server/rpc/handlers/resume.js +11 -0
- package/dist/server/rpc/handlers/suspend.d.ts +3 -0
- package/dist/server/rpc/handlers/suspend.js +11 -0
- package/dist/server/rpc/handlers/transcribe-stream.d.ts +1 -1
- package/dist/server/rpc/handlers/transcribe-stream.js +2 -2
- package/dist/server/rpc/handlers/transcribe.d.ts +3 -0
- package/dist/server/rpc/handlers/transcribe.js +4 -0
- package/dist/server/rpc/profiling/operation-metrics.js +107 -16
- package/dist/server/rpc/profiling/operation-wrappers.d.ts +1 -1
- package/dist/server/rpc/profiling/operation-wrappers.js +51 -19
- package/dist/server/rpc/progress-throttle.d.ts +8 -0
- package/dist/server/rpc/progress-throttle.js +47 -0
- package/dist/server/rpc/rpc-utils.d.ts +5 -0
- package/dist/server/rpc/rpc-utils.js +11 -0
- package/dist/server/utils/path-security.js +1 -1
- package/dist/server/utils/tool-integration.js +10 -0
- package/dist/server/utils/tool-parser.js +9 -5
- package/dist/server/worker-core.d.ts +2 -0
- package/dist/server/worker-core.js +26 -23
- package/dist/server/worker.js +2 -1
- package/dist/utils/encoding.d.ts +9 -0
- package/dist/utils/encoding.js +14 -0
- package/dist/utils/errors-server.d.ts +6 -0
- package/dist/utils/errors-server.js +11 -0
- package/package.json +81 -25
- package/dist/server/rpc/delegate-utils.d.ts +0 -2
- package/dist/server/rpc/delegate-utils.js +0 -5
|
@@ -74,7 +74,7 @@ export type RegistryItem = {
|
|
|
74
74
|
blobBlockLength: number;
|
|
75
75
|
blobByteOffset: number;
|
|
76
76
|
modelId: string;
|
|
77
|
-
addon: "llm" | "whisper" | "embeddings" | "nmt" | "vad" | "tts" | "ocr" | "parakeet" | "other";
|
|
77
|
+
addon: "llm" | "whisper" | "embeddings" | "nmt" | "vad" | "tts" | "ocr" | "parakeet" | "diffusion" | "other";
|
|
78
78
|
expectedSize: number;
|
|
79
79
|
sha256Checksum: string;
|
|
80
80
|
engine: string;
|
|
@@ -103,7 +103,7 @@ export type ModelConstant = {
|
|
|
103
103
|
modelId: string;
|
|
104
104
|
expectedSize: number;
|
|
105
105
|
sha256Checksum: string;
|
|
106
|
-
addon: "llm" | "whisper" | "embeddings" | "nmt" | "vad" | "tts" | "ocr" | "parakeet" | "other";
|
|
106
|
+
addon: "llm" | "whisper" | "embeddings" | "nmt" | "vad" | "tts" | "ocr" | "parakeet" | "diffusion" | "other";
|
|
107
107
|
engine: string;
|
|
108
108
|
quantization: string;
|
|
109
109
|
params: string;
|
|
@@ -101,6 +101,8 @@ function generateBaseName(input) {
|
|
|
101
101
|
return generateOcrName(input);
|
|
102
102
|
case "parakeet":
|
|
103
103
|
return generateParakeetName(input);
|
|
104
|
+
case "diffusion":
|
|
105
|
+
return generateDiffusionName(input);
|
|
104
106
|
default:
|
|
105
107
|
return cleanPart(input.filename.replace(/\.\w+$/, ""));
|
|
106
108
|
}
|
|
@@ -314,6 +316,30 @@ function generateOcrName({ filename, tagName, modelName, tagExtra, }) {
|
|
|
314
316
|
const nameParts = [name, language, fileType].filter((p) => p && p !== "");
|
|
315
317
|
return `OCR_${nameParts.map(cleanPart).join("_")}`;
|
|
316
318
|
}
|
|
319
|
+
function generateDiffusionName({ filename, modelName, quantization, params, tags, }) {
|
|
320
|
+
// VAE / auxiliary models (tagged "vae" instead of "generation")
|
|
321
|
+
if (tags.includes("vae")) {
|
|
322
|
+
const name = modelName || "SD";
|
|
323
|
+
return `${cleanPart(name)}_VAE`;
|
|
324
|
+
}
|
|
325
|
+
// Extract family name from filename
|
|
326
|
+
let family = filename
|
|
327
|
+
.replace(/\.\w+$/, "")
|
|
328
|
+
.replace(/^stable-diffusion-xl/i, "SDXL")
|
|
329
|
+
.replace(/^stable-diffusion/i, "SD");
|
|
330
|
+
// Strip trailing params (e.g. "-4b") and quant (e.g. "-Q8_0") from family
|
|
331
|
+
// to avoid duplication since they're appended separately
|
|
332
|
+
if (params) {
|
|
333
|
+
const paramsEsc = params.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
334
|
+
family = family.replace(new RegExp(`[-_]${paramsEsc}[-_].*$`, "i"), "");
|
|
335
|
+
}
|
|
336
|
+
if (quantization) {
|
|
337
|
+
const quantEsc = quantization.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
338
|
+
family = family.replace(new RegExp(`[-_]${quantEsc}$`, "i"), "");
|
|
339
|
+
}
|
|
340
|
+
const nameParts = [family, params, quantization].filter((p) => p && p !== "");
|
|
341
|
+
return nameParts.map(cleanPart).join("_");
|
|
342
|
+
}
|
|
317
343
|
function generateParakeetName({ filename, lowerPath, quantization, }) {
|
|
318
344
|
const lower = filename.toLowerCase();
|
|
319
345
|
// Detect model variant from registry path
|
package/dist/pear/pre.js
CHANGED
|
@@ -31,6 +31,7 @@ const BUILTIN_PLUGINS = [
|
|
|
31
31
|
"@qvac/sdk/nmtcpp-translation/plugin",
|
|
32
32
|
"@qvac/sdk/onnx-tts/plugin",
|
|
33
33
|
"@qvac/sdk/onnx-ocr/plugin",
|
|
34
|
+
"@qvac/sdk/sdcpp-generation/plugin",
|
|
34
35
|
];
|
|
35
36
|
const BUILTIN_PLUGIN_EXPORTS = {
|
|
36
37
|
"llamacpp-completion": "llmPlugin",
|
|
@@ -39,6 +40,7 @@ const BUILTIN_PLUGIN_EXPORTS = {
|
|
|
39
40
|
"nmtcpp-translation": "nmtPlugin",
|
|
40
41
|
"onnx-tts": "ttsPlugin",
|
|
41
42
|
"onnx-ocr": "ocrPlugin",
|
|
43
|
+
"sdcpp-generation": "diffusionPlugin",
|
|
42
44
|
};
|
|
43
45
|
const SDK_NAME = "@qvac/sdk";
|
|
44
46
|
const DEFAULT_PEAR_WORKER = "worker.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -91,8 +91,13 @@ function formatNumber(n) {
|
|
|
91
91
|
return n.toFixed(2);
|
|
92
92
|
return n.toFixed(1);
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
const METRIC_TYPE_REGISTRY = {
|
|
95
|
+
// Exceptions that patterns can't infer correctly
|
|
96
|
+
timeToFirstToken: "duration",
|
|
97
|
+
totalSegments: "number",
|
|
98
|
+
totalSamples: "number",
|
|
99
|
+
};
|
|
100
|
+
function inferMetricTypeFromPattern(lowerName) {
|
|
96
101
|
if (lowerName.includes("bps") || lowerName.includes("speed")) {
|
|
97
102
|
return "throughput";
|
|
98
103
|
}
|
|
@@ -104,22 +109,22 @@ function detectMetricType(metricName) {
|
|
|
104
109
|
lowerName.endsWith("duration") ||
|
|
105
110
|
lowerName.includes("ttfb") ||
|
|
106
111
|
lowerName.includes("latency") ||
|
|
107
|
-
lowerName.includes("wait") ||
|
|
108
112
|
lowerName.includes("overhead") ||
|
|
109
|
-
lowerName.includes("
|
|
110
|
-
lowerName.includes("stringify") ||
|
|
111
|
-
lowerName.includes("validation") ||
|
|
112
|
-
lowerName.includes("execution") ||
|
|
113
|
-
lowerName.includes("serialization") ||
|
|
114
|
-
lowerName.includes("connection")) {
|
|
113
|
+
lowerName.includes("execution")) {
|
|
115
114
|
return "duration";
|
|
116
115
|
}
|
|
117
|
-
if (lowerName.includes("count") || lowerName.includes("
|
|
116
|
+
if (lowerName.includes("count") || lowerName.includes("tokens") || lowerName.includes("factor")) {
|
|
118
117
|
return "number";
|
|
119
118
|
}
|
|
120
119
|
// Default to duration for unknown metrics (most profiling is timing)
|
|
121
120
|
return "duration";
|
|
122
121
|
}
|
|
122
|
+
function detectMetricType(metricName) {
|
|
123
|
+
if (METRIC_TYPE_REGISTRY[metricName]) {
|
|
124
|
+
return METRIC_TYPE_REGISTRY[metricName];
|
|
125
|
+
}
|
|
126
|
+
return inferMetricTypeFromPattern(metricName.toLowerCase());
|
|
127
|
+
}
|
|
123
128
|
function formatMetricValue(value, metricName) {
|
|
124
129
|
const type = detectMetricType(metricName);
|
|
125
130
|
switch (type) {
|
|
@@ -146,7 +151,7 @@ export function exportTable() {
|
|
|
146
151
|
if (entries.length === 0) {
|
|
147
152
|
return "No profiling data recorded.";
|
|
148
153
|
}
|
|
149
|
-
const metricWidth =
|
|
154
|
+
const metricWidth = 48;
|
|
150
155
|
const numWidth = 12;
|
|
151
156
|
const header = [
|
|
152
157
|
pad("Metric", metricWidth),
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for propagating model execution timing via internal symbols.
|
|
3
|
+
*/
|
|
4
|
+
export declare function hasDefinedValues<T extends Record<string, unknown>>(obj: T): boolean;
|
|
5
|
+
export declare function attachModelExecutionMs<T>(target: T, ms: number | undefined): T;
|
|
6
|
+
export declare function readModelExecutionMs(target: unknown): number | undefined;
|
|
7
|
+
export declare function forwardModelExecution<T>(target: T, source: unknown): T;
|
|
8
|
+
export interface StreamResult<S = unknown> {
|
|
9
|
+
modelExecutionMs: number;
|
|
10
|
+
stats?: S;
|
|
11
|
+
}
|
|
12
|
+
export declare function buildStreamResult<S extends Record<string, unknown>>(modelExecutionMs: number, stats?: S): StreamResult<S>;
|
|
13
|
+
export declare function buildUnaryResult<T extends Record<string, unknown>, S extends Record<string, unknown>>(response: T, modelExecutionMs: number, stats?: S): T & {
|
|
14
|
+
stats?: S;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=model-execution.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for propagating model execution timing via internal symbols.
|
|
3
|
+
*/
|
|
4
|
+
import { MODEL_EXECUTION_KEY } from "../schemas/index.js";
|
|
5
|
+
export function hasDefinedValues(obj) {
|
|
6
|
+
return Object.values(obj).some((v) => v !== undefined);
|
|
7
|
+
}
|
|
8
|
+
export function attachModelExecutionMs(target, ms) {
|
|
9
|
+
if (ms !== undefined) {
|
|
10
|
+
target[MODEL_EXECUTION_KEY] = ms;
|
|
11
|
+
}
|
|
12
|
+
return target;
|
|
13
|
+
}
|
|
14
|
+
export function readModelExecutionMs(target) {
|
|
15
|
+
return target?.[MODEL_EXECUTION_KEY];
|
|
16
|
+
}
|
|
17
|
+
export function forwardModelExecution(target, source) {
|
|
18
|
+
return attachModelExecutionMs(target, readModelExecutionMs(source));
|
|
19
|
+
}
|
|
20
|
+
export function buildStreamResult(modelExecutionMs, stats) {
|
|
21
|
+
const result = { modelExecutionMs };
|
|
22
|
+
if (stats && hasDefinedValues(stats)) {
|
|
23
|
+
result.stats = stats;
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
export function buildUnaryResult(response, modelExecutionMs, stats) {
|
|
28
|
+
const result = { ...response };
|
|
29
|
+
if (stats && hasDefinedValues(stats)) {
|
|
30
|
+
result.stats = stats;
|
|
31
|
+
}
|
|
32
|
+
return attachModelExecutionMs(result, modelExecutionMs);
|
|
33
|
+
}
|