Skip to content

Commit a6d2201

Browse files
authored
Merge branch 'main' into rl.token.count.js.modality
2 parents 421ab29 + ce2c775 commit a6d2201

Some content is hidden

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

45 files changed

+2384
-575
lines changed

.changeset/tough-kiwis-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/app-check': patch
3+
---
4+
5+
Fixed a bug that caused an error to be thrown when the debug exchange failed.

.changeset/violet-planets-impress.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+
**Public Preview** Added support for generating images using the Imagen 3 model.

common/api-review/vertexai.api.md

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,14 @@ export interface GenerativeContentBlob {
324324
}
325325

326326
// @public
327-
export class GenerativeModel {
327+
export class GenerativeModel extends VertexAIModel {
328328
constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions);
329329
countTokens(request: CountTokensRequest | string | Array<string | Part>): Promise<CountTokensResponse>;
330330
generateContent(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentResult>;
331331
generateContentStream(request: GenerateContentRequest | string | Array<string | Part>): Promise<GenerateContentStreamResult>;
332332
// (undocumented)
333333
generationConfig: GenerationConfig;
334334
// (undocumented)
335-
model: string;
336-
// (undocumented)
337335
requestOptions?: RequestOptions;
338336
// (undocumented)
339337
safetySettings: SafetySetting[];
@@ -349,6 +347,9 @@ export class GenerativeModel {
349347
// @public
350348
export function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
351349

350+
// @beta
351+
export function getImagenModel(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel;
352+
352353
// @public
353354
export function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI;
354355

@@ -430,6 +431,90 @@ export enum HarmSeverity {
430431
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE"
431432
}
432433

434+
// @beta
435+
export enum ImagenAspectRatio {
436+
LANDSCAPE_16x9 = "16:9",
437+
LANDSCAPE_3x4 = "3:4",
438+
PORTRAIT_4x3 = "4:3",
439+
PORTRAIT_9x16 = "9:16",
440+
SQUARE = "1:1"
441+
}
442+
443+
// @public
444+
export interface ImagenGCSImage {
445+
gcsURI: string;
446+
mimeType: string;
447+
}
448+
449+
// @beta
450+
export interface ImagenGenerationConfig {
451+
addWatermark?: boolean;
452+
aspectRatio?: ImagenAspectRatio;
453+
imageFormat?: ImagenImageFormat;
454+
negativePrompt?: string;
455+
numberOfImages?: number;
456+
}
457+
458+
// @beta
459+
export interface ImagenGenerationResponse<T extends ImagenInlineImage | ImagenGCSImage> {
460+
filteredReason?: string;
461+
images: T[];
462+
}
463+
464+
// @beta
465+
export class ImagenImageFormat {
466+
compressionQuality?: number;
467+
static jpeg(compressionQuality?: number): ImagenImageFormat;
468+
mimeType: string;
469+
static png(): ImagenImageFormat;
470+
}
471+
472+
// @beta
473+
export interface ImagenInlineImage {
474+
bytesBase64Encoded: string;
475+
mimeType: string;
476+
}
477+
478+
// @beta
479+
export class ImagenModel extends VertexAIModel {
480+
constructor(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined);
481+
generateImages(prompt: string): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
482+
// @internal
483+
generateImagesGCS(prompt: string, gcsURI: string): Promise<ImagenGenerationResponse<ImagenGCSImage>>;
484+
generationConfig?: ImagenGenerationConfig;
485+
// (undocumented)
486+
requestOptions?: RequestOptions | undefined;
487+
safetySettings?: ImagenSafetySettings;
488+
}
489+
490+
// @beta
491+
export interface ImagenModelParams {
492+
generationConfig?: ImagenGenerationConfig;
493+
model: string;
494+
safetySettings?: ImagenSafetySettings;
495+
}
496+
497+
// @beta
498+
export enum ImagenPersonFilterLevel {
499+
ALLOW_ADULT = "allow_adult",
500+
ALLOW_ALL = "allow_all",
501+
BLOCK_ALL = "dont_allow"
502+
}
503+
504+
// @beta
505+
export enum ImagenSafetyFilterLevel {
506+
BLOCK_LOW_AND_ABOVE = "block_low_and_above",
507+
BLOCK_MEDIUM_AND_ABOVE = "block_medium_and_above",
508+
BLOCK_NONE = "block_none",
509+
BLOCK_ONLY_HIGH = "block_only_high"
510+
}
511+
512+
// @beta
513+
export interface ImagenSafetySettings {
514+
personFilterLevel?: ImagenPersonFilterLevel;
515+
safetyFilterLevel?: ImagenSafetyFilterLevel;
516+
}
517+
433518
// @public
434519
export interface InlineDataPart {
435520
// (undocumented)
@@ -739,6 +824,16 @@ export const enum VertexAIErrorCode {
739824
RESPONSE_ERROR = "response-error"
740825
}
741826

827+
// @public
828+
export abstract class VertexAIModel {
829+
// @internal
830+
protected constructor(vertexAI: VertexAI, modelName: string);
831+
// @internal (undocumented)
832+
protected _apiSettings: ApiSettings;
833+
readonly model: string;
834+
static normalizeModelName(modelName: string): string;
835+
}
836+
742837
// @public
743838
export interface VertexAIOptions {
744839
// (undocumented)

docs-devsite/_toc.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,22 @@ toc:
536536
path: /docs/reference/js/vertexai.groundingattribution.md
537537
- title: GroundingMetadata
538538
path: /docs/reference/js/vertexai.groundingmetadata.md
539+
- title: ImagenGCSImage
540+
path: /docs/reference/js/vertexai.imagengcsimage.md
541+
- title: ImagenGenerationConfig
542+
path: /docs/reference/js/vertexai.imagengenerationconfig.md
543+
- title: ImagenGenerationResponse
544+
path: /docs/reference/js/vertexai.imagengenerationresponse.md
545+
- title: ImagenImageFormat
546+
path: /docs/reference/js/vertexai.imagenimageformat.md
547+
- title: ImagenInlineImage
548+
path: /docs/reference/js/vertexai.imageninlineimage.md
549+
- title: ImagenModel
550+
path: /docs/reference/js/vertexai.imagenmodel.md
551+
- title: ImagenModelParams
552+
path: /docs/reference/js/vertexai.imagenmodelparams.md
553+
- title: ImagenSafetySettings
554+
path: /docs/reference/js/vertexai.imagensafetysettings.md
539555
- title: InlineDataPart
540556
path: /docs/reference/js/vertexai.inlinedatapart.md
541557
- title: IntegerSchema
@@ -586,6 +602,8 @@ toc:
586602
path: /docs/reference/js/vertexai.vertexai.md
587603
- title: VertexAIError
588604
path: /docs/reference/js/vertexai.vertexaierror.md
605+
- title: VertexAIModel
606+
path: /docs/reference/js/vertexai.vertexaimodel.md
589607
- title: VertexAIOptions
590608
path: /docs/reference/js/vertexai.vertexaioptions.md
591609
- title: VideoMetadata

docs-devsite/firestore_.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ https://github.com/firebase/firebase-js-sdk
157157
| [SnapshotMetadata](./firestore_.snapshotmetadata.md#snapshotmetadata_class) | Metadata about a snapshot, describing the state of the snapshot. |
158158
| [Timestamp](./firestore_.timestamp.md#timestamp_class) | A <code>Timestamp</code> represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.<!-- -->It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.<!-- -->For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto)<!-- -->. |
159159
| [Transaction](./firestore_.transaction.md#transaction_class) | A reference to a transaction.<!-- -->The <code>Transaction</code> object passed to a transaction's <code>updateFunction</code> provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4)<!-- -->. |
160-
| [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue |
160+
| [VectorValue](./firestore_.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with <code>[vector()](./firestore_.md#vector_0dbdaf2)</code>. VectorValue |
161161
| [WriteBatch](./firestore_.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.<!-- -->A <code>WriteBatch</code> object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0)<!-- -->. It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. |
162162

163163
## Interfaces

docs-devsite/firestore_.vectorvalue.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk
1010
{% endcomment %}
1111

1212
# VectorValue class
13-
Represents a vector type in Firestore documents. Create an instance with .
13+
Represents a vector type in Firestore documents. Create an instance with <code>[vector()](./firestore_.md#vector_0dbdaf2)</code>.
1414

1515
VectorValue
1616

@@ -24,12 +24,12 @@ export declare class VectorValue
2424

2525
| Method | Modifiers | Description |
2626
| --- | --- | --- |
27-
| [isEqual(other)](./firestore_.vectorvalue.md#vectorvalueisequal) | | Returns <code>true</code> if the two VectorValue has the same raw number arrays, returns <code>false</code> otherwise. |
27+
| [isEqual(other)](./firestore_.vectorvalue.md#vectorvalueisequal) | | Returns <code>true</code> if the two <code>VectorValue</code> values have the same raw number arrays, returns <code>false</code> otherwise. |
2828
| [toArray()](./firestore_.vectorvalue.md#vectorvaluetoarray) | | Returns a copy of the raw number array form of the vector. |
2929

3030
## VectorValue.isEqual()
3131

32-
Returns `true` if the two VectorValue has the same raw number arrays, returns `false` otherwise.
32+
Returns `true` if the two `VectorValue` values have the same raw number arrays, returns `false` otherwise.
3333

3434
<b>Signature:</b>
3535

docs-devsite/firestore_lite.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ https://github.com/firebase/firebase-js-sdk
119119
| [QueryStartAtConstraint](./firestore_lite.querystartatconstraint.md#querystartatconstraint_class) | A <code>QueryStartAtConstraint</code> is used to exclude documents from the start of a result set returned by a Firestore query. <code>QueryStartAtConstraint</code>s are created by invoking [startAt()](./firestore_.md#startat_9a4477f) or [startAfter()](./firestore_.md#startafter_9a4477f) and can then be passed to [query()](./firestore_.md#query_9f7b0f4) to create a new query instance that also contains this <code>QueryStartAtConstraint</code>. |
120120
| [Timestamp](./firestore_lite.timestamp.md#timestamp_class) | A <code>Timestamp</code> represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time.<!-- -->It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.<!-- -->For examples and further specifications, refer to the [Timestamp definition](https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto)<!-- -->. |
121121
| [Transaction](./firestore_lite.transaction.md#transaction_class) | A reference to a transaction.<!-- -->The <code>Transaction</code> object passed to a transaction's <code>updateFunction</code> provides the methods to read and write data within the transaction context. See [runTransaction()](./firestore_.md#runtransaction_6f03ec4)<!-- -->. |
122-
| [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with . VectorValue |
122+
| [VectorValue](./firestore_lite.vectorvalue.md#vectorvalue_class) | Represents a vector type in Firestore documents. Create an instance with <code>[vector()](./firestore_.md#vector_0dbdaf2)</code>. VectorValue |
123123
| [WriteBatch](./firestore_lite.writebatch.md#writebatch_class) | A write batch, used to perform multiple writes as a single atomic unit.<!-- -->A <code>WriteBatch</code> object can be acquired by calling [writeBatch()](./firestore_.md#writebatch_231a8e0)<!-- -->. It provides methods for adding writes to the write batch. None of the writes will be committed (or visible locally) until [WriteBatch.commit()](./firestore_.writebatch.md#writebatchcommit) is called. |
124124

125125
## Interfaces

docs-devsite/firestore_lite.vectorvalue.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk
1010
{% endcomment %}
1111

1212
# VectorValue class
13-
Represents a vector type in Firestore documents. Create an instance with .
13+
Represents a vector type in Firestore documents. Create an instance with <code>[vector()](./firestore_.md#vector_0dbdaf2)</code>.
1414

1515
VectorValue
1616

@@ -24,12 +24,12 @@ export declare class VectorValue
2424

2525
| Method | Modifiers | Description |
2626
| --- | --- | --- |
27-
| [isEqual(other)](./firestore_lite.vectorvalue.md#vectorvalueisequal) | | Returns <code>true</code> if the two VectorValue has the same raw number arrays, returns <code>false</code> otherwise. |
27+
| [isEqual(other)](./firestore_lite.vectorvalue.md#vectorvalueisequal) | | Returns <code>true</code> if the two <code>VectorValue</code> values have the same raw number arrays, returns <code>false</code> otherwise. |
2828
| [toArray()](./firestore_lite.vectorvalue.md#vectorvaluetoarray) | | Returns a copy of the raw number array form of the vector. |
2929

3030
## VectorValue.isEqual()
3131

32-
Returns `true` if the two VectorValue has the same raw number arrays, returns `false` otherwise.
32+
Returns `true` if the two `VectorValue` values have the same raw number arrays, returns `false` otherwise.
3333

3434
<b>Signature:</b>
3535

docs-devsite/vertexai.generativemodel.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ Class for generative model APIs.
1515
<b>Signature:</b>
1616

1717
```typescript
18-
export declare class GenerativeModel
18+
export declare class GenerativeModel extends VertexAIModel
1919
```
20+
<b>Extends:</b> [VertexAIModel](./vertexai.vertexaimodel.md#vertexaimodel_class)
2021
2122
## Constructors
2223
@@ -29,7 +30,6 @@ export declare class GenerativeModel
2930
| Property | Modifiers | Type | Description |
3031
| --- | --- | --- | --- |
3132
| [generationConfig](./vertexai.generativemodel.md#generativemodelgenerationconfig) | | [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | |
32-
| [model](./vertexai.generativemodel.md#generativemodelmodel) | | string | |
3333
| [requestOptions](./vertexai.generativemodel.md#generativemodelrequestoptions) | | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | |
3434
| [safetySettings](./vertexai.generativemodel.md#generativemodelsafetysettings) | | [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface)<!-- -->\[\] | |
3535
| [systemInstruction](./vertexai.generativemodel.md#generativemodelsysteminstruction) | | [Content](./vertexai.content.md#content_interface) | |
@@ -71,14 +71,6 @@ constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: Reque
7171
generationConfig: GenerationConfig;
7272
```
7373
74-
## GenerativeModel.model
75-
76-
<b>Signature:</b>
77-
78-
```typescript
79-
model: string;
80-
```
81-
8274
## GenerativeModel.requestOptions
8375
8476
<b>Signature:</b>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
# ImagenGCSImage interface
13+
An image generated by Imagen, stored in a Cloud Storage for Firebase bucket.
14+
15+
This feature is not available yet.
16+
17+
<b>Signature:</b>
18+
19+
```typescript
20+
export interface ImagenGCSImage
21+
```
22+
23+
## Properties
24+
25+
| Property | Type | Description |
26+
| --- | --- | --- |
27+
| [gcsURI](./vertexai.imagengcsimage.md#imagengcsimagegcsuri) | string | The URI of the file stored in a Cloud Storage for Firebase bucket. |
28+
| [mimeType](./vertexai.imagengcsimage.md#imagengcsimagemimetype) | string | The MIME type of the image; either <code>&quot;image/png&quot;</code> or <code>&quot;image/jpeg&quot;</code>.<!-- -->To request a different format, set the <code>imageFormat</code> property in your <code>[ImagenGenerationConfig](./vertexai.imagengenerationconfig.md#imagengenerationconfig_interface)</code>. |
29+
30+
## ImagenGCSImage.gcsURI
31+
32+
The URI of the file stored in a Cloud Storage for Firebase bucket.
33+
34+
<b>Signature:</b>
35+
36+
```typescript
37+
gcsURI: string;
38+
```
39+
40+
### Example
41+
42+
`"gs://bucket-name/path/sample_0.jpg"`<!-- -->.
43+
44+
## ImagenGCSImage.mimeType
45+
46+
The MIME type of the image; either `"image/png"` or `"image/jpeg"`<!-- -->.
47+
48+
To request a different format, set the `imageFormat` property in your <code>[ImagenGenerationConfig](./vertexai.imagengenerationconfig.md#imagengenerationconfig_interface)</code>.
49+
50+
<b>Signature:</b>
51+
52+
```typescript
53+
mimeType: string;
54+
```

0 commit comments

Comments
 (0)