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 CHANGED
@@ -9,7 +9,8 @@ declare enum GPTModel {
9
9
  GPT35_0125 = "gpt-3.5-turbo-0125",
10
10
  GPT4_1106_PREVIEW = "gpt-4-1106-preview",
11
11
  GPT4_0125_PREVIEW = "gpt-4-0125-preview",
12
- GPT4_0409 = "gpt-4-turbo-2024-04-09"
12
+ GPT4_0409 = "gpt-4-turbo-2024-04-09",
13
+ GPT4O = "gpt-4o"
13
14
  }
14
15
  declare enum GroqModel {
15
16
  LLAMA_3_70B_8192 = "llama3-70b-8192"
package/dist/index.d.ts CHANGED
@@ -9,7 +9,8 @@ declare enum GPTModel {
9
9
  GPT35_0125 = "gpt-3.5-turbo-0125",
10
10
  GPT4_1106_PREVIEW = "gpt-4-1106-preview",
11
11
  GPT4_0125_PREVIEW = "gpt-4-0125-preview",
12
- GPT4_0409 = "gpt-4-turbo-2024-04-09"
12
+ GPT4_0409 = "gpt-4-turbo-2024-04-09",
13
+ GPT4O = "gpt-4o"
13
14
  }
14
15
  declare enum GroqModel {
15
16
  LLAMA_3_70B_8192 = "llama3-70b-8192"
package/dist/index.js CHANGED
@@ -27035,6 +27035,7 @@ var GPTModel = /* @__PURE__ */ ((GPTModel2) => {
27035
27035
  GPTModel2["GPT4_1106_PREVIEW"] = "gpt-4-1106-preview";
27036
27036
  GPTModel2["GPT4_0125_PREVIEW"] = "gpt-4-0125-preview";
27037
27037
  GPTModel2["GPT4_0409"] = "gpt-4-turbo-2024-04-09";
27038
+ GPTModel2["GPT4O"] = "gpt-4o";
27038
27039
  return GPTModel2;
27039
27040
  })(GPTModel || {});
27040
27041
  var GroqModel = /* @__PURE__ */ ((GroqModel2) => {
@@ -31586,6 +31587,19 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
31586
31587
  }
31587
31588
  const azureConfig = openAiConfig.modelConfigMap[model];
31588
31589
  const endpoint = `${openAiConfig.baseUrl}/azure-openai/${azureConfig.resource}/${azureConfig.deployment}/chat/completions?api-version=${azureConfig.apiVersion}`;
31590
+ try {
31591
+ const stringifiedPayload = JSON.stringify({
31592
+ ...openAiPayload,
31593
+ stream: true
31594
+ });
31595
+ const parsedPayload = JSON.parse(stringifiedPayload);
31596
+ } catch (error) {
31597
+ console.error(
31598
+ identifier,
31599
+ "Stream error: Azure OpenAI JSON parsing error:",
31600
+ JSON.stringify(error)
31601
+ );
31602
+ }
31589
31603
  response = await fetch(endpoint, {
31590
31604
  method: "POST",
31591
31605
  headers: {
@@ -31696,11 +31710,11 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
31696
31710
  console.error(
31697
31711
  identifier,
31698
31712
  "Stream error: OpenAI error:",
31699
- json.error
31713
+ json.error && JSON.stringify(json.error)
31700
31714
  );
31701
31715
  const error = new Error("Stream error: OpenAI error");
31702
31716
  error.data = json.error;
31703
- error.requestBody = JSON.stringify(openAiPayload);
31717
+ error.requestBody = openAiPayload;
31704
31718
  throw error;
31705
31719
  }
31706
31720
  if (chunkIndex !== 0)
@@ -32121,26 +32135,27 @@ async function prepareOpenAIPayload(payload) {
32121
32135
  });
32122
32136
  }
32123
32137
  for (const file of message.files || []) {
32124
- if (!((_b = file.mimeType) == null ? void 0 : _b.startsWith("image"))) {
32138
+ if ((_b = file.mimeType) == null ? void 0 : _b.startsWith("image")) {
32139
+ if (file.url) {
32140
+ openAIContentBlocks.push({
32141
+ type: "image_url",
32142
+ image_url: {
32143
+ url: file.url
32144
+ }
32145
+ });
32146
+ } else if (file.data) {
32147
+ openAIContentBlocks.push({
32148
+ type: "image_url",
32149
+ image_url: {
32150
+ url: `data:${file.mimeType};base64,${file.data}`
32151
+ }
32152
+ });
32153
+ }
32154
+ } else {
32125
32155
  console.warn(
32126
- "OpenAI API does not support non-image file types. Skipping file."
32156
+ "Skipping file. Type not supported by OpenAI API:",
32157
+ file.mimeType
32127
32158
  );
32128
- continue;
32129
- }
32130
- if (file.url) {
32131
- openAIContentBlocks.push({
32132
- type: "image_url",
32133
- image_url: {
32134
- url: file.url
32135
- }
32136
- });
32137
- } else if (file.data) {
32138
- openAIContentBlocks.push({
32139
- type: "image_url",
32140
- image_url: {
32141
- url: `data:${file.mimeType};base64,${file.data}`
32142
- }
32143
- });
32144
32159
  }
32145
32160
  }
32146
32161
  preparedPayload.messages.push({