@qvac/sdk 0.8.3 → 0.9.1

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.
Files changed (217) hide show
  1. package/NOTICE +267 -63
  2. package/README.md +1 -1
  3. package/dist/client/api/diffusion.d.ts +32 -0
  4. package/dist/client/api/diffusion.js +103 -0
  5. package/dist/client/api/embed.d.ts +9 -3
  6. package/dist/client/api/embed.js +4 -1
  7. package/dist/client/api/finetune.d.ts +69 -0
  8. package/dist/client/api/finetune.js +139 -0
  9. package/dist/client/api/get-model-info.d.ts +1 -1
  10. package/dist/client/api/index.d.ts +4 -0
  11. package/dist/client/api/index.js +4 -0
  12. package/dist/client/api/rag.d.ts +1 -1
  13. package/dist/client/api/rag.js +1 -1
  14. package/dist/client/api/resume.d.ts +14 -0
  15. package/dist/client/api/resume.js +20 -0
  16. package/dist/client/api/suspend.d.ts +13 -0
  17. package/dist/client/api/suspend.js +19 -0
  18. package/dist/client/api/transcribe.d.ts +25 -17
  19. package/dist/client/api/transcribe.js +115 -35
  20. package/dist/client/rpc/bare-client.d.ts +5 -1
  21. package/dist/client/rpc/bare-client.js +70 -57
  22. package/dist/client/rpc/expo-rpc-client.d.ts +4 -0
  23. package/dist/client/rpc/expo-rpc-client.js +8 -0
  24. package/dist/client/rpc/node-rpc-client.d.ts +4 -0
  25. package/dist/client/rpc/node-rpc-client.js +8 -0
  26. package/dist/client/rpc/rpc-client.d.ts +13 -0
  27. package/dist/client/rpc/rpc-client.js +131 -1
  28. package/dist/examples/delegated-inference/composite.d.ts +2 -0
  29. package/dist/examples/delegated-inference/composite.js +99 -0
  30. package/dist/examples/diffusion-flux2-klein.d.ts +2 -0
  31. package/dist/examples/diffusion-flux2-klein.js +46 -0
  32. package/dist/examples/diffusion-simple.d.ts +2 -0
  33. package/dist/examples/diffusion-simple.js +17 -0
  34. package/dist/examples/diffusion-txt2img.d.ts +2 -0
  35. package/dist/examples/diffusion-txt2img.js +40 -0
  36. package/dist/examples/embed-p2p.js +2 -2
  37. package/dist/examples/finetune/llamacpp-finetune.d.ts +2 -0
  38. package/dist/examples/finetune/llamacpp-finetune.js +78 -0
  39. package/dist/examples/logging-streaming.js +1 -1
  40. package/dist/examples/mcp-websearch.js +2 -0
  41. package/dist/examples/ocr-fasttext.js +11 -0
  42. package/dist/examples/profiling/per-call.js +3 -3
  43. package/dist/examples/rag/rag-chromadb.js +2 -2
  44. package/dist/examples/rag/rag-hyperdb/pipeline.js +1 -1
  45. package/dist/examples/rag/rag-lancedb.js +2 -2
  46. package/dist/examples/rag/rag-sqlite.js +2 -2
  47. package/dist/examples/suspend-resume.d.ts +2 -0
  48. package/dist/examples/suspend-resume.js +52 -0
  49. package/dist/examples/transcription/parakeet-ctc-filesystem.js +3 -5
  50. package/dist/examples/transcription/parakeet-microphone-record.js +42 -33
  51. package/dist/examples/transcription/parakeet-sortformer.js +13 -3
  52. package/dist/examples/transcription/parakeet-tdt-filesystem.js +5 -7
  53. package/dist/examples/transcription/whispercpp-filesystem-streaming.d.ts +2 -0
  54. package/dist/examples/transcription/whispercpp-filesystem-streaming.js +99 -0
  55. package/dist/examples/transcription/whispercpp-microphone-record.js +78 -299
  56. package/dist/examples/transcription/whispercpp-prompt.js +11 -0
  57. package/dist/examples/translation/translation-llm.js +2 -2
  58. package/dist/examples/tts/supertonic-multilingual.d.ts +2 -0
  59. package/dist/examples/tts/supertonic-multilingual.js +56 -0
  60. package/dist/examples/tts/supertonic.js +12 -7
  61. package/dist/index.d.ts +3 -2
  62. package/dist/index.js +3 -2
  63. package/dist/logging/utils.js +1 -1
  64. package/dist/models/registry/models.d.ts +15176 -4264
  65. package/dist/models/registry/models.js +18657 -7404
  66. package/dist/models/update-models/codegen.js +2 -2
  67. package/dist/models/update-models/naming.js +26 -0
  68. package/dist/pear/pre.js +2 -0
  69. package/dist/polyfills/bare-globals.d.ts +2 -0
  70. package/dist/polyfills/bare-globals.js +4 -0
  71. package/dist/polyfills/bare-globals.noop.d.ts +2 -0
  72. package/dist/polyfills/bare-globals.noop.js +1 -0
  73. package/dist/profiling/exporters.js +16 -11
  74. package/dist/profiling/model-execution.d.ts +16 -0
  75. package/dist/profiling/model-execution.js +33 -0
  76. package/dist/schemas/common.d.ts +967 -198
  77. package/dist/schemas/common.js +16 -1
  78. package/dist/schemas/completion-stream.d.ts +14 -6
  79. package/dist/schemas/completion-stream.js +4 -3
  80. package/dist/schemas/download-asset.d.ts +7 -3
  81. package/dist/schemas/embed.d.ts +19 -0
  82. package/dist/schemas/embed.js +7 -0
  83. package/dist/schemas/engine-addon-map.js +4 -1
  84. package/dist/schemas/finetune.d.ts +620 -0
  85. package/dist/schemas/finetune.js +161 -0
  86. package/dist/schemas/get-model-info.d.ts +2 -0
  87. package/dist/schemas/get-model-info.js +1 -0
  88. package/dist/schemas/index.d.ts +5 -1
  89. package/dist/schemas/index.js +5 -1
  90. package/dist/schemas/llamacpp-config.d.ts +26 -6
  91. package/dist/schemas/llamacpp-config.js +12 -0
  92. package/dist/schemas/load-model.d.ts +4005 -1400
  93. package/dist/schemas/load-model.js +34 -1
  94. package/dist/schemas/model-src-utils.d.ts +10 -2
  95. package/dist/schemas/model-types.d.ts +19 -1
  96. package/dist/schemas/model-types.js +11 -0
  97. package/dist/schemas/ocr.d.ts +2 -0
  98. package/dist/schemas/plugin.d.ts +24 -3
  99. package/dist/schemas/plugin.js +14 -0
  100. package/dist/schemas/profiling.d.ts +4 -0
  101. package/dist/schemas/profiling.js +4 -0
  102. package/dist/schemas/registry.d.ts +18 -0
  103. package/dist/schemas/registry.js +2 -0
  104. package/dist/schemas/reload-config.d.ts +9 -1
  105. package/dist/schemas/resume.d.ts +10 -0
  106. package/dist/schemas/resume.js +7 -0
  107. package/dist/schemas/sdcpp-config.d.ts +327 -0
  108. package/dist/schemas/sdcpp-config.js +102 -0
  109. package/dist/schemas/sdk-config.d.ts +1225 -235
  110. package/dist/schemas/sdk-config.js +4 -0
  111. package/dist/schemas/sdk-errors-server.d.ts +2 -0
  112. package/dist/schemas/sdk-errors-server.js +12 -0
  113. package/dist/schemas/suspend.d.ts +10 -0
  114. package/dist/schemas/suspend.js +7 -0
  115. package/dist/schemas/text-to-speech.d.ts +187 -10
  116. package/dist/schemas/text-to-speech.js +12 -4
  117. package/dist/schemas/transcription-config.d.ts +16 -56
  118. package/dist/schemas/transcription-config.js +0 -2
  119. package/dist/schemas/transcription.d.ts +66 -6
  120. package/dist/schemas/transcription.js +29 -7
  121. package/dist/schemas/translate.d.ts +14 -4
  122. package/dist/schemas/translate.js +10 -2
  123. package/dist/schemas/translation-config.d.ts +30 -10
  124. package/dist/server/bare/delegate-rpc-client.js +3 -3
  125. package/dist/server/bare/hyperswarm.js +15 -3
  126. package/dist/server/bare/ops/embed.d.ts +8 -4
  127. package/dist/server/bare/ops/embed.js +15 -4
  128. package/dist/server/bare/ops/transcribe.d.ts +6 -2
  129. package/dist/server/bare/ops/transcribe.js +53 -1
  130. package/dist/server/bare/ops/translate.d.ts +4 -1
  131. package/dist/server/bare/ops/translate.js +28 -65
  132. package/dist/server/bare/ops/unload-model.js +2 -0
  133. package/dist/server/bare/plugins/index.d.ts +1 -0
  134. package/dist/server/bare/plugins/index.js +1 -0
  135. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +3 -1
  136. package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +45 -9
  137. package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.d.ts +11 -0
  138. package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +112 -0
  139. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +175 -5
  140. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +45 -35
  141. package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +11 -1
  142. package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +9 -4
  143. package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +17 -2
  144. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +16 -15
  145. package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.d.ts +5 -7
  146. package/dist/server/bare/plugins/onnx-ocr/ops/ocr-stream.js +11 -3
  147. package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +2 -0
  148. package/dist/server/bare/plugins/onnx-ocr/plugin.js +24 -19
  149. package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.d.ts +7 -2
  150. package/dist/server/bare/plugins/onnx-tts/ops/text-to-speech.js +22 -97
  151. package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +98 -9
  152. package/dist/server/bare/plugins/onnx-tts/plugin.js +85 -46
  153. package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +30 -60
  154. package/dist/server/bare/plugins/parakeet-transcription/plugin.js +49 -37
  155. package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.d.ts +3 -0
  156. package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +51 -0
  157. package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +278 -0
  158. package/dist/server/bare/plugins/sdcpp-generation/plugin.js +70 -0
  159. package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +38 -2
  160. package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +43 -22
  161. package/dist/server/bare/rag-hyperdb/handlers/ingest.js +2 -1
  162. package/dist/server/bare/rag-hyperdb/handlers/search.js +2 -1
  163. package/dist/server/bare/rag-hyperdb/rag-workspace-manager.js +7 -0
  164. package/dist/server/bare/registry/model-config-utils.js +3 -0
  165. package/dist/server/bare/registry/model-registry.d.ts +2 -2
  166. package/dist/server/bare/registry/model-registry.js +1 -1
  167. package/dist/server/bare/registry/registry-client.js +21 -0
  168. package/dist/server/bare/runtime-lifecycle.d.ts +28 -0
  169. package/dist/server/bare/runtime-lifecycle.js +132 -0
  170. package/dist/server/bare/types/addon-responses.d.ts +62 -0
  171. package/dist/server/bare/types/addon-responses.js +1 -0
  172. package/dist/server/env.js +3 -1
  173. package/dist/server/rpc/delegate-transport.js +1 -1
  174. package/dist/server/rpc/handle-request.js +50 -4
  175. package/dist/server/rpc/handler-registry.js +20 -1
  176. package/dist/server/rpc/handler-utils.d.ts +5 -3
  177. package/dist/server/rpc/handler-utils.js +52 -50
  178. package/dist/server/rpc/handlers/delete-cache.js +3 -0
  179. package/dist/server/rpc/handlers/diffusion-stream.d.ts +3 -0
  180. package/dist/server/rpc/handlers/diffusion-stream.js +4 -0
  181. package/dist/server/rpc/handlers/finetune.d.ts +3 -0
  182. package/dist/server/rpc/handlers/finetune.js +16 -0
  183. package/dist/server/rpc/handlers/index.d.ts +10 -0
  184. package/dist/server/rpc/handlers/index.js +10 -0
  185. package/dist/server/rpc/handlers/load-model/hyperdrive.js +24 -9
  186. package/dist/server/rpc/handlers/load-model/registry.d.ts +11 -0
  187. package/dist/server/rpc/handlers/load-model/registry.js +31 -4
  188. package/dist/server/rpc/handlers/plugin-dispatch.d.ts +1 -13
  189. package/dist/server/rpc/handlers/plugin-dispatch.js +21 -21
  190. package/dist/server/rpc/handlers/resume.d.ts +3 -0
  191. package/dist/server/rpc/handlers/resume.js +11 -0
  192. package/dist/server/rpc/handlers/suspend.d.ts +3 -0
  193. package/dist/server/rpc/handlers/suspend.js +11 -0
  194. package/dist/server/rpc/handlers/transcribe-stream.d.ts +1 -1
  195. package/dist/server/rpc/handlers/transcribe-stream.js +2 -2
  196. package/dist/server/rpc/handlers/transcribe.d.ts +3 -0
  197. package/dist/server/rpc/handlers/transcribe.js +4 -0
  198. package/dist/server/rpc/profiling/operation-metrics.js +107 -16
  199. package/dist/server/rpc/profiling/operation-wrappers.d.ts +1 -1
  200. package/dist/server/rpc/profiling/operation-wrappers.js +51 -19
  201. package/dist/server/rpc/progress-throttle.d.ts +8 -0
  202. package/dist/server/rpc/progress-throttle.js +47 -0
  203. package/dist/server/rpc/rpc-utils.d.ts +5 -0
  204. package/dist/server/rpc/rpc-utils.js +11 -0
  205. package/dist/server/utils/path-security.js +1 -1
  206. package/dist/server/utils/tool-integration.js +10 -0
  207. package/dist/server/utils/tool-parser.js +9 -5
  208. package/dist/server/worker-core.d.ts +2 -0
  209. package/dist/server/worker-core.js +26 -23
  210. package/dist/server/worker.js +2 -1
  211. package/dist/utils/encoding.d.ts +9 -0
  212. package/dist/utils/encoding.js +14 -0
  213. package/dist/utils/errors-server.d.ts +6 -0
  214. package/dist/utils/errors-server.js +11 -0
  215. package/package.json +36 -25
  216. package/dist/server/rpc/delegate-utils.d.ts +0 -2
  217. 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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bare-globals.d.ts.map
@@ -0,0 +1,4 @@
1
+ import process from "bare-process";
2
+ if (typeof globalThis.process === "undefined") {
3
+ globalThis.process = process;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bare-globals.noop.d.ts.map
@@ -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
- function detectMetricType(metricName) {
95
- const lowerName = metricName.toLowerCase();
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("parse") ||
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("token")) {
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 = 40;
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
+ }