Skip to content

Commit

Permalink
Add a responseMimeType to generationConfig (#133)
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 c39015c commit 58ab777
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-snails-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@google/generative-ai": minor
---

Added responseMimeType to GenerationConfig to allow for JSON formatted responses.
1 change: 1 addition & 0 deletions docs/reference/main/generative-ai.generationconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface GenerationConfig
| --- | --- | --- | --- |
| [candidateCount?](./generative-ai.generationconfig.candidatecount.md) | | number | _(Optional)_ |
| [maxOutputTokens?](./generative-ai.generationconfig.maxoutputtokens.md) | | number | _(Optional)_ |
| [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. |
| [stopSequences?](./generative-ai.generationconfig.stopsequences.md) | | string\[\] | _(Optional)_ |
| [temperature?](./generative-ai.generationconfig.temperature.md) | | number | _(Optional)_ |
| [topK?](./generative-ai.generationconfig.topk.md) | | number | _(Optional)_ |
Expand Down
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; [GenerationConfig](./generative-ai.generationconfig.md) &gt; [responseMimeType](./generative-ai.generationconfig.responsemimetype.md)

## GenerationConfig.responseMimeType property

Output response mimetype of the generated candidate text. Supported mimetype: `text/plain`<!-- -->: (default) Text output. `application/json`<!-- -->: JSON response in the candidates.

**Signature:**

```typescript
responseMimeType?: string;
```
7 changes: 7 additions & 0 deletions packages/main/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ export interface GenerationConfig {
temperature?: number;
topP?: number;
topK?: number;
/**
* Output response mimetype of the generated candidate text.
* Supported mimetype:
* `text/plain`: (default) Text output.
* `application/json`: JSON response in the candidates.
*/
responseMimeType?: string;
}

/**
Expand Down

0 comments on commit 58ab777

Please sign in to comment.