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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +37 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -27031,6 +27031,7 @@ var GPTModel = /* @__PURE__ */ ((GPTModel2) => {
|
|
|
27031
27031
|
GPTModel2["GPT4_0125_PREVIEW"] = "gpt-4-0125-preview";
|
|
27032
27032
|
GPTModel2["GPT4_0409"] = "gpt-4-turbo-2024-04-09";
|
|
27033
27033
|
GPTModel2["GPT4O"] = "gpt-4o";
|
|
27034
|
+
GPTModel2["GPT4O_MINI"] = "gpt-4o-mini";
|
|
27034
27035
|
return GPTModel2;
|
|
27035
27036
|
})(GPTModel || {});
|
|
27036
27037
|
var GroqModel = /* @__PURE__ */ ((GroqModel2) => {
|
|
@@ -31508,7 +31509,7 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
|
|
|
31508
31509
|
if (errorCode === "content_policy_violation") {
|
|
31509
31510
|
console.log(
|
|
31510
31511
|
identifier,
|
|
31511
|
-
`
|
|
31512
|
+
`Removing images due to content policy violation error`
|
|
31512
31513
|
);
|
|
31513
31514
|
openAiPayload.messages.forEach((message) => {
|
|
31514
31515
|
if (Array.isArray(message.content)) {
|
|
@@ -31635,9 +31636,9 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31635
31636
|
let functionCallArgs = "";
|
|
31636
31637
|
const reader = response.body.getReader();
|
|
31637
31638
|
let partialChunk = "";
|
|
31638
|
-
let abortTimeout;
|
|
31639
|
+
let abortTimeout = null;
|
|
31639
31640
|
const startAbortTimeout = () => {
|
|
31640
|
-
clearTimeout(abortTimeout);
|
|
31641
|
+
abortTimeout && clearTimeout(abortTimeout);
|
|
31641
31642
|
return setTimeout(() => {
|
|
31642
31643
|
console.log(
|
|
31643
31644
|
identifier,
|
|
@@ -31710,7 +31711,7 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31710
31711
|
);
|
|
31711
31712
|
const error = new Error("Stream error: OpenAI error");
|
|
31712
31713
|
error.data = json.error;
|
|
31713
|
-
error.requestBody = openAiPayload;
|
|
31714
|
+
error.requestBody = truncatePayload(openAiPayload);
|
|
31714
31715
|
throw error;
|
|
31715
31716
|
}
|
|
31716
31717
|
if (chunkIndex !== 0)
|
|
@@ -31742,6 +31743,28 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31742
31743
|
throw new Error("Stream error: no response body");
|
|
31743
31744
|
}
|
|
31744
31745
|
}
|
|
31746
|
+
function truncatePayload(payload) {
|
|
31747
|
+
return JSON.stringify(
|
|
31748
|
+
{
|
|
31749
|
+
...payload,
|
|
31750
|
+
messages: payload.messages.map((message) => {
|
|
31751
|
+
if (typeof message.content === "string") {
|
|
31752
|
+
message.content = message.content.slice(0, 100);
|
|
31753
|
+
} else if (Array.isArray(message.content)) {
|
|
31754
|
+
message.content = message.content.map((block) => {
|
|
31755
|
+
if (block.type === "image_url") {
|
|
31756
|
+
block.image_url.url = block.image_url.url.slice(0, 100);
|
|
31757
|
+
}
|
|
31758
|
+
return block;
|
|
31759
|
+
});
|
|
31760
|
+
}
|
|
31761
|
+
return message;
|
|
31762
|
+
})
|
|
31763
|
+
},
|
|
31764
|
+
null,
|
|
31765
|
+
2
|
|
31766
|
+
);
|
|
31767
|
+
}
|
|
31745
31768
|
async function callAnthropicWithRetries(identifier, AiPayload, AiConfig, attempts = 5) {
|
|
31746
31769
|
var _a3, _b, _c, _d;
|
|
31747
31770
|
console.log(identifier, "Calling Anthropic API with retries");
|
|
@@ -31896,14 +31919,17 @@ function jigAnthropicMessages(messages) {
|
|
|
31896
31919
|
}
|
|
31897
31920
|
const lastMessage = acc[acc.length - 1];
|
|
31898
31921
|
if (lastMessage.role === message.role) {
|
|
31899
|
-
|
|
31900
|
-
|
|
31901
|
-
|
|
31902
|
-
|
|
31903
|
-
|
|
31904
|
-
|
|
31905
|
-
message
|
|
31922
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
|
|
31923
|
+
const newContent = Array.isArray(message.content) ? message.content : [{ type: "text", text: message.content }];
|
|
31924
|
+
lastMessage.content = [
|
|
31925
|
+
...lastContent,
|
|
31926
|
+
{ type: "text", text: "\n\n---\n\n" },
|
|
31927
|
+
...newContent
|
|
31906
31928
|
];
|
|
31929
|
+
return acc;
|
|
31930
|
+
}
|
|
31931
|
+
if (typeof message.content === "string") {
|
|
31932
|
+
message.content = [{ type: "text", text: message.content }];
|
|
31907
31933
|
}
|
|
31908
31934
|
return [...acc, message];
|
|
31909
31935
|
}, []);
|