@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.mjs
CHANGED
|
@@ -721,11 +721,7 @@ import {
|
|
|
721
721
|
function convertBase64ToUint8Array(base64) {
|
|
722
722
|
try {
|
|
723
723
|
const binaryString = atob(base64);
|
|
724
|
-
|
|
725
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
726
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
727
|
-
}
|
|
728
|
-
return bytes;
|
|
724
|
+
return Uint8Array.from(binaryString, (c) => c.charCodeAt(0));
|
|
729
725
|
} catch (error) {
|
|
730
726
|
throw new Error(`Failed to convert base64 to Uint8Array: ${error}`);
|
|
731
727
|
}
|
|
@@ -991,19 +987,7 @@ function gatherUnsupportedSettingWarnings(options) {
|
|
|
991
987
|
}
|
|
992
988
|
|
|
993
989
|
// src/utils/prompt-utils.ts
|
|
994
|
-
function
|
|
995
|
-
for (const message of prompt) {
|
|
996
|
-
if (message.role === "user") {
|
|
997
|
-
for (const part of message.content) {
|
|
998
|
-
if (part.type === "file") {
|
|
999
|
-
return true;
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
return false;
|
|
1005
|
-
}
|
|
1006
|
-
function getExpectedInputs(prompt) {
|
|
990
|
+
function getMultimodalInfo(prompt) {
|
|
1007
991
|
const inputs = /* @__PURE__ */ new Set();
|
|
1008
992
|
for (const message of prompt) {
|
|
1009
993
|
if (message.role === "user") {
|
|
@@ -1018,7 +1002,11 @@ function getExpectedInputs(prompt) {
|
|
|
1018
1002
|
}
|
|
1019
1003
|
}
|
|
1020
1004
|
}
|
|
1021
|
-
|
|
1005
|
+
const hasMultiModalInput = inputs.size > 0;
|
|
1006
|
+
return {
|
|
1007
|
+
hasMultiModalInput,
|
|
1008
|
+
expectedInputs: hasMultiModalInput ? Array.from(inputs, (type) => ({ type })) : void 0
|
|
1009
|
+
};
|
|
1022
1010
|
}
|
|
1023
1011
|
|
|
1024
1012
|
// src/chat/session-manager.ts
|
|
@@ -1192,17 +1180,8 @@ var SessionManager = class {
|
|
|
1192
1180
|
};
|
|
1193
1181
|
}
|
|
1194
1182
|
}
|
|
1195
|
-
this.sanitizeOptions(mergedOptions);
|
|
1196
1183
|
return mergedOptions;
|
|
1197
1184
|
}
|
|
1198
|
-
/**
|
|
1199
|
-
* Removes custom options that aren't part of LanguageModel.create API
|
|
1200
|
-
*
|
|
1201
|
-
* @param options - Options object to sanitize in-place
|
|
1202
|
-
* @private
|
|
1203
|
-
*/
|
|
1204
|
-
sanitizeOptions(options) {
|
|
1205
|
-
}
|
|
1206
1185
|
};
|
|
1207
1186
|
|
|
1208
1187
|
// src/chat/browser-ai-language-model.ts
|
|
@@ -1278,7 +1257,7 @@ var BrowserAIChatLanguageModel = class {
|
|
|
1278
1257
|
)
|
|
1279
1258
|
);
|
|
1280
1259
|
}
|
|
1281
|
-
const hasMultiModalInput =
|
|
1260
|
+
const { hasMultiModalInput, expectedInputs } = getMultimodalInfo(prompt);
|
|
1282
1261
|
const { systemMessage, messages } = convertToBrowserAIMessages(prompt);
|
|
1283
1262
|
const promptOptions = {};
|
|
1284
1263
|
if (responseFormat?.type === "json") {
|
|
@@ -1296,7 +1275,7 @@ var BrowserAIChatLanguageModel = class {
|
|
|
1296
1275
|
warnings,
|
|
1297
1276
|
promptOptions,
|
|
1298
1277
|
hasMultiModalInput,
|
|
1299
|
-
expectedInputs
|
|
1278
|
+
expectedInputs,
|
|
1300
1279
|
functionTools
|
|
1301
1280
|
};
|
|
1302
1281
|
}
|