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

Imagen #276

Closed
wants to merge 15 commits into from
5 changes: 0 additions & 5 deletions .changeset/good-beans-cheat.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/twelve-toes-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@google/generative-ai": minor
---

Add support for imagen model.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ temp/
*.tgz
.DS_Store
testfiles
nodejs-vertexai/
samples/yarn.lock
nodejs-vertexai/
59 changes: 51 additions & 8 deletions common/api-review/generative-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

```ts

import * as jspb from 'google-protobuf';

// @public
export interface BaseParams {
// (undocumented)
Expand Down Expand Up @@ -267,27 +269,19 @@ export interface FileDataPart {

// @public
export enum FinishReason {
// (undocumented)
BLOCKLIST = "BLOCKLIST",
// (undocumented)
FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED",
// (undocumented)
LANGUAGE = "LANGUAGE",
// (undocumented)
MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL",
// (undocumented)
MAX_TOKENS = "MAX_TOKENS",
// (undocumented)
OTHER = "OTHER",
// (undocumented)
PROHIBITED_CONTENT = "PROHIBITED_CONTENT",
// (undocumented)
RECITATION = "RECITATION",
// (undocumented)
SAFETY = "SAFETY",
// (undocumented)
SPII = "SPII",
// (undocumented)
STOP = "STOP"
}

Expand Down Expand Up @@ -511,6 +505,7 @@ export class GoogleGenerativeAI {
apiKey: string;
getGenerativeModel(modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;
getGenerativeModelFromCachedContent(cachedContent: CachedContent, modelParams?: Partial<ModelParams>, requestOptions?: RequestOptions): GenerativeModel;
getImageGenerationModel(modelParams: ModelParams, requestOptions?: RequestOptions): ImageGenerationModel;
}

// @public
Expand Down Expand Up @@ -627,6 +622,42 @@ export enum HarmProbability {
NEGLIGIBLE = "NEGLIGIBLE"
}

// @public
export interface ImageGenerationRequest {
// (undocumented)
aspectRatio?: "1:1" | "9:16" | "16:9" | "4:3" | "3:4";
// (undocumented)
compressionQuality?: number;
// (undocumented)
guidanceScale?: number;
// (undocumented)
height?: number;
// (undocumented)
language?: string;
// (undocumented)
negativePrompt?: string;
// (undocumented)
numberOfImages?: number;
// (undocumented)
outputMimeType?: "image/png" | "image/jpeg";
// (undocumented)
personGeneration?: "dont_allow" | "allow_adult";
// (undocumented)
prompt: string;
// (undocumented)
safetyFilterLevel?: "block_low_and_above" | "block_medium_and_above" | "block_only_high";
// (undocumented)
width?: number;
}

// @public
export interface ImageGenerationResponse {
// Warning: (ae-forgotten-export) The symbol "GeneratedImage" needs to be exported by the entry point index.d.ts
//
// (undocumented)
images: GeneratedImage[];
}

// @public
export interface InlineDataPart {
// (undocumented)
Expand Down Expand Up @@ -686,6 +717,18 @@ export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionRespon
// @public
export const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"];

// @public
export interface PredictRequest {
instances?: any[];
model?: string;
parameters?: any;
}

// @public
export interface PredictResponse {
predictions?: jspb.FieldValue[];
}

// @public
export interface PromptFeedback {
// (undocumented)
Expand Down
4 changes: 0 additions & 4 deletions docs/reference/main/generative-ai.finishreason.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ export declare enum FinishReason

| Member | Value | Description |
| --- | --- | --- |
| BLOCKLIST | <code>&quot;BLOCKLIST&quot;</code> | |
| FINISH\_REASON\_UNSPECIFIED | <code>&quot;FINISH_REASON_UNSPECIFIED&quot;</code> | |
| LANGUAGE | <code>&quot;LANGUAGE&quot;</code> | |
| MALFORMED\_FUNCTION\_CALL | <code>&quot;MALFORMED_FUNCTION_CALL&quot;</code> | |
| MAX\_TOKENS | <code>&quot;MAX_TOKENS&quot;</code> | |
| OTHER | <code>&quot;OTHER&quot;</code> | |
| PROHIBITED\_CONTENT | <code>&quot;PROHIBITED_CONTENT&quot;</code> | |
| RECITATION | <code>&quot;RECITATION&quot;</code> | |
| SAFETY | <code>&quot;SAFETY&quot;</code> | |
| SPII | <code>&quot;SPII&quot;</code> | |
| STOP | <code>&quot;STOP&quot;</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [GoogleGenerativeAI](./generative-ai.googlegenerativeai.md) &gt; [getImageGenerationModel](./generative-ai.googlegenerativeai.getimagegenerationmodel.md)

## GoogleGenerativeAI.getImageGenerationModel() method

Gets a [ImageGenerationModel](./generative-ai.imagegenerationmodel.md) instance for the provided model name.

**Signature:**

```typescript
getImageGenerationModel(modelParams: ModelParams, requestOptions?: RequestOptions): ImageGenerationModel;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| modelParams | [ModelParams](./generative-ai.modelparams.md) | |
| requestOptions | [RequestOptions](./generative-ai.requestoptions.md) | _(Optional)_ |

