/** * @license * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { ReactNativeFirebase } from '@react-native-firebase/app'; import type { Auth } from '@react-native-firebase/auth'; import type { AppCheck } from '@react-native-firebase/app-check'; import { Backend } from './backend'; export * from './types'; export { Backend }; /** * An instance of the Firebase AI SDK. * * Do not create this instance directly. Instead, use {@link getAI | getAI()}. * * @public */ export interface AI { /** * The {@link @firebase/app!FirebaseApp} this {@link AI} instance is associated with. */ app: ReactNativeFirebase.FirebaseApp; appCheck?: AppCheck | null; auth?: Auth | null; /** * A {@link Backend} instance that specifies the configuration for the target backend, * either the Gemini Developer API (using {@link GoogleAIBackend}) or the * Agent Platform Gemini API (using {@link AgentPlatformBackend}). */ backend: Backend; /** * Options applied to this {@link AI} instance. */ options?: AIOptions; /** * @deprecated use `AI.backend.location` instead. * * The location configured for this AI service instance, relevant for * Agent Platform Gemini API backends. */ location: string; } /** * An enum-like object containing constants that represent the supported backends * for the Firebase AI SDK. * This determines which backend service (Gemini Developer API or Agent Platform Gemini API) * the SDK will communicate with. * * These values are assigned to the `backendType` property within the specific backend * configuration objects ({@link GoogleAIBackend} or {@link AgentPlatformBackend}) to identify * which service to target. * * @public */ export const BackendType = { /** * Identifies the backend service for the Agent Platform Gemini API provided through Google Cloud. * Use this constant when creating a {@link AgentPlatformBackend} configuration. */ AGENT_PLATFORM: 'AGENT_PLATFORM', /** * Identifies the backend service for the Agent Platform Gemini API * (formerly known as Vertex AI Gemini API) provided through Google Cloud. * Use this constant when creating a {@link VertexAIBackend} configuration. * @deprecated Use {@link AgentPlatformBackend} instead. */ VERTEX_AI: 'VERTEX_AI', /** * Identifies the backend service for the Gemini Developer API ({@link https://ai.google/ | Google AI}). * Use this constant when creating a {@link GoogleAIBackend} configuration. */ GOOGLE_AI: 'GOOGLE_AI', } as const; // Using 'as const' makes the string values literal types /** * Type alias representing valid backend types. * It should be either `'AGENT_PLATFORM'` or `'GOOGLE_AI'` (`'VERTEX_AI'` is deprecated). * * @public */ export type BackendType = (typeof BackendType)[keyof typeof BackendType]; /** * Options for initializing the AI service using {@link getAI | getAI()}. * This allows specifying which backend to use (Gemini Developer API or Agent Platform Gemini API) * and configuring its specific options (like location for Agent Platform). * * @public */ export interface AIOptions { /** * The backend configuration to use for the AI service instance. * Defaults to the Gemini Developer API backend ({@link GoogleAIBackend}). */ backend?: Backend; /** * Whether to use App Check limited use tokens. Defaults to false. */ useLimitedUseAppCheckTokens?: boolean; appCheck?: AppCheck | null; auth?: Auth | null; }