vertexAI static method
FirebaseAI
vertexAI({
- FirebaseApp? app,
- @Deprecated('Passing an explicit instance is deprecated, internal handling is now automatic.') FirebaseAppCheck? appCheck,
- @Deprecated('Passing an explicit instance is deprecated, internal handling is now automatic.') FirebaseAuth? auth,
- String? location,
- bool? useLimitedUseAppCheckTokens,
Returns an instance using a specified FirebaseApp.
If app is not provided, the default Firebase app will be used.
If pass in appCheck, request session will get protected from abusing.
Implementation
static FirebaseAI vertexAI({
FirebaseApp? app,
@Deprecated(
'Passing an explicit instance is deprecated, internal handling is now automatic.')
FirebaseAppCheck? appCheck,
@Deprecated(
'Passing an explicit instance is deprecated, internal handling is now automatic.')
FirebaseAuth? auth,
String? location,
bool? useLimitedUseAppCheckTokens,
}) {
app ??= Firebase.app();
appCheck ??= app.getService<FirebaseAppCheck>();
auth ??= app.getService<FirebaseAuth>();
var instanceKey = '${app.name}::vertexai::$location';
if (_cachedInstances.containsKey(instanceKey)) {
return _cachedInstances[instanceKey]!;
}
location ??= _defaultLocation;
FirebaseAI newInstance = FirebaseAI._(
app: app,
location: location,
appCheck: appCheck,
auth: auth,
useVertexBackend: true,
useLimitedUseAppCheckTokens: useLimitedUseAppCheckTokens ?? false,
);
_cachedInstances[instanceKey] = newInstance;
return newInstance;
}