190proof 1.0.47 → 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.js +26 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -31509,7 +31509,7 @@ async function callOpenAiWithRetries(identifier, openAiPayload, openAiConfig, re
|
|
|
31509
31509
|
if (errorCode === "content_policy_violation") {
|
|
31510
31510
|
console.log(
|
|
31511
31511
|
identifier,
|
|
31512
|
-
`
|
|
31512
|
+
`Removing images due to content policy violation error`
|
|
31513
31513
|
);
|
|
31514
31514
|
openAiPayload.messages.forEach((message) => {
|
|
31515
31515
|
if (Array.isArray(message.content)) {
|
|
@@ -31636,9 +31636,9 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31636
31636
|
let functionCallArgs = "";
|
|
31637
31637
|
const reader = response.body.getReader();
|
|
31638
31638
|
let partialChunk = "";
|
|
31639
|
-
let abortTimeout;
|
|
31639
|
+
let abortTimeout = null;
|
|
31640
31640
|
const startAbortTimeout = () => {
|
|
31641
|
-
clearTimeout(abortTimeout);
|
|
31641
|
+
abortTimeout && clearTimeout(abortTimeout);
|
|
31642
31642
|
return setTimeout(() => {
|
|
31643
31643
|
console.log(
|
|
31644
31644
|
identifier,
|
|
@@ -31711,7 +31711,7 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31711
31711
|
);
|
|
31712
31712
|
const error = new Error("Stream error: OpenAI error");
|
|
31713
31713
|
error.data = json.error;
|
|
31714
|
-
error.requestBody = openAiPayload;
|
|
31714
|
+
error.requestBody = truncatePayload(openAiPayload);
|
|
31715
31715
|
throw error;
|
|
31716
31716
|
}
|
|
31717
31717
|
if (chunkIndex !== 0)
|
|
@@ -31743,6 +31743,28 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31743
31743
|
throw new Error("Stream error: no response body");
|
|
31744
31744
|
}
|
|
31745
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
|
+
}
|
|
31746
31768
|
async function callAnthropicWithRetries(identifier, AiPayload, AiConfig, attempts = 5) {
|
|
31747
31769
|
var _a3, _b, _c, _d;
|
|
31748
31770
|
console.log(identifier, "Calling Anthropic API with retries");
|