Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/tall-zoos-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'firebase': minor
'@firebase/vertexai': minor
---

Add support for the Google AI API, enabling usage in a free tier, and add new `AI` API to accomodate new product naming.
197 changes: 148 additions & 49 deletions common/api-review/vertexai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,62 @@ import { FirebaseApp } from '@firebase/app';
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
import { FirebaseError } from '@firebase/util';

// @public
export interface AI {
app: FirebaseApp;
backend: Backend;
// @deprecated
location: string;
}

// @public
export class AIError extends FirebaseError {
constructor(code: AIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
// (undocumented)
readonly code: AIErrorCode;
// (undocumented)
readonly customErrorData?: CustomErrorData | undefined;
}

// @public
const enum AIErrorCode {
API_NOT_ENABLED = "api-not-enabled",
ERROR = "error",
FETCH_ERROR = "fetch-error",
INVALID_CONTENT = "invalid-content",
INVALID_SCHEMA = "invalid-schema",
NO_API_KEY = "no-api-key",
NO_APP_ID = "no-app-id",
NO_MODEL = "no-model",
NO_PROJECT_ID = "no-project-id",
PARSE_FAILED = "parse-failed",
REQUEST_ERROR = "request-error",
RESPONSE_ERROR = "response-error",
UNSUPPORTED = "unsupported"
}

export { AIErrorCode }

export { AIErrorCode as VertexAIErrorCode }

// @public
export abstract class AIModel {
// @internal
protected constructor(ai: AI, modelName: string);
// Warning: (ae-forgotten-export) The symbol "ApiSettings" needs to be exported by the entry point index.d.ts
//
// @internal (undocumented)
protected _apiSettings: ApiSettings;
readonly model: string;
// @internal
static normalizeModelName(modelName: string, backendType: BackendType): string;
}

// @public
export interface AIOptions {
backend: Backend;
}

// @public
export class ArraySchema extends Schema {
constructor(schemaParams: SchemaParams, items: TypedSchema);
Expand All @@ -18,6 +74,21 @@ export class ArraySchema extends Schema {
toJSON(): SchemaRequest;
}

// @public
export abstract class Backend {
protected constructor(type: BackendType);
readonly backendType: BackendType;
}

// @public
export const BackendType: {
readonly VERTEX_AI: "VERTEX_AI";
readonly GOOGLE_AI: "GOOGLE_AI";
};

// @public
export type BackendType = (typeof BackendType)[keyof typeof BackendType];

// @public
export interface BaseParams {
// (undocumented)
Expand All @@ -41,7 +112,6 @@ export class BooleanSchema extends Schema {

// @public
export class ChatSession {
// Warning: (ae-forgotten-export) The symbol "ApiSettings" needs to be exported by the entry point index.d.ts
constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined);
getHistory(): Promise<Content[]>;
// (undocumented)
Expand All @@ -60,11 +130,9 @@ export interface Citation {
endIndex?: number;
// (undocumented)
license?: string;
// (undocumented)
publicationDate?: Date_2;
// (undocumented)
startIndex?: number;
// (undocumented)
title?: string;
// (undocumented)
uri?: string;
Expand Down Expand Up @@ -323,8 +391,8 @@ export interface GenerativeContentBlob {
}

// @public
export class GenerativeModel extends VertexAIModel {
constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions);
export class GenerativeModel extends AIModel {
constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions);
countTokens(request: CountTokensRequest | string | Array<string | Part>): Promise<CountTokensResponse>;
generateContent(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentResult>;
generateContentStream(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentStreamResult>;
Expand All @@ -344,14 +412,76 @@ export class GenerativeModel extends VertexAIModel {
}

// @public
export function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
export function getAI(app?: FirebaseApp, options?: AIOptions): AI;

// @public
export function getGenerativeModel(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;

// @beta
export function getImagenModel(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
export function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;

// @public
export function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI;

// @public
export class GoogleAIBackend extends Backend {
constructor();
}

// Warning: (ae-internal-missing-underscore) The name "GoogleAICitationMetadata" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export interface GoogleAICitationMetadata {
// (undocumented)
citationSources: Citation[];
}

// Warning: (ae-internal-missing-underscore) The name "GoogleAICountTokensRequest" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export interface GoogleAICountTokensRequest {
// (undocumented)
generateContentRequest: {
model: string;
contents: Content[];
systemInstruction?: string | Part | Content;
tools?: Tool[];
generationConfig?: GenerationConfig;
};
}

// Warning: (ae-internal-missing-underscore) The name "GoogleAIGenerateContentCandidate" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export interface GoogleAIGenerateContentCandidate {
// (undocumented)
citationMetadata?: GoogleAICitationMetadata;
// (undocumented)
content: Content;
// (undocumented)
finishMessage?: string;
// (undocumented)
finishReason?: FinishReason;
// (undocumented)
groundingMetadata?: GroundingMetadata;
// (undocumented)
index: number;
// (undocumented)
safetyRatings?: SafetyRating[];
}

// Warning: (ae-internal-missing-underscore) The name "GoogleAIGenerateContentResponse" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export interface GoogleAIGenerateContentResponse {
// (undocumented)
candidates?: GoogleAIGenerateContentCandidate[];
// (undocumented)
promptFeedback?: PromptFeedback;
// (undocumented)
usageMetadata?: UsageMetadata;
}

// @public @deprecated (undocumented)
export interface GroundingAttribution {
// (undocumented)
Expand All @@ -374,7 +504,7 @@ export interface GroundingMetadata {
webSearchQueries?: string[];
}

// @public (undocumented)
// @public
export enum HarmBlockMethod {
PROBABILITY = "PROBABILITY",
SEVERITY = "SEVERITY"
Expand Down Expand Up @@ -413,7 +543,8 @@ export enum HarmSeverity {
HARM_SEVERITY_HIGH = "HARM_SEVERITY_HIGH",
HARM_SEVERITY_LOW = "HARM_SEVERITY_LOW",
HARM_SEVERITY_MEDIUM = "HARM_SEVERITY_MEDIUM",
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE"
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE",
HARM_SEVERITY_UNSUPPORTED = "HARM_SEVERITY_UNSUPPORTED"
}

// @beta
Expand Down Expand Up @@ -461,8 +592,8 @@ export interface ImagenInlineImage {
}

// @beta
export class ImagenModel extends VertexAIModel {
constructor(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined);
export class ImagenModel extends AIModel {
constructor(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined);
generateImages(prompt: string): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
// @internal
generateImagesGCS(prompt: string, gcsURI: string): Promise<ImagenGenerationResponse<ImagenGCSImage>>;
Expand Down Expand Up @@ -584,7 +715,6 @@ export const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"];
export interface PromptFeedback {
// (undocumented)
blockReason?: BlockReason;
// (undocumented)
blockReasonMessage?: string;
// (undocumented)
safetyRatings: SafetyRating[];
Expand Down Expand Up @@ -615,19 +745,15 @@ export interface SafetyRating {
category: HarmCategory;
// (undocumented)
probability: HarmProbability;
// (undocumented)
probabilityScore: number;
// (undocumented)
severity: HarmSeverity;
// (undocumented)
severityScore: number;
}

// @public
export interface SafetySetting {
// (undocumented)
category: HarmCategory;
// (undocumented)
method?: HarmBlockMethod;
// (undocumented)
threshold: HarmBlockThreshold;
Expand Down Expand Up @@ -779,46 +905,19 @@ export interface UsageMetadata {
}

// @public
export interface VertexAI {
app: FirebaseApp;
// (undocumented)
location: string;
}
export type VertexAI = AI;

// @public
export class VertexAIError extends FirebaseError {
constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
// (undocumented)
readonly code: VertexAIErrorCode;
// (undocumented)
readonly customErrorData?: CustomErrorData | undefined;
export class VertexAIBackend extends Backend {
constructor(location?: string);
readonly location: string;
}

// @public
export const enum VertexAIErrorCode {
API_NOT_ENABLED = "api-not-enabled",
ERROR = "error",
FETCH_ERROR = "fetch-error",
INVALID_CONTENT = "invalid-content",
INVALID_SCHEMA = "invalid-schema",
NO_API_KEY = "no-api-key",
NO_APP_ID = "no-app-id",
NO_MODEL = "no-model",
NO_PROJECT_ID = "no-project-id",
PARSE_FAILED = "parse-failed",
REQUEST_ERROR = "request-error",
RESPONSE_ERROR = "response-error"
}
export const VertexAIError: typeof AIError;

// @public
export abstract class VertexAIModel {
// @internal
protected constructor(vertexAI: VertexAI, modelName: string);
// @internal (undocumented)
protected _apiSettings: ApiSettings;
readonly model: string;
static normalizeModelName(modelName: string): string;
}
export const VertexAIModel: typeof AIModel;

// @public
export interface VertexAIOptions {
Expand Down
3 changes: 2 additions & 1 deletion config/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ module.exports = {
}
}
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
// We prefer using interfaces, but we need to use types for aliases like '
// '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
Expand Down
14 changes: 8 additions & 6 deletions docs-devsite/_toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,14 @@ toc:
- title: vertexai
path: /docs/reference/js/vertexai.md
section:
- title: AI
path: /docs/reference/js/vertexai.ai.md
- title: AIError
path: /docs/reference/js/vertexai.aierror.md
- title: AIModel
path: /docs/reference/js/vertexai.aimodel.md
- title: AIOptions
path: /docs/reference/js/vertexai.aioptions.md
- title: ArraySchema
path: /docs/reference/js/vertexai.arrayschema.md
- title: BaseParams
Expand Down Expand Up @@ -598,12 +606,6 @@ toc:
path: /docs/reference/js/vertexai.toolconfig.md
- title: UsageMetadata
path: /docs/reference/js/vertexai.usagemetadata.md
- title: VertexAI
path: /docs/reference/js/vertexai.vertexai.md
- title: VertexAIError
path: /docs/reference/js/vertexai.vertexaierror.md
- title: VertexAIModel
path: /docs/reference/js/vertexai.vertexaimodel.md
- title: VertexAIOptions
path: /docs/reference/js/vertexai.vertexaioptions.md
- title: VideoMetadata
Expand Down
2 changes: 1 addition & 1 deletion docs-devsite/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ https://github.com/firebase/firebase-js-sdk
| [@firebase/performance](./performance.md#performance_package) | The Firebase Performance Monitoring Web SDK. This SDK does not work in a Node.js environment. |
| [@firebase/remote-config](./remote-config.md#remote-config_package) | The Firebase Remote Config Web SDK. This SDK does not work in a Node.js environment. |
| [@firebase/storage](./storage.md#storage_package) | Cloud Storage for Firebase |
| [@firebase/vertexai](./vertexai.md#vertexai_package) | The Vertex AI in Firebase Web SDK. |
| [@firebase/vertexai](./vertexai.md#vertexai_package) | The Firebase AI Web SDK. |

Loading