Skip to content

feat(client): expose request body setter and getter #392

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

Merged
merged 1 commit into from
Apr 2, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ private constructor(
additionalQueryParams = speechCreateParams.additionalQueryParams.toBuilder()
}

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [input]
* - [model]
* - [voice]
* - [instructions]
* - [responseFormat]
* - etc.
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/** The text to generate audio for. The maximum length is 4096 characters. */
fun input(input: String) = apply { body.input(input) }

Expand Down Expand Up @@ -408,7 +422,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

override fun _headers(): Headers = additionalHeaders

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,20 @@ private constructor(
additionalQueryParams = transcriptionCreateParams.additionalQueryParams.toBuilder()
}

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [file]
* - [model]
* - [include]
* - [language]
* - [prompt]
* - etc.
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/**
* The audio file object (not file name) to transcribe, in one of these formats: flac, mp3,
* mp4, mpeg, mpga, m4a, ogg, wav, or webm.
Expand Down Expand Up @@ -503,8 +517,7 @@ private constructor(
)
}

@JvmSynthetic
internal fun _body(): Map<String, MultipartField<*>> =
fun _body(): Map<String, MultipartField<*>> =
mapOf(
"file" to _file(),
"model" to _model(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ private constructor(
additionalQueryParams = translationCreateParams.additionalQueryParams.toBuilder()
}

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [file]
* - [model]
* - [prompt]
* - [responseFormat]
* - [temperature]
* - etc.
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/**
* The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4,
* mpeg, mpga, m4a, ogg, wav, or webm.
Expand Down Expand Up @@ -372,8 +386,7 @@ private constructor(
)
}

@JvmSynthetic
internal fun _body(): Map<String, MultipartField<*>> =
fun _body(): Map<String, MultipartField<*>> =
mapOf(
"file" to _file(),
"model" to _model(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ private constructor(
)
}

@JvmSynthetic
internal fun _body(): Optional<Map<String, JsonValue>> =
fun _body(): Optional<Map<String, JsonValue>> =
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })

fun _pathParam(index: Int): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ private constructor(
additionalQueryParams = batchCreateParams.additionalQueryParams.toBuilder()
}

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [completionWindow]
* - [endpoint]
* - [inputFileId]
* - [metadata]
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/**
* The time frame within which the batch should be processed. Currently only `24h` is
* supported.
Expand Down Expand Up @@ -363,7 +375,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

override fun _headers(): Headers = additionalHeaders

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,20 @@ private constructor(
additionalQueryParams = assistantCreateParams.additionalQueryParams.toBuilder()
}

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [model]
* - [description]
* - [instructions]
* - [metadata]
* - [name]
* - etc.
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/**
* ID of the model to use. You can use the
* [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all
Expand Down Expand Up @@ -728,7 +742,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

override fun _headers(): Headers = additionalHeaders

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ private constructor(
)
}

@JvmSynthetic
internal fun _body(): Optional<Map<String, JsonValue>> =
fun _body(): Optional<Map<String, JsonValue>> =
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })

fun _pathParam(index: Int): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ private constructor(

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

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [description]
* - [instructions]
* - [metadata]
* - [model]
* - [name]
* - etc.
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/** The description of the assistant. The maximum length is 512 characters. */
fun description(description: String?) = apply { body.description(description) }

Expand Down Expand Up @@ -726,7 +740,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

fun _pathParam(index: Int): String =
when (index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,20 @@ private constructor(
additionalQueryParams = threadCreateAndRunParams.additionalQueryParams.toBuilder()
}

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [assistantId]
* - [instructions]
* - [maxCompletionTokens]
* - [maxPromptTokens]
* - [metadata]
* - etc.
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/**
* The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) to
* use to execute this run.
Expand Down Expand Up @@ -923,7 +937,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

override fun _headers(): Headers = additionalHeaders

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ private constructor(
additionalQueryParams = threadCreateParams.additionalQueryParams.toBuilder()
}

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [messages]
* - [metadata]
* - [toolResources]
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/**
* A list of [messages](https://platform.openai.com/docs/api-reference/messages) to start
* the thread with.
Expand Down Expand Up @@ -326,7 +337,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

override fun _headers(): Headers = additionalHeaders

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ private constructor(
)
}

@JvmSynthetic
internal fun _body(): Optional<Map<String, JsonValue>> =
fun _body(): Optional<Map<String, JsonValue>> =
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })

fun _pathParam(index: Int): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ private constructor(

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

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [metadata]
* - [toolResources]
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
* storing additional information about the object in a structured format, and querying for
Expand Down Expand Up @@ -294,7 +304,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

fun _pathParam(index: Int): String =
when (index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ private constructor(

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

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [content]
* - [role]
* - [attachments]
* - [metadata]
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/** The text contents of the message. */
fun content(content: Content) = apply { body.content(content) }

Expand Down Expand Up @@ -382,7 +394,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

fun _pathParam(index: Int): String =
when (index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ private constructor(
)
}

@JvmSynthetic
internal fun _body(): Optional<Map<String, JsonValue>> =
fun _body(): Optional<Map<String, JsonValue>> =
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })

fun _pathParam(index: Int): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ private constructor(

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

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [metadata]
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/**
* Set of 16 key-value pairs that can be attached to an object. This can be useful for
* storing additional information about the object in a structured format, and querying for
Expand Down Expand Up @@ -261,7 +270,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

fun _pathParam(index: Int): String =
when (index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ private constructor(
)
}

@JvmSynthetic
internal fun _body(): Optional<Map<String, JsonValue>> =
fun _body(): Optional<Map<String, JsonValue>> =
Optional.ofNullable(additionalBodyProperties.ifEmpty { null })

fun _pathParam(index: Int): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,20 @@ private constructor(
this.include = (this.include ?: mutableListOf()).apply { add(include) }
}

/**
* Sets the entire request body.
*
* This is generally only useful if you are already constructing the body separately.
* Otherwise, it's more convenient to use the top-level setters instead:
* - [assistantId]
* - [additionalInstructions]
* - [additionalMessages]
* - [instructions]
* - [maxCompletionTokens]
* - etc.
*/
fun body(body: Body) = apply { this.body = body.toBuilder() }

/**
* The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) to
* use to execute this run.
Expand Down Expand Up @@ -1059,7 +1073,7 @@ private constructor(
)
}

@JvmSynthetic internal fun _body(): Body = body
fun _body(): Body = body

fun _pathParam(index: Int): String =
when (index) {
Expand Down
Loading