@firebase/ai 1.4.1-canary.2d720995d → 1.4.1-canary.5200f7bb7

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.
@@ -4,7 +4,7 @@ import { FirebaseError, getModularInstance } from '@firebase/util';
4
4
  import { Logger } from '@firebase/logger';
5
5
 
6
6
  var name = "@firebase/ai";
7
- var version = "1.4.1-canary.2d720995d";
7
+ var version = "1.4.1-canary.5200f7bb7";
8
8
 
9
9
  /**
10
10
  * @license
@@ -2307,12 +2307,19 @@ class ImagenModel extends AIModel {
2307
2307
  */
2308
2308
  class Schema {
2309
2309
  constructor(schemaParams) {
2310
+ // TODO(dlarocque): Enforce this with union types
2311
+ if (!schemaParams.type && !schemaParams.anyOf) {
2312
+ throw new AIError(AIErrorCode.INVALID_SCHEMA, "A schema must have either a 'type' or an 'anyOf' array of sub-schemas.");
2313
+ }
2310
2314
  // eslint-disable-next-line guard-for-in
2311
2315
  for (const paramKey in schemaParams) {
2312
2316
  this[paramKey] = schemaParams[paramKey];
2313
2317
  }
2314
2318
  // Ensure these are explicitly set to avoid TS errors.
2315
2319
  this.type = schemaParams.type;
2320
+ this.format = schemaParams.hasOwnProperty('format')
2321
+ ? schemaParams.format
2322
+ : undefined;
2316
2323
  this.nullable = schemaParams.hasOwnProperty('nullable')
2317
2324
  ? !!schemaParams.nullable
2318
2325
  : false;
@@ -2359,6 +2366,9 @@ class Schema {
2359
2366
  static boolean(booleanParams) {
2360
2367
  return new BooleanSchema(booleanParams);
2361
2368
  }
2369
+ static anyOf(anyOfParams) {
2370
+ return new AnyOfSchema(anyOfParams);
2371
+ }
2362
2372
  }
2363
2373
  /**
2364
2374
  * Schema class for "integer" types.
@@ -2486,6 +2496,34 @@ class ObjectSchema extends Schema {
2486
2496
  return obj;
2487
2497
  }
2488
2498
  }
2499
+ /**
2500
+ * Schema class representing a value that can conform to any of the provided sub-schemas. This is
2501
+ * useful when a field can accept multiple distinct types or structures.
2502
+ * @public
2503
+ */
2504
+ class AnyOfSchema extends Schema {
2505
+ constructor(schemaParams) {
2506
+ if (schemaParams.anyOf.length === 0) {
2507
+ throw new AIError(AIErrorCode.INVALID_SCHEMA, "The 'anyOf' array must not be empty.");
2508
+ }
2509
+ super({
2510
+ ...schemaParams,
2511
+ type: undefined // anyOf schemas do not have an explicit type
2512
+ });
2513
+ this.anyOf = schemaParams.anyOf;
2514
+ }
2515
+ /**
2516
+ * @internal
2517
+ */
2518
+ toJSON() {
2519
+ const obj = super.toJSON();
2520
+ // Ensure the 'anyOf' property contains serialized SchemaRequest objects.
2521
+ if (this.anyOf && Array.isArray(this.anyOf)) {
2522
+ obj.anyOf = this.anyOf.map(s => s.toJSON());
2523
+ }
2524
+ return obj;
2525
+ }
2526
+ }
2489
2527
 
2490
2528
  /**
2491
2529
  * @license
@@ -2660,5 +2698,5 @@ function registerAI() {
2660
2698
  }
2661
2699
  registerAI();
2662
2700
 
2663
- export { AIError, AIErrorCode, AIModel, ArraySchema, Backend, BackendType, BlockReason, BooleanSchema, ChatSession, FinishReason, FunctionCallingMode, GenerativeModel, GoogleAIBackend, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, ImagenAspectRatio, ImagenImageFormat, ImagenModel, ImagenPersonFilterLevel, ImagenSafetyFilterLevel, IntegerSchema, Modality, NumberSchema, ObjectSchema, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, VertexAIBackend, getAI, getGenerativeModel, getImagenModel };
2701
+ export { AIError, AIErrorCode, AIModel, AnyOfSchema, ArraySchema, Backend, BackendType, BlockReason, BooleanSchema, ChatSession, FinishReason, FunctionCallingMode, GenerativeModel, GoogleAIBackend, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, ImagenAspectRatio, ImagenImageFormat, ImagenModel, ImagenPersonFilterLevel, ImagenSafetyFilterLevel, IntegerSchema, Modality, NumberSchema, ObjectSchema, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, VertexAIBackend, getAI, getGenerativeModel, getImagenModel };
2664
2702
  //# sourceMappingURL=index.node.mjs.map