@firebase/ai 2.1.0-canary.02280d747 → 2.1.0-canary.2058432e6

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,17 +4,10 @@
4
4
  * @packageDocumentation
5
5
  */
6
6
 
7
- import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
8
7
  import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
9
- import { ComponentContainer } from '@firebase/component';
10
8
  import { FirebaseApp } from '@firebase/app';
11
- import { FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
12
- import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
13
- import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
14
9
  import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
15
10
  import { FirebaseError } from '@firebase/util';
16
- import { InstanceFactoryOptions } from '@firebase/component';
17
- import { Provider } from '@firebase/component';
18
11
 
19
12
  /**
20
13
  * An instance of the Firebase AI SDK.
@@ -34,10 +27,6 @@ export declare interface AI {
34
27
  * Vertex AI Gemini API (using {@link VertexAIBackend}).
35
28
  */
36
29
  backend: Backend;
37
- /**
38
- * Options applied to this {@link AI} instance.
39
- */
40
- options?: AIOptions;
41
30
  /**
42
31
  * @deprecated use `AI.backend.location` instead.
43
32
  *
@@ -136,26 +125,8 @@ export declare abstract class AIModel {
136
125
  export declare interface AIOptions {
137
126
  /**
138
127
  * The backend configuration to use for the AI service instance.
139
- * Defaults to the Gemini Developer API backend ({@link GoogleAIBackend}).
140
128
  */
141
- backend?: Backend;
142
- /**
143
- * Whether to use App Check limited use tokens. Defaults to false.
144
- */
145
- useLimitedUseAppCheckTokens?: boolean;
146
- }
147
-
148
- declare class AIService implements AI, _FirebaseService {
149
- app: FirebaseApp;
150
129
  backend: Backend;
151
- auth: FirebaseAuthInternal | null;
152
- appCheck: FirebaseAppCheckInternal | null;
153
- _options?: Omit<AIOptions, 'backend'>;
154
- location: string;
155
- constructor(app: FirebaseApp, backend: Backend, authProvider?: Provider<FirebaseAuthInternalName>, appCheckProvider?: Provider<AppCheckInternalComponentName>);
156
- _delete(): Promise<void>;
157
- set options(optionsToSet: AIOptions);
158
- get options(): AIOptions | undefined;
159
130
  }
160
131
 
161
132
  /**
@@ -516,8 +487,6 @@ export declare interface ErrorDetails {
516
487
  [key: string]: unknown;
517
488
  }
518
489
 
519
- export declare function factory(container: ComponentContainer, { instanceIdentifier }: InstanceFactoryOptions): AIService;
520
-
521
490
  /**
522
491
  * Data pointing to a file uploaded on Google Cloud Storage.
523
492
  * @public
@@ -588,8 +557,6 @@ export declare const FinishReason: {
588
557
  */
589
558
  export declare type FinishReason = (typeof FinishReason)[keyof typeof FinishReason];
590
559
 
591
- /* Excluded from this release type: _FirebaseService */
592
-
593
560
  /**
594
561
  * A predicted {@link FunctionCall} returned from the model
595
562
  * that contains a string representing the {@link FunctionDeclaration.name}
package/dist/ai.d.ts CHANGED
@@ -4,18 +4,10 @@
4
4
  * @packageDocumentation
5
5
  */
6
6
 
7
- import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
8
7
  import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
9
- import { ComponentContainer } from '@firebase/component';
10
8
  import { FirebaseApp } from '@firebase/app';
11
- import { FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
12
- import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
13
- import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
14
9
  import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
15
10
  import { FirebaseError } from '@firebase/util';
16
- import { _FirebaseService } from '@firebase/app';
17
- import { InstanceFactoryOptions } from '@firebase/component';
18
- import { Provider } from '@firebase/component';
19
11
 
20
12
  /**
21
13
  * An instance of the Firebase AI SDK.
@@ -35,10 +27,6 @@ export declare interface AI {
35
27
  * Vertex AI Gemini API (using {@link VertexAIBackend}).
36
28
  */
37
29
  backend: Backend;
38
- /**
39
- * Options applied to this {@link AI} instance.
40
- */
41
- options?: AIOptions;
42
30
  /**
43
31
  * @deprecated use `AI.backend.location` instead.
44
32
  *
@@ -123,7 +111,7 @@ export declare abstract class AIModel {
123
111
  /**
124
112
  * @internal
125
113
  */
126
- _apiSettings: ApiSettings;
114
+ protected _apiSettings: ApiSettings;
127
115
  /**
128
116
  * Constructs a new instance of the {@link AIModel} class.
129
117
  *
@@ -171,26 +159,8 @@ export declare abstract class AIModel {
171
159
  export declare interface AIOptions {
172
160
  /**
173
161
  * The backend configuration to use for the AI service instance.
174
- * Defaults to the Gemini Developer API backend ({@link GoogleAIBackend}).
175
162
  */
176
- backend?: Backend;
177
- /**
178
- * Whether to use App Check limited use tokens. Defaults to false.
179
- */
180
- useLimitedUseAppCheckTokens?: boolean;
181
- }
182
-
183
- declare class AIService implements AI, _FirebaseService {
184
- app: FirebaseApp;
185
163
  backend: Backend;
186
- auth: FirebaseAuthInternal | null;
187
- appCheck: FirebaseAppCheckInternal | null;
188
- _options?: Omit<AIOptions, 'backend'>;
189
- location: string;
190
- constructor(app: FirebaseApp, backend: Backend, authProvider?: Provider<FirebaseAuthInternalName>, appCheckProvider?: Provider<AppCheckInternalComponentName>);
191
- _delete(): Promise<void>;
192
- set options(optionsToSet: AIOptions);
193
- get options(): AIOptions | undefined;
194
164
  }
