190proof 1.0.19 → 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 +25 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31487,7 +31487,12 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
|
|
|
31487
31487
|
);
|
|
31488
31488
|
return res;
|
|
31489
31489
|
} catch (error) {
|
|
31490
|
-
|
|
31490
|
+
console.error(error);
|
|
31491
|
+
console.error(
|
|
31492
|
+
identifier,
|
|
31493
|
+
`Retrying due to error: received bad response from OpenAI API [${openAiConfig == null ? void 0 : openAiConfig.service}-${openAiPayload.model}-${openAiConfig == null ? void 0 : openAiConfig.orgId}]: ${error.message} - ${JSON.stringify((_a3 = error.response) == null ? void 0 : _a3.data)}`
|
|
31494
|
+
);
|
|
31495
|
+
const errorCode = (_b = error.data) == null ? void 0 : _b.code;
|
|
31491
31496
|
if (errorCode) {
|
|
31492
31497
|
console.error(
|
|
31493
31498
|
identifier,
|
|
@@ -31525,11 +31530,6 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
|
|
|
31525
31530
|
openAiPayload.tool_choice = "none";
|
|
31526
31531
|
}
|
|
31527
31532
|
}
|
|
31528
|
-
console.error(error);
|
|
31529
|
-
console.error(
|
|
31530
|
-
identifier,
|
|
31531
|
-
`Retrying due to error: received bad response from OpenAI API [${openAiConfig == null ? void 0 : openAiConfig.service}-${openAiPayload.model}-${openAiConfig == null ? void 0 : openAiConfig.orgId}]: ${error.message} - ${JSON.stringify((_b = error.response) == null ? void 0 : _b.data)}`
|
|
31532
|
-
);
|
|
31533
31533
|
await timeout(250);
|
|
31534
31534
|
}
|
|
31535
31535
|
}
|
|
@@ -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)
|