**Returns:**

[ImageGenerationModel](./generative-ai.imagegenerationmodel.md)

1 change: 1 addition & 0 deletions docs/reference/main/generative-ai.googlegenerativeai.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export declare class GoogleGenerativeAI
| --- | --- | --- |
| [getGenerativeModel(modelParams, requestOptions)](./generative-ai.googlegenerativeai.getgenerativemodel.md) | | Gets a [GenerativeModel](./generative-ai.generativemodel.md) instance for the provided model name. |
| [getGenerativeModelFromCachedContent(cachedContent, modelParams, requestOptions)](./generative-ai.googlegenerativeai.getgenerativemodelfromcachedcontent.md) | | Creates a [GenerativeModel](./generative-ai.generativemodel.md) instance from provided content cache. |
| [getImageGenerationModel(modelParams, requestOptions)](./generative-ai.googlegenerativeai.getimagegenerationmodel.md) | | Gets a [ImageGenerationModel](./generative-ai.imagegenerationmodel.md) instance for the provided model name. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationModel](./generative-ai.imagegenerationmodel.md) &gt; [(constructor)](./generative-ai.imagegenerationmodel._constructor_.md)

## ImageGenerationModel.(constructor)

Constructs a new instance of the `ImageGenerationModel` class

**Signature:**

```typescript
constructor(apiKey: string, modelParams: ModelParams, _requestOptions?: RequestOptions);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| apiKey | string | |
| modelParams | [ModelParams](./generative-ai.modelparams.md) | |
| \_requestOptions | [RequestOptions](./generative-ai.requestoptions.md) | _(Optional)_ |

11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.imagegenerationmodel.apikey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationModel](./generative-ai.imagegenerationmodel.md) &gt; [apiKey](./generative-ai.imagegenerationmodel.apikey.md)

## ImageGenerationModel.apiKey property

**Signature:**

```typescript
apiKey: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationModel](./generative-ai.imagegenerationmodel.md) &gt; [generateImages](./generative-ai.imagegenerationmodel.generateimages.md)

## ImageGenerationModel.generateImages() method

Makes a single non-streaming call to the model and returns an object containing a single [ImageGenerationResponse](./generative-ai.imagegenerationresponse.md)<!-- -->.

Inside the response there will be generated pictures specified by numberOfImages in [ImageGenerationRequest](./generative-ai.imagegenerationrequest.md)

Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getImageGenerationModel()](./generative-ai.googlegenerativeai.getimagegenerationmodel.md)<!-- -->.

**Signature:**

