@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
|
@@ -103,6 +103,16 @@ export interface GenerationConfig {
|
|
|
103
103
|
* this is limited to `application/json` and `text/x.enum`.
|
|
104
104
|
*/
|
|
105
105
|
responseSchema?: TypedSchema | SchemaRequest;
|
|
106
|
+
/**
|
|
107
|
+
* Output schema of the generated response. This is an alternative to
|
|
108
|
+
* `responseSchema` that accepts [JSON Schema](https://json-schema.org/).
|
|
109
|
+
*
|
|
110
|
+
* If set, `responseSchema` must be omitted, but `responseMimeType`
|
|
111
|
+
* is required and must be set to `application/json`.
|
|
112
|
+
*/
|
|
113
|
+
responseJsonSchema?: {
|
|
114
|
+
[key: string]: unknown;
|
|
115
|
+
};
|
|
106
116
|
/**
|
|
107
117
|
* Generation modalities to be returned in generation responses.
|
|
108
118
|
*
|
package/dist/index.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ var util = require('@firebase/util');
|
|
|
8
8
|
var logger$1 = require('@firebase/logger');
|
|
9
9
|
|
|
10
10
|
var name = "@firebase/ai";
|
|
11
|
-
var version = "2.
|
|
11
|
+
var version = "2.10.0";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -3138,6 +3138,17 @@ function validateGenerationConfig(generationConfig) {
|
|
|
3138
3138
|
generationConfig.thinkingConfig?.thinkingLevel) {
|
|
3139
3139
|
throw new AIError(AIErrorCode.UNSUPPORTED, `Cannot set both thinkingBudget and thinkingLevel in a config.`);
|
|
3140
3140
|
}
|
|
3141
|
+
if (
|
|
3142
|
+
// != allows for null and undefined.
|
|
3143
|
+
generationConfig.responseSchema != null &&
|
|
3144
|
+
generationConfig.responseJsonSchema != null) {
|
|
3145
|
+
throw new AIError(AIErrorCode.UNSUPPORTED, `Cannot set both responseSchema and responseJsonSchema in a config.`);
|
|
3146
|
+
}
|
|
3147
|
+
if ((generationConfig.responseSchema != null ||
|
|
3148
|
+
generationConfig.responseJsonSchema != null) &&
|
|
3149
|
+
generationConfig.responseMimeType) {
|
|
3150
|
+
throw new AIError(AIErrorCode.UNSUPPORTED, `responseMimeType must be set if responseSchema or responseJsonSchema are set.`);
|
|
3151
|
+
}
|
|
3141
3152
|
}
|
|
3142
3153
|
|
|
3143
3154
|
/**
|
|
@@ -4658,6 +4669,11 @@ function getAI(app$1 = app.getApp(), options) {
|
|
|
4658
4669
|
aiInstance.options = finalOptions;
|
|
4659
4670
|
return aiInstance;
|
|
4660
4671
|
}
|
|
4672
|
+
const hybridParamKeys = [
|
|
4673
|
+
'mode',
|
|
4674
|
+
'onDeviceParams',
|
|
4675
|
+
'inCloudParams'
|
|
4676
|
+
];
|
|
4661
4677
|
/**
|
|
4662
4678
|
* Returns a {@link GenerativeModel} class with methods for inference
|
|
4663
4679
|
* and other functionality.
|
|
@@ -4669,6 +4685,16 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
|
|
|
4669
4685
|
const hybridParams = modelParams;
|
|
4670
4686
|
let inCloudParams;
|
|
4671
4687
|
if (hybridParams.mode) {
|
|
4688
|
+
for (const param of Object.keys(modelParams)) {
|
|
4689
|
+
if (!hybridParamKeys.includes(param)) {
|
|
4690
|
+
logger.warn(`When a hybrid inference mode is specified (mode is currently set` +
|
|
4691
|
+
` to ${hybridParams.mode}), "${param}" cannot be ` +
|
|
4692
|
+
`configured at the top level. Configuration for in-cloud and ` +
|
|
4693
|
+
`on-device must be done separately in inCloudParams and onDeviceParams. ` +
|
|
4694
|
+
`Configuration values set outside of inCloudParams and onDeviceParams will` +
|
|
4695
|
+
` be ignored.`);
|
|
4696
|
+
}
|
|
4697
|
+
}
|
|
4672
4698
|
inCloudParams = hybridParams.inCloudParams || {
|
|
4673
4699
|
model: DEFAULT_HYBRID_IN_CLOUD_MODEL
|
|
4674
4700
|
};
|