From b0e9d316bde7866f0d6c9381a5bec5a6667f46f6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 14:40:47 +0000 Subject: [PATCH 1/4] chore(internal): codegen related update (#389) --- .../kotlin/com/openai/core/ObjectMappers.kt | 64 ++++++++++++++++++- .../com/openai/core/ObjectMappersTest.kt | 21 ++++++ 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/openai-java-core/src/main/kotlin/com/openai/core/ObjectMappers.kt b/openai-java-core/src/main/kotlin/com/openai/core/ObjectMappers.kt index 7be25df3..24bec380 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/ObjectMappers.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/ObjectMappers.kt @@ -4,12 +4,16 @@ package com.openai.core import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParseException +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.MapperFeature import com.fasterxml.jackson.databind.SerializationFeature import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.cfg.CoercionAction import com.fasterxml.jackson.databind.cfg.CoercionInputShape +import com.fasterxml.jackson.databind.deser.std.StdDeserializer import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.databind.module.SimpleModule import com.fasterxml.jackson.databind.type.LogicalType @@ -17,13 +21,23 @@ import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule import com.fasterxml.jackson.module.kotlin.kotlinModule import java.io.InputStream +import java.time.DateTimeException +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField fun jsonMapper(): JsonMapper = JsonMapper.builder() .addModule(kotlinModule()) .addModule(Jdk8Module()) .addModule(JavaTimeModule()) - .addModule(SimpleModule().addSerializer(InputStreamJsonSerializer)) + .addModule( + SimpleModule() + .addSerializer(InputStreamSerializer) + .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + ) .withCoercionConfig(LogicalType.Boolean) { it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) @@ -91,7 +105,10 @@ fun jsonMapper(): JsonMapper = .disable(MapperFeature.AUTO_DETECT_SETTERS) .build() -private object InputStreamJsonSerializer : BaseSerializer(InputStream::class) { +/** A serializer that serializes [InputStream] to bytes. */ +private object InputStreamSerializer : BaseSerializer(InputStream::class) { + + private fun readResolve(): Any = InputStreamSerializer override fun serialize( value: InputStream?, @@ -105,3 +122,46 @@ private object InputStreamJsonSerializer : BaseSerializer(InputStre } } } + +/** + * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + */ +private class LenientLocalDateTimeDeserializer : + StdDeserializer(LocalDateTime::class.java) { + + companion object { + + private val DATE_TIME_FORMATTERS = + listOf( + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ) + } + + override fun logicalType(): LogicalType = LogicalType.DateTime + + override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + val exceptions = mutableListOf() + + for (formatter in DATE_TIME_FORMATTERS) { + try { + val temporal = formatter.parse(p.text) + + return when { + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + } catch (e: DateTimeException) { + exceptions.add(e) + } + } + + throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + exceptions.forEach { addSuppressed(it) } + } + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/core/ObjectMappersTest.kt b/openai-java-core/src/test/kotlin/com/openai/core/ObjectMappersTest.kt index 17fe45c3..2dbf1a4c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/core/ObjectMappersTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/core/ObjectMappersTest.kt @@ -2,10 +2,15 @@ package com.openai.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException +import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDateTime import kotlin.reflect.KClass import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource import org.junitpioneer.jupiter.cartesian.CartesianTest internal class ObjectMappersTest { @@ -78,4 +83,20 @@ internal class ObjectMappersTest { assertThat(e).isInstanceOf(MismatchedInputException::class.java) } } + + enum class LenientLocalDateTimeTestCase(val string: String) { + DATE("1998-04-21"), + DATE_TIME("1998-04-21T04:00:00"), + ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), + ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + } + + @ParameterizedTest + @EnumSource + fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(testCase.string) + + assertDoesNotThrow { jsonMapper().readValue(json) } + } } From 967952553d5fd2e7f47cd7c82fac45cc9dcef43e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 14:51:47 +0000 Subject: [PATCH 2/4] feat(api): manual updates --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 1f1a1736..b80d385d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 80 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-4bce8217a697c729ac98046d4caf2c9e826b54c427fb0ab4f98e549a2e0ce31c.yml openapi_spec_hash: 7996d2c34cc44fe2ce9ffe93c0ab774e -config_hash: 178ba1bfb1237bf6b94abb3408072aa7 +config_hash: 578c5bff4208d560c0c280f13324409f From eaa0bc96ba8898e064709a571e97d6b99f478597 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 20:34:00 +0000 Subject: [PATCH 3/4] feat(client): expose request body setter and getter (#392) --- .../models/audio/speech/SpeechCreateParams.kt | 16 +++++++++++++++- .../transcriptions/TranscriptionCreateParams.kt | 17 +++++++++++++++-- .../translations/TranslationCreateParams.kt | 17 +++++++++++++++-- .../openai/models/batches/BatchCancelParams.kt | 3 +-- .../openai/models/batches/BatchCreateParams.kt | 14 +++++++++++++- .../beta/assistants/AssistantCreateParams.kt | 16 +++++++++++++++- .../beta/assistants/AssistantDeleteParams.kt | 3 +-- .../beta/assistants/AssistantUpdateParams.kt | 16 +++++++++++++++- .../beta/threads/ThreadCreateAndRunParams.kt | 16 +++++++++++++++- .../models/beta/threads/ThreadCreateParams.kt | 13 ++++++++++++- .../models/beta/threads/ThreadDeleteParams.kt | 3 +-- .../models/beta/threads/ThreadUpdateParams.kt | 12 +++++++++++- .../threads/messages/MessageCreateParams.kt | 14 +++++++++++++- .../threads/messages/MessageDeleteParams.kt | 3 +-- .../threads/messages/MessageUpdateParams.kt | 11 ++++++++++- .../models/beta/threads/runs/RunCancelParams.kt | 3 +-- .../models/beta/threads/runs/RunCreateParams.kt | 16 +++++++++++++++- .../threads/runs/RunSubmitToolOutputsParams.kt | 11 ++++++++++- .../models/beta/threads/runs/RunUpdateParams.kt | 11 ++++++++++- .../completions/ChatCompletionCreateParams.kt | 16 +++++++++++++++- .../completions/ChatCompletionDeleteParams.kt | 3 +-- .../completions/ChatCompletionUpdateParams.kt | 11 ++++++++++- .../completions/CompletionCreateParams.kt | 16 +++++++++++++++- .../models/embeddings/EmbeddingCreateParams.kt | 16 +++++++++++++++- .../com/openai/models/files/FileCreateParams.kt | 13 +++++++++++-- .../com/openai/models/files/FileDeleteParams.kt | 3 +-- .../models/finetuning/jobs/JobCancelParams.kt | 3 +-- .../models/finetuning/jobs/JobCreateParams.kt | 16 +++++++++++++++- .../models/images/ImageCreateVariationParams.kt | 17 +++++++++++++++-- .../com/openai/models/images/ImageEditParams.kt | 17 +++++++++++++++-- .../openai/models/images/ImageGenerateParams.kt | 16 +++++++++++++++- .../openai/models/models/ModelDeleteParams.kt | 3 +-- .../moderations/ModerationCreateParams.kt | 12 +++++++++++- .../models/responses/ResponseCreateParams.kt | 16 +++++++++++++++- .../models/responses/ResponseDeleteParams.kt | 3 +-- .../openai/models/uploads/UploadCancelParams.kt | 3 +-- .../models/uploads/UploadCompleteParams.kt | 12 +++++++++++- .../openai/models/uploads/UploadCreateParams.kt | 14 +++++++++++++- .../models/uploads/parts/PartCreateParams.kt | 12 ++++++++++-- .../vectorstores/VectorStoreCreateParams.kt | 16 +++++++++++++++- .../vectorstores/VectorStoreDeleteParams.kt | 3 +-- .../vectorstores/VectorStoreSearchParams.kt | 16 +++++++++++++++- .../vectorstores/VectorStoreUpdateParams.kt | 13 ++++++++++++- .../filebatches/FileBatchCancelParams.kt | 3 +-- .../filebatches/FileBatchCreateParams.kt | 13 ++++++++++++- .../vectorstores/files/FileCreateParams.kt | 13 ++++++++++++- .../vectorstores/files/FileDeleteParams.kt | 3 +-- .../vectorstores/files/FileUpdateParams.kt | 11 ++++++++++- 48 files changed, 460 insertions(+), 68 deletions(-) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt index 44190cfa..089121a4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechCreateParams.kt @@ -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) } @@ -408,7 +422,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt index 5ff32133..5973dd72 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt @@ -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. @@ -503,8 +517,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Map> = + fun _body(): Map> = mapOf( "file" to _file(), "model" to _model(), diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt index dc7565f5..ec4db548 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt @@ -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. @@ -372,8 +386,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Map> = + fun _body(): Map> = mapOf( "file" to _file(), "model" to _model(), diff --git a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCancelParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCancelParams.kt index 8ffd2380..c9a0e725 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCancelParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCancelParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt index f03e6ec7..577bd86e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt @@ -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. @@ -363,7 +375,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt index dc3ecf12..6ccb814b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt @@ -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 @@ -728,7 +742,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleteParams.kt index 2b140761..f0c6d40f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleteParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt index 55626900..4442efa9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt @@ -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) } @@ -726,7 +740,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateAndRunParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateAndRunParams.kt index dcfcd309..6b6a3c2f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateAndRunParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateAndRunParams.kt @@ -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. @@ -923,7 +937,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateParams.kt index 7c1c8168..d09b5c2c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateParams.kt @@ -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. @@ -326,7 +337,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadDeleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadDeleteParams.kt index 6b76abc1..fd960288 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadDeleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadDeleteParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadUpdateParams.kt index e7283d40..6821167a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadUpdateParams.kt @@ -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 @@ -294,7 +304,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageCreateParams.kt index 8834c034..70d795cb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageCreateParams.kt @@ -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) } @@ -382,7 +394,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeleteParams.kt index 375ad537..e2022510 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeleteParams.kt @@ -212,8 +212,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageUpdateParams.kt index 40757811..430dcfad 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageUpdateParams.kt @@ -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 @@ -261,7 +270,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCancelParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCancelParams.kt index 811ff5f4..cf442b6c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCancelParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCancelParams.kt @@ -212,8 +212,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt index 5d94026e..85a293b2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt @@ -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. @@ -1059,7 +1073,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunSubmitToolOutputsParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunSubmitToolOutputsParams.kt index 0c586261..22bb60bb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunSubmitToolOutputsParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunSubmitToolOutputsParams.kt @@ -100,6 +100,15 @@ private constructor( fun runId(runId: String) = apply { this.runId = runId } + /** + * 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: + * - [toolOutputs] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** A list of tools for which the outputs are being submitted. */ fun toolOutputs(toolOutputs: List) = apply { body.toolOutputs(toolOutputs) } @@ -262,7 +271,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunUpdateParams.kt index aae006b8..0ee5f8b6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunUpdateParams.kt @@ -99,6 +99,15 @@ private constructor( fun runId(runId: String) = apply { this.runId = runId } + /** + * 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 @@ -261,7 +270,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt index 4a5b8530..592b703d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt @@ -662,6 +662,20 @@ private constructor( additionalQueryParams = chatCompletionCreateParams.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] + * - [model] + * - [audio] + * - [frequencyPenalty] + * - [functionCall] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * A list of messages comprising the conversation so far. Depending on the * [model](https://platform.openai.com/docs/models) you use, different message types @@ -1714,7 +1728,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeleteParams.kt index 3d17ad09..0cd4d7fa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeleteParams.kt @@ -206,8 +206,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUpdateParams.kt index 3e22c07f..fa1d07cd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUpdateParams.kt @@ -96,6 +96,15 @@ private constructor( fun completionId(completionId: String) = apply { this.completionId = completionId } + /** + * 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 @@ -257,7 +266,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionCreateParams.kt index 49ba5183..707d4ec3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionCreateParams.kt @@ -397,6 +397,20 @@ private constructor( additionalQueryParams = completionCreateParams.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] + * - [prompt] + * - [bestOf] + * - [echo] + * - [frequencyPenalty] + * - 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 @@ -987,7 +1001,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt index 075ffd2b..79ccadb0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt @@ -164,6 +164,20 @@ private constructor( additionalQueryParams = embeddingCreateParams.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] + * - [dimensions] + * - [encodingFormat] + * - [user] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in * a single request, pass an array of strings or array of token arrays. The input must not @@ -412,7 +426,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/files/FileCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/files/FileCreateParams.kt index 323aa78e..b8798287 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/files/FileCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/files/FileCreateParams.kt @@ -108,6 +108,16 @@ private constructor( additionalQueryParams = fileCreateParams.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] + * - [purpose] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** The File object (not file name) to be uploaded. */ fun file(file: InputStream) = apply { body.file(file) } @@ -258,8 +268,7 @@ private constructor( FileCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - @JvmSynthetic - internal fun _body(): Map> = + fun _body(): Map> = mapOf("file" to _file(), "purpose" to _purpose()).toImmutable() override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/files/FileDeleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/files/FileDeleteParams.kt index f7d17248..2bc93b6a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/files/FileDeleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/files/FileDeleteParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCancelParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCancelParams.kt index 0355291c..4d7c9f96 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCancelParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCancelParams.kt @@ -204,8 +204,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCreateParams.kt index 05f0b876..92144ee8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCreateParams.kt @@ -260,6 +260,20 @@ private constructor( additionalQueryParams = jobCreateParams.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] + * - [trainingFile] + * - [hyperparameters] + * - [integrations] + * - [metadata] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * The name of the model to fine-tune. You can select one of the * [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned). @@ -603,7 +617,7 @@ private constructor( JobCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageCreateVariationParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageCreateVariationParams.kt index a75a9437..f7e452c7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageCreateVariationParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageCreateVariationParams.kt @@ -159,6 +159,20 @@ private constructor( additionalQueryParams = imageCreateVariationParams.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: + * - [image] + * - [model] + * - [n] + * - [responseFormat] + * - [size] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * The image to use as the basis for the variation(s). Must be a valid PNG file, less than * 4MB, and square. @@ -405,8 +419,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Map> = + fun _body(): Map> = mapOf( "image" to _image(), "model" to _model(), diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt index f78b2820..ff88c723 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt @@ -191,6 +191,20 @@ private constructor( additionalQueryParams = imageEditParams.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: + * - [image] + * - [prompt] + * - [mask] + * - [model] + * - [n] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not * provided, image must have transparency, which will be used as the mask. @@ -472,8 +486,7 @@ private constructor( ImageEditParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } - @JvmSynthetic - internal fun _body(): Map> = + fun _body(): Map> = mapOf( "image" to _image(), "prompt" to _prompt(), diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt index b69e0c2d..f36bc481 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt @@ -194,6 +194,20 @@ private constructor( additionalQueryParams = imageGenerateParams.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: + * - [prompt] + * - [model] + * - [n] + * - [quality] + * - [responseFormat] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * A text description of the desired image(s). The maximum length is 1000 characters for * `dall-e-2` and 4000 characters for `dall-e-3`. @@ -481,7 +495,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/models/ModelDeleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/models/ModelDeleteParams.kt index f6f51b1f..f87f9a5a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/models/ModelDeleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/models/ModelDeleteParams.kt @@ -204,8 +204,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationCreateParams.kt index d44786e5..feab74f1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationCreateParams.kt @@ -110,6 +110,16 @@ private constructor( additionalQueryParams = moderationCreateParams.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] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * Input (or inputs) to classify. Can be a single string, an array of strings, or an array * of multi-modal input objects similar to other models. @@ -300,7 +310,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt index 00823cd4..afc93b5a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt @@ -405,6 +405,20 @@ private constructor( additionalQueryParams = responseCreateParams.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] + * - [include] + * - [instructions] + * - [maxOutputTokens] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * Text, image, or file inputs to the model, used to generate a response. * @@ -984,7 +998,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseDeleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseDeleteParams.kt index d7362f32..b3fae35d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseDeleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseDeleteParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCancelParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCancelParams.kt index 903d89f1..5b2fe821 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCancelParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCancelParams.kt @@ -202,8 +202,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCompleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCompleteParams.kt index cc4d3435..a3a1bbce 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCompleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCompleteParams.kt @@ -115,6 +115,16 @@ private constructor( fun uploadId(uploadId: String) = apply { this.uploadId = uploadId } + /** + * 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: + * - [partIds] + * - [md5] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** The ordered list of Part IDs. */ fun partIds(partIds: List) = apply { body.partIds(partIds) } @@ -287,7 +297,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCreateParams.kt index 1b72bc29..9cb3ad20 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/uploads/UploadCreateParams.kt @@ -148,6 +148,18 @@ private constructor( additionalQueryParams = uploadCreateParams.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: + * - [bytes] + * - [filename] + * - [mimeType] + * - [purpose] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** The number of bytes in the file you are uploading. */ fun bytes(bytes: Long) = apply { body.bytes(bytes) } @@ -343,7 +355,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/uploads/parts/PartCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/uploads/parts/PartCreateParams.kt index c8739566..a396a730 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/uploads/parts/PartCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/uploads/parts/PartCreateParams.kt @@ -90,6 +90,15 @@ private constructor( fun uploadId(uploadId: String) = apply { this.uploadId = uploadId } + /** + * 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: + * - [data] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** The chunk of bytes for this Part. */ fun data(data: InputStream) = apply { body.data(data) } @@ -228,8 +237,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Map> = mapOf("data" to _data()).toImmutable() + fun _body(): Map> = mapOf("data" to _data()).toImmutable() fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreCreateParams.kt index 37df3d3a..a9b3f99d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreCreateParams.kt @@ -143,6 +143,20 @@ private constructor( additionalQueryParams = vectorStoreCreateParams.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: + * - [chunkingStrategy] + * - [expiresAfter] + * - [fileIds] + * - [metadata] + * - [name] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * The chunking strategy used to chunk the file(s). If not set, will use the `auto` * strategy. Only applicable if `file_ids` is non-empty. @@ -385,7 +399,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body override fun _headers(): Headers = additionalHeaders diff --git a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreDeleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreDeleteParams.kt index cc1fedb1..efd70d98 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreDeleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreDeleteParams.kt @@ -203,8 +203,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreSearchParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreSearchParams.kt index a9abb4d4..74b41f12 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreSearchParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreSearchParams.kt @@ -160,6 +160,20 @@ private constructor( fun vectorStoreId(vectorStoreId: String) = apply { this.vectorStoreId = vectorStoreId } + /** + * 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: + * - [query] + * - [filters] + * - [maxNumResults] + * - [rankingOptions] + * - [rewriteQuery] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** A query string for a search */ fun query(query: Query) = apply { body.query(query) } @@ -380,7 +394,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreUpdateParams.kt index e4c1be13..f979dd19 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/VectorStoreUpdateParams.kt @@ -121,6 +121,17 @@ private constructor( fun vectorStoreId(vectorStoreId: String) = apply { this.vectorStoreId = vectorStoreId } + /** + * 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: + * - [expiresAfter] + * - [metadata] + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** The expiration policy for a vector store. */ fun expiresAfter(expiresAfter: ExpiresAfter?) = apply { body.expiresAfter(expiresAfter) } @@ -313,7 +324,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/filebatches/FileBatchCancelParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/filebatches/FileBatchCancelParams.kt index a99835be..1cc88512 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/filebatches/FileBatchCancelParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/filebatches/FileBatchCancelParams.kt @@ -215,8 +215,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/filebatches/FileBatchCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/filebatches/FileBatchCreateParams.kt index 74f41929..44a238da 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/filebatches/FileBatchCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/filebatches/FileBatchCreateParams.kt @@ -128,6 +128,17 @@ private constructor( fun vectorStoreId(vectorStoreId: String) = apply { this.vectorStoreId = vectorStoreId } + /** + * 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: + * - [fileIds] + * - [attributes] + * - [chunkingStrategy] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that the * vector store should use. Useful for tools like `file_search` that can access files. @@ -353,7 +364,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileCreateParams.kt index 01567fa7..2d33d8e7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileCreateParams.kt @@ -131,6 +131,17 @@ private constructor( fun vectorStoreId(vectorStoreId: String) = apply { this.vectorStoreId = vectorStoreId } + /** + * 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: + * - [fileId] + * - [attributes] + * - [chunkingStrategy] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + /** * A [File](https://platform.openai.com/docs/api-reference/files) ID that the vector store * should use. Useful for tools like `file_search` that can access files. @@ -348,7 +359,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileDeleteParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileDeleteParams.kt index 9742ec0a..7ac510f2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileDeleteParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileDeleteParams.kt @@ -216,8 +216,7 @@ private constructor( ) } - @JvmSynthetic - internal fun _body(): Optional> = + fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) fun _pathParam(index: Int): String = diff --git a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileUpdateParams.kt index e6237fde..7b6911cc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/vectorstores/files/FileUpdateParams.kt @@ -98,6 +98,15 @@ private constructor( fun fileId(fileId: String) = apply { this.fileId = fileId } + /** + * 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: + * - [attributes] + */ + 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 @@ -260,7 +269,7 @@ private constructor( ) } - @JvmSynthetic internal fun _body(): Body = body + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { From ba222fe7abd4c31b4393a9c7d83a939f6d969078 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 20:34:29 +0000 Subject: [PATCH 4/4] release: 0.43.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 14 ++++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 52afe059..fe87cd91 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.42.0" + ".": "0.43.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d05d1214..920a70bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.43.0 (2025-04-02) + +Full Changelog: [v0.42.0...v0.43.0](https://github.com/openai/openai-java/compare/v0.42.0...v0.43.0) + +### Features + +* **api:** manual updates ([9679525](https://github.com/openai/openai-java/commit/967952553d5fd2e7f47cd7c82fac45cc9dcef43e)) +* **client:** expose request body setter and getter ([#392](https://github.com/openai/openai-java/issues/392)) ([eaa0bc9](https://github.com/openai/openai-java/commit/eaa0bc96ba8898e064709a571e97d6b99f478597)) + + +### Chores + +* **internal:** codegen related update ([#389](https://github.com/openai/openai-java/issues/389)) ([b0e9d31](https://github.com/openai/openai-java/commit/b0e9d316bde7866f0d6c9381a5bec5a6667f46f6)) + ## 0.42.0 (2025-04-02) Full Changelog: [v0.41.1...v0.42.0](https://github.com/openai/openai-java/compare/v0.41.1...v0.42.0) diff --git a/README.md b/README.md index f1d9f7ba..ea25d2d2 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.42.0) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.42.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.42.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.43.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.43.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.43.0) @@ -18,7 +18,7 @@ The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https:// -The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/0.42.0). +The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/0.43.0). @@ -29,7 +29,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor ### Gradle ```kotlin -implementation("com.openai:openai-java:0.42.0") +implementation("com.openai:openai-java:0.43.0") ``` ### Maven @@ -38,7 +38,7 @@ implementation("com.openai:openai-java:0.42.0") com.openai openai-java - 0.42.0 + 0.43.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 12705605..9794d6c5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "0.42.0" // x-release-please-version + version = "0.43.0" // x-release-please-version } subprojects {