Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Image Generation support using Imagen #8683

Draft
wants to merge 32 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ec35231
WIP
dlarocque Dec 9, 2024
180f091
Introduce VertexAIModel base class, add documentation, and respond to…
dlarocque Jan 2, 2025
497727f
Generate devsite docs
dlarocque Jan 2, 2025
8471bbc
revert dataconnect change
dlarocque Jan 2, 2025
5c518b1
formatting
dlarocque Jan 2, 2025
b680a2a
WIP
dlarocque Dec 9, 2024
d00cccd
Introduce VertexAIModel base class, add documentation, and respond to…
dlarocque Jan 2, 2025
4b6c42f
Generate devsite docs
dlarocque Jan 2, 2025
6215781
revert dataconnect change
dlarocque Jan 2, 2025
025035a
formatting
dlarocque Jan 2, 2025
2f8b45d
Fix ImagenRequestConfig comment
dlarocque Jan 3, 2025
89a73de
Improve tests
dlarocque Jan 3, 2025
a0c8c89
Merge branch 'dl/vertex-imagen' of https://github.com/firebase/fireba…
dlarocque Jan 3, 2025
80021f9
Formatting
dlarocque Jan 3, 2025
858f260
Add ImagenGenerationResponse
dlarocque Jan 9, 2025
bfc2c0f
Formatting
dlarocque Jan 9, 2025
886a4df
Update to match API changes
dlarocque Jan 21, 2025
b8dd77e
Merge branch 'main' into dl/vertex-imagen
dlarocque Jan 22, 2025
d967900
fixes
dlarocque Feb 3, 2025
d53d3dd
format
dlarocque Feb 3, 2025
ae0f87e
Update API reports
dlarocque Feb 3, 2025
37aa71a
add changeset
dlarocque Feb 3, 2025
f7f919d
Merge branch 'main' into dl/vertex-imagen
dlarocque Feb 6, 2025
ece898f
update
dlarocque Feb 6, 2025
967cd78
format
dlarocque Feb 6, 2025
b27a45e
Update API reports
dlarocque Feb 6, 2025
f095563
remove public docs
dlarocque Feb 7, 2025
0cd9ae4
Merge branch 'main' into dl/vertex-imagen
dlarocque Feb 7, 2025
d6a4f24
Nest imageFormat in outputOptions
dlarocque Feb 10, 2025
66b3b9f
remove unecessary console.log
dlarocque Feb 10, 2025
48b658d
Log warning if compressionQuality outside of range
dlarocque Feb 11, 2025
c3173a9
format
dlarocque Feb 11, 2025
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
184 changes: 184 additions & 0 deletions common/api-review/vertexai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ export class GenerativeModel {
// @public
export function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;

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

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

Expand Down Expand Up @@ -429,6 +432,148 @@ export enum HarmSeverity {
HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE"
}

// @public (undocumented)
export enum ImagenAspectRatio {
// (undocumented)
CLASSIC_LANDSCAPE = "4:3",
// (undocumented)
CLASSIC_PORTRAIT = "3:4",
// (undocumented)
PORTRAIT = "9:16",
// (undocumented)
SQUARE = "1:1",
// (undocumented)
WIDESCREEN = "16:9"
}

// Warning: (ae-incompatible-release-tags) The symbol "ImagenGCSImage" is marked as @public, but its signature references "ImagenImage" which is marked as @internal
//
// @public
export interface ImagenGCSImage extends ImagenImage {
gcsURI: string;
dlarocque marked this conversation as resolved.
Show resolved Hide resolved
}

// @public (undocumented)
export interface ImagenGCSImageResponse {
// (undocumented)
filteredReason?: string;
// (undocumented)
images: ImagenGCSImage[];
}

// @public (undocumented)
export interface ImagenGenerationConfig {
// (undocumented)
aspectRatio?: ImagenAspectRatio;
// (undocumented)
negativePrompt?: string;
// (undocumented)
numberOfImages?: number;
}

// Warning: (ae-internal-missing-underscore) The name "ImagenImage" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export interface ImagenImage {
// (undocumented)
mimeType: string;
}

// @public (undocumented)
export interface ImagenImageFormat {
// (undocumented)
compressionQuality?: number;
// (undocumented)
mimeType: string;
}

// @public (undocumented)
export interface ImagenImageReponse {
// (undocumented)
filteredReason?: string;
// Warning: (ae-incompatible-release-tags) The symbol "images" is marked as @public, but its signature references "ImagenImage" which is marked as @internal
//
// (undocumented)
images: ImagenImage[];
}