195
165
 
196
166
  /**
@@ -560,8 +530,6 @@ export declare interface ErrorDetails {
560
530
  [key: string]: unknown;
561
531
  }
562
532
 
563
- export declare function factory(container: ComponentContainer, { instanceIdentifier }: InstanceFactoryOptions): AIService;
564
-
565
533
  /**
566
534
  * Data pointing to a file uploaded on Google Cloud Storage.
567
535
  * @public
@@ -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 = "2.1.0-canary.02280d747";
7
+ var version = "2.1.0-canary.2058432e6";
8
8
 
9
9
  /**
10
10
  * @license
@@ -653,12 +653,6 @@ class AIService {
653
653
  _delete() {
654
654
  return Promise.resolve();
655
655
  }
656
- set options(optionsToSet) {
657
- this._options = optionsToSet;
658
- }
659
- get options() {
660
- return this._options;
661
- }
662
656
  }
663
657
 
664
658
  /**
@@ -843,12 +837,7 @@ class AIModel {
843
837
  };
844
838
  }
845
839
  else if (ai.appCheck) {
846
- if (ai.options?.useLimitedUseAppCheckTokens) {
847
- this._apiSettings.getAppCheckToken = () => ai.appCheck.getLimitedUseToken();
848
- }
849
- else {
850
- this._apiSettings.getAppCheckToken = () => ai.appCheck.getToken();
851
- }
840
+ this._apiSettings.getAppCheckToken = () => ai.appCheck.getToken();
852
841
  }
853
842
  if (ai.auth) {
854
843
  this._apiSettings.getAuthToken = () => ai.auth.getToken();
@@ -2970,20 +2959,14 @@ class ImagenImageFormat {
2970
2959
  *
2971
2960
  * @public
2972
2961
  */
2973
- function getAI(app = getApp(), options) {
2962
+ function getAI(app = getApp(), options = { backend: new GoogleAIBackend() }) {
2974
2963
  app = getModularInstance(app);
2975
2964
  // Dependencies
2976
2965
  const AIProvider = _getProvider(app, AI_TYPE);
2977
- const backend = options?.backend ?? new GoogleAIBackend();
2978
- const finalOptions = {
2979
- useLimitedUseAppCheckTokens: options?.useLimitedUseAppCheckTokens ?? false
2980
- };
2981
- const identifier = encodeInstanceIdentifier(backend);
2982
- const aiInstance = AIProvider.getImmediate({
2966
+ const identifier = encodeInstanceIdentifier(options.backend);
2967
+ return AIProvider.getImmediate({
2983
2968
  identifier
2984
2969
  });
2985
- aiInstance.options = finalOptions;
2986
- return aiInstance;
2987
2970
  }
2988
2971
  /**
2989
2972
  * Returns a {@link GenerativeModel} class with methods for inference
@@ -3039,24 +3022,23 @@ function getImagenModel(ai, modelParams, requestOptions) {
3039
3022
  *
3040
3023
  * @packageDocumentation
3041
3024
  */
3042
- function factory(container, { instanceIdentifier }) {
3043
- if (!instanceIdentifier) {
3044
- throw new AIError(AIErrorCode.ERROR, 'AIService instance identifier is undefined.');
3045
- }
3046
- const backend = decodeInstanceIdentifier(instanceIdentifier);
3047
- // getImmediate for FirebaseApp will always succeed
3048
- const app = container.getProvider('app').getImmediate();
3049
- const auth = container.getProvider('auth-internal');
3050
- const appCheckProvider = container.getProvider('app-check-internal');
3051
- return new AIService(app, backend, auth, appCheckProvider);
3052
- }
3053
3025
  function registerAI() {
3054
- _registerComponent(new Component(AI_TYPE, factory, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));
3026
+ _registerComponent(new Component(AI_TYPE, (container, { instanceIdentifier }) => {
3027
+ if (!instanceIdentifier) {
3028
+ throw new AIError(AIErrorCode.ERROR, 'AIService instance identifier is undefined.');
3029
+ }
3030
+ const backend = decodeInstanceIdentifier(instanceIdentifier);
3031
+ // getImmediate for FirebaseApp will always succeed
3032
+ const app = container.getProvider('app').getImmediate();
3033
+ const auth = container.getProvider('auth-internal');
3034
+ const appCheckProvider = container.getProvider('app-check-internal');
3035
+ return new AIService(app, backend, auth, appCheckProvider);
3036
+ }, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));
3055
3037
  registerVersion(name, version);
3056
3038
  // BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation
3057
3039
  registerVersion(name, version, 'esm2020');
3058
3040
  }
3059
3041
  registerAI();
3060
3042
 
3061
- 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, InferenceMode, IntegerSchema, Modality, NumberSchema, ObjectSchema, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, VertexAIBackend, factory, getAI, getGenerativeModel, getImagenModel };
3043
+ 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, InferenceMode, IntegerSchema, Modality, NumberSchema, ObjectSchema, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, VertexAIBackend, getAI, getGenerativeModel, getImagenModel };
3062
3044
  //# sourceMappingURL=index.esm.js.map