```typescript
generateImages(request: ImageGenerationRequest | string, requestOptions?: SingleRequestOptions): Promise<ImageGenerationResponse>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| request | [ImageGenerationRequest](./generative-ai.imagegenerationrequest.md) \| string | |
| requestOptions | [SingleRequestOptions](./generative-ai.singlerequestoptions.md) | _(Optional)_ |

**Returns:**

Promise&lt;[ImageGenerationResponse](./generative-ai.imagegenerationresponse.md)<!-- -->&gt;

33 changes: 33 additions & 0 deletions docs/reference/main/generative-ai.imagegenerationmodel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationModel](./generative-ai.imagegenerationmodel.md)

## ImageGenerationModel class

Class for generative model APIs.

**Signature:**

```typescript
export declare class ImageGenerationModel
```

## Constructors

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(apiKey, modelParams, \_requestOptions)](./generative-ai.imagegenerationmodel._constructor_.md) | | Constructs a new instance of the <code>ImageGenerationModel</code> class |

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [apiKey](./generative-ai.imagegenerationmodel.apikey.md) | | string | |
| [model](./generative-ai.imagegenerationmodel.model.md) | | string | |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [generateImages(request, requestOptions)](./generative-ai.imagegenerationmodel.generateimages.md) | | <p>Makes a single non-streaming call to the model and returns an object containing a single [ImageGenerationResponse](./generative-ai.imagegenerationresponse.md)<!-- -->.</p><p>Inside the response there will be generated pictures specified by numberOfImages in [ImageGenerationRequest](./generative-ai.imagegenerationrequest.md)</p><p>Fields set in the optional [SingleRequestOptions](./generative-ai.singlerequestoptions.md) parameter will take precedence over the [RequestOptions](./generative-ai.requestoptions.md) values provided to [GoogleGenerativeAI.getImageGenerationModel()](./generative-ai.googlegenerativeai.getimagegenerationmodel.md)<!-- -->.</p> |

11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.imagegenerationmodel.model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationModel](./generative-ai.imagegenerationmodel.md) &gt; [model](./generative-ai.imagegenerationmodel.model.md)

## ImageGenerationModel.model property

**Signature:**

```typescript
model: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationRequest](./generative-ai.imagegenerationrequest.md) &gt; [aspectRatio](./generative-ai.imagegenerationrequest.aspectratio.md)

## ImageGenerationRequest.aspectRatio property

Changes the aspect ratio of the generated image. Supported values are: \* "1:1" : 1:1 aspect ratio \* "9:16" : 9:16 aspect ratio \* "16:9" : 16:9 aspect ratio \* "4:3" : 4:3 aspect ratio \* "3:4" : 3:4 aspect\_ratio

**Signature:**

```typescript
aspectRatio?: "1:1" | "9:16" | "16:9" | "4:3" | "3:4";
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationRequest](./generative-ai.imagegenerationrequest.md) &gt; [compressionQuality](./generative-ai.imagegenerationrequest.compressionquality.md)

## ImageGenerationRequest.compressionQuality property

Level of compression if the output mime type is selected to be image/jpeg. Float between 0 to 100

**Signature:**

```typescript
compressionQuality?: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationRequest](./generative-ai.imagegenerationrequest.md) &gt; [guidanceScale](./generative-ai.imagegenerationrequest.guidancescale.md)

## ImageGenerationRequest.guidanceScale property

Controls the strength of the prompt. Suggested values are: \* 0-9 (low strength) \* 10-20 (medium strength) \* 21+ (high strength)

**Signature:**

```typescript
guidanceScale?: number;
```
13 changes: 13 additions & 0 deletions docs/reference/main/generative-ai.imagegenerationrequest.height.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationRequest](./generative-ai.imagegenerationrequest.md) &gt; [height](./generative-ai.imagegenerationrequest.height.md)

## ImageGenerationRequest.height property

Height of the image. One of the Width/Height sizes must be 256 or 1024.

**Signature:**

