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.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
  }
@@ -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
- paragraph,
31633
- functionCallName,
31634
- functionCallArgs
31644
+ rawStreamedBody
31635
31645
  );
31636
31646
  throw new Error("Stream error: ended prematurely");
31637
31647
  }
@@ -31695,11 +31705,11 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
31695
31705
  );
31696
31706
  continue;
31697
31707
  }
31698
- const toolCall = (_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];
31699
- if (toolCall) {
31700
- 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;
31701
31711
  if (toolCallIndex === 0) {
31702
- const dFn = toolCall.function || {};
31712
+ const dFn = dToolCall.function || {};
31703
31713
  if (dFn.name)
31704
31714
  functionCallName += dFn.name;
31705
31715
  if (dFn.arguments)