190proof 1.0.35 → 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 +19 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -31505,6 +31505,10 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
|
|
|
31505
31505
|
openAiPayload.model = "gpt-4-turbo-2024-04-09" /* GPT4_0409 */;
|
|
31506
31506
|
openAiPayload.temperature = 0.8;
|
|
31507
31507
|
if (errorCode === "content_policy_violation") {
|
|
31508
|
+
console.log(
|
|
31509
|
+
identifier,
|
|
31510
|
+
`Switching to OpenAI service due to content policy violation error`
|
|
31511
|
+
);
|
|
31508
31512
|
openAiPayload.messages.forEach((message) => {
|
|
31509
31513
|
if (Array.isArray(message.content)) {
|
|
31510
31514
|
message.content = message.content.filter(
|
|
@@ -31522,11 +31526,19 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
|
|
|
31522
31526
|
}
|
|
31523
31527
|
if (i5 === 3) {
|
|
31524
31528
|
if ((openAiConfig == null ? void 0 : openAiConfig.service) === "azure") {
|
|
31529
|
+
console.log(
|
|
31530
|
+
identifier,
|
|
31531
|
+
`Switching to OpenAI service due to Azure service error`
|
|
31532
|
+
);
|
|
31525
31533
|
openAiConfig.service = "openai";
|
|
31526
31534
|
}
|
|
31527
31535
|
}
|
|
31528
31536
|
if (i5 === 4) {
|
|
31529
31537
|
if (openAiPayload.tools) {
|
|
31538
|
+
console.log(
|
|
31539
|
+
identifier,
|
|
31540
|
+
`Switching to no tool choice due to persistent error`
|
|
31541
|
+
);
|
|
31530
31542
|
openAiPayload.tool_choice = "none";
|
|
31531
31543
|
}
|
|
31532
31544
|
}
|
|
@@ -31543,7 +31555,7 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
|
|
|
31543
31555
|
);
|
|
31544
31556
|
}
|
|
31545
31557
|
async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTimeoutMs) {
|
|
31546
|
-
var _a3, _b, _c, _d;
|
|
31558
|
+
var _a3, _b, _c, _d, _e, _f, _g;
|
|
31547
31559
|
const functionNames = openAiPayload.tools ? new Set(openAiPayload.tools.map((fn) => fn.function.name)) : null;
|
|
31548
31560
|
if (!openAiConfig) {
|
|
31549
31561
|
const defaultOpenAIBaseUrl = (
|
|
@@ -31629,9 +31641,7 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31629
31641
|
console.log(
|
|
31630
31642
|
identifier,
|
|
31631
31643
|
`Stream error: ended after ${chunkIndex + 1} chunks via reader done flag.`,
|
|
31632
|
-
|
|
31633
|
-
functionCallName,
|
|
31634
|
-
functionCallArgs
|
|
31644
|
+
rawStreamedBody
|
|
31635
31645
|
);
|
|
31636
31646
|
throw new Error("Stream error: ended prematurely");
|
|
31637
31647
|
}
|
|
@@ -31695,19 +31705,18 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31695
31705
|
);
|
|
31696
31706
|
continue;
|
|
31697
31707
|
}
|
|
31698
|
-
const
|
|
31699
|
-
|
|
31700
|
-
|
|
31701
|
-
const toolCallIndex = toolCall.index || 0;
|
|
31708
|
+
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];
|
|
31709
|
+
if (dToolCall) {
|
|
31710
|
+
const toolCallIndex = dToolCall.index || 0;
|
|
31702
31711
|
if (toolCallIndex === 0) {
|
|
31703
|
-
const dFn =
|
|
31712
|
+
const dFn = dToolCall.function || {};
|
|
31704
31713
|
if (dFn.name)
|
|
31705
31714
|
functionCallName += dFn.name;
|
|
31706
31715
|
if (dFn.arguments)
|
|
31707
31716
|
functionCallArgs += dFn.arguments;
|
|
31708
31717
|
}
|
|
31709
31718
|
}
|
|
31710
|
-
const text = (
|
|
31719
|
+
const text = (_g = (_f = (_e = json.choices) == null ? void 0 : _e[0]) == null ? void 0 : _f.delta) == null ? void 0 : _g.content;
|
|
31711
31720
|
if (text) {
|
|
31712
31721
|
paragraph += text;
|
|
31713
31722
|
}
|