Skip to content

Commit 880d331

Browse files
committed
(WIP)feat(vertexai): Migrate to GenAI
1 parent 88a8055 commit 880d331

Some content is hidden

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

50 files changed

+1300
-450
lines changed

common/api-review/vertexai.api.md

Lines changed: 106 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ export class ArraySchema extends Schema {
1818
toJSON(): SchemaRequest;
1919
}
2020

21+
// @public (undocumented)
22+
export type Backend = GoogleAIBackend | VertexAIBackend;
23+
24+
// @public (undocumented)
25+
export const BackendType: {
26+
readonly VERTEX_AI: "VERTEX_AI";
27+
readonly GOOGLE_AI: "GOOGLE_AI";
28+
};
29+
30+
// @public (undocumented)
31+
export type BackendType = typeof BackendType[keyof typeof BackendType];
32+
2133
// @public
2234
export interface BaseParams {
2335
// (undocumented)
@@ -239,6 +251,70 @@ export interface FunctionResponsePart {
239251
text?: never;
240252
}
241253

254+
// @public
255+
export interface GenAI {
256+
app: FirebaseApp;
257+
// (undocumented)
258+
backend: Backend;
259+
// @deprecated (undocumented)
260+
location: string;
261+
}
262+
263+
// @public
264+
class GenAIError extends FirebaseError {
265+
constructor(code: GenAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
266+
// (undocumented)
267+
readonly code: GenAIErrorCode;
268+
// (undocumented)
269+
readonly customErrorData?: CustomErrorData | undefined;
270+
}
271+
272+
export { GenAIError }
273+
274+
export { GenAIError as VertexAIError }
275+
276+
// @public
277+
const enum GenAIErrorCode {
278+
API_NOT_ENABLED = "api-not-enabled",
279+
ERROR = "error",
280+
FETCH_ERROR = "fetch-error",
281+
INVALID_CONTENT = "invalid-content",
282+
INVALID_SCHEMA = "invalid-schema",
283+
NO_API_KEY = "no-api-key",
284+
NO_APP_ID = "no-app-id",
285+
NO_MODEL = "no-model",
286+
NO_PROJECT_ID = "no-project-id",
287+
PARSE_FAILED = "parse-failed",
288+
REQUEST_ERROR = "request-error",
289+
RESPONSE_ERROR = "response-error",
290+
UNSUPPORTED = "unsupported"
291+
}
292+
293+
export { GenAIErrorCode }
294+
295+
export { GenAIErrorCode as VertexAIErrorCode }
296+
297+
// @public
298+
abstract class GenAIModel {
299+
// @internal
300+
protected constructor(genAI: GenAI, modelName: string);
301+
// @internal (undocumented)
302+
protected _apiSettings: ApiSettings;
303+
readonly model: string;
304+
// @internal (undocumented)
305+
static normalizeModelName(modelName: string, backendType: BackendType): string;
306+
}
307+
308+
export { GenAIModel }
309+
310+
export { GenAIModel as VertexAIModel }
311+
312+
// @public (undocumented)
313+
export interface GenAIOptions {
314+
// (undocumented)
315+
backend: Backend;
316+
}
317+
242318
// @public
243319
export interface GenerateContentCandidate {
244320
// (undocumented)
@@ -323,8 +399,8 @@ export interface GenerativeContentBlob {
323399
}
324400

325401
// @public
326-
export class GenerativeModel extends VertexAIModel {
327-
constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions);
402+
export class GenerativeModel extends GenAIModel {
403+
constructor(genAI: GenAI, modelParams: ModelParams, requestOptions?: RequestOptions);
328404
countTokens(request: CountTokensRequest | string | Array<string | Part>): Promise<CountTokensResponse>;
329405
generateContent(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentResult>;
330406
generateContentStream(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentStreamResult>;
@@ -344,14 +420,25 @@ export class GenerativeModel extends VertexAIModel {
344420
}
345421

346422
// @public
347-
export function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
423+
export function getGenAI(app?: FirebaseApp, options?: GenAIOptions): GenAI;
424+
425+
// @public
426+
export function getGenerativeModel(genAI: GenAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
348427

349428
// @beta
350-
export function getImagenModel(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
429+
export function getImagenModel(genAI: GenAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
351430

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

434+
// @public (undocumented)
435+
export type GoogleAIBackend = {
436+
backendType: typeof BackendType.GOOGLE_AI;
437+
};
438+
439+
// @public (undocumented)
440+
export function googleAIBackend(): GoogleAIBackend;
441+
355442
// @public @deprecated (undocumented)
356443
export interface GroundingAttribution {
357444
// (undocumented)
@@ -413,7 +500,8 @@ export enum HarmSeverity {
413500
HARM_SEVERITY_HIGH = "HARM_SEVERITY_HIGH",
414501
HARM_SEVERITY_LOW = "HARM_SEVERITY_LOW",
415502
HARM_SEVERITY_MEDIUM = "HARM_SEVERITY_MEDIUM",
416-
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE"
503+
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE",
504+
HARM_SEVERITY_UNSUPPORTED = "HARM_SEVERITY_UNSPECIFIED"
417505
}
418506

419507
// @beta
@@ -461,7 +549,7 @@ export interface ImagenInlineImage {
461549
}
462550

463551
// @beta
464-
export class ImagenModel extends VertexAIModel {
552+
export class ImagenModel extends GenAIModel {
465553
constructor(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined);
466554
generateImages(prompt: string): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
467555
// @internal
@@ -513,6 +601,9 @@ export interface InlineDataPart {
513601
videoMetadata?: VideoMetadata;
514602
}
515603

604+
// @public (undocumented)
605+
export type InstanceIdentifier = Backend;
606+
516607
// @public
517608
export class IntegerSchema extends Schema {
518609
constructor(schemaParams?: SchemaParams);
@@ -627,7 +718,6 @@ export interface SafetyRating {
627718
export interface SafetySetting {
628719
// (undocumented)
629720
category: HarmCategory;
630-
// (undocumented)
631721
method?: HarmBlockMethod;
632722
// (undocumented)
633723
threshold: HarmBlockThreshold;
@@ -778,47 +868,17 @@ export interface UsageMetadata {
778868
totalTokenCount: number;
779869
}
780870

781-
// @public
782-
export interface VertexAI {
783-
app: FirebaseApp;
784-
// (undocumented)
785-
location: string;
786-
}
787-
788-
// @public
789-
export class VertexAIError extends FirebaseError {
790-
constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
791-
// (undocumented)
792-
readonly code: VertexAIErrorCode;
793-
// (undocumented)
794-
readonly customErrorData?: CustomErrorData | undefined;
795-
}
871+
// @public (undocumented)
872+
export type VertexAI = GenAI;
796873

797-
// @public
798-
export const enum VertexAIErrorCode {
799-
API_NOT_ENABLED = "api-not-enabled",
800-
ERROR = "error",
801-
FETCH_ERROR = "fetch-error",
802-
INVALID_CONTENT = "invalid-content",
803-
INVALID_SCHEMA = "invalid-schema",
804-
NO_API_KEY = "no-api-key",
805-
NO_APP_ID = "no-app-id",
806-
NO_MODEL = "no-model",
807-
NO_PROJECT_ID = "no-project-id",
808-
PARSE_FAILED = "parse-failed",
809-
REQUEST_ERROR = "request-error",
810-
RESPONSE_ERROR = "response-error"
811-
}
874+
// @public (undocumented)
875+
export type VertexAIBackend = {
876+
backendType: typeof BackendType.VERTEX_AI;
877+
location: string;
878+
};
812879

813-
// @public
814-
export abstract class VertexAIModel {
815-
// @internal
816-
protected constructor(vertexAI: VertexAI, modelName: string);
817-
// @internal (undocumented)
818-
protected _apiSettings: ApiSettings;
819-
readonly model: string;
820-
static normalizeModelName(modelName: string): string;
821-
}
880+
// @public (undocumented)
881+
export function vertexAIBackend(location?: string): VertexAIBackend;
822882

823883
// @public
824884
export interface VertexAIOptions {

docs-devsite/_toc.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,12 @@ toc:
516516
path: /docs/reference/js/vertexai.functionresponse.md
517517
- title: FunctionResponsePart
518518
path: /docs/reference/js/vertexai.functionresponsepart.md
519+
- title: GenAI
520+
path: /docs/reference/js/vertexai.genai.md
521+
- title: GenAIError
522+
path: /docs/reference/js/vertexai.genaierror.md
523+
- title: GenAIOptions
524+
path: /docs/reference/js/vertexai.genaioptions.md
519525
- title: GenerateContentCandidate
520526
path: /docs/reference/js/vertexai.generatecontentcandidate.md
521527
- title: GenerateContentRequest
@@ -598,10 +604,6 @@ toc:
598604
path: /docs/reference/js/vertexai.toolconfig.md
599605
- title: UsageMetadata
600606
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
605607
- title: VertexAIModel
606608
path: /docs/reference/js/vertexai.vertexaimodel.md
607609
- title: VertexAIOptions

docs-devsite/vertexai.genai.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# GenAI interface
13+
An instance of the Firebase GenAI SDK.
14+
15+
<b>Signature:</b>
16+
17+
```typescript
18+
export interface GenAI
19+
```
20+
21+
## Properties
22+
23+
| Property | Type | Description |
24+
| --- | --- | --- |
25+
| [app](./vertexai.genai.md#genaiapp) | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this <code>[GenAI](./vertexai.genai.md#genai_interface)</code> instance is associated with. |
26+
| [backend](./vertexai.genai.md#genaibackend) | [Backend](./vertexai.md#backend) | |
27+
| [location](./vertexai.genai.md#genailocation) | string | |
28+
29+
## GenAI.app
30+
31+
The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this <code>[GenAI](./vertexai.genai.md#genai_interface)</code> instance is associated with.
32+
33+
<b>Signature:</b>
34+
35+
```typescript
36+
app: FirebaseApp;
37+
```
38+
39+
## GenAI.backend
40+
41+
<b>Signature:</b>
42+
43+
```typescript
44+
backend: Backend;
45+
```
46+
47+
## GenAI.location
48+
49+
> Warning: This API is now obsolete.
50+
>
51+
> This is here to maintain backwards-compatibility. Use `GenAI.backend.location` instead.
52+
>
53+
54+
<b>Signature:</b>
55+
56+
```typescript
57+
location: string;
58+
```
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,56 @@ overwritten. Changes should be made in the source code at
99
https://github.com/firebase/firebase-js-sdk
1010
{% endcomment %}
1111

12-
# VertexAIError class
12+
# GenAIError class
1313
Error class for the Vertex AI in Firebase SDK.
1414

1515
<b>Signature:</b>
1616

1717
```typescript
18-
export declare class VertexAIError extends FirebaseError
18+
export declare class GenAIError extends FirebaseError
1919
```
2020
<b>Extends:</b> [FirebaseError](./util.firebaseerror.md#firebaseerror_class)
2121
2222
## Constructors
2323
2424
| Constructor | Modifiers | Description |
2525
| --- | --- | --- |
26-
| [(constructor)(code, message, customErrorData)](./vertexai.vertexaierror.md#vertexaierrorconstructor) | | Constructs a new instance of the <code>VertexAIError</code> class. |
26+
| [(constructor)(code, message, customErrorData)](./vertexai.genaierror.md#genaierrorconstructor) | | Constructs a new instance of the <code>VertexAIError</code> class. |
2727
2828
## Properties
2929
3030
| Property | Modifiers | Type | Description |
3131
| --- | --- | --- | --- |
32-
| [code](./vertexai.vertexaierror.md#vertexaierrorcode) | | [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | |
33-
| [customErrorData](./vertexai.vertexaierror.md#vertexaierrorcustomerrordata) | | [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) \| undefined | |
32+
| [code](./vertexai.genaierror.md#genaierrorcode) | | [GenAIErrorCode](./vertexai.md#genaierrorcode) | |
33+
| [customErrorData](./vertexai.genaierror.md#genaierrorcustomerrordata) | | [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) \| undefined | |
3434
35-
## VertexAIError.(constructor)
35+
## GenAIError.(constructor)
3636
3737
Constructs a new instance of the `VertexAIError` class.
3838
3939
<b>Signature:</b>
4040
4141
```typescript
42-
constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
42+
constructor(code: GenAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
4343
```
4444
4545
#### Parameters
4646
4747
| Parameter | Type | Description |
4848
| --- | --- | --- |
49-
| code | [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | The error code from <code>[VertexAIErrorCode](./vertexai.md#vertexaierrorcode)</code>. |
49+
| code | [GenAIErrorCode](./vertexai.md#genaierrorcode) | The error code from <code>[GenAIErrorCode](./vertexai.md#genaierrorcode)</code>. |
5050
| message | string | A human-readable message describing the error. |
5151
| customErrorData | [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) \| undefined | Optional error data. |
5252
53-
## VertexAIError.code
53+
## GenAIError.code
5454
5555
<b>Signature:</b>
5656
5757
```typescript
58-
readonly code: VertexAIErrorCode;
58+
readonly code: GenAIErrorCode;
5959
```
6060
61-
## VertexAIError.customErrorData
61+
## GenAIError.customErrorData
6262
6363
<b>Signature:</b>
6464

0 commit comments

Comments
 (0)