Skip to content

Commit eaa0bc9

Browse files
feat(client): expose request body setter and getter (#392)
1 parent 9679525 commit eaa0bc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+460
-68
lines changed

openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,20 @@ private constructor(
161161
additionalQueryParams = speechCreateParams.additionalQueryParams.toBuilder()
162162
}
163163

164+
/**
165+
* Sets the entire request body.
166+
*
167+
* This is generally only useful if you are already constructing the body separately.
168+
* Otherwise, it's more convenient to use the top-level setters instead:
169+
* - [input]
170+
* - [model]
171+
* - [voice]
172+
* - [instructions]
173+
* - [responseFormat]
174+
* - etc.
175+
*/
176+
fun body(body: Body) = apply { this.body = body.toBuilder() }
177+
164178
/** The text to generate audio for. The maximum length is 4096 characters. */
165179
fun input(input: String) = apply { body.input(input) }
166180

@@ -408,7 +422,7 @@ private constructor(
408422
)
409423
}
410424

411-
@JvmSynthetic internal fun _body(): Body = body
425+
fun _body(): Body = body
412426

413427
override fun _headers(): Headers = additionalHeaders
414428

openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt

+15-2
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ private constructor(
208208
additionalQueryParams = transcriptionCreateParams.additionalQueryParams.toBuilder()
209209
}
210210

211+
/**
212+
* Sets the entire request body.
213+
*
214+
* This is generally only useful if you are already constructing the body separately.
215+
* Otherwise, it's more convenient to use the top-level setters instead:
216+
* - [file]
217+
* - [model]
218+
* - [include]
219+
* - [language]
220+
* - [prompt]
221+
* - etc.
222+
*/
223+
fun body(body: Body) = apply { this.body = body.toBuilder() }
224+
211225
/**
212226
* The audio file object (not file name) to transcribe, in one of these formats: flac, mp3,
213227
* mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -503,8 +517,7 @@ private constructor(
503517
)
504518
}
505519

506-
@JvmSynthetic
507-
internal fun _body(): Map<String, MultipartField<*>> =
520+
fun _body(): Map<String, MultipartField<*>> =
508521
mapOf(
509522
"file" to _file(),
510523
"model" to _model(),

openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt

+15-2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,20 @@ private constructor(
149149
additionalQueryParams = translationCreateParams.additionalQueryParams.toBuilder()
150150
}
151151

152+
/**
153+
* Sets the entire request body.
154+
*
155+
* This is generally only useful if you are already constructing the body separately.
156+
* Otherwise, it's more convenient to use the top-level setters instead:
157+
* - [file]
158+
* - [model]
159+
* - [prompt]
160+
* - [responseFormat]
161+
* - [temperature]
162+
* - etc.
163+
*/
164+
fun body(body: Body) = apply { this.body = body.toBuilder() }
165+
152166
/**
153167
* The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4,
154168
* mpeg, mpga, m4a, ogg, wav, or webm.
@@ -372,8 +386,7 @@ private constructor(
372386
)
373387
}
374388

375-
@JvmSynthetic
376-
internal fun _body(): Map<String, MultipartField<*>> =
389+
fun _body(): Map<String, MultipartField<*>> =
377390
mapOf(
378391
"file" to _file(),
379392
"model" to _model(),

openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCancelParams.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ private constructor(
206206
)
207207
}
208208

209-
@JvmSynthetic
210-
internal fun _body(): Optional<Map<String, JsonValue>> =
209+
fun _body(): Optional<Map<String, JsonValue>> =
211210
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
212211

213212
fun _pathParam(index: Int): String =

openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ private constructor(
144144
additionalQueryParams = batchCreateParams.additionalQueryParams.toBuilder()
145145
}
146146

147+
/**
148+
* Sets the entire request body.
149+
*
150+
* This is generally only useful if you are already constructing the body separately.
151+
* Otherwise, it's more convenient to use the top-level setters instead:
152+
* - [completionWindow]
153+
* - [endpoint]
154+
* - [inputFileId]
155+
* - [metadata]
156+
*/
157+
fun body(body: Body) = apply { this.body = body.toBuilder() }
158+
147159
/**
148160
* The time frame within which the batch should be processed. Currently only `24h` is
149161
* supported.
@@ -363,7 +375,7 @@ private constructor(
363375
)
364376
}
365377

366-
@JvmSynthetic internal fun _body(): Body = body
378+
fun _body(): Body = body
367379

368380
override fun _headers(): Headers = additionalHeaders
369381

openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,20 @@ private constructor(
285285
additionalQueryParams = assistantCreateParams.additionalQueryParams.toBuilder()
286286
}
287287

288+
/**
289+
* Sets the entire request body.
290+
*
291+
* This is generally only useful if you are already constructing the body separately.
292+
* Otherwise, it's more convenient to use the top-level setters instead:
293+
* - [model]
294+
* - [description]
295+
* - [instructions]
296+
* - [metadata]
297+
* - [name]
298+
* - etc.
299+
*/
300+
fun body(body: Body) = apply { this.body = body.toBuilder() }
301+
288302
/**
289303
* ID of the model to use. You can use the
290304
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all
@@ -728,7 +742,7 @@ private constructor(
728742
)
729743
}
730744

731-
@JvmSynthetic internal fun _body(): Body = body
745+
fun _body(): Body = body
732746

733747
override fun _headers(): Headers = additionalHeaders
734748

openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleteParams.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ private constructor(
202202
)
203203
}
204204

205-
@JvmSynthetic
206-
internal fun _body(): Optional<Map<String, JsonValue>> =
205+
fun _body(): Optional<Map<String, JsonValue>> =
207206
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
208207

209208
fun _pathParam(index: Int): String =

openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,20 @@ private constructor(
282282

283283
fun assistantId(assistantId: String) = apply { this.assistantId = assistantId }
284284

285+
/**
286+
* Sets the entire request body.
287+
*
288+
* This is generally only useful if you are already constructing the body separately.
289+
* Otherwise, it's more convenient to use the top-level setters instead:
290+
* - [description]
291+
* - [instructions]
292+
* - [metadata]
293+
* - [model]
294+
* - [name]
295+
* - etc.
296+
*/
297+
fun body(body: Body) = apply { this.body = body.toBuilder() }
298+
285299
/** The description of the assistant. The maximum length is 512 characters. */
286300
fun description(description: String?) = apply { body.description(description) }
287301

@@ -726,7 +740,7 @@ private constructor(
726740
)
727741
}
728742

729-
@JvmSynthetic internal fun _body(): Body = body
743+
fun _body(): Body = body
730744

731745
fun _pathParam(index: Int): String =
732746
when (index) {

openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateAndRunParams.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,20 @@ private constructor(
362362
additionalQueryParams = threadCreateAndRunParams.additionalQueryParams.toBuilder()
363363
}
364364

365+
/**
366+
* Sets the entire request body.
367+
*
368+
* This is generally only useful if you are already constructing the body separately.
369+
* Otherwise, it's more convenient to use the top-level setters instead:
370+
* - [assistantId]
371+
* - [instructions]
372+
* - [maxCompletionTokens]
373+
* - [maxPromptTokens]
374+
* - [metadata]
375+
* - etc.
376+
*/
377+
fun body(body: Body) = apply { this.body = body.toBuilder() }
378+
365379
/**
366380
* The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) to
367381
* use to execute this run.
@@ -923,7 +937,7 @@ private constructor(
923937
)
924938
}
925939

926-
@JvmSynthetic internal fun _body(): Body = body
940+
fun _body(): Body = body
927941

928942
override fun _headers(): Headers = additionalHeaders
929943

openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateParams.kt

+12-1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ private constructor(
127127
additionalQueryParams = threadCreateParams.additionalQueryParams.toBuilder()
128128
}
129129

130+
/**
131+
* Sets the entire request body.
132+
*
133+
* This is generally only useful if you are already constructing the body separately.
134+
* Otherwise, it's more convenient to use the top-level setters instead:
135+
* - [messages]
136+
* - [metadata]
137+
* - [toolResources]
138+
*/
139+
fun body(body: Body) = apply { this.body = body.toBuilder() }
140+
130141
/**
131142
* A list of [messages](https://platform.openai.com/docs/api-reference/messages) to start
132143
* the thread with.
@@ -326,7 +337,7 @@ private constructor(
326337
)
327338
}
328339

329-
@JvmSynthetic internal fun _body(): Body = body
340+
fun _body(): Body = body
330341

331342
override fun _headers(): Headers = additionalHeaders
332343

openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadDeleteParams.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ private constructor(
202202
)
203203
}
204204

205-
@JvmSynthetic
206-
internal fun _body(): Optional<Map<String, JsonValue>> =
205+
fun _body(): Optional<Map<String, JsonValue>> =
207206
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
208207

209208
fun _pathParam(index: Int): String =

openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadUpdateParams.kt

+11-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ private constructor(
109109

110110
fun threadId(threadId: String) = apply { this.threadId = threadId }
111111

112+
/**
113+
* Sets the entire request body.
114+
*
115+
* This is generally only useful if you are already constructing the body separately.
116+
* Otherwise, it's more convenient to use the top-level setters instead:
117+
* - [metadata]
118+
* - [toolResources]
119+
*/
120+
fun body(body: Body) = apply { this.body = body.toBuilder() }
121+
112122
/**
113123
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
114124
* storing additional information about the object in a structured format, and querying for
@@ -294,7 +304,7 @@ private constructor(
294304
)
295305
}
296306

297-
@JvmSynthetic internal fun _body(): Body = body
307+
fun _body(): Body = body
298308

299309
fun _pathParam(index: Int): String =
300310
when (index) {

openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageCreateParams.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ private constructor(
156156

157157
fun threadId(threadId: String) = apply { this.threadId = threadId }
158158

159+
/**
160+
* Sets the entire request body.
161+
*
162+
* This is generally only useful if you are already constructing the body separately.
163+
* Otherwise, it's more convenient to use the top-level setters instead:
164+
* - [content]
165+
* - [role]
166+
* - [attachments]
167+
* - [metadata]
168+
*/
169+
fun body(body: Body) = apply { this.body = body.toBuilder() }
170+
159171
/** The text contents of the message. */
160172
fun content(content: Content) = apply { body.content(content) }
161173

@@ -382,7 +394,7 @@ private constructor(
382394
)
383395
}
384396

385-
@JvmSynthetic internal fun _body(): Body = body
397+
fun _body(): Body = body
386398

387399
fun _pathParam(index: Int): String =
388400
when (index) {

openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeleteParams.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ private constructor(
212212
)
213213
}
214214

215-
@JvmSynthetic
216-
internal fun _body(): Optional<Map<String, JsonValue>> =
215+
fun _body(): Optional<Map<String, JsonValue>> =
217216
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
218217

219218
fun _pathParam(index: Int): String =

openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageUpdateParams.kt

+10-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ private constructor(
9999

100100
fun messageId(messageId: String) = apply { this.messageId = messageId }
101101

102+
/**
103+
* Sets the entire request body.
104+
*
105+
* This is generally only useful if you are already constructing the body separately.
106+
* Otherwise, it's more convenient to use the top-level setters instead:
107+
* - [metadata]
108+
*/
109+
fun body(body: Body) = apply { this.body = body.toBuilder() }
110+
102111
/**
103112
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
104113
* storing additional information about the object in a structured format, and querying for
@@ -261,7 +270,7 @@ private constructor(
261270
)
262271
}
263272

264-
@JvmSynthetic internal fun _body(): Body = body
273+
fun _body(): Body = body
265274

266275
fun _pathParam(index: Int): String =
267276
when (index) {

openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCancelParams.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ private constructor(
212212
)
213213
}
214214

215-
@JvmSynthetic
216-
internal fun _body(): Optional<Map<String, JsonValue>> =
215+
fun _body(): Optional<Map<String, JsonValue>> =
217216
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })
218217

219218
fun _pathParam(index: Int): String =

openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,20 @@ private constructor(
437437
this.include = (this.include ?: mutableListOf()).apply { add(include) }
438438
}
439439

440+
/**
441+
* Sets the entire request body.
442+
*
443+
* This is generally only useful if you are already constructing the body separately.
444+
* Otherwise, it's more convenient to use the top-level setters instead:
445+
* - [assistantId]
446+
* - [additionalInstructions]
447+
* - [additionalMessages]
448+
* - [instructions]
449+
* - [maxCompletionTokens]
450+
* - etc.
451+
*/
452+
fun body(body: Body) = apply { this.body = body.toBuilder() }
453+
440454
/**
441455
* The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) to
442456
* use to execute this run.
@@ -1059,7 +1073,7 @@ private constructor(
10591073
)
10601074
}
10611075

1062-
@JvmSynthetic internal fun _body(): Body = body
1076+
fun _body(): Body = body
10631077

10641078
fun _pathParam(index: Int): String =
10651079
when (index) {

0 commit comments

Comments
 (0)