@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/ai-public.d.ts
CHANGED
|
@@ -960,6 +960,16 @@ export declare interface GenerationConfig {
|
|
|
960
960
|
* this is limited to `application/json` and `text/x.enum`.
|
|
961
961
|
*/
|
|
962
962
|
responseSchema?: TypedSchema | SchemaRequest;
|
|
963
|
+
/**
|
|
964
|
+
* Output schema of the generated response. This is an alternative to
|
|
965
|
+
* `responseSchema` that accepts [JSON Schema](https://json-schema.org/).
|
|
966
|
+
*
|
|
967
|
+
* If set, `responseSchema` must be omitted, but `responseMimeType`
|
|
968
|
+
* is required and must be set to `application/json`.
|
|
969
|
+
*/
|
|
970
|
+
responseJsonSchema?: {
|
|
971
|
+
[key: string]: unknown;
|
|
972
|
+
};
|
|
963
973
|
/**
|
|
964
974
|
* Generation modalities to be returned in generation responses.
|
|
965
975
|
*
|
package/dist/ai.d.ts
CHANGED
|
@@ -1045,6 +1045,16 @@ export declare interface GenerationConfig {
|
|
|
1045
1045
|
* this is limited to `application/json` and `text/x.enum`.
|
|
1046
1046
|
*/
|
|
1047
1047
|
responseSchema?: TypedSchema | SchemaRequest;
|
|
1048
|
+
/**
|
|
1049
|
+
* Output schema of the generated response. This is an alternative to
|
|
1050
|
+
* `responseSchema` that accepts [JSON Schema](https://json-schema.org/).
|
|
1051
|
+
*
|
|
1052
|
+
* If set, `responseSchema` must be omitted, but `responseMimeType`
|
|
1053
|
+
* is required and must be set to `application/json`.
|
|
1054
|
+
*/
|
|
1055
|
+
responseJsonSchema?: {
|
|
1056
|
+
[key: string]: unknown;
|
|
1057
|
+
};
|
|
1048
1058
|
/**
|
|
1049
1059
|
* Generation modalities to be returned in generation responses.
|
|
1050
1060
|
*
|
package/dist/esm/index.esm.js
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
|
|
@@ -3134,6 +3134,17 @@ function validateGenerationConfig(generationConfig) {
|
|
|
3134
3134
|
generationConfig.thinkingConfig?.thinkingLevel) {
|
|
3135
3135
|
throw new AIError(AIErrorCode.UNSUPPORTED, `Cannot set both thinkingBudget and thinkingLevel in a config.`);
|
|
3136
3136
|
}
|
|
3137
|
+
if (
|
|
3138
|
+
// != allows for null and undefined.
|
|
3139
|
+
generationConfig.responseSchema != null &&
|
|
3140
|
+
generationConfig.responseJsonSchema != null) {
|
|
3141
|
+
throw new AIError(AIErrorCode.UNSUPPORTED, `Cannot set both responseSchema and responseJsonSchema in a config.`);
|
|
3142
|
+
}
|
|
3143
|
+
if ((generationConfig.responseSchema != null ||
|
|
3144
|
+
generationConfig.responseJsonSchema != null) &&
|
|
3145
|
+
generationConfig.responseMimeType) {
|
|
3146
|
+
throw new AIError(AIErrorCode.UNSUPPORTED, `responseMimeType must be set if responseSchema or responseJsonSchema are set.`);
|
|
3147
|
+
}
|
|
3137
3148
|
}
|
|
3138
3149
|
|
|
3139
3150
|
/**
|
|
@@ -4654,6 +4665,11 @@ function getAI(app = getApp(), options) {
|
|
|
4654
4665
|
aiInstance.options = finalOptions;
|
|
4655
4666
|
return aiInstance;
|
|
4656
4667
|
}
|
|
4668
|
+
const hybridParamKeys = [
|
|
4669
|
+
'mode',
|
|
4670
|
+
'onDeviceParams',
|
|
4671
|
+
'inCloudParams'
|
|
4672
|
+
];
|
|
4657
4673
|
/**
|
|
4658
4674
|
* Returns a {@link GenerativeModel} class with methods for inference
|
|
4659
4675
|
* and other functionality.
|
|
@@ -4665,6 +4681,16 @@ function getGenerativeModel(ai, modelParams, requestOptions) {
|
|
|
4665
4681
|
const hybridParams = modelParams;
|
|
4666
4682
|
let inCloudParams;
|
|
4667
4683
|
if (hybridParams.mode) {
|
|
4684
|
+
for (const param of Object.keys(modelParams)) {
|
|
4685
|
+
if (!hybridParamKeys.includes(param)) {
|
|
4686
|
+
logger.warn(`When a hybrid inference mode is specified (mode is currently set` +
|
|
4687
|
+
` to ${hybridParams.mode}), "${param}" cannot be ` +
|
|
4688
|
+
`configured at the top level. Configuration for in-cloud and ` +
|
|
4689
|
+
`on-device must be done separately in inCloudParams and onDeviceParams. ` +
|
|
4690
|
+
`Configuration values set outside of inCloudParams and onDeviceParams will` +
|
|
4691
|
+
` be ignored.`);
|
|
4692
|
+
}
|
|
4693
|
+
}
|
|
4668
4694
|
inCloudParams = hybridParams.inCloudParams || {
|
|
4669
4695
|
model: DEFAULT_HYBRID_IN_CLOUD_MODEL
|
|
4670
4696
|
};
|