@firebase/ai 2.9.0 → 2.10.0
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/ai-public.d.ts +10 -0
- package/dist/ai.d.ts +10 -0
- package/dist/esm/index.esm.js +27 -1
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/types/requests.d.ts +10 -0
- package/dist/index.cjs.js +27 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +27 -1
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +27 -1
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/types/requests.d.ts +10 -0
- package/package.json +4 -4
package/dist/index.node.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { FirebaseError, Deferred, getModularInstance } from '@firebase/util';
|
|
|
4
4
|
import { Logger } from '@firebase/logger';
|
|
5
5
|
|
|
6
6
|
var name = "@firebase/ai";
|
|
7
|
-
var version = "2.
|
|
7
|
+
var version = "2.10.0";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -2826,6 +2826,17 @@ function validateGenerationConfig(generationConfig) {
|
|
|
2826
2826
|
generationConfig.thinkingConfig?.thinkingLevel) {
|
|
2827
2827
|
throw new AIError(AIErrorCode.UNSUPPORTED, `Cannot set both thinkingBudget and thinkingLevel in a config.`);
|
|
2828
2828
|
}
|
|
2829
|
+
if (
|
|
2830
|
+
// != allows for null and undefined.
|
|
2831
|
+
generationConfig.responseSchema != null &&
|
|
2832
|
+
generationConfig.responseJsonSchema != null) {
|
|
2833
|
+
throw new AIError(AIErrorCode.UNSUPPORTED, `Cannot set both responseSchema and responseJsonSchema in a config.`);
|
|
2834
|
+
}
|
|
2835
|
+
if ((generationConfig.responseSchema != null ||
|
|
2836
|
+
generationConfig.responseJsonSchema != null) &&
|
|
2837
|
+
generationConfig.responseMimeType) {
|
|
2838
|
+
throw new AIError(AIErrorCode.UNSUPPORTED, `responseMimeType must be set if responseSchema or responseJsonSchema are set.`);
|
|
2839
|
+
}
|
|
2829
2840
|
}
|
|
2830
2841
|
|
|
2831
2842
|
/**
|
|
@@ -4346,6 +4357,11 @@ function getAI(app = getApp(), options) {
|
|
|
4346
4357
|
aiInstance.options = finalOptions;
|
|
4347
4358
|
return aiInstance;
|
|
4348
4359
|
}
|
|
4360
|
+
const hybridParamKeys = [
|
|
4361
|
+
'mode',
|
|
4362
|
+
'onDeviceParams',
|
|
4363
|
+
'inCloudParams'
|
|
4364
|
+
];
|
|
4349
4365
|
/**
|
|
4350
4366
|
* Returns a {@link GenerativeModel} class with methods for inference
|
|
4351
4367
|
* and other functionality.
|
|
@@ -4357,6 +4373,16 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
|
|
|
4357
4373
|
const hybridParams = modelParams;
|
|
4358
4374
|
let inCloudParams;
|
|
4359
4375
|
if (hybridParams.mode) {
|
|
4376
|
+
for (const param of Object.keys(modelParams)) {
|
|
4377
|
+
if (!hybridParamKeys.includes(param)) {
|
|
4378
|
+
logger.warn(`When a hybrid inference mode is specified (mode is currently set` +
|
|
4379
|
+
` to ${hybridParams.mode}), "${param}" cannot be ` +
|
|
4380
|
+
`configured at the top level. Configuration for in-cloud and ` +
|
|
4381
|
+
`on-device must be done separately in inCloudParams and onDeviceParams. ` +
|
|
4382
|
+
`Configuration values set outside of inCloudParams and onDeviceParams will` +
|
|
4383
|
+
` be ignored.`);
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4360
4386
|
inCloudParams = hybridParams.inCloudParams || {
|
|
4361
4387
|
model: DEFAULT_HYBRID_IN_CLOUD_MODEL
|
|
4362
4388
|
};
|