@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.
- package/dist/ai-public.d.ts +0 -33
- package/dist/ai.d.ts +1 -33
- package/dist/esm/index.esm.js +17 -35
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/index.d.ts +0 -3
- package/dist/esm/src/models/ai-model.d.ts +1 -1
- package/dist/esm/src/public-types.d.ts +1 -10
- package/dist/esm/src/service.d.ts +1 -4
- package/dist/index.cjs.js +16 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +5 -22
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +5 -22
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/index.d.ts +0 -3
- package/dist/src/models/ai-model.d.ts +1 -1
- package/dist/src/public-types.d.ts +1 -10
- package/dist/src/service.d.ts +1 -4
- package/package.json +8 -8
package/dist/esm/src/index.d.ts
CHANGED
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import { AIService } from './service';
|
|
7
|
-
import { ComponentContainer, InstanceFactoryOptions } from '@firebase/component';
|
|
8
6
|
declare global {
|
|
9
7
|
interface Window {
|
|
10
8
|
[key: string]: unknown;
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
|
-
export declare function factory(container: ComponentContainer, { instanceIdentifier }: InstanceFactoryOptions): AIService;
|
|
14
11
|
export * from './api';
|
|
15
12
|
export * from './public-types';
|
|
@@ -35,10 +35,6 @@ export interface AI {
|
|
|
35
35
|
* Vertex AI Gemini API (using {@link VertexAIBackend}).
|
|
36
36
|
*/
|
|
37
37
|
backend: Backend;
|
|
38
|
-
/**
|
|
39
|
-
* Options applied to this {@link AI} instance.
|
|
40
|
-
*/
|
|
41
|
-
options?: AIOptions;
|
|
42
38
|
/**
|
|
43
39
|
* @deprecated use `AI.backend.location` instead.
|
|
44
40
|
*
|
|
@@ -87,11 +83,6 @@ export type BackendType = (typeof BackendType)[keyof typeof BackendType];
|
|
|
87
83
|
export interface AIOptions {
|
|
88
84
|
/**
|
|
89
85
|
* The backend configuration to use for the AI service instance.
|
|
90
|
-
* Defaults to the Gemini Developer API backend ({@link GoogleAIBackend}).
|
|
91
86
|
*/
|
|
92
|
-
backend
|
|
93
|
-
/**
|
|
94
|
-
* Whether to use App Check limited use tokens. Defaults to false.
|
|
95
|
-
*/
|
|
96
|
-
useLimitedUseAppCheckTokens?: boolean;
|
|
87
|
+
backend: Backend;
|
|
97
88
|
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { FirebaseApp, _FirebaseService } from '@firebase/app';
|
|
18
|
-
import { AI
|
|
18
|
+
import { AI } from './public-types';
|
|
19
19
|
import { AppCheckInternalComponentName, FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
|
|
20
20
|
import { Provider } from '@firebase/component';
|
|
21
21
|
import { FirebaseAuthInternal, FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
@@ -25,10 +25,7 @@ export declare class AIService implements AI, _FirebaseService {
|
|
|
25
25
|
backend: Backend;
|
|
26
26
|
auth: FirebaseAuthInternal | null;
|
|
27
27
|
appCheck: FirebaseAppCheckInternal | null;
|
|
28
|
-
_options?: Omit<AIOptions, 'backend'>;
|
|
29
28
|
location: string;
|
|
30
29
|
constructor(app: FirebaseApp, backend: Backend, authProvider?: Provider<FirebaseAuthInternalName>, appCheckProvider?: Provider<AppCheckInternalComponentName>);
|
|
31
30
|
_delete(): Promise<void>;
|
|
32
|
-
set options(optionsToSet: AIOptions);
|
|
33
|
-
get options(): AIOptions | undefined;
|
|
34
31
|
}
|
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.1.0-canary.
|
|
11
|
+
var version = "2.1.0-canary.2058432e6";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -657,12 +657,6 @@ class AIService {
|
|
|
657
657
|
_delete() {
|
|
658
658
|
return Promise.resolve();
|
|
659
659
|
}
|
|
660
|
-
set options(optionsToSet) {
|
|
661
|
-
this._options = optionsToSet;
|
|
662
|
-
}
|
|
663
|
-
get options() {
|
|
664
|
-
return this._options;
|
|
665
|
-
}
|
|
666
660
|
}
|
|
667
661
|
|
|
668
662
|
/**
|
|
@@ -847,12 +841,7 @@ class AIModel {
|
|
|
847
841
|
};
|
|
848
842
|
}
|
|
849
843
|
else if (ai.appCheck) {
|
|
850
|
-
|
|
851
|
-
this._apiSettings.getAppCheckToken = () => ai.appCheck.getLimitedUseToken();
|
|
852
|
-
}
|
|
853
|
-
else {
|
|
854
|
-
this._apiSettings.getAppCheckToken = () => ai.appCheck.getToken();
|
|
855
|
-
}
|
|
844
|
+
this._apiSettings.getAppCheckToken = () => ai.appCheck.getToken();
|
|
856
845
|
}
|
|
857
846
|
if (ai.auth) {
|
|
858
847
|
this._apiSettings.getAuthToken = () => ai.auth.getToken();
|
|
@@ -2974,20 +2963,14 @@ class ImagenImageFormat {
|
|
|
2974
2963
|
*
|
|
2975
2964
|
* @public
|
|
2976
2965
|
*/
|
|
2977
|
-
function getAI(app$1 = app.getApp(), options) {
|
|
2966
|
+
function getAI(app$1 = app.getApp(), options = { backend: new GoogleAIBackend() }) {
|
|
2978
2967
|
app$1 = util.getModularInstance(app$1);
|
|
2979
2968
|
// Dependencies
|
|
2980
2969
|
const AIProvider = app._getProvider(app$1, AI_TYPE);
|
|
2981
|
-
const
|
|
2982
|
-
|
|
2983
|
-
useLimitedUseAppCheckTokens: options?.useLimitedUseAppCheckTokens ?? false
|
|
2984
|
-
};
|
|
2985
|
-
const identifier = encodeInstanceIdentifier(backend);
|
|
2986
|
-
const aiInstance = AIProvider.getImmediate({
|
|
2970
|
+
const identifier = encodeInstanceIdentifier(options.backend);
|
|
2971
|
+
return AIProvider.getImmediate({
|
|
2987
2972
|
identifier
|
|
2988
2973
|
});
|
|
2989
|
-
aiInstance.options = finalOptions;
|
|
2990
|
-
return aiInstance;
|
|
2991
2974
|
}
|
|
2992
2975
|
/**
|
|
2993
2976
|
* Returns a {@link GenerativeModel} class with methods for inference
|
|
@@ -3043,19 +3026,18 @@ function getImagenModel(ai, modelParams, requestOptions) {
|
|
|
3043
3026
|
*
|
|
3044
3027
|
* @packageDocumentation
|
|
3045
3028
|
*/
|
|
3046
|
-
function factory(container, { instanceIdentifier }) {
|
|
3047
|
-
if (!instanceIdentifier) {
|
|
3048
|
-
throw new AIError(AIErrorCode.ERROR, 'AIService instance identifier is undefined.');
|
|
3049
|
-
}
|
|
3050
|
-
const backend = decodeInstanceIdentifier(instanceIdentifier);
|
|
3051
|
-
// getImmediate for FirebaseApp will always succeed
|
|
3052
|
-
const app = container.getProvider('app').getImmediate();
|
|
3053
|
-
const auth = container.getProvider('auth-internal');
|
|
3054
|
-
const appCheckProvider = container.getProvider('app-check-internal');
|
|
3055
|
-
return new AIService(app, backend, auth, appCheckProvider);
|
|
3056
|
-
}
|
|
3057
3029
|
function registerAI() {
|
|
3058
|
-
app._registerComponent(new component.Component(AI_TYPE,
|
|
3030
|
+
app._registerComponent(new component.Component(AI_TYPE, (container, { instanceIdentifier }) => {
|
|
3031
|
+
if (!instanceIdentifier) {
|
|
3032
|
+
throw new AIError(AIErrorCode.ERROR, 'AIService instance identifier is undefined.');
|
|
3033
|
+
}
|
|
3034
|
+
const backend = decodeInstanceIdentifier(instanceIdentifier);
|
|
3035
|
+
// getImmediate for FirebaseApp will always succeed
|
|
3036
|
+
const app = container.getProvider('app').getImmediate();
|
|
3037
|
+
const auth = container.getProvider('auth-internal');
|
|
3038
|
+
const appCheckProvider = container.getProvider('app-check-internal');
|
|
3039
|
+
return new AIService(app, backend, auth, appCheckProvider);
|
|
3040
|
+
}, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));
|
|
3059
3041
|
app.registerVersion(name, version);
|
|
3060
3042
|
// BUILD_TARGET will be replaced by values like esm, cjs, etc during the compilation
|
|
3061
3043
|
app.registerVersion(name, version, 'cjs2020');
|
|
@@ -3097,7 +3079,6 @@ exports.Schema = Schema;
|
|
|
3097
3079
|
exports.SchemaType = SchemaType;
|
|
3098
3080
|
exports.StringSchema = StringSchema;
|
|
3099
3081
|
exports.VertexAIBackend = VertexAIBackend;
|
|
3100
|
-
exports.factory = factory;
|
|
3101
3082
|
exports.getAI = getAI;
|
|
3102
3083
|
exports.getGenerativeModel = getGenerativeModel;
|
|
3103
3084
|
exports.getImagenModel = getImagenModel;
|