// Warning: (ae-incompatible-release-tags) The symbol "ImagenInlineImage" is marked as @public, but its signature references "ImagenImage" which is marked as @internal
//
// @public
export interface ImagenInlineImage extends ImagenImage {
// (undocumented)
bytesBase64Encoded: string;
}

// @public
export interface ImagenInlineImageResponse {
filteredReason?: string;
images: ImagenInlineImage[];
}

// @public
export class ImagenModel {
constructor(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined);
generateImages(prompt: string, imagenRequestOptions?: ImagenGenerationConfig): Promise<ImagenInlineImageResponse>;
generateImagesGCS(prompt: string, gcsURI: string, imagenRequestOptions?: ImagenGenerationConfig): Promise<ImagenGCSImageResponse>;
// (undocumented)
model: string;
}

// @public (undocumented)
export interface ImagenModelConfig {
// (undocumented)
addWatermark?: boolean;
// (undocumented)
imageFormat?: ImagenImageFormat;
// (undocumented)
safetySettings?: ImagenSafetySettings;
}

// @public
export interface ImagenModelParams extends ImagenModelConfig {
// (undocumented)
model: string;
}

// @public (undocumented)
export enum ImagenPersonFilterLevel {
// (undocumented)
ALLOW_ADULT = "allow_adult",
// (undocumented)
ALLOW_ALL = "allow_all",
// (undocumented)
BLOCK_ALL = "dont_allow"
}

// Warning: (ae-internal-missing-underscore) The name "ImagenRequestConfig" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export interface ImagenRequestConfig extends ImagenModelConfig, ImagenGenerationConfig {
// (undocumented)
gcsURI?: string;
// (undocumented)
prompt: string;
}

// @public (undocumented)
export enum ImagenSafetyFilterLevel {
// (undocumented)
BLOCK_LOW_AND_ABOVE = "block_low_and_above",
// (undocumented)
BLOCK_MEDIUM_AND_ABOVE = "block_medium_and_above",
// (undocumented)
BLOCK_NONE = "block_none",
// (undocumented)
BLOCK_ONLY_HIGH = "block_only_high"
}

// @public (undocumented)
export interface ImagenSafetySettings {
personFilterLevel?: ImagenPersonFilterLevel;
safetyFilterLevel?: ImagenSafetyFilterLevel;
}

