@browser-ai/core 2.1.7 → 2.1.9
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/README.md +1 -0
- package/dist/index.js +32 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
[](https://www.npmjs.com/package/@browser-ai/core)
|
|
12
12
|
[](https://www.npmjs.com/package/@browser-ai/core)
|
|
13
|
+
[](https://www.jsdelivr.com/package/npm/@browser-ai/core)
|
|
13
14
|
|
|
14
15
|
</div>
|
|
15
16
|
|
package/dist/index.js
CHANGED
|
@@ -1076,7 +1076,9 @@ var SessionManager = class {
|
|
|
1076
1076
|
if (this.session) {
|
|
1077
1077
|
return this.session;
|
|
1078
1078
|
}
|
|
1079
|
-
const availability = await LanguageModel.availability(
|
|
1079
|
+
const availability = await LanguageModel.availability(
|
|
1080
|
+
this.prepareAvailabilityOptions(options)
|
|
1081
|
+
);
|
|
1080
1082
|
if (availability === "unavailable") {
|
|
1081
1083
|
throw new import_provider2.LoadSettingError({
|
|
1082
1084
|
message: "Built-in model not available in this browser"
|
|
@@ -1136,11 +1138,11 @@ var SessionManager = class {
|
|
|
1136
1138
|
* }
|
|
1137
1139
|
* ```
|
|
1138
1140
|
*/
|
|
1139
|
-
async checkAvailability() {
|
|
1141
|
+
async checkAvailability(options) {
|
|
1140
1142
|
if (typeof LanguageModel === "undefined") {
|
|
1141
1143
|
return "unavailable";
|
|
1142
1144
|
}
|
|
1143
|
-
return LanguageModel.availability();
|
|
1145
|
+
return LanguageModel.availability(this.prepareAvailabilityOptions(options));
|
|
1144
1146
|
}
|
|
1145
1147
|
/**
|
|
1146
1148
|
* Gets the current session if it exists
|
|
@@ -1192,6 +1194,33 @@ var SessionManager = class {
|
|
|
1192
1194
|
getInputUsage() {
|
|
1193
1195
|
return this.getContextUsage();
|
|
1194
1196
|
}
|
|
1197
|
+
/**
|
|
1198
|
+
* Prepares merged availability options from base config and request options
|
|
1199
|
+
*
|
|
1200
|
+
* @param options - Optional request-specific options
|
|
1201
|
+
* @returns Merged and sanitized core options ready for LanguageModel.availability()
|
|
1202
|
+
* @private
|
|
1203
|
+
*/
|
|
1204
|
+
prepareAvailabilityOptions(options) {
|
|
1205
|
+
const mergedOptions = { ...this.baseOptions, ...options };
|
|
1206
|
+
const availabilityOptions = {};
|
|
1207
|
+
if (mergedOptions.topK !== void 0) {
|
|
1208
|
+
availabilityOptions.topK = mergedOptions.topK;
|
|
1209
|
+
}
|
|
1210
|
+
if (mergedOptions.temperature !== void 0) {
|
|
1211
|
+
availabilityOptions.temperature = mergedOptions.temperature;
|
|
1212
|
+
}
|
|
1213
|
+
if (mergedOptions.expectedInputs !== void 0) {
|
|
1214
|
+
availabilityOptions.expectedInputs = mergedOptions.expectedInputs;
|
|
1215
|
+
}
|
|
1216
|
+
if (mergedOptions.expectedOutputs !== void 0) {
|
|
1217
|
+
availabilityOptions.expectedOutputs = mergedOptions.expectedOutputs;
|
|
1218
|
+
}
|
|
1219
|
+
if (mergedOptions.tools !== void 0) {
|
|
1220
|
+
availabilityOptions.tools = mergedOptions.tools;
|
|
1221
|
+
}
|
|
1222
|
+
return availabilityOptions;
|
|
1223
|
+
}
|
|
1195
1224
|
/**
|
|
1196
1225
|
* Prepares merged session options from base config and request options
|
|
1197
1226
|
*
|