Skip to content

Commit 21c9f90

Browse files
Backport: fix(ai): remove unused mode setting from generateObject and streamObject (#10897)
This is an automated backport of #10896 to the release-v5.0 branch. FYI @lgrammel Co-authored-by: Lars Grammel <lars.grammel@gmail.com>
1 parent 4ae103c commit 21c9f90

File tree

5 files changed

+5
-48
lines changed

5 files changed

+5
-48
lines changed

.changeset/thin-jobs-train.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ai': patch
3+
---
4+
5+
fix(ai): remove unused mode setting from generateObject and streamObject

content/docs/07-reference/01-ai-sdk-core/03-generate-object.mdx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,6 @@ To see `generateObject` in action, check out the [additional examples](#more-exa
105105
type: "'object' | 'array' | 'enum' | 'no-schema' | undefined",
106106
description: "The type of output to generate. Defaults to 'object'.",
107107
},
108-
{
109-
name: 'mode',
110-
type: "'auto' | 'json' | 'tool'",
111-
description:
112-
"The mode to use for object generation. Not every model supports all modes. \
113-
Defaults to 'auto' for 'object' output and to 'json' for 'no-schema' output. \
114-
Must be 'json' for 'no-schema' output.",
115-
},
116108
{
117109
name: 'schema',
118110
type: 'Zod Schema | JSON Schema',

content/docs/07-reference/01-ai-sdk-core/04-stream-object.mdx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,6 @@ To see `streamObject` in action, check out the [additional examples](#more-examp
118118
type: "'object' | 'array' | 'enum' | 'no-schema' | undefined",
119119
description: "The type of output to generate. Defaults to 'object'.",
120120
},
121-
{
122-
name: 'mode',
123-
type: "'auto' | 'json' | 'tool'",
124-
description:
125-
"The mode to use for object generation. Not every model supports all modes. \
126-
Defaults to 'auto' for 'object' output and to 'json' for 'no-schema' output. \
127-
Must be 'json' for 'no-schema' output.",
128-
},
129121
{
130122
name: 'schema',
131123
type: 'Zod Schema | JSON Schema',

packages/ai/src/generate-object/generate-object.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ export async function generateObject<
128128
The enum values that the model should use.
129129
*/
130130
enum: Array<RESULT>;
131-
mode?: 'json';
132131
output: 'enum';
133132
}
134133
: OUTPUT extends 'no-schema'
@@ -152,21 +151,6 @@ Used by some providers for additional LLM guidance, e.g.
152151
via tool or schema description.
153152
*/
154153
schemaDescription?: string;
155-
156-
/**
157-
The mode to use for object generation.
158-
159-
The schema is converted into a JSON schema and used in one of the following ways
160-
161-
- 'auto': The provider will choose the best mode for the model.
162-
- 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
163-
- 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
164-
165-
Please note that most providers do not support all modes.
166-
167-
Default and recommended: 'auto' (best mode for the model).
168-
*/
169-
mode?: 'auto' | 'json' | 'tool';
170154
}) & {
171155
output?: OUTPUT;
172156

packages/ai/src/generate-object/stream-object.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ export function streamObject<
185185
The enum values that the model should use.
186186
*/
187187
enum: Array<RESULT>;
188-
mode?: 'json';
189188
output: 'enum';
190189
}
191190
: OUTPUT extends 'no-schema'
@@ -209,21 +208,6 @@ Used by some providers for additional LLM guidance, e.g.
209208
via tool or schema description.
210209
*/
211210
schemaDescription?: string;
212-
213-
/**
214-
The mode to use for object generation.
215-
216-
The schema is converted into a JSON schema and used in one of the following ways
217-
218-
- 'auto': The provider will choose the best mode for the model.
219-
- 'tool': A tool with the JSON schema as parameters is provided and the provider is instructed to use it.
220-
- 'json': The JSON schema and an instruction are injected into the prompt. If the provider supports JSON mode, it is enabled. If the provider supports JSON grammars, the grammar is used.
221-
222-
Please note that most providers do not support all modes.
223-
224-
Default and recommended: 'auto' (best mode for the model).
225-
*/
226-
mode?: 'auto' | 'json' | 'tool';
227211
}) & {
228212
output?: OUTPUT;
229213

0 commit comments

Comments
 (0)