Skip to content

Commit 6e66af7

Browse files
authored
Merge 07f68ad into 6be75f7
2 parents 6be75f7 + 07f68ad commit 6e66af7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2765
-669
lines changed

.changeset/tall-zoos-stare.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'firebase': minor
3+
'@firebase/vertexai': minor
4+
---
5+
6+
Add support for the Gemini Developer API, enabling usage in a free tier, and add new `AI` API to accomodate new product naming.

common/api-review/vertexai.api.md

Lines changed: 148 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,62 @@ import { FirebaseApp } from '@firebase/app';
99
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
1010
import { FirebaseError } from '@firebase/util';
1111

12+
// @public
13+
export interface AI {
14+
app: FirebaseApp;
15+
backend: Backend;
16+
// @deprecated
17+
location: string;
18+
}
19+
20+
// @public
21+
export class AIError extends FirebaseError {
22+
constructor(code: AIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
23+
// (undocumented)
24+
readonly code: AIErrorCode;
25+
// (undocumented)
26+
readonly customErrorData?: CustomErrorData | undefined;
27+
}
28+
29+
// @public
30+
const enum AIErrorCode {
31+
API_NOT_ENABLED = "api-not-enabled",
32+
ERROR = "error",
33+
FETCH_ERROR = "fetch-error",
34+
INVALID_CONTENT = "invalid-content",
35+
INVALID_SCHEMA = "invalid-schema",
36+
NO_API_KEY = "no-api-key",
37+
NO_APP_ID = "no-app-id",
38+
NO_MODEL = "no-model",
39+
NO_PROJECT_ID = "no-project-id",
40+
PARSE_FAILED = "parse-failed",
41+
REQUEST_ERROR = "request-error",
42+
RESPONSE_ERROR = "response-error",
43+
UNSUPPORTED = "unsupported"
44+
}
45+
46+
export { AIErrorCode }
47+
48+
export { AIErrorCode as VertexAIErrorCode }
49+
50+
// @public
51+
export abstract class AIModel {
52+
// @internal
53+
protected constructor(ai: AI, modelName: string);
54+
// Warning: (ae-forgotten-export) The symbol "ApiSettings" needs to be exported by the entry point index.d.ts
55+
//
56+
// @internal (undocumented)
57+
protected _apiSettings: ApiSettings;
58+
readonly model: string;
59+
// @internal
60+
static normalizeModelName(modelName: string, backendType: BackendType): string;
61+
}
62+
63+
// @public
64+
export interface AIOptions {
65+
backend: Backend;
66+
}
67+
1268
// @public
1369
export class ArraySchema extends Schema {
1470
constructor(schemaParams: SchemaParams, items: TypedSchema);
@@ -18,6 +74,21 @@ export class ArraySchema extends Schema {
1874
toJSON(): SchemaRequest;
1975
}
2076

77+
// @public
78+
export abstract class Backend {
79+
protected constructor(type: BackendType);
80+
readonly backendType: BackendType;
81+
}
82+
83+
// @public
84+
export const BackendType: {
85+
readonly VERTEX_AI: "VERTEX_AI";
86+
readonly GOOGLE_AI: "GOOGLE_AI";
87+
};
88+
89+
// @public
90+
export type BackendType = (typeof BackendType)[keyof typeof BackendType];
91+
2192
// @public
2293
export interface BaseParams {
2394
// (undocumented)
@@ -41,7 +112,6 @@ export class BooleanSchema extends Schema {
41112

42113
// @public
43114
export class ChatSession {
44-
// Warning: (ae-forgotten-export) The symbol "ApiSettings" needs to be exported by the entry point index.d.ts
45115
constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined);
46116
getHistory(): Promise<Content[]>;
47117
// (undocumented)
@@ -60,11 +130,9 @@ export interface Citation {
60130
endIndex?: number;
61131
// (undocumented)
62132
license?: string;
63-
// (undocumented)
64133
publicationDate?: Date_2;
65134
// (undocumented)
66135
startIndex?: number;
67-
// (undocumented)
68136
title?: string;
69137
// (undocumented)
70138
uri?: string;
@@ -326,8 +394,8 @@ export interface GenerativeContentBlob {
326394
}
327395

328396
// @public
329-
export class GenerativeModel extends VertexAIModel {
330-
constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions);
397+
export class GenerativeModel extends AIModel {
398+
constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions);
331399
countTokens(request: CountTokensRequest | string | Array<string | Part>): Promise<CountTokensResponse>;
332400
generateContent(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentResult>;
333401
generateContentStream(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentStreamResult>;
@@ -347,14 +415,76 @@ export class GenerativeModel extends VertexAIModel {
347415
}
348416

349417
// @public
350-
export function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
418+
export function getAI(app?: FirebaseApp, options?: AIOptions): AI;
419+
420+
// @public
421+
export function getGenerativeModel(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
351422

352423
// @beta
353-
export function getImagenModel(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
424+
export function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
354425

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

429+
// @public
430+
export class GoogleAIBackend extends Backend {
431+
constructor();
432+
}
433+
434+
// Warning: (ae-internal-missing-underscore) The name "GoogleAICitationMetadata" should be prefixed with an underscore because the declaration is marked as @internal
435+
//
436+
// @internal (undocumented)
437+
export interface GoogleAICitationMetadata {
438+
// (undocumented)
439+
citationSources: Citation[];
440+
}
441+
442+
// Warning: (ae-internal-missing-underscore) The name "GoogleAICountTokensRequest" should be prefixed with an underscore because the declaration is marked as @internal
443+
//
444+
// @internal (undocumented)
445+
export interface GoogleAICountTokensRequest {
446+
// (undocumented)
447+
generateContentRequest: {
448+
model: string;
449+
contents: Content[];
450+
systemInstruction?: string | Part | Content;
451+
tools?: Tool[];
452+
generationConfig?: GenerationConfig;
453+
};
454+
}
455+
456+
// Warning: (ae-internal-missing-underscore) The name "GoogleAIGenerateContentCandidate" should be prefixed with an underscore because the declaration is marked as @internal
457+
//
458+
// @internal (undocumented)
459+
export interface GoogleAIGenerateContentCandidate {
460+
// (undocumented)
461+
citationMetadata?: GoogleAICitationMetadata;
462+
// (undocumented)
463+
content: Content;
464+
// (undocumented)
465+
finishMessage?: string;
466+
// (undocumented)
467+
finishReason?: FinishReason;
468+
// (undocumented)
469+
groundingMetadata?: GroundingMetadata;
470+
// (undocumented)
471+
index: number;
472+
// (undocumented)
473+
safetyRatings?: SafetyRating[];
474+
}
475+
476+
// Warning: (ae-internal-missing-underscore) The name "GoogleAIGenerateContentResponse" should be prefixed with an underscore because the declaration is marked as @internal
477+
//
478+
// @internal (undocumented)
479+
export interface GoogleAIGenerateContentResponse {
480+
// (undocumented)
481+
candidates?: GoogleAIGenerateContentCandidate[];
482+
// (undocumented)
483+
promptFeedback?: PromptFeedback;
484+
// (undocumented)
485+
usageMetadata?: UsageMetadata;
486+
}
487+
358488
// @public @deprecated (undocumented)
359489
export interface GroundingAttribution {
360490
// (undocumented)
@@ -377,7 +507,7 @@ export interface GroundingMetadata {
377507
webSearchQueries?: string[];
378508
}
379509

380-
// @public (undocumented)
510+
// @public
381511
export enum HarmBlockMethod {
382512
PROBABILITY = "PROBABILITY",
383513
SEVERITY = "SEVERITY"
@@ -416,7 +546,8 @@ export enum HarmSeverity {
416546
HARM_SEVERITY_HIGH = "HARM_SEVERITY_HIGH",
417547
HARM_SEVERITY_LOW = "HARM_SEVERITY_LOW",
418548
HARM_SEVERITY_MEDIUM = "HARM_SEVERITY_MEDIUM",
419-
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE"
549+
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE",
550+
HARM_SEVERITY_UNSUPPORTED = "HARM_SEVERITY_UNSUPPORTED"
420551
}
421552

422553
// @beta
@@ -464,8 +595,8 @@ export interface ImagenInlineImage {
464595
}
465596

466597
// @beta
467-
export class ImagenModel extends VertexAIModel {
468-
constructor(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined);
598+
export class ImagenModel extends AIModel {
599+
constructor(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined);
469600
generateImages(prompt: string): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
470601
// @internal
471602
generateImagesGCS(prompt: string, gcsURI: string): Promise<ImagenGenerationResponse<ImagenGCSImage>>;
@@ -587,7 +718,6 @@ export const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"];
587718
export interface PromptFeedback {
588719
// (undocumented)
589720
blockReason?: BlockReason;
590-
// (undocumented)
591721
blockReasonMessage?: string;
592722
// (undocumented)
593723
safetyRatings: SafetyRating[];
@@ -627,19 +757,15 @@ export interface SafetyRating {
627757
category: HarmCategory;
628758
// (undocumented)
629759
probability: HarmProbability;
630-
// (undocumented)
631760
probabilityScore: number;
632-
// (undocumented)
633761
severity: HarmSeverity;
634-
// (undocumented)
635762
severityScore: number;
636763
}
637764

638765
// @public
639766
export interface SafetySetting {
640767
// (undocumented)
641768
category: HarmCategory;
642-
// (undocumented)
643769
method?: HarmBlockMethod;
644770
// (undocumented)
645771
threshold: HarmBlockThreshold;
@@ -791,46 +917,19 @@ export interface UsageMetadata {
791917
}
792918

793919
// @public
794-
export interface VertexAI {
795-
app: FirebaseApp;
796-
// (undocumented)
797-
location: string;
798-
}
920+
export type VertexAI = AI;
799921

800922
// @public
801-
export class VertexAIError extends FirebaseError {
802-
constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
803-
// (undocumented)
804-
readonly code: VertexAIErrorCode;
805-
// (undocumented)
806-
readonly customErrorData?: CustomErrorData | undefined;
923+
export class VertexAIBackend extends Backend {
924+
constructor(location?: string);
925+
readonly location: string;
807926
}
808927

809928
// @public
810-
export const enum VertexAIErrorCode {
811-
API_NOT_ENABLED = "api-not-enabled",
812-
ERROR = "error",
813-
FETCH_ERROR = "fetch-error",
814-
INVALID_CONTENT = "invalid-content",
815-
INVALID_SCHEMA = "invalid-schema",
816-
NO_API_KEY = "no-api-key",
817-
NO_APP_ID = "no-app-id",
818-
NO_MODEL = "no-model",
819-
NO_PROJECT_ID = "no-project-id",
820-
PARSE_FAILED = "parse-failed",
821-
REQUEST_ERROR = "request-error",
822-
RESPONSE_ERROR = "response-error"
823-
}
929+
export const VertexAIError: typeof AIError;
824930

825931
// @public
826-
export abstract class VertexAIModel {
827-
// @internal
828-
protected constructor(vertexAI: VertexAI, modelName: string);
829-
// @internal (undocumented)
830-
protected _apiSettings: ApiSettings;
831-
readonly model: string;
832-
static normalizeModelName(modelName: string): string;
833-
}
932+
export const VertexAIModel: typeof AIModel;
834933

835934
// @public
836935
export interface VertexAIOptions {

docs-devsite/_toc.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,18 @@ toc:
472472
- title: vertexai
473473
path: /docs/reference/js/vertexai.md
474474
section:
475+
- title: AI
476+
path: /docs/reference/js/vertexai.ai.md
477+
- title: AIError
478+
path: /docs/reference/js/vertexai.aierror.md
479+
- title: AIModel
480+
path: /docs/reference/js/vertexai.aimodel.md
481+
- title: AIOptions
482+
path: /docs/reference/js/vertexai.aioptions.md
475483
- title: ArraySchema
476484
path: /docs/reference/js/vertexai.arrayschema.md
485+
- title: Backend
486+
path: /docs/reference/js/vertexai.backend.md
477487
- title: BaseParams
478488
path: /docs/reference/js/vertexai.baseparams.md
479489
- title: BooleanSchema
@@ -532,6 +542,8 @@ toc:
532542
path: /docs/reference/js/vertexai.generativecontentblob.md
533543
- title: GenerativeModel
534544
path: /docs/reference/js/vertexai.generativemodel.md
545+
- title: GoogleAIBackend
546+
path: /docs/reference/js/vertexai.googleaibackend.md
535547
- title: GroundingAttribution
536548
path: /docs/reference/js/vertexai.groundingattribution.md
537549
- title: GroundingMetadata
@@ -598,12 +610,8 @@ toc:
598610
path: /docs/reference/js/vertexai.toolconfig.md
599611
- title: UsageMetadata
600612
path: /docs/reference/js/vertexai.usagemetadata.md
601-
- title: VertexAI
602-
path: /docs/reference/js/vertexai.vertexai.md
603-
- title: VertexAIError
604-
path: /docs/reference/js/vertexai.vertexaierror.md
605-
- title: VertexAIModel
606-
path: /docs/reference/js/vertexai.vertexaimodel.md
613+
- title: VertexAIBackend
614+
path: /docs/reference/js/vertexai.vertexaibackend.md
607615
- title: VertexAIOptions
608616
path: /docs/reference/js/vertexai.vertexaioptions.md
609617
- title: VideoMetadata

docs-devsite/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ https://github.com/firebase/firebase-js-sdk
2727
| [@firebase/performance](./performance.md#performance_package) | The Firebase Performance Monitoring Web SDK. This SDK does not work in a Node.js environment. |
2828
| [@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. |
2929
| [@firebase/storage](./storage.md#storage_package) | Cloud Storage for Firebase |
30-
| [@firebase/vertexai](./vertexai.md#vertexai_package) | The Vertex AI in Firebase Web SDK. |
30+
| [@firebase/vertexai](./vertexai.md#vertexai_package) | The Firebase AI Web SDK. |
3131

0 commit comments

Comments
 (0)