@meistrari/tela-sdk-js 2.6.0 → 2.6.2
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/dist/index.cjs +15 -13
- package/dist/index.mjs +15 -13
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ const changeCase__namespace = /*#__PURE__*/_interopNamespaceCompat(changeCase);
|
|
|
23
23
|
const z__default = /*#__PURE__*/_interopDefaultCompat(z);
|
|
24
24
|
const Emittery__default = /*#__PURE__*/_interopDefaultCompat(Emittery);
|
|
25
25
|
|
|
26
|
-
const version = "2.6.
|
|
26
|
+
const version = "2.6.2";
|
|
27
27
|
|
|
28
28
|
var __defProp$a = Object.defineProperty;
|
|
29
29
|
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -2496,6 +2496,18 @@ const BatchResultItem = z__default.looseObject({
|
|
|
2496
2496
|
}),
|
|
2497
2497
|
error: z__default.null()
|
|
2498
2498
|
});
|
|
2499
|
+
function extractBatchResultItemContent(batchId, result) {
|
|
2500
|
+
const parsedResult = BatchResultItem.safeParse(result);
|
|
2501
|
+
if (!parsedResult.success) {
|
|
2502
|
+
console.warn(`[Tela SDK - WARNING] Invalid result from the batch API for batch ${batchId}: ${z__default.prettifyError(parsedResult.error)}`);
|
|
2503
|
+
const content = result?.result?.outputContent?.content;
|
|
2504
|
+
if (content !== void 0 && content !== null) {
|
|
2505
|
+
return content;
|
|
2506
|
+
}
|
|
2507
|
+
throw new Error(`Cannot parse result from the batch API for batch ${batchId}`, { cause: parsedResult.error });
|
|
2508
|
+
}
|
|
2509
|
+
return parsedResult.data.result.outputContent.content;
|
|
2510
|
+
}
|
|
2499
2511
|
class BatchExecutionResult {
|
|
2500
2512
|
/**
|
|
2501
2513
|
* Creates a new batch execution result wrapper.
|
|
@@ -2650,13 +2662,7 @@ class BatchExecutionResult {
|
|
|
2650
2662
|
async getResults() {
|
|
2651
2663
|
const resultFile = await this.downloadOutputFile();
|
|
2652
2664
|
const results = await resultFile.text();
|
|
2653
|
-
return results.split("\n").filter((line) => line.trim().length > 0).map((result) => JSON.parse(result)).map((result) =>
|
|
2654
|
-
const parsedResult = BatchResultItem.safeParse(result);
|
|
2655
|
-
if (!parsedResult.success) {
|
|
2656
|
-
throw new Error("Invalid result from the batch API", { cause: parsedResult.error });
|
|
2657
|
-
}
|
|
2658
|
-
return parsedResult.data.result.outputContent.content;
|
|
2659
|
-
});
|
|
2665
|
+
return results.split("\n").filter((line) => line.trim().length > 0).map((result) => JSON.parse(result)).map((result) => extractBatchResultItemContent(this.id, result));
|
|
2660
2666
|
}
|
|
2661
2667
|
/**
|
|
2662
2668
|
* Asynchronously iterates over raw result items from the output file.
|
|
@@ -2710,11 +2716,7 @@ class BatchExecutionResult {
|
|
|
2710
2716
|
*/
|
|
2711
2717
|
async *iterateResults(params = {}) {
|
|
2712
2718
|
for await (const result of this.iterateRawResults(params)) {
|
|
2713
|
-
|
|
2714
|
-
if (!parsedResult.success) {
|
|
2715
|
-
throw new Error("Invalid result from the batch API", { cause: parsedResult.error });
|
|
2716
|
-
}
|
|
2717
|
-
yield parsedResult.data.result.outputContent.content;
|
|
2719
|
+
yield extractBatchResultItemContent(this.id, result);
|
|
2718
2720
|
}
|
|
2719
2721
|
}
|
|
2720
2722
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { minimatch } from 'minimatch';
|
|
|
3
3
|
import z, { z as z$1, ZodError } from 'zod';
|
|
4
4
|
import Emittery from 'emittery';
|
|
5
5
|
|
|
6
|
-
const version = "2.6.
|
|
6
|
+
const version = "2.6.2";
|
|
7
7
|
|
|
8
8
|
var __defProp$a = Object.defineProperty;
|
|
9
9
|
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -2476,6 +2476,18 @@ const BatchResultItem = z.looseObject({
|
|
|
2476
2476
|
}),
|
|
2477
2477
|
error: z.null()
|
|
2478
2478
|
});
|
|
2479
|
+
function extractBatchResultItemContent(batchId, result) {
|
|
2480
|
+
const parsedResult = BatchResultItem.safeParse(result);
|
|
2481
|
+
if (!parsedResult.success) {
|
|
2482
|
+
console.warn(`[Tela SDK - WARNING] Invalid result from the batch API for batch ${batchId}: ${z.prettifyError(parsedResult.error)}`);
|
|
2483
|
+
const content = result?.result?.outputContent?.content;
|
|
2484
|
+
if (content !== void 0 && content !== null) {
|
|
2485
|
+
return content;
|
|
2486
|
+
}
|
|
2487
|
+
throw new Error(`Cannot parse result from the batch API for batch ${batchId}`, { cause: parsedResult.error });
|
|
2488
|
+
}
|
|
2489
|
+
return parsedResult.data.result.outputContent.content;
|
|
2490
|
+
}
|
|
2479
2491
|
class BatchExecutionResult {
|
|
2480
2492
|
/**
|
|
2481
2493
|
* Creates a new batch execution result wrapper.
|
|
@@ -2630,13 +2642,7 @@ class BatchExecutionResult {
|
|
|
2630
2642
|
async getResults() {
|
|
2631
2643
|
const resultFile = await this.downloadOutputFile();
|
|
2632
2644
|
const results = await resultFile.text();
|
|
2633
|
-
return results.split("\n").filter((line) => line.trim().length > 0).map((result) => JSON.parse(result)).map((result) =>
|
|
2634
|
-
const parsedResult = BatchResultItem.safeParse(result);
|
|
2635
|
-
if (!parsedResult.success) {
|
|
2636
|
-
throw new Error("Invalid result from the batch API", { cause: parsedResult.error });
|
|
2637
|
-
}
|
|
2638
|
-
return parsedResult.data.result.outputContent.content;
|
|
2639
|
-
});
|
|
2645
|
+
return results.split("\n").filter((line) => line.trim().length > 0).map((result) => JSON.parse(result)).map((result) => extractBatchResultItemContent(this.id, result));
|
|
2640
2646
|
}
|
|
2641
2647
|
/**
|
|
2642
2648
|
* Asynchronously iterates over raw result items from the output file.
|
|
@@ -2690,11 +2696,7 @@ class BatchExecutionResult {
|
|
|
2690
2696
|
*/
|
|
2691
2697
|
async *iterateResults(params = {}) {
|
|
2692
2698
|
for await (const result of this.iterateRawResults(params)) {
|
|
2693
|
-
|
|
2694
|
-
if (!parsedResult.success) {
|
|
2695
|
-
throw new Error("Invalid result from the batch API", { cause: parsedResult.error });
|
|
2696
|
-
}
|
|
2697
|
-
yield parsedResult.data.result.outputContent.content;
|
|
2699
|
+
yield extractBatchResultItemContent(this.id, result);
|
|
2698
2700
|
}
|
|
2699
2701
|
}
|
|
2700
2702
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/tela-sdk-js",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/meistrari/tela-sdk-js.git"
|
|
@@ -70,4 +70,4 @@
|
|
|
70
70
|
},
|
|
71
71
|
"type": "module",
|
|
72
72
|
"types": "dist/index.d.ts"
|
|
73
|
-
}
|
|
73
|
+
}
|