190proof 1.0.37 → 1.0.39
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 +35 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -27029,6 +27029,7 @@ var GPTModel = /* @__PURE__ */ ((GPTModel2) => {
|
|
|
27029
27029
|
GPTModel2["GPT4_1106_PREVIEW"] = "gpt-4-1106-preview";
|
|
27030
27030
|
GPTModel2["GPT4_0125_PREVIEW"] = "gpt-4-0125-preview";
|
|
27031
27031
|
GPTModel2["GPT4_0409"] = "gpt-4-turbo-2024-04-09";
|
|
27032
|
+
GPTModel2["GPT4O"] = "gpt-4o";
|
|
27032
27033
|
return GPTModel2;
|
|
27033
27034
|
})(GPTModel || {});
|
|
27034
27035
|
var GroqModel = /* @__PURE__ */ ((GroqModel2) => {
|
|
@@ -31580,6 +31581,19 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31580
31581
|
}
|
|
31581
31582
|
const azureConfig = openAiConfig.modelConfigMap[model];
|
|
31582
31583
|
const endpoint = `${openAiConfig.baseUrl}/azure-openai/${azureConfig.resource}/${azureConfig.deployment}/chat/completions?api-version=${azureConfig.apiVersion}`;
|
|
31584
|
+
try {
|
|
31585
|
+
const stringifiedPayload = JSON.stringify({
|
|
31586
|
+
...openAiPayload,
|
|
31587
|
+
stream: true
|
|
31588
|
+
});
|
|
31589
|
+
const parsedPayload = JSON.parse(stringifiedPayload);
|
|
31590
|
+
} catch (error) {
|
|
31591
|
+
console.error(
|
|
31592
|
+
identifier,
|
|
31593
|
+
"Stream error: Azure OpenAI JSON parsing error:",
|
|
31594
|
+
JSON.stringify(error)
|
|
31595
|
+
);
|
|
31596
|
+
}
|
|
31583
31597
|
response = await fetch(endpoint, {
|
|
31584
31598
|
method: "POST",
|
|
31585
31599
|
headers: {
|
|
@@ -31690,11 +31704,11 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31690
31704
|
console.error(
|
|
31691
31705
|
identifier,
|
|
31692
31706
|
"Stream error: OpenAI error:",
|
|
31693
|
-
json.error
|
|
31707
|
+
json.error && JSON.stringify(json.error)
|
|
31694
31708
|
);
|
|
31695
31709
|
const error = new Error("Stream error: OpenAI error");
|
|
31696
31710
|
error.data = json.error;
|
|
31697
|
-
error.requestBody =
|
|
31711
|
+
error.requestBody = openAiPayload;
|
|
31698
31712
|
throw error;
|
|
31699
31713
|
}
|
|
31700
31714
|
if (chunkIndex !== 0)
|
|
@@ -32115,26 +32129,27 @@ async function prepareOpenAIPayload(payload) {
|
|
|
32115
32129
|
});
|
|
32116
32130
|
}
|
|
32117
32131
|
for (const file of message.files || []) {
|
|
32118
|
-
if (
|
|
32132
|
+
if ((_b = file.mimeType) == null ? void 0 : _b.startsWith("image")) {
|
|
32133
|
+
if (file.url) {
|
|
32134
|
+
openAIContentBlocks.push({
|
|
32135
|
+
type: "image_url",
|
|
32136
|
+
image_url: {
|
|
32137
|
+
url: file.url
|
|
32138
|
+
}
|
|
32139
|
+
});
|
|
32140
|
+
} else if (file.data) {
|
|
32141
|
+
openAIContentBlocks.push({
|
|
32142
|
+
type: "image_url",
|
|
32143
|
+
image_url: {
|
|
32144
|
+
url: `data:${file.mimeType};base64,${file.data}`
|
|
32145
|
+
}
|
|
32146
|
+
});
|
|
32147
|
+
}
|
|
32148
|
+
} else {
|
|
32119
32149
|
console.warn(
|
|
32120
|
-
"
|
|
32150
|
+
"Skipping file. Type not supported by OpenAI API:",
|
|
32151
|
+
file.mimeType
|
|
32121
32152
|
);
|
|
32122
|
-
continue;
|
|
32123
|
-
}
|
|
32124
|
-
if (file.url) {
|
|
32125
|
-
openAIContentBlocks.push({
|
|
32126
|
-
type: "image_url",
|
|
32127
|
-
image_url: {
|
|
32128
|
-
url: file.url
|
|
32129
|
-
}
|
|
32130
|
-
});
|
|
32131
|
-
} else if (file.data) {
|
|
32132
|
-
openAIContentBlocks.push({
|
|
32133
|
-
type: "image_url",
|
|
32134
|
-
image_url: {
|
|
32135
|
-
url: `data:${file.mimeType};base64,${file.data}`
|
|
32136
|
-
}
|
|
32137
|
-
});
|
|
32138
32153
|
}
|
|
32139
32154
|
}
|
|
32140
32155
|
preparedPayload.messages.push({
|