Skip to content

Commit 58ab777

Browse files
authoredMay 8, 2024··
Add a responseMimeType to generationConfig (#133)
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.
1 parent c39015c commit 58ab777

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed
 

‎.changeset/dirty-snails-unite.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@google/generative-ai": minor
3+
---
4+
5+
Added responseMimeType to GenerationConfig to allow for JSON formatted responses.

‎docs/reference/main/generative-ai.generationconfig.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface GenerationConfig
1818
| --- | --- | --- | --- |
1919
| [candidateCount?](./generative-ai.generationconfig.candidatecount.md) | | number | _(Optional)_ |
2020
| [maxOutputTokens?](./generative-ai.generationconfig.maxoutputtokens.md) | | number | _(Optional)_ |
21+
| [responseMimeType?](./generative-ai.generationconfig.responsemimetype.md) | | string | _(Optional)_ 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. |
2122
| [stopSequences?](./generative-ai.generationconfig.stopsequences.md) | | string\[\] | _(Optional)_ |
2223
| [temperature?](./generative-ai.generationconfig.temperature.md) | | number | _(Optional)_ |
2324
| [topK?](./generative-ai.generationconfig.topk.md) | | number | _(Optional)_ |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [GenerationConfig](./generative-ai.generationconfig.md) &gt; [responseMimeType](./generative-ai.generationconfig.responsemimetype.md)
4+
5+
## GenerationConfig.responseMimeType property
6+
7+
Output response mimetype of the generated candidate text. Supported mimetype: `text/plain`<!-- -->: (default) Text output. `application/json`<!-- -->: JSON response in the candidates.
8+
9+
**Signature:**
10+
11+
```typescript
12+
responseMimeType?: string;
13+
```

‎packages/main/types/requests.ts

+7
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ export interface GenerationConfig {
7474
temperature?: number;
7575
topP?: number;
7676
topK?: number;
77+
/**
78+
* Output response mimetype of the generated candidate text.
79+
* Supported mimetype:
80+
* `text/plain`: (default) Text output.
81+
* `application/json`: JSON response in the candidates.
82+
*/
83+
responseMimeType?: string;
7784
}
7885

7986
/**

0 commit comments

Comments
 (0)
Please sign in to comment.