190proof 1.0.36 → 1.0.37
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 +17 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31511,6 +31511,10 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
|
|
|
31511
31511
|
openAiPayload.model = "gpt-4-turbo-2024-04-09" /* GPT4_0409 */;
|
|
31512
31512
|
openAiPayload.temperature = 0.8;
|
|
31513
31513
|
if (errorCode === "content_policy_violation") {
|
|
31514
|
+
console.log(
|
|
31515
|
+
identifier,
|
|
31516
|
+
`Switching to OpenAI service due to content policy violation error`
|
|
31517
|
+
);
|
|
31514
31518
|
openAiPayload.messages.forEach((message) => {
|
|
31515
31519
|
if (Array.isArray(message.content)) {
|
|
31516
31520
|
message.content = message.content.filter(
|
|
@@ -31528,11 +31532,19 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
|
|
|
31528
31532
|
}
|
|
31529
31533
|
if (i5 === 3) {
|
|
31530
31534
|
if ((openAiConfig == null ? void 0 : openAiConfig.service) === "azure") {
|
|
31535
|
+
console.log(
|
|
31536
|
+
identifier,
|
|
31537
|
+
`Switching to OpenAI service due to Azure service error`
|
|
31538
|
+
);
|
|
31531
31539
|
openAiConfig.service = "openai";
|
|
31532
31540
|
}
|
|
31533
31541
|
}
|
|
31534
31542
|
if (i5 === 4) {
|
|
31535
31543
|
if (openAiPayload.tools) {
|
|
31544
|
+
console.log(
|
|
31545
|
+
identifier,
|
|
31546
|
+
`Switching to no tool choice due to persistent error`
|
|
31547
|
+
);
|
|
31536
31548
|
openAiPayload.tool_choice = "none";
|
|
31537
31549
|
}
|
|
31538
31550
|
}
|
|
@@ -31635,9 +31647,7 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31635
31647
|
console.log(
|
|
31636
31648
|
identifier,
|
|
31637
31649
|
`Stream error: ended after ${chunkIndex + 1} chunks via reader done flag.`,
|
|
31638
|
-
|
|
31639
|
-
functionCallName,
|
|
31640
|
-
functionCallArgs
|
|
31650
|
+
rawStreamedBody
|
|
31641
31651
|
);
|
|
31642
31652
|
throw new Error("Stream error: ended prematurely");
|
|
31643
31653
|
}
|
|
@@ -31701,11 +31711,11 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31701
31711
|
);
|
|
31702
31712
|
continue;
|
|
31703
31713
|
}
|
|
31704
|
-
const
|
|
31705
|
-
if (
|
|
31706
|
-
const toolCallIndex =
|
|
31714
|
+
const dToolCall = (_d = (_c = (_b = (_a3 = json.choices) == null ? void 0 : _a3[0]) == null ? void 0 : _b.delta) == null ? void 0 : _c.tool_calls) == null ? void 0 : _d[0];
|
|
31715
|
+
if (dToolCall) {
|
|
31716
|
+
const toolCallIndex = dToolCall.index || 0;
|
|
31707
31717
|
if (toolCallIndex === 0) {
|
|
31708
|
-
const dFn =
|
|
31718
|
+
const dFn = dToolCall.function || {};
|
|
31709
31719
|
if (dFn.name)
|
|
31710
31720
|
functionCallName += dFn.name;
|
|
31711
31721
|
if (dFn.arguments)
|