// @public
export interface InlineDataPart {
// (undocumented)
Expand All @@ -447,6 +592,9 @@ export class IntegerSchema extends Schema {
constructor(schemaParams?: SchemaParams);
}

// @public
export function jpeg(compressionQuality: number): ImagenImageFormat;

// @public
export interface ModelParams extends BaseParams {
// (undocumented)
Expand Down Expand Up @@ -490,9 +638,37 @@ export interface ObjectSchemaInterface extends SchemaInterface {
// @public
export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;

// @public
export function png(): ImagenImageFormat;

// @public
export const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"];

// Warning: (ae-internal-missing-underscore) The name "PredictRequestBody" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal
export interface PredictRequestBody {
// (undocumented)
instances: [
{
prompt: string;
}
];
// (undocumented)
parameters: {
sampleCount: number;
aspectRatio: string;
mimeType: string;
compressionQuality?: number;
negativePrompt?: string;
storageUri?: string;
addWatermark?: boolean;
safetyFilterLevel?: string;
personGeneration?: string;
includeRaiReason: boolean;
};
}

// @public
export interface PromptFeedback {
// (undocumented)
Expand Down Expand Up @@ -520,6 +696,14 @@ export interface RetrievedContextAttribution {
// @public
export type Role = (typeof POSSIBLE_ROLES)[number];

// @public (undocumented)
export interface SafetyAttributes {
// (undocumented)
categories: string[];
// (undocumented)
scores: number[];
}

// @public
export interface SafetyRating {
// (undocumented)
Expand Down
24 changes: 24 additions & 0 deletions docs-devsite/_toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,28 @@ toc:
path: /docs/reference/js/vertexai.groundingattribution.md
- title: GroundingMetadata
path: /docs/reference/js/vertexai.groundingmetadata.md
- title: ImagenGCSImage
path: /docs/reference/js/vertexai.imagengcsimage.md
- title: ImagenGCSImageResponse
path: /docs/reference/js/vertexai.imagengcsimageresponse.md
- title: ImagenGenerationConfig
path: /docs/reference/js/vertexai.imagengenerationconfig.md
- title: ImagenImageFormat
path: /docs/reference/js/vertexai.imagenimageformat.md
- title: ImagenImageReponse
path: /docs/reference/js/vertexai.imagenimagereponse.md
- title: ImagenInlineImage
path: /docs/reference/js/vertexai.imageninlineimage.md
- title: ImagenInlineImageResponse
path: /docs/reference/js/vertexai.imageninlineimageresponse.md
- title: ImagenModel
path: /docs/reference/js/vertexai.imagenmodel.md
- title: ImagenModelConfig
path: /docs/reference/js/vertexai.imagenmodelconfig.md
- title: ImagenModelParams
path: /docs/reference/js/vertexai.imagenmodelparams.md
- title: ImagenSafetySettings
path: /docs/reference/js/vertexai.imagensafetysettings.md
- title: InlineDataPart
path: /docs/reference/js/vertexai.inlinedatapart.md
- title: IntegerSchema
Expand All @@ -546,6 +568,8 @@ toc:
path: /docs/reference/js/vertexai.requestoptions.md
- title: RetrievedContextAttribution
path: /docs/reference/js/vertexai.retrievedcontextattribution.md
- title: SafetyAttributes
path: /docs/reference/js/vertexai.safetyattributes.md
- title: SafetyRating
path: /docs/reference/js/vertexai.safetyrating.md
- title: SafetySetting
Expand Down
36 changes: 36 additions & 0 deletions docs-devsite/vertexai.imagengcsimage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Project: /docs/reference/js/_project.yaml
Book: /docs/reference/_book.yaml
page_type: reference

{% comment %}
DO NOT EDIT THIS FILE!
This is generated by the JS SDK team, and any local changes will be
overwritten. Changes should be made in the source code at
https://github.com/firebase/firebase-js-sdk
{% endcomment %}

# ImagenGCSImage interface
Image generated by Imagen, stored in Google Cloud Storage (GCS).

<b>Signature:</b>

```typescript
export interface ImagenGCSImage extends ImagenImage
```
<b>Extends:</b> ImagenImage

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [gcsURI](./vertexai.imagengcsimage.md#imagengcsimagegcsuri) | string | The Google Cloud Storage (GCS) URI at which the generated image is stored. |

## ImagenGCSImage.gcsURI

The Google Cloud Storage (GCS) URI at which the generated image is stored.

<b>Signature:</b>

```typescript
gcsURI: string;
```
40 changes: 40 additions & 0 deletions docs-devsite/vertexai.imagengcsimageresponse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Project: /docs/reference/js/_project.yaml
Book: /docs/reference/_book.yaml
page_type: reference

{% comment %}
DO NOT EDIT THIS FILE!
This is generated by the JS SDK team, and any local changes will be
overwritten. Changes should be made in the source code at
https://github.com/firebase/firebase-js-sdk
{% endcomment %}

# ImagenGCSImageResponse interface
<b>Signature:</b>

```typescript
export interface ImagenGCSImageResponse
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [filteredReason](./vertexai.imagengcsimageresponse.md#imagengcsimageresponsefilteredreason) | string | |
| [images](./vertexai.imagengcsimageresponse.md#imagengcsimageresponseimages) | [ImagenGCSImage](./vertexai.imagengcsimage.md#imagengcsimage_interface)<!-- -->\[\] | |

## ImagenGCSImageResponse.filteredReason

<b>Signature:</b>

```typescript
filteredReason?: string;
```

## ImagenGCSImageResponse.images

<b>Signature:</b>

```typescript
images: ImagenGCSImage[];
```
49 changes: 49 additions & 0 deletions docs-devsite/vertexai.imagengenerationconfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Project: /docs/reference/js/_project.yaml
Book: /docs/reference/_book.yaml
page_type: reference

{% comment %}
DO NOT EDIT THIS FILE!
This is generated by the JS SDK team, and any local changes will be
overwritten. Changes should be made in the source code at
https://github.com/firebase/firebase-js-sdk
{% endcomment %}

# ImagenGenerationConfig interface
<b>Signature:</b>

```typescript
export interface ImagenGenerationConfig
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [aspectRatio](./vertexai.imagengenerationconfig.md#imagengenerationconfigaspectratio) | [ImagenAspectRatio](./vertexai.md#imagenaspectratio) | |
| [negativePrompt](./vertexai.imagengenerationconfig.md#imagengenerationconfignegativeprompt) | string | |
| [numberOfImages](./vertexai.imagengenerationconfig.md#imagengenerationconfignumberofimages) | number | |

## ImagenGenerationConfig.aspectRatio

<b>Signature:</b>

```typescript
aspectRatio?: ImagenAspectRatio;
```

## ImagenGenerationConfig.negativePrompt

<b>Signature:</b>

```typescript
negativePrompt?: string;
```

## ImagenGenerationConfig.numberOfImages

<b>Signature:</b>

```typescript
numberOfImages?: number;
```
Loading
Loading