190proof 1.0.20 → 1.0.21
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.js +19 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31601,6 +31601,7 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31601
31601
|
});
|
|
31602
31602
|
}
|
|
31603
31603
|
if (response.body) {
|
|
31604
|
+
let rawStreamedBody = "";
|
|
31604
31605
|
let paragraph = "";
|
|
31605
31606
|
let functionCallName = "";
|
|
31606
31607
|
let functionCallArgs = "";
|
|
@@ -31635,6 +31636,7 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31635
31636
|
throw new Error("Stream error: ended prematurely");
|
|
31636
31637
|
}
|
|
31637
31638
|
let chunk = new TextDecoder().decode(value);
|
|
31639
|
+
rawStreamedBody += chunk + "\n";
|
|
31638
31640
|
if (partialChunk) {
|
|
31639
31641
|
chunk = partialChunk + chunk;
|
|
31640
31642
|
partialChunk = "";
|
|
@@ -31649,13 +31651,22 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31649
31651
|
identifier,
|
|
31650
31652
|
`Stream explicitly marked as done after ${chunkIndex + 1} chunks.`
|
|
31651
31653
|
);
|
|
31652
|
-
|
|
31653
|
-
|
|
31654
|
-
|
|
31655
|
-
|
|
31656
|
-
|
|
31657
|
-
|
|
31658
|
-
|
|
31654
|
+
try {
|
|
31655
|
+
return parseStreamedResponse(
|
|
31656
|
+
identifier,
|
|
31657
|
+
paragraph,
|
|
31658
|
+
functionCallName,
|
|
31659
|
+
functionCallArgs,
|
|
31660
|
+
functionNames
|
|
31661
|
+
);
|
|
31662
|
+
} catch (error) {
|
|
31663
|
+
console.error(
|
|
31664
|
+
identifier,
|
|
31665
|
+
"Stream error: parsing response:",
|
|
31666
|
+
rawStreamedBody
|
|
31667
|
+
);
|
|
31668
|
+
throw error;
|
|
31669
|
+
}
|
|
31659
31670
|
}
|
|
31660
31671
|
let json;
|
|
31661
31672
|
try {
|
|
@@ -31673,6 +31684,7 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31673
31684
|
);
|
|
31674
31685
|
const error = new Error("Stream error: OpenAI error");
|
|
31675
31686
|
error.data = json.error;
|
|
31687
|
+
error.requestBody = JSON.stringify(openAiPayload);
|
|
31676
31688
|
throw error;
|
|
31677
31689
|
}
|
|
31678
31690
|
if (chunkIndex !== 0)
|