Skip to content

Commit

Permalink
[Vertex AI] Add a responseMimeType to generationConfig (#8235)
Browse files Browse the repository at this point in the history
Provide Apps with an ability to configure the responseMimeType. This enables applications to request that VertexAI returns the response in a JSON format instead of a normal textual format.
  • Loading branch information
DellaBitta authored May 8, 2024
1 parent c66445c commit f6a2b88
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions common/api-review/vertexai-preview.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export interface GenerationConfig {
maxOutputTokens?: number;
// (undocumented)
presencePenalty?: number;
responseMimeType?: string;
// (undocumented)
stopSequences?: string[];
// (undocumented)
Expand Down
11 changes: 11 additions & 0 deletions docs-devsite/vertexai-preview.generationconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface GenerationConfig
| [frequencyPenalty](./vertexai-preview.generationconfig.md#generationconfigfrequencypenalty) | number | |
| [maxOutputTokens](./vertexai-preview.generationconfig.md#generationconfigmaxoutputtokens) | number | |
| [presencePenalty](./vertexai-preview.generationconfig.md#generationconfigpresencepenalty) | number | |
| [responseMimeType](./vertexai-preview.generationconfig.md#generationconfigresponsemimetype) | string | Output response mimetype of the generated candidate text. Supported mimetype: <code>text/plain</code>: (default) Text output. <code>application/json</code>: JSON response in the candidates. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature. |
| [stopSequences](./vertexai-preview.generationconfig.md#generationconfigstopsequences) | string\[\] | |
| [temperature](./vertexai-preview.generationconfig.md#generationconfigtemperature) | number | |
| [topK](./vertexai-preview.generationconfig.md#generationconfigtopk) | number | |
Expand Down Expand Up @@ -63,6 +64,16 @@ maxOutputTokens?: number;
presencePenalty?: number;
```

## GenerationConfig.responseMimeType

Output response mimetype of the generated candidate text. Supported mimetype: `text/plain`<!-- -->: (default) Text output. `application/json`<!-- -->: JSON response in the candidates. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature.

<b>Signature:</b>

```typescript
responseMimeType?: string;
```

## GenerationConfig.stopSequences

<b>Signature:</b>
Expand Down
10 changes: 10 additions & 0 deletions packages/vertexai/src/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ export interface GenerationConfig {
topK?: number;
presencePenalty?: number;
frequencyPenalty?: number;
/**
* Output response mimetype of the generated candidate text.
* Supported mimetype:
* `text/plain`: (default) Text output.
* `application/json`: JSON response in the candidates.
* The model needs to be prompted to output the appropriate response type,
* otherwise the behavior is undefined.
* This is a preview feature.
*/
responseMimeType?: string;
}

/**
Expand Down

0 comments on commit f6a2b88

Please sign in to comment.