190proof 1.0.46 → 1.0.48

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.d.mts CHANGED
@@ -11,7 +11,8 @@ declare enum GPTModel {
11
11
  GPT4_1106_PREVIEW = "gpt-4-1106-preview",
12
12
  GPT4_0125_PREVIEW = "gpt-4-0125-preview",
13
13
  GPT4_0409 = "gpt-4-turbo-2024-04-09",
14
- GPT4O = "gpt-4o"
14
+ GPT4O = "gpt-4o",
15
+ GPT4O_MINI = "gpt-4o-mini"
15
16
  }
16
17
  declare enum GroqModel {
17
18
  LLAMA_3_70B_8192 = "llama3-70b-8192"
package/dist/index.d.ts CHANGED
@@ -11,7 +11,8 @@ declare enum GPTModel {
11
11
  GPT4_1106_PREVIEW = "gpt-4-1106-preview",
12
12
  GPT4_0125_PREVIEW = "gpt-4-0125-preview",
13
13
  GPT4_0409 = "gpt-4-turbo-2024-04-09",
14
- GPT4O = "gpt-4o"
14
+ GPT4O = "gpt-4o",
15
+ GPT4O_MINI = "gpt-4o-mini"
15
16
  }
16
17
  declare enum GroqModel {
17
18
  LLAMA_3_70B_8192 = "llama3-70b-8192"
package/dist/index.js CHANGED
@@ -27037,6 +27037,7 @@ var GPTModel = /* @__PURE__ */ ((GPTModel2) => {
27037
27037
  GPTModel2["GPT4_0125_PREVIEW"] = "gpt-4-0125-preview";
27038
27038
  GPTModel2["GPT4_0409"] = "gpt-4-turbo-2024-04-09";
27039
27039
  GPTModel2["GPT4O"] = "gpt-4o";
27040
+ GPTModel2["GPT4O_MINI"] = "gpt-4o-mini";
27040
27041
  return GPTModel2;
27041
27042
  })(GPTModel || {});
27042
27043
  var GroqModel = /* @__PURE__ */ ((GroqModel2) => {
@@ -31514,7 +31515,7 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
31514
31515
  if (errorCode === "content_policy_violation") {
31515
31516
  console.log(
31516
31517
  identifier,
31517
- `Switching to OpenAI service due to content policy violation error`
31518
+ `Removing images due to content policy violation error`
31518
31519
  );
31519
31520
  openAiPayload.messages.forEach((message) => {
31520
31521
  if (Array.isArray(message.content)) {
@@ -31641,9 +31642,9 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
31641
31642
  let functionCallArgs = "";
31642
31643
  const reader = response.body.getReader();
31643
31644
  let partialChunk = "";
31644
- let abortTimeout;
31645
+ let abortTimeout = null;
31645
31646
  const startAbortTimeout = () => {
31646
- clearTimeout(abortTimeout);
31647
+ abortTimeout && clearTimeout(abortTimeout);
31647
31648
  return setTimeout(() => {
31648
31649
  console.log(
31649
31650
  identifier,
@@ -31716,7 +31717,7 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
31716
31717
  );
31717
31718
  const error = new Error("Stream error: OpenAI error");
31718
31719
  error.data = json.error;
31719
- error.requestBody = openAiPayload;
31720
+ error.requestBody = truncatePayload(openAiPayload);
31720
31721
  throw error;
31721
31722
  }
31722
31723
  if (chunkIndex !== 0)
@@ -31748,6 +31749,28 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
31748
31749
  throw new Error("Stream error: no response body");
31749
31750
  }
31750
31751
  }
31752
+ function truncatePayload(payload) {
31753
+ return JSON.stringify(
31754
+ {
31755
+ ...payload,
31756
+ messages: payload.messages.map((message) => {
31757
+ if (typeof message.content === "string") {
31758
+ message.content = message.content.slice(0, 100);
31759
+ } else if (Array.isArray(message.content)) {
31760
+ message.content = message.content.map((block) => {
31761
+ if (block.type === "image_url") {
31762
+ block.image_url.url = block.image_url.url.slice(0, 100);
31763
+ }
31764
+ return block;
31765
+ });
31766
+ }
31767
+ return message;
31768
+ })
31769
+ },
31770
+ null,
31771
+ 2
31772
+ );
31773
+ }
31751
31774
  async function callAnthropicWithRetries(identifier, AiPayload, AiConfig, attempts = 5) {
31752
31775
  var _a3, _b, _c, _d;
31753
31776
  console.log(identifier, "Calling Anthropic API with retries");
@@ -31902,14 +31925,17 @@ function jigAnthropicMessages(messages) {
31902
31925
  }
31903
31926
  const lastMessage = acc[acc.length - 1];
31904
31927
  if (lastMessage.role === message.role) {
31905
- return [
31906
- ...acc,
31907
- {
31908
- role: message.role === "user" ? "assistant" : "user",
31909
- content: "..."
31910
- },
31911
- message
31928
+ const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
31929
+ const newContent = Array.isArray(message.content) ? message.content : [{ type: "text", text: message.content }];
31930
+ lastMessage.content = [
31931
+ ...lastContent,
31932
+ { type: "text", text: "\n\n---\n\n" },
31933
+ ...newContent
31912
31934
  ];
31935
+ return acc;
31936
+ }
31937
+ if (typeof message.content === "string") {
31938
+ message.content = [{ type: "text", text: message.content }];
31913
31939
  }
31914
31940
  return [...acc, message];
31915
31941
  }, []);