observa-sdk 0.0.15 → 0.0.16
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 +18 -2
- package/dist/index.js +18 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -549,10 +549,26 @@ function wrapReadableStream(stream, onComplete, onError) {
|
|
|
549
549
|
while (true) {
|
|
550
550
|
const { done, value } = await reader.read();
|
|
551
551
|
if (done) break;
|
|
552
|
-
if (firstTokenTime === null && value) {
|
|
552
|
+
if (firstTokenTime === null && value !== null && value !== void 0) {
|
|
553
553
|
firstTokenTime = Date.now();
|
|
554
554
|
}
|
|
555
|
-
|
|
555
|
+
let text;
|
|
556
|
+
if (typeof value === "string") {
|
|
557
|
+
text = value;
|
|
558
|
+
} else if (value !== null && value !== void 0) {
|
|
559
|
+
try {
|
|
560
|
+
const testValue = value;
|
|
561
|
+
if (testValue instanceof Uint8Array || typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && ArrayBuffer.isView(testValue)) {
|
|
562
|
+
text = decoder.decode(testValue, { stream: true });
|
|
563
|
+
} else {
|
|
564
|
+
text = String(value);
|
|
565
|
+
}
|
|
566
|
+
} catch {
|
|
567
|
+
text = String(value);
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
556
572
|
chunks.push(text);
|
|
557
573
|
}
|
|
558
574
|
const fullText = chunks.join("");
|
package/dist/index.js
CHANGED
|
@@ -529,10 +529,26 @@ function wrapReadableStream(stream, onComplete, onError) {
|
|
|
529
529
|
while (true) {
|
|
530
530
|
const { done, value } = await reader.read();
|
|
531
531
|
if (done) break;
|
|
532
|
-
if (firstTokenTime === null && value) {
|
|
532
|
+
if (firstTokenTime === null && value !== null && value !== void 0) {
|
|
533
533
|
firstTokenTime = Date.now();
|
|
534
534
|
}
|
|
535
|
-
|
|
535
|
+
let text;
|
|
536
|
+
if (typeof value === "string") {
|
|
537
|
+
text = value;
|
|
538
|
+
} else if (value !== null && value !== void 0) {
|
|
539
|
+
try {
|
|
540
|
+
const testValue = value;
|
|
541
|
+
if (testValue instanceof Uint8Array || typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && ArrayBuffer.isView(testValue)) {
|
|
542
|
+
text = decoder.decode(testValue, { stream: true });
|
|
543
|
+
} else {
|
|
544
|
+
text = String(value);
|
|
545
|
+
}
|
|
546
|
+
} catch {
|
|
547
|
+
text = String(value);
|
|
548
|
+
}
|
|
549
|
+
} else {
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
536
552
|
chunks.push(text);
|
|
537
553
|
}
|
|
538
554
|
const fullText = chunks.join("");
|
package/package.json
CHANGED