```typescript
height?: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationRequest](./generative-ai.imagegenerationrequest.md) &gt; [language](./generative-ai.imagegenerationrequest.language.md)

## ImageGenerationRequest.language property

Language of the text prompt for the image. Default: None. Supported values are `"en"` for English, `"hi"` for Hindi, `"ja"` for Japanese, `"ko"` for Korean, and `"auto"` for automatic language detection.

**Signature:**

```typescript
language?: string;
```
31 changes: 31 additions & 0 deletions docs/reference/main/generative-ai.imagegenerationrequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ImageGenerationRequest](./generative-ai.imagegenerationrequest.md)

## ImageGenerationRequest interface

Request message for generating image.

**Signature:**

```typescript
export interface ImageGenerationRequest
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [aspectRatio?](./generative-ai.imagegenerationrequest.aspectratio.md) | | "1:1" \| "9:16" \| "16:9" \| "4:3" \| "3:4" | _(Optional)_ Changes the aspect ratio of the generated image. Supported values are: \* "1:1" : 1:1 aspect ratio \* "9:16" : 9:16 aspect ratio \* "16:9" : 16:9 aspect ratio \* "4:3" : 4:3 aspect ratio \* "3:4" : 3:4 aspect\_ratio |
| [compressionQuality?](./generative-ai.imagegenerationrequest.compressionquality.md) | | number | _(Optional)_ Level of compression if the output mime type is selected to be image/jpeg. Float between 0 to 100 |
| [guidanceScale?](./generative-ai.imagegenerationrequest.guidancescale.md) | | number | _(Optional)_ Controls the strength of the prompt. Suggested values are: \* 0-9 (low strength) \* 10-20 (medium strength) \* 21+ (high strength) |
| [height?](./generative-ai.imagegenerationrequest.height.md) | | number | _(Optional)_ Height of the image. One of the Width/Height sizes must be 256 or 1024. |
| [language?](./generative-ai.imagegenerationrequest.language.md) | | string | _(Optional)_ Language of the text prompt for the image. Default: None. Supported values are <code>&quot;en&quot;</code> for English, <code>&quot;hi&quot;</code> for Hindi, <code>&quot;ja&quot;</code> for Japanese, <code>&quot;ko&quot;</code> for Korean, and <code>&quot;auto&quot;</code> for automatic language detection. |
| [negativePrompt?](./generative-ai.imagegenerationrequest.negativeprompt.md) | | string | _(Optional)_ A description of what you want to omit in the generated images. |
| [numberOfImages?](./generative-ai.imagegenerationrequest.numberofimages.md) | | number | _(Optional)_ Number of images to generate. Range: 1..8. |
| [outputMimeType?](./generative-ai.imagegenerationrequest.outputmimetype.md) | | "image/png" \| "image/jpeg" | _(Optional)_ hich image format should the output be saved as. Supported values: \* image/png: Save as a PNG image \* image/jpeg: Save as a JPEG image |
| [personGeneration?](./generative-ai.imagegenerationrequest.persongeneration.md) | | "dont\_allow" \| "allow\_adult" | _(Optional)_ Allow generation of people by the model Supported values are: \* "dont\_allow" : Block generation of people \* "allow\_adult" : Generate adults, but not children |
| [prompt](./generative-ai.imagegenerationrequest.prompt.md) | | string | Text prompt for the image. |
| [safetyFilterLevel?](./generative-ai.imagegenerationrequest.safetyfilterlevel.md) | | "block\_low\_and\_above" \| "block\_medium\_and\_above" \| "block\_only\_high" | _(Optional)_ Adds a filter level to Safety filtering. Supported values are: \* "block\_most" : Strongest filtering level, most strict blocking \* "block\_some" : Block some problematic prompts and responses \* "block\_few" : Block fewer problematic prompts and responses |
| [width?](./generative-ai.imagegenerationrequest.width.md) | | number | _(Optional)_ Width of the image. One of the Width/Height sizes must be 256 or 1024. |

Loading
Loading