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 a responseMimeType to generationConfig #133

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading