tempest-react-sdk 0.33.2 → 0.35.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.
Files changed (87) hide show
  1. package/README.md +5 -3
  2. package/dist/components/AIChat/AIChat.cjs +2 -0
  3. package/dist/components/AIChat/AIChat.cjs.map +1 -0
  4. package/dist/components/AIChat/AIChat.js +141 -0
  5. package/dist/components/AIChat/AIChat.js.map +1 -0
  6. package/dist/components/AIChat/AIChat.module.cjs +2 -0
  7. package/dist/components/AIChat/AIChat.module.cjs.map +1 -0
  8. package/dist/components/AIChat/AIChat.module.js +58 -0
  9. package/dist/components/AIChat/AIChat.module.js.map +1 -0
  10. package/dist/components/AIChat/AIChatComposer.cjs +2 -0
  11. package/dist/components/AIChat/AIChatComposer.cjs.map +1 -0
  12. package/dist/components/AIChat/AIChatComposer.js +87 -0
  13. package/dist/components/AIChat/AIChatComposer.js.map +1 -0
  14. package/dist/components/AIChat/AIChatTurn.cjs +3 -0
  15. package/dist/components/AIChat/AIChatTurn.cjs.map +1 -0
  16. package/dist/components/AIChat/AIChatTurn.js +217 -0
  17. package/dist/components/AIChat/AIChatTurn.js.map +1 -0
  18. package/dist/components/AIChat/ai-chat-turns.cjs +2 -0
  19. package/dist/components/AIChat/ai-chat-turns.cjs.map +1 -0
  20. package/dist/components/AIChat/ai-chat-turns.js +90 -0
  21. package/dist/components/AIChat/ai-chat-turns.js.map +1 -0
  22. package/dist/perf/cache-size.cjs +2 -0
  23. package/dist/perf/cache-size.cjs.map +1 -0
  24. package/dist/perf/cache-size.js +16 -0
  25. package/dist/perf/cache-size.js.map +1 -0
  26. package/dist/perf/device.cjs +2 -0
  27. package/dist/perf/device.cjs.map +1 -0
  28. package/dist/perf/device.js +22 -0
  29. package/dist/perf/device.js.map +1 -0
  30. package/dist/perf/format.cjs +2 -0
  31. package/dist/perf/format.cjs.map +1 -0
  32. package/dist/perf/format.js +8 -0
  33. package/dist/perf/format.js.map +1 -0
  34. package/dist/perf/profiler.cjs +2 -0
  35. package/dist/perf/profiler.cjs.map +1 -0
  36. package/dist/perf/profiler.js +46 -0
  37. package/dist/perf/profiler.js.map +1 -0
  38. package/dist/styles.css +1 -1
  39. package/dist/tempest-react-sdk.cjs +1 -1
  40. package/dist/tempest-react-sdk.d.ts +626 -9
  41. package/dist/tempest-react-sdk.js +122 -114
  42. package/dist/vision/core/timing.cjs +2 -0
  43. package/dist/vision/core/timing.cjs.map +1 -0
  44. package/dist/vision/core/timing.js +24 -0
  45. package/dist/vision/core/timing.js.map +1 -0
  46. package/dist/vision/index.cjs +1 -1
  47. package/dist/vision/index.cjs.map +1 -1
  48. package/dist/vision/index.js +16 -15
  49. package/dist/vision/index.js.map +1 -1
  50. package/dist/vision/postprocess/detection.cjs +1 -1
  51. package/dist/vision/postprocess/detection.cjs.map +1 -1
  52. package/dist/vision/postprocess/detection.js +2 -2
  53. package/dist/vision/postprocess/detection.js.map +1 -1
  54. package/dist/vision/postprocess/segmentation.cjs +1 -1
  55. package/dist/vision/postprocess/segmentation.cjs.map +1 -1
  56. package/dist/vision/postprocess/segmentation.js +1 -1
  57. package/dist/vision/postprocess/segmentation.js.map +1 -1
  58. package/dist/vision/results.cjs +1 -1
  59. package/dist/vision/results.cjs.map +1 -1
  60. package/dist/vision/results.js +18 -13
  61. package/dist/vision/results.js.map +1 -1
  62. package/dist/vision/tasks/classifier.cjs +1 -1
  63. package/dist/vision/tasks/classifier.cjs.map +1 -1
  64. package/dist/vision/tasks/classifier.js +46 -39
  65. package/dist/vision/tasks/classifier.js.map +1 -1
  66. package/dist/vision/tasks/detector.cjs +1 -1
  67. package/dist/vision/tasks/detector.cjs.map +1 -1
  68. package/dist/vision/tasks/detector.js +40 -33
  69. package/dist/vision/tasks/detector.js.map +1 -1
  70. package/dist/vision/tasks/segmenter.cjs +1 -1
  71. package/dist/vision/tasks/segmenter.cjs.map +1 -1
  72. package/dist/vision/tasks/segmenter.js +35 -28
  73. package/dist/vision/tasks/segmenter.js.map +1 -1
  74. package/dist/vision.cjs +1 -1
  75. package/dist/vision.d.ts +68 -10
  76. package/dist/vision.js +19 -18
  77. package/dist/ws/create-web-socket.cjs +1 -1
  78. package/dist/ws/create-web-socket.cjs.map +1 -1
  79. package/dist/ws/create-web-socket.js +54 -37
  80. package/dist/ws/create-web-socket.js.map +1 -1
  81. package/dist/ws/use-web-socket.cjs +1 -1
  82. package/dist/ws/use-web-socket.cjs.map +1 -1
  83. package/dist/ws/use-web-socket.js +49 -18
  84. package/dist/ws/use-web-socket.js.map +1 -1
  85. package/package.json +1 -1
  86. package/template/src/lib/api.ts +27 -5
  87. package/template/src/stores/auth.ts +14 -0
