Skip to content

Commit ff384b2

Browse files
add json schema to request
1 parent 11dc862 commit ff384b2

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

components/openai/actions/chat-using-file-search/chat-using-file-search.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default {
145145
props.jsonSchema = {
146146
type: "string",
147147
label: "JSON Schema",
148-
description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).",
148+
description: "Define the schema that the model's output must adhere to. [Generate one here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).",
149149
};
150150
}
151151

@@ -201,6 +201,15 @@ export default {
201201
};
202202
}
203203

204+
if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
205+
data.text = {
206+
format: {
207+
type: this.responseFormat,
208+
...JSON.parse(this.jsonSchema),
209+
},
210+
};
211+
}
212+
204213
const response = await this.openai.responses({
205214
$,
206215
data,

components/openai/actions/chat-using-functions/chat-using-functions.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export default {
166166
props.jsonSchema = {
167167
type: "string",
168168
label: "JSON Schema",
169-
description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).",
169+
description: "Define the schema that the model's output must adhere to. [Generate one here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).",
170170
};
171171
}
172172

@@ -227,6 +227,15 @@ export default {
227227
};
228228
}
229229

230+
if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
231+
data.text = {
232+
format: {
233+
type: this.responseFormat,
234+
...JSON.parse(this.jsonSchema),
235+
},
236+
};
237+
}
238+
230239
const response = await this.openai.responses({
231240
$,
232241
data,

components/openai/actions/chat-using-web-search/chat-using-web-search.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default {
136136
props.jsonSchema = {
137137
type: "string",
138138
label: "JSON Schema",
139-
description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).",
139+
description: "Define the schema that the model's output must adhere to. [Generate one here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).",
140140
};
141141
}
142142

@@ -172,6 +172,15 @@ export default {
172172
],
173173
};
174174

175+
if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
176+
data.text = {
177+
format: {
178+
type: this.responseFormat,
179+
...JSON.parse(this.jsonSchema),
180+
},
181+
};
182+
}
183+
175184
const response = await this.openai.responses({
176185
$,
177186
data,

0 commit comments

Comments
 (0)