@browser-ai/core 2.1.4 → 2.1.5
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 +9 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -749,11 +749,7 @@ var import_provider = require("@ai-sdk/provider");
|
|
|
749
749
|
function convertBase64ToUint8Array(base64) {
|
|
750
750
|
try {
|
|
751
751
|
const binaryString = atob(base64);
|
|
752
|
-
|
|
753
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
754
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
755
|
-
}
|
|
756
|
-
return bytes;
|
|
752
|
+
return Uint8Array.from(binaryString, (c) => c.charCodeAt(0));
|
|
757
753
|
} catch (error) {
|
|
758
754
|
throw new Error(`Failed to convert base64 to Uint8Array: ${error}`);
|
|
759
755
|
}
|
|
@@ -1019,19 +1015,7 @@ function gatherUnsupportedSettingWarnings(options) {
|
|
|
1019
1015
|
}
|
|
1020
1016
|
|
|
1021
1017
|
// src/utils/prompt-utils.ts
|
|
1022
|
-
function
|
|
1023
|
-
for (const message of prompt) {
|
|
1024
|
-
if (message.role === "user") {
|
|
1025
|
-
for (const part of message.content) {
|
|
1026
|
-
if (part.type === "file") {
|
|
1027
|
-
return true;
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
return false;
|
|
1033
|
-
}
|
|
1034
|
-
function getExpectedInputs(prompt) {
|
|
1018
|
+
function getMultimodalInfo(prompt) {
|
|
1035
1019
|
const inputs = /* @__PURE__ */ new Set();
|
|
1036
1020
|
for (const message of prompt) {
|
|
1037
1021
|
if (message.role === "user") {
|
|
@@ -1046,7 +1030,11 @@ function getExpectedInputs(prompt) {
|
|
|
1046
1030
|
}
|
|
1047
1031
|
}
|
|
1048
1032
|
}
|
|
1049
|
-
|
|
1033
|
+
const hasMultiModalInput = inputs.size > 0;
|
|
1034
|
+
return {
|
|
1035
|
+
hasMultiModalInput,
|
|
1036
|
+
expectedInputs: hasMultiModalInput ? Array.from(inputs, (type) => ({ type })) : void 0
|
|
1037
|
+
};
|
|
1050
1038
|
}
|
|
1051
1039
|
|
|
1052
1040
|
// src/chat/session-manager.ts
|
|
@@ -1220,17 +1208,8 @@ var SessionManager = class {
|
|
|
1220
1208
|
};
|
|
1221
1209
|
}
|
|
1222
1210
|
}
|
|
1223
|
-
this.sanitizeOptions(mergedOptions);
|
|
1224
1211
|
return mergedOptions;
|
|
1225
1212
|
}
|
|
1226
|
-
/**
|
|
1227
|
-
* Removes custom options that aren't part of LanguageModel.create API
|
|
1228
|
-
*
|
|
1229
|
-
* @param options - Options object to sanitize in-place
|
|
1230
|
-
* @private
|
|
1231
|
-
*/
|
|
1232
|
-
sanitizeOptions(options) {
|
|
1233
|
-
}
|
|
1234
1213
|
};
|
|
1235
1214
|
|
|
1236
1215
|
// src/chat/browser-ai-language-model.ts
|
|
@@ -1306,7 +1285,7 @@ var BrowserAIChatLanguageModel = class {
|
|
|
1306
1285
|
)
|
|
1307
1286
|
);
|
|
1308
1287
|
}
|
|
1309
|
-
const hasMultiModalInput =
|
|
1288
|
+
const { hasMultiModalInput, expectedInputs } = getMultimodalInfo(prompt);
|
|
1310
1289
|
const { systemMessage, messages } = convertToBrowserAIMessages(prompt);
|
|
1311
1290
|
const promptOptions = {};
|
|
1312
1291
|
if (responseFormat?.type === "json") {
|
|
@@ -1324,7 +1303,7 @@ var BrowserAIChatLanguageModel = class {
|
|
|
1324
1303
|
warnings,
|
|
1325
1304
|
promptOptions,
|
|
1326
1305
|
hasMultiModalInput,
|
|
1327
|
-
expectedInputs
|
|
1306
|
+
expectedInputs,
|
|
1328
1307
|
functionTools
|
|
1329
1308
|
};
|
|
1330
1309
|
}
|