@@ -0,0 +1,46 @@
1
+ import { cachedResponseBytes as e } from "./cache-size.js";
2
+ import { readDeviceProfile as t } from "./device.js";
3
+ //#region src/perf/profiler.ts
4
+ function n() {
5
+ let n = performance.now(), r = /* @__PURE__ */ new Map(), i = (e, t) => {
6
+ r.set(e, (r.get(e) ?? 0) + t);
7
+ };
8
+ return {
9
+ async stage(e, t) {
10
+ let n = performance.now();
11
+ try {
12
+ return await t();
13
+ } finally {
14
+ i(e, performance.now() - n);
15
+ }
16
+ },
17
+ stageSync(e, t) {
18
+ let n = performance.now();
19
+ try {
20
+ return t();
21
+ } finally {
22
+ i(e, performance.now() - n);
23
+ }
24
+ },
25
+ mark(e, t) {
26
+ i(e, t);
27
+ },
28
+ async report(i = {}) {
29
+ let a = performance.now() - n, o = await Promise.all((i.models ?? []).map(async (t) => ({
30
+ name: t.name,
31
+ bytes: await e(t.cacheName, t.url)
32
+ })));
33
+ return {
34
+ timings: Object.fromEntries(r),
35
+ totalMs: a,
36
+ device: t(),
37
+ models: o,
38
+ measuredAt: Date.now()
39
+ };
40
+ }
41
+ };
42
+ }
43
+ //#endregion
44
+ export { n as createInferenceProfiler };
45
+
46
+ //# sourceMappingURL=profiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiler.js","names":[],"sources":["../../src/perf/profiler.ts"],"sourcesContent":["import { cachedResponseBytes } from \"./cache-size\";\nimport { readDeviceProfile } from \"./device\";\nimport type {\n InferenceProfiler,\n InferenceReport,\n InferenceReportOptions,\n ProfiledModelSize,\n} from \"./types\";\n\n/**\n * Timing and cost accounting for a pipeline that runs on the user's device.\n */\n\n/**\n * Create a profiler for one run of a pipeline.\n *\n * Wrap each step in {@link InferenceProfiler.stage}, fold in durations you\n * already have (an SDK `speed` breakdown, say) with\n * {@link InferenceProfiler.mark}, then call `report()` once the run finishes.\n *\n * Stages are timed independently rather than as a tiling of the run, so\n * concurrent work is charged its real wall-clock span to each stage and the\n * timings can sum to more than `totalMs`. Surface that to users when you\n * render the breakdown — a bar chart implying a partition of the total would\n * be wrong for a pipeline that overlaps stages.\n *\n * @returns A profiler bound to the moment it was created.\n *\n * @example\n * ```typescript\n * import { createInferenceProfiler } from \"tempest-react-sdk\";\n * import { Detector } from \"tempest-react-sdk/vision\";\n *\n * const profiler = createInferenceProfiler();\n * const detector = await profiler.stage(\"load-model\", () =>\n * Detector.create(\"/models/detect.onnx\"),\n * );\n * const results = await profiler.stage(\"detect\", () => detector.predict(blob));\n * profiler.mark(\"forward-pass\", results[0].speed.inference);\n *\n * const report = await profiler.report({\n * models: [\n * { name: \"detector\", cacheName: \"app-models\", url: \"/models/detect.onnx\" },\n * ],\n * });\n * console.log(report.timings, report.totalMs, report.device, report.models);\n * ```\n */\nexport function createInferenceProfiler(): InferenceProfiler {\n const startedAt = performance.now();\n const timings = new Map<string, number>();\n\n const add = (name: string, durationMs: number): void => {\n timings.set(name, (timings.get(name) ?? 0) + durationMs);\n };\n\n return {\n async stage<T>(name: string, run: () => Promise<T>): Promise<T> {\n const from = performance.now();\n try {\n return await run();\n } finally {\n add(name, performance.now() - from);\n }\n },\n\n stageSync<T>(name: string, run: () => T): T {\n const from = performance.now();\n try {\n return run();\n } finally {\n add(name, performance.now() - from);\n }\n },\n\n mark(name: string, durationMs: number): void {\n add(name, durationMs);\n },\n\n async report(options: InferenceReportOptions = {}): Promise<InferenceReport> {\n const totalMs = performance.now() - startedAt;\n const models: ProfiledModelSize[] = await Promise.all(\n (options.models ?? []).map(async (model) => ({\n name: model.name,\n bytes: await cachedResponseBytes(model.cacheName, model.url),\n })),\n );\n\n return {\n timings: Object.fromEntries(timings),\n totalMs,\n device: readDeviceProfile(),\n models,\n measuredAt: Date.now(),\n };\n },\n };\n}\n"],"mappings":";;;AAgDA,SAAgB,IAA6C;CACzD,IAAM,IAAY,YAAY,IAAI,GAC5B,oBAAU,IAAI,IAAoB,GAElC,KAAO,GAAc,MAA6B;EACpD,EAAQ,IAAI,IAAO,EAAQ,IAAI,CAAI,KAAK,KAAK,CAAU;CAC3D;CAEA,OAAO;EACH,MAAM,MAAS,GAAc,GAAmC;GAC5D,IAAM,IAAO,YAAY,IAAI;GAC7B,IAAI;IACA,OAAO,MAAM,EAAI;GACrB,UAAU;IACN,EAAI,GAAM,YAAY,IAAI,IAAI,CAAI;GACtC;EACJ;EAEA,UAAa,GAAc,GAAiB;GACxC,IAAM,IAAO,YAAY,IAAI;GAC7B,IAAI;IACA,OAAO,EAAI;GACf,UAAU;IACN,EAAI,GAAM,YAAY,IAAI,IAAI,CAAI;GACtC;EACJ;EAEA,KAAK,GAAc,GAA0B;GACzC,EAAI,GAAM,CAAU;EACxB;EAEA,MAAM,OAAO,IAAkC,CAAC,GAA6B;GACzE,IAAM,IAAU,YAAY,IAAI,IAAI,GAC9B,IAA8B,MAAM,QAAQ,KAC7C,EAAQ,UAAU,CAAC,EAAA,CAAG,IAAI,OAAO,OAAW;IACzC,MAAM,EAAM;IACZ,OAAO,MAAM,EAAoB,EAAM,WAAW,EAAM,GAAG;GAC/D,EAAE,CACN;GAEA,OAAO;IACH,SAAS,OAAO,YAAY,CAAO;IACnC;IACA,QAAQ,EAAkB;IAC1B;IACA,YAAY,KAAK,IAAI;GACzB;EACJ;CACJ;AACJ"}