diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 751389532..f391d4162 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "3.5.3"
+ ".": "3.6.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 905a02c44..c961e232c 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 118
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-d30ff992a48873c1466c49f3c01f2ec8933faebff23424748f8d056065b1bcef.yml
-openapi_spec_hash: e933ec43b46f45c348adb78840e5808d
-config_hash: bf45940f0a7805b4ec2017eecdd36893
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-ea23db36b0899cc715f56d0098956069b2d92880f448adff3a4ac1bb53cb2cec.yml
+openapi_spec_hash: 36f76ea31297c9593bcfae453f6255cc
+config_hash: 666d6bb4b564f0d9d431124b5d1a0665
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20dbaf706..b43458517 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,20 @@
# Changelog
+## 3.6.0 (2025-09-19)
+
+Full Changelog: [v3.5.3...v3.6.0](https://github.com/openai/openai-java/compare/v3.5.3...v3.6.0)
+
+### Features
+
+* **api:** add reasoning_text ([2bde290](https://github.com/openai/openai-java/commit/2bde29036040664aa4ae54f6522e5e5336ed2c87))
+* **api:** type updates for conversations, reasoning_effort and results for evals ([364a176](https://github.com/openai/openai-java/commit/364a1766d34b6cc19fca81a445b287fc9ccefe2c))
+* **client:** expose sleeper option ([a5ffd57](https://github.com/openai/openai-java/commit/a5ffd57e75b6f0abe14d326c87f58abd2048cf73))
+
+
+### Bug Fixes
+
+* **client:** ensure single timer is created per client ([a5ffd57](https://github.com/openai/openai-java/commit/a5ffd57e75b6f0abe14d326c87f58abd2048cf73))
+
## 3.5.3 (2025-09-15)
Full Changelog: [v3.5.2...v3.5.3](https://github.com/openai/openai-java/compare/v3.5.2...v3.5.3)
diff --git a/README.md b/README.md
index a8e593227..50bf0b89f 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.openai/openai-java/3.5.3)
-[](https://javadoc.io/doc/com.openai/openai-java/3.5.3)
+[](https://central.sonatype.com/artifact/com.openai/openai-java/3.6.0)
+[](https://javadoc.io/doc/com.openai/openai-java/3.6.0)
@@ -11,7 +11,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 available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/3.5.3).
+The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/3.6.0).
@@ -24,7 +24,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
### Gradle
```kotlin
-implementation("com.openai:openai-java:3.5.3")
+implementation("com.openai:openai-java:3.6.0")
```
### Maven
@@ -33,7 +33,7 @@ implementation("com.openai:openai-java:3.5.3")
com.openai
openai-java
- 3.5.3
+ 3.6.0
```
@@ -1342,7 +1342,7 @@ If you're using Spring Boot, then you can use the SDK's [Spring Boot starter](ht
#### Gradle
```kotlin
-implementation("com.openai:openai-java-spring-boot-starter:3.5.3")
+implementation("com.openai:openai-java-spring-boot-starter:3.6.0")
```
#### Maven
@@ -1351,7 +1351,7 @@ implementation("com.openai:openai-java-spring-boot-starter:3.5.3")
com.openai
openai-java-spring-boot-starter
- 3.5.3
+ 3.6.0
```
diff --git a/build.gradle.kts b/build.gradle.kts
index 46de19e37..fd0c9dd35 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.openai"
- version = "3.5.3" // x-release-please-version
+ version = "3.6.0" // x-release-please-version
}
subprojects {
diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt
index 353f94f1c..818d0f824 100644
--- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt
+++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt
@@ -8,6 +8,7 @@ import com.openai.azure.AzureUrlPathMode
import com.openai.client.OpenAIClient
import com.openai.client.OpenAIClientImpl
import com.openai.core.ClientOptions
+import com.openai.core.Sleeper
import com.openai.core.Timeout
import com.openai.core.http.AsyncStreamResponse
import com.openai.core.http.Headers
@@ -135,6 +136,17 @@ class OpenAIOkHttpClient private constructor() {
clientOptions.streamHandlerExecutor(streamHandlerExecutor)
}
+ /**
+ * The interface to use for delaying execution, like during retries.
+ *
+ * This is primarily useful for using fake delays in tests.
+ *
+ * Defaults to real execution delays.
+ *
+ * This class takes ownership of the sleeper and closes it when closed.
+ */
+ fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) }
+
/**
* The clock to use for operations that require timing, like retries.
*
diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt
index 9707fffb3..bb3352e39 100644
--- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt
+++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt
@@ -8,6 +8,7 @@ import com.openai.azure.AzureUrlPathMode
import com.openai.client.OpenAIClientAsync
import com.openai.client.OpenAIClientAsyncImpl
import com.openai.core.ClientOptions
+import com.openai.core.Sleeper
import com.openai.core.Timeout
import com.openai.core.http.AsyncStreamResponse
import com.openai.core.http.Headers
@@ -135,6 +136,17 @@ class OpenAIOkHttpClientAsync private constructor() {
clientOptions.streamHandlerExecutor(streamHandlerExecutor)
}
+ /**
+ * The interface to use for delaying execution, like during retries.
+ *
+ * This is primarily useful for using fake delays in tests.
+ *
+ * Defaults to real execution delays.
+ *
+ * This class takes ownership of the sleeper and closes it when closed.
+ */
+ fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) }
+
/**
* The clock to use for operations that require timing, like retries.
*
diff --git a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt
index 515eb4f49..70ff74e6a 100644
--- a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt
@@ -60,6 +60,16 @@ private constructor(
* This class takes ownership of the executor and shuts it down, if possible, when closed.
*/
@get:JvmName("streamHandlerExecutor") val streamHandlerExecutor: Executor,
+ /**
+ * The interface to use for delaying execution, like during retries.
+ *
+ * This is primarily useful for using fake delays in tests.
+ *
+ * Defaults to real execution delays.
+ *
+ * This class takes ownership of the sleeper and closes it when closed.
+ */
+ @get:JvmName("sleeper") val sleeper: Sleeper,
/**
* The clock to use for operations that require timing, like retries.
*
@@ -162,6 +172,7 @@ private constructor(
private var checkJacksonVersionCompatibility: Boolean = true
private var jsonMapper: JsonMapper = jsonMapper()
private var streamHandlerExecutor: Executor? = null
+ private var sleeper: Sleeper? = null
private var clock: Clock = Clock.systemUTC()
private var baseUrl: String? = null
private var headers: Headers.Builder = Headers.builder()
@@ -182,6 +193,7 @@ private constructor(
checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility
jsonMapper = clientOptions.jsonMapper
streamHandlerExecutor = clientOptions.streamHandlerExecutor
+ sleeper = clientOptions.sleeper
clock = clientOptions.clock
baseUrl = clientOptions.baseUrl
headers = clientOptions.headers.toBuilder()
@@ -241,6 +253,17 @@ private constructor(
else streamHandlerExecutor
}
+ /**
+ * The interface to use for delaying execution, like during retries.
+ *
+ * This is primarily useful for using fake delays in tests.
+ *
+ * Defaults to real execution delays.
+ *
+ * This class takes ownership of the sleeper and closes it when closed.
+ */
+ fun sleeper(sleeper: Sleeper) = apply { this.sleeper = PhantomReachableSleeper(sleeper) }
+
/**
* The clock to use for operations that require timing, like retries.
*
@@ -479,6 +502,25 @@ private constructor(
*/
fun build(): ClientOptions {
val httpClient = checkRequired("httpClient", httpClient)
+ val streamHandlerExecutor =
+ streamHandlerExecutor
+ ?: PhantomReachableExecutorService(
+ Executors.newCachedThreadPool(
+ object : ThreadFactory {
+
+ private val threadFactory: ThreadFactory =
+ Executors.defaultThreadFactory()
+ private val count = AtomicLong(0)
+
+ override fun newThread(runnable: Runnable): Thread =
+ threadFactory.newThread(runnable).also {
+ it.name =
+ "openai-stream-handler-thread-${count.getAndIncrement()}"
+ }
+ }
+ )
+ )
+ val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper())
val credential = checkRequired("credential", credential)
val headers = Headers.builder()
@@ -530,26 +572,14 @@ private constructor(
httpClient,
RetryingHttpClient.builder()
.httpClient(httpClient)
+ .sleeper(sleeper)
.clock(clock)
.maxRetries(maxRetries)
.build(),
checkJacksonVersionCompatibility,
jsonMapper,
- streamHandlerExecutor
- ?: Executors.newCachedThreadPool(
- object : ThreadFactory {
-
- private val threadFactory: ThreadFactory =
- Executors.defaultThreadFactory()
- private val count = AtomicLong(0)
-
- override fun newThread(runnable: Runnable): Thread =
- threadFactory.newThread(runnable).also {
- it.name =
- "openai-stream-handler-thread-${count.getAndIncrement()}"
- }
- }
- ),
+ streamHandlerExecutor,
+ sleeper,
clock,
baseUrl,
headers.build(),
@@ -580,5 +610,6 @@ private constructor(
fun close() {
httpClient.close()
(streamHandlerExecutor as? ExecutorService)?.shutdown()
+ sleeper.close()
}
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/core/DefaultSleeper.kt b/openai-java-core/src/main/kotlin/com/openai/core/DefaultSleeper.kt
new file mode 100644
index 000000000..bd8b250b0
--- /dev/null
+++ b/openai-java-core/src/main/kotlin/com/openai/core/DefaultSleeper.kt
@@ -0,0 +1,28 @@
+package com.openai.core
+
+import java.time.Duration
+import java.util.Timer
+import java.util.TimerTask
+import java.util.concurrent.CompletableFuture
+
+class DefaultSleeper : Sleeper {
+
+ private val timer = Timer("DefaultSleeper", true)
+
+ override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis())
+
+ override fun sleepAsync(duration: Duration): CompletableFuture {
+ val future = CompletableFuture()
+ timer.schedule(
+ object : TimerTask() {
+ override fun run() {
+ future.complete(null)
+ }
+ },
+ duration.toMillis(),
+ )
+ return future
+ }
+
+ override fun close() = timer.cancel()
+}
diff --git a/openai-java-core/src/main/kotlin/com/openai/core/PhantomReachableSleeper.kt b/openai-java-core/src/main/kotlin/com/openai/core/PhantomReachableSleeper.kt
new file mode 100644
index 000000000..65ec40080
--- /dev/null
+++ b/openai-java-core/src/main/kotlin/com/openai/core/PhantomReachableSleeper.kt
@@ -0,0 +1,23 @@
+package com.openai.core
+
+import java.time.Duration
+import java.util.concurrent.CompletableFuture
+
+/**
+ * A delegating wrapper around a [Sleeper] that closes it once it's only phantom reachable.
+ *
+ * This class ensures the [Sleeper] is closed even if the user forgets to do it.
+ */
+internal class PhantomReachableSleeper(private val sleeper: Sleeper) : Sleeper {
+
+ init {
+ closeWhenPhantomReachable(this, sleeper)
+ }
+
+ override fun sleep(duration: Duration) = sleeper.sleep(duration)
+
+ override fun sleepAsync(duration: Duration): CompletableFuture =
+ sleeper.sleepAsync(duration)
+
+ override fun close() = sleeper.close()
+}
diff --git a/openai-java-core/src/main/kotlin/com/openai/core/Sleeper.kt b/openai-java-core/src/main/kotlin/com/openai/core/Sleeper.kt
new file mode 100644
index 000000000..788bb1c16
--- /dev/null
+++ b/openai-java-core/src/main/kotlin/com/openai/core/Sleeper.kt
@@ -0,0 +1,21 @@
+package com.openai.core
+
+import java.time.Duration
+import java.util.concurrent.CompletableFuture
+
+/**
+ * An interface for delaying execution for a specified amount of time.
+ *
+ * Useful for testing and cleaning up resources.
+ */
+interface Sleeper : AutoCloseable {
+
+ /** Synchronously pauses execution for the given [duration]. */
+ fun sleep(duration: Duration)
+
+ /** Asynchronously pauses execution for the given [duration]. */
+ fun sleepAsync(duration: Duration): CompletableFuture
+
+ /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */
+ override fun close()
+}
diff --git a/openai-java-core/src/main/kotlin/com/openai/core/http/RetryingHttpClient.kt b/openai-java-core/src/main/kotlin/com/openai/core/http/RetryingHttpClient.kt
index cf515198d..6eaa33a25 100644
--- a/openai-java-core/src/main/kotlin/com/openai/core/http/RetryingHttpClient.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/core/http/RetryingHttpClient.kt
@@ -1,6 +1,8 @@
package com.openai.core.http
+import com.openai.core.DefaultSleeper
import com.openai.core.RequestOptions
+import com.openai.core.Sleeper
import com.openai.core.checkRequired
import com.openai.errors.OpenAIIoException
import com.openai.errors.OpenAIRetryableException
@@ -11,8 +13,6 @@ import java.time.OffsetDateTime
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException
import java.time.temporal.ChronoUnit
-import java.util.Timer
-import java.util.TimerTask
import java.util.UUID
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ThreadLocalRandom
@@ -130,7 +130,10 @@ private constructor(
return executeWithRetries(modifiedRequest, requestOptions)
}
- override fun close() = httpClient.close()
+ override fun close() {
+ httpClient.close()
+ sleeper.close()
+ }
private fun isRetryable(request: HttpRequest): Boolean =
// Some requests, such as when a request body is being streamed, cannot be retried because
@@ -235,33 +238,14 @@ private constructor(
class Builder internal constructor() {
private var httpClient: HttpClient? = null
- private var sleeper: Sleeper =
- object : Sleeper {
-
- private val timer = Timer("RetryingHttpClient", true)
-
- override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis())
-
- override fun sleepAsync(duration: Duration): CompletableFuture {
- val future = CompletableFuture()
- timer.schedule(
- object : TimerTask() {
- override fun run() {
- future.complete(null)
- }
- },
- duration.toMillis(),
- )
- return future
- }
- }
+ private var sleeper: Sleeper? = null
private var clock: Clock = Clock.systemUTC()
private var maxRetries: Int = 2
private var idempotencyHeader: String? = null
fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient }
- @JvmSynthetic internal fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper }
+ fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper }
fun clock(clock: Clock) = apply { this.clock = clock }
@@ -272,17 +256,10 @@ private constructor(
fun build(): HttpClient =
RetryingHttpClient(
checkRequired("httpClient", httpClient),
- sleeper,
+ sleeper ?: DefaultSleeper(),
clock,
maxRetries,
idempotencyHeader,
)
}
-
- internal interface Sleeper {
-
- fun sleep(duration: Duration)
-
- fun sleepAsync(duration: Duration): CompletableFuture
- }
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ComputerScreenshotContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ComputerScreenshotContent.kt
index 39efe0bb0..a3d5cb6a9 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ComputerScreenshotContent.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ComputerScreenshotContent.kt
@@ -17,6 +17,7 @@ import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
+/** A screenshot of a computer. */
class ComputerScreenshotContent
private constructor(
private val fileId: JsonField,
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ContainerFileCitationBody.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ContainerFileCitationBody.kt
deleted file mode 100644
index 67c0ff2d5..000000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ContainerFileCitationBody.kt
+++ /dev/null
@@ -1,372 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.conversations
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.openai.core.ExcludeMissing
-import com.openai.core.JsonField
-import com.openai.core.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.core.checkRequired
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-
-class ContainerFileCitationBody
-private constructor(
- private val containerId: JsonField,
- private val endIndex: JsonField,
- private val fileId: JsonField,
- private val filename: JsonField,
- private val startIndex: JsonField,
- private val type: JsonValue,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("container_id")
- @ExcludeMissing
- containerId: JsonField = JsonMissing.of(),
- @JsonProperty("end_index") @ExcludeMissing endIndex: JsonField = JsonMissing.of(),
- @JsonProperty("file_id") @ExcludeMissing fileId: JsonField = JsonMissing.of(),
- @JsonProperty("filename") @ExcludeMissing filename: JsonField = JsonMissing.of(),
- @JsonProperty("start_index") @ExcludeMissing startIndex: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- ) : this(containerId, endIndex, fileId, filename, startIndex, type, mutableMapOf())
-
- /**
- * The ID of the container file.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun containerId(): String = containerId.getRequired("container_id")
-
- /**
- * The index of the last character of the container file citation in the message.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun endIndex(): Long = endIndex.getRequired("end_index")
-
- /**
- * The ID of the file.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun fileId(): String = fileId.getRequired("file_id")
-
- /**
- * The filename of the container file cited.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun filename(): String = filename.getRequired("filename")
-
- /**
- * The index of the first character of the container file citation in the message.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun startIndex(): Long = startIndex.getRequired("start_index")
-
- /**
- * The type of the container file citation. Always `container_file_citation`.
- *
- * Expected to always return the following:
- * ```java
- * JsonValue.from("container_file_citation")
- * ```
- *
- * However, this method can be useful for debugging and logging (e.g. if the server responded
- * with an unexpected value).
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
-
- /**
- * Returns the raw JSON value of [containerId].
- *
- * Unlike [containerId], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("container_id")
- @ExcludeMissing
- fun _containerId(): JsonField = containerId
-
- /**
- * Returns the raw JSON value of [endIndex].
- *
- * Unlike [endIndex], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("end_index") @ExcludeMissing fun _endIndex(): JsonField = endIndex
-
- /**
- * Returns the raw JSON value of [fileId].
- *
- * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId
-
- /**
- * Returns the raw JSON value of [filename].
- *
- * Unlike [filename], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename
-
- /**
- * Returns the raw JSON value of [startIndex].
- *
- * Unlike [startIndex], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("start_index") @ExcludeMissing fun _startIndex(): JsonField = startIndex
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [ContainerFileCitationBody].
- *
- * The following fields are required:
- * ```java
- * .containerId()
- * .endIndex()
- * .fileId()
- * .filename()
- * .startIndex()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [ContainerFileCitationBody]. */
- class Builder internal constructor() {
-
- private var containerId: JsonField? = null
- private var endIndex: JsonField? = null
- private var fileId: JsonField? = null
- private var filename: JsonField? = null
- private var startIndex: JsonField? = null
- private var type: JsonValue = JsonValue.from("container_file_citation")
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(containerFileCitationBody: ContainerFileCitationBody) = apply {
- containerId = containerFileCitationBody.containerId
- endIndex = containerFileCitationBody.endIndex
- fileId = containerFileCitationBody.fileId
- filename = containerFileCitationBody.filename
- startIndex = containerFileCitationBody.startIndex
- type = containerFileCitationBody.type
- additionalProperties = containerFileCitationBody.additionalProperties.toMutableMap()
- }
-
- /** The ID of the container file. */
- fun containerId(containerId: String) = containerId(JsonField.of(containerId))
-
- /**
- * Sets [Builder.containerId] to an arbitrary JSON value.
- *
- * You should usually call [Builder.containerId] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun containerId(containerId: JsonField) = apply { this.containerId = containerId }
-
- /** The index of the last character of the container file citation in the message. */
- fun endIndex(endIndex: Long) = endIndex(JsonField.of(endIndex))
-
- /**
- * Sets [Builder.endIndex] to an arbitrary JSON value.
- *
- * You should usually call [Builder.endIndex] with a well-typed [Long] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun endIndex(endIndex: JsonField) = apply { this.endIndex = endIndex }
-
- /** The ID of the file. */
- fun fileId(fileId: String) = fileId(JsonField.of(fileId))
-
- /**
- * Sets [Builder.fileId] to an arbitrary JSON value.
- *
- * You should usually call [Builder.fileId] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun fileId(fileId: JsonField) = apply { this.fileId = fileId }
-
- /** The filename of the container file cited. */
- fun filename(filename: String) = filename(JsonField.of(filename))
-
- /**
- * Sets [Builder.filename] to an arbitrary JSON value.
- *
- * You should usually call [Builder.filename] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun filename(filename: JsonField) = apply { this.filename = filename }
-
- /** The index of the first character of the container file citation in the message. */
- fun startIndex(startIndex: Long) = startIndex(JsonField.of(startIndex))
-
- /**
- * Sets [Builder.startIndex] to an arbitrary JSON value.
- *
- * You should usually call [Builder.startIndex] with a well-typed [Long] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun startIndex(startIndex: JsonField) = apply { this.startIndex = startIndex }
-
- /**
- * Sets the field to an arbitrary JSON value.
- *
- * It is usually unnecessary to call this method because the field defaults to the
- * following:
- * ```java
- * JsonValue.from("container_file_citation")
- * ```
- *
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonValue) = apply { this.type = type }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [ContainerFileCitationBody].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .containerId()
- * .endIndex()
- * .fileId()
- * .filename()
- * .startIndex()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): ContainerFileCitationBody =
- ContainerFileCitationBody(
- checkRequired("containerId", containerId),
- checkRequired("endIndex", endIndex),
- checkRequired("fileId", fileId),
- checkRequired("filename", filename),
- checkRequired("startIndex", startIndex),
- type,
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): ContainerFileCitationBody = apply {
- if (validated) {
- return@apply
- }
-
- containerId()
- endIndex()
- fileId()
- filename()
- startIndex()
- _type().let {
- if (it != JsonValue.from("container_file_citation")) {
- throw OpenAIInvalidDataException("'type' is invalid, received $it")
- }
- }
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (containerId.asKnown().isPresent) 1 else 0) +
- (if (endIndex.asKnown().isPresent) 1 else 0) +
- (if (fileId.asKnown().isPresent) 1 else 0) +
- (if (filename.asKnown().isPresent) 1 else 0) +
- (if (startIndex.asKnown().isPresent) 1 else 0) +
- type.let { if (it == JsonValue.from("container_file_citation")) 1 else 0 }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is ContainerFileCitationBody &&
- containerId == other.containerId &&
- endIndex == other.endIndex &&
- fileId == other.fileId &&
- filename == other.filename &&
- startIndex == other.startIndex &&
- type == other.type &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy {
- Objects.hash(
- containerId,
- endIndex,
- fileId,
- filename,
- startIndex,
- type,
- additionalProperties,
- )
- }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "ContainerFileCitationBody{containerId=$containerId, endIndex=$endIndex, fileId=$fileId, filename=$filename, startIndex=$startIndex, type=$type, additionalProperties=$additionalProperties}"
-}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/FileCitationBody.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/FileCitationBody.kt
deleted file mode 100644
index e82bfe5df..000000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/FileCitationBody.kt
+++ /dev/null
@@ -1,287 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.conversations
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.openai.core.ExcludeMissing
-import com.openai.core.JsonField
-import com.openai.core.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.core.checkRequired
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-
-class FileCitationBody
-private constructor(
- private val fileId: JsonField,
- private val filename: JsonField,
- private val index: JsonField,
- private val type: JsonValue,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("file_id") @ExcludeMissing fileId: JsonField = JsonMissing.of(),
- @JsonProperty("filename") @ExcludeMissing filename: JsonField = JsonMissing.of(),
- @JsonProperty("index") @ExcludeMissing index: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- ) : this(fileId, filename, index, type, mutableMapOf())
-
- /**
- * The ID of the file.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun fileId(): String = fileId.getRequired("file_id")
-
- /**
- * The filename of the file cited.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun filename(): String = filename.getRequired("filename")
-
- /**
- * The index of the file in the list of files.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun index(): Long = index.getRequired("index")
-
- /**
- * The type of the file citation. Always `file_citation`.
- *
- * Expected to always return the following:
- * ```java
- * JsonValue.from("file_citation")
- * ```
- *
- * However, this method can be useful for debugging and logging (e.g. if the server responded
- * with an unexpected value).
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
-
- /**
- * Returns the raw JSON value of [fileId].
- *
- * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId
-
- /**
- * Returns the raw JSON value of [filename].
- *
- * Unlike [filename], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename
-
- /**
- * Returns the raw JSON value of [index].
- *
- * Unlike [index], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("index") @ExcludeMissing fun _index(): JsonField = index
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [FileCitationBody].
- *
- * The following fields are required:
- * ```java
- * .fileId()
- * .filename()
- * .index()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [FileCitationBody]. */
- class Builder internal constructor() {
-
- private var fileId: JsonField? = null
- private var filename: JsonField? = null
- private var index: JsonField? = null
- private var type: JsonValue = JsonValue.from("file_citation")
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(fileCitationBody: FileCitationBody) = apply {
- fileId = fileCitationBody.fileId
- filename = fileCitationBody.filename
- index = fileCitationBody.index
- type = fileCitationBody.type
- additionalProperties = fileCitationBody.additionalProperties.toMutableMap()
- }
-
- /** The ID of the file. */
- fun fileId(fileId: String) = fileId(JsonField.of(fileId))
-
- /**
- * Sets [Builder.fileId] to an arbitrary JSON value.
- *
- * You should usually call [Builder.fileId] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun fileId(fileId: JsonField) = apply { this.fileId = fileId }
-
- /** The filename of the file cited. */
- fun filename(filename: String) = filename(JsonField.of(filename))
-
- /**
- * Sets [Builder.filename] to an arbitrary JSON value.
- *
- * You should usually call [Builder.filename] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun filename(filename: JsonField) = apply { this.filename = filename }
-
- /** The index of the file in the list of files. */
- fun index(index: Long) = index(JsonField.of(index))
-
- /**
- * Sets [Builder.index] to an arbitrary JSON value.
- *
- * You should usually call [Builder.index] with a well-typed [Long] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun index(index: JsonField) = apply { this.index = index }
-
- /**
- * Sets the field to an arbitrary JSON value.
- *
- * It is usually unnecessary to call this method because the field defaults to the
- * following:
- * ```java
- * JsonValue.from("file_citation")
- * ```
- *
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonValue) = apply { this.type = type }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [FileCitationBody].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .fileId()
- * .filename()
- * .index()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): FileCitationBody =
- FileCitationBody(
- checkRequired("fileId", fileId),
- checkRequired("filename", filename),
- checkRequired("index", index),
- type,
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): FileCitationBody = apply {
- if (validated) {
- return@apply
- }
-
- fileId()
- filename()
- index()
- _type().let {
- if (it != JsonValue.from("file_citation")) {
- throw OpenAIInvalidDataException("'type' is invalid, received $it")
- }
- }
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (fileId.asKnown().isPresent) 1 else 0) +
- (if (filename.asKnown().isPresent) 1 else 0) +
- (if (index.asKnown().isPresent) 1 else 0) +
- type.let { if (it == JsonValue.from("file_citation")) 1 else 0 }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is FileCitationBody &&
- fileId == other.fileId &&
- filename == other.filename &&
- index == other.index &&
- type == other.type &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy {
- Objects.hash(fileId, filename, index, type, additionalProperties)
- }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "FileCitationBody{fileId=$fileId, filename=$filename, index=$index, type=$type, additionalProperties=$additionalProperties}"
-}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/InputFileContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/InputFileContent.kt
deleted file mode 100644
index 428456c98..000000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/InputFileContent.kt
+++ /dev/null
@@ -1,288 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.conversations
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.openai.core.ExcludeMissing
-import com.openai.core.JsonField
-import com.openai.core.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.core.checkRequired
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-import java.util.Optional
-import kotlin.jvm.optionals.getOrNull
-
-class InputFileContent
-private constructor(
- private val fileId: JsonField,
- private val type: JsonValue,
- private val fileUrl: JsonField,
- private val filename: JsonField,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("file_id") @ExcludeMissing fileId: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- @JsonProperty("file_url") @ExcludeMissing fileUrl: JsonField = JsonMissing.of(),
- @JsonProperty("filename") @ExcludeMissing filename: JsonField = JsonMissing.of(),
- ) : this(fileId, type, fileUrl, filename, mutableMapOf())
-
- /**
- * The ID of the file to be sent to the model.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun fileId(): Optional = fileId.getOptional("file_id")
-
- /**
- * The type of the input item. Always `input_file`.
- *
- * Expected to always return the following:
- * ```java
- * JsonValue.from("input_file")
- * ```
- *
- * However, this method can be useful for debugging and logging (e.g. if the server responded
- * with an unexpected value).
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
-
- /**
- * The URL of the file to be sent to the model.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun fileUrl(): Optional = fileUrl.getOptional("file_url")
-
- /**
- * The name of the file to be sent to the model.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun filename(): Optional = filename.getOptional("filename")
-
- /**
- * Returns the raw JSON value of [fileId].
- *
- * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId
-
- /**
- * Returns the raw JSON value of [fileUrl].
- *
- * Unlike [fileUrl], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("file_url") @ExcludeMissing fun _fileUrl(): JsonField = fileUrl
-
- /**
- * Returns the raw JSON value of [filename].
- *
- * Unlike [filename], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [InputFileContent].
- *
- * The following fields are required:
- * ```java
- * .fileId()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [InputFileContent]. */
- class Builder internal constructor() {
-
- private var fileId: JsonField? = null
- private var type: JsonValue = JsonValue.from("input_file")
- private var fileUrl: JsonField = JsonMissing.of()
- private var filename: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(inputFileContent: InputFileContent) = apply {
- fileId = inputFileContent.fileId
- type = inputFileContent.type
- fileUrl = inputFileContent.fileUrl
- filename = inputFileContent.filename
- additionalProperties = inputFileContent.additionalProperties.toMutableMap()
- }
-
- /** The ID of the file to be sent to the model. */
- fun fileId(fileId: String?) = fileId(JsonField.ofNullable(fileId))
-
- /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */
- fun fileId(fileId: Optional) = fileId(fileId.getOrNull())
-
- /**
- * Sets [Builder.fileId] to an arbitrary JSON value.
- *
- * You should usually call [Builder.fileId] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun fileId(fileId: JsonField) = apply { this.fileId = fileId }
-
- /**
- * Sets the field to an arbitrary JSON value.
- *
- * It is usually unnecessary to call this method because the field defaults to the
- * following:
- * ```java
- * JsonValue.from("input_file")
- * ```
- *
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonValue) = apply { this.type = type }
-
- /** The URL of the file to be sent to the model. */
- fun fileUrl(fileUrl: String) = fileUrl(JsonField.of(fileUrl))
-
- /**
- * Sets [Builder.fileUrl] to an arbitrary JSON value.
- *
- * You should usually call [Builder.fileUrl] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun fileUrl(fileUrl: JsonField) = apply { this.fileUrl = fileUrl }
-
- /** The name of the file to be sent to the model. */
- fun filename(filename: String) = filename(JsonField.of(filename))
-
- /**
- * Sets [Builder.filename] to an arbitrary JSON value.
- *
- * You should usually call [Builder.filename] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun filename(filename: JsonField) = apply { this.filename = filename }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [InputFileContent].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .fileId()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): InputFileContent =
- InputFileContent(
- checkRequired("fileId", fileId),
- type,
- fileUrl,
- filename,
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): InputFileContent = apply {
- if (validated) {
- return@apply
- }
-
- fileId()
- _type().let {
- if (it != JsonValue.from("input_file")) {
- throw OpenAIInvalidDataException("'type' is invalid, received $it")
- }
- }
- fileUrl()
- filename()
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (fileId.asKnown().isPresent) 1 else 0) +
- type.let { if (it == JsonValue.from("input_file")) 1 else 0 } +
- (if (fileUrl.asKnown().isPresent) 1 else 0) +
- (if (filename.asKnown().isPresent) 1 else 0)
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is InputFileContent &&
- fileId == other.fileId &&
- type == other.type &&
- fileUrl == other.fileUrl &&
- filename == other.filename &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy {
- Objects.hash(fileId, type, fileUrl, filename, additionalProperties)
- }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "InputFileContent{fileId=$fileId, type=$type, fileUrl=$fileUrl, filename=$filename, additionalProperties=$additionalProperties}"
-}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/InputImageContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/InputImageContent.kt
deleted file mode 100644
index c0043c729..000000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/InputImageContent.kt
+++ /dev/null
@@ -1,439 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.conversations
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.openai.core.Enum
-import com.openai.core.ExcludeMissing
-import com.openai.core.JsonField
-import com.openai.core.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.core.checkRequired
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-import java.util.Optional
-import kotlin.jvm.optionals.getOrNull
-
-class InputImageContent
-private constructor(
- private val detail: JsonField,
- private val fileId: JsonField,
- private val imageUrl: JsonField,
- private val type: JsonValue,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("detail") @ExcludeMissing detail: JsonField = JsonMissing.of(),
- @JsonProperty("file_id") @ExcludeMissing fileId: JsonField = JsonMissing.of(),
- @JsonProperty("image_url") @ExcludeMissing imageUrl: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- ) : this(detail, fileId, imageUrl, type, mutableMapOf())
-
- /**
- * The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`.
- * Defaults to `auto`.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun detail(): Detail = detail.getRequired("detail")
-
- /**
- * The ID of the file to be sent to the model.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun fileId(): Optional = fileId.getOptional("file_id")
-
- /**
- * The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image
- * in a data URL.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun imageUrl(): Optional = imageUrl.getOptional("image_url")
-
- /**
- * The type of the input item. Always `input_image`.
- *
- * Expected to always return the following:
- * ```java
- * JsonValue.from("input_image")
- * ```
- *
- * However, this method can be useful for debugging and logging (e.g. if the server responded
- * with an unexpected value).
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
-
- /**
- * Returns the raw JSON value of [detail].
- *
- * Unlike [detail], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("detail") @ExcludeMissing fun _detail(): JsonField = detail
-
- /**
- * Returns the raw JSON value of [fileId].
- *
- * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId
-
- /**
- * Returns the raw JSON value of [imageUrl].
- *
- * Unlike [imageUrl], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("image_url") @ExcludeMissing fun _imageUrl(): JsonField = imageUrl
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [InputImageContent].
- *
- * The following fields are required:
- * ```java
- * .detail()
- * .fileId()
- * .imageUrl()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [InputImageContent]. */
- class Builder internal constructor() {
-
- private var detail: JsonField? = null
- private var fileId: JsonField? = null
- private var imageUrl: JsonField? = null
- private var type: JsonValue = JsonValue.from("input_image")
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(inputImageContent: InputImageContent) = apply {
- detail = inputImageContent.detail
- fileId = inputImageContent.fileId
- imageUrl = inputImageContent.imageUrl
- type = inputImageContent.type
- additionalProperties = inputImageContent.additionalProperties.toMutableMap()
- }
-
- /**
- * The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`.
- * Defaults to `auto`.
- */
- fun detail(detail: Detail) = detail(JsonField.of(detail))
-
- /**
- * Sets [Builder.detail] to an arbitrary JSON value.
- *
- * You should usually call [Builder.detail] with a well-typed [Detail] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun detail(detail: JsonField) = apply { this.detail = detail }
-
- /** The ID of the file to be sent to the model. */
- fun fileId(fileId: String?) = fileId(JsonField.ofNullable(fileId))
-
- /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */
- fun fileId(fileId: Optional) = fileId(fileId.getOrNull())
-
- /**
- * Sets [Builder.fileId] to an arbitrary JSON value.
- *
- * You should usually call [Builder.fileId] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun fileId(fileId: JsonField) = apply { this.fileId = fileId }
-
- /**
- * The URL of the image to be sent to the model. A fully qualified URL or base64 encoded
- * image in a data URL.
- */
- fun imageUrl(imageUrl: String?) = imageUrl(JsonField.ofNullable(imageUrl))
-
- /** Alias for calling [Builder.imageUrl] with `imageUrl.orElse(null)`. */
- fun imageUrl(imageUrl: Optional) = imageUrl(imageUrl.getOrNull())
-
- /**
- * Sets [Builder.imageUrl] to an arbitrary JSON value.
- *
- * You should usually call [Builder.imageUrl] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun imageUrl(imageUrl: JsonField) = apply { this.imageUrl = imageUrl }
-
- /**
- * Sets the field to an arbitrary JSON value.
- *
- * It is usually unnecessary to call this method because the field defaults to the
- * following:
- * ```java
- * JsonValue.from("input_image")
- * ```
- *
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonValue) = apply { this.type = type }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [InputImageContent].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .detail()
- * .fileId()
- * .imageUrl()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): InputImageContent =
- InputImageContent(
- checkRequired("detail", detail),
- checkRequired("fileId", fileId),
- checkRequired("imageUrl", imageUrl),
- type,
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): InputImageContent = apply {
- if (validated) {
- return@apply
- }
-
- detail().validate()
- fileId()
- imageUrl()
- _type().let {
- if (it != JsonValue.from("input_image")) {
- throw OpenAIInvalidDataException("'type' is invalid, received $it")
- }
- }
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (detail.asKnown().getOrNull()?.validity() ?: 0) +
- (if (fileId.asKnown().isPresent) 1 else 0) +
- (if (imageUrl.asKnown().isPresent) 1 else 0) +
- type.let { if (it == JsonValue.from("input_image")) 1 else 0 }
-
- /**
- * The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`.
- * Defaults to `auto`.
- */
- class Detail @JsonCreator private constructor(private val value: JsonField) : Enum {
-
- /**
- * Returns this class instance's raw value.
- *
- * This is usually only useful if this instance was deserialized from data that doesn't
- * match any known member, and you want to know that value. For example, if the SDK is on an
- * older version than the API, then the API may respond with new members that the SDK is
- * unaware of.
- */
- @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
-
- companion object {
-
- @JvmField val LOW = of("low")
-
- @JvmField val HIGH = of("high")
-
- @JvmField val AUTO = of("auto")
-
- @JvmStatic fun of(value: String) = Detail(JsonField.of(value))
- }
-
- /** An enum containing [Detail]'s known values. */
- enum class Known {
- LOW,
- HIGH,
- AUTO,
- }
-
- /**
- * An enum containing [Detail]'s known values, as well as an [_UNKNOWN] member.
- *
- * An instance of [Detail] can contain an unknown value in a couple of cases:
- * - It was deserialized from data that doesn't match any known member. For example, if the
- * SDK is on an older version than the API, then the API may respond with new members that
- * the SDK is unaware of.
- * - It was constructed with an arbitrary value using the [of] method.
- */
- enum class Value {
- LOW,
- HIGH,
- AUTO,
- /** An enum member indicating that [Detail] was instantiated with an unknown value. */
- _UNKNOWN,
- }
-
- /**
- * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN]
- * if the class was instantiated with an unknown value.
- *
- * Use the [known] method instead if you're certain the value is always known or if you want
- * to throw for the unknown case.
- */
- fun value(): Value =
- when (this) {
- LOW -> Value.LOW
- HIGH -> Value.HIGH
- AUTO -> Value.AUTO
- else -> Value._UNKNOWN
- }
-
- /**
- * Returns an enum member corresponding to this class instance's value.
- *
- * Use the [value] method instead if you're uncertain the value is always known and don't
- * want to throw for the unknown case.
- *
- * @throws OpenAIInvalidDataException if this class instance's value is a not a known
- * member.
- */
- fun known(): Known =
- when (this) {
- LOW -> Known.LOW
- HIGH -> Known.HIGH
- AUTO -> Known.AUTO
- else -> throw OpenAIInvalidDataException("Unknown Detail: $value")
- }
-
- /**
- * Returns this class instance's primitive wire representation.
- *
- * This differs from the [toString] method because that method is primarily for debugging
- * and generally doesn't throw.
- *
- * @throws OpenAIInvalidDataException if this class instance's value does not have the
- * expected primitive type.
- */
- fun asString(): String =
- _value().asString().orElseThrow { OpenAIInvalidDataException("Value is not a String") }
-
- private var validated: Boolean = false
-
- fun validate(): Detail = apply {
- if (validated) {
- return@apply
- }
-
- known()
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object
- * recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is Detail && value == other.value
- }
-
- override fun hashCode() = value.hashCode()
-
- override fun toString() = value.toString()
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is InputImageContent &&
- detail == other.detail &&
- fileId == other.fileId &&
- imageUrl == other.imageUrl &&
- type == other.type &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy {
- Objects.hash(detail, fileId, imageUrl, type, additionalProperties)
- }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "InputImageContent{detail=$detail, fileId=$fileId, imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}"
-}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/InputTextContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/InputTextContent.kt
deleted file mode 100644
index 9b45525a0..000000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/InputTextContent.kt
+++ /dev/null
@@ -1,209 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.conversations
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.openai.core.ExcludeMissing
-import com.openai.core.JsonField
-import com.openai.core.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.core.checkRequired
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-
-class InputTextContent
-private constructor(
- private val text: JsonField,
- private val type: JsonValue,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- ) : this(text, type, mutableMapOf())
-
- /**
- * The text input to the model.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun text(): String = text.getRequired("text")
-
- /**
- * The type of the input item. Always `input_text`.
- *
- * Expected to always return the following:
- * ```java
- * JsonValue.from("input_text")
- * ```
- *
- * However, this method can be useful for debugging and logging (e.g. if the server responded
- * with an unexpected value).
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
-
- /**
- * Returns the raw JSON value of [text].
- *
- * Unlike [text], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [InputTextContent].
- *
- * The following fields are required:
- * ```java
- * .text()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [InputTextContent]. */
- class Builder internal constructor() {
-
- private var text: JsonField? = null
- private var type: JsonValue = JsonValue.from("input_text")
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(inputTextContent: InputTextContent) = apply {
- text = inputTextContent.text
- type = inputTextContent.type
- additionalProperties = inputTextContent.additionalProperties.toMutableMap()
- }
-
- /** The text input to the model. */
- fun text(text: String) = text(JsonField.of(text))
-
- /**
- * Sets [Builder.text] to an arbitrary JSON value.
- *
- * You should usually call [Builder.text] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun text(text: JsonField) = apply { this.text = text }
-
- /**
- * Sets the field to an arbitrary JSON value.
- *
- * It is usually unnecessary to call this method because the field defaults to the
- * following:
- * ```java
- * JsonValue.from("input_text")
- * ```
- *
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonValue) = apply { this.type = type }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [InputTextContent].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .text()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): InputTextContent =
- InputTextContent(checkRequired("text", text), type, additionalProperties.toMutableMap())
- }
-
- private var validated: Boolean = false
-
- fun validate(): InputTextContent = apply {
- if (validated) {
- return@apply
- }
-
- text()
- _type().let {
- if (it != JsonValue.from("input_text")) {
- throw OpenAIInvalidDataException("'type' is invalid, received $it")
- }
- }
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (text.asKnown().isPresent) 1 else 0) +
- type.let { if (it == JsonValue.from("input_text")) 1 else 0 }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is InputTextContent &&
- text == other.text &&
- type == other.type &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy { Objects.hash(text, type, additionalProperties) }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "InputTextContent{text=$text, type=$type, additionalProperties=$additionalProperties}"
-}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/LobProb.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/LobProb.kt
deleted file mode 100644
index af2ac367c..000000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/LobProb.kt
+++ /dev/null
@@ -1,307 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.conversations
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.openai.core.ExcludeMissing
-import com.openai.core.JsonField
-import com.openai.core.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.core.checkKnown
-import com.openai.core.checkRequired
-import com.openai.core.toImmutable
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-import kotlin.jvm.optionals.getOrNull
-
-class LobProb
-private constructor(
- private val token: JsonField,
- private val bytes: JsonField>,
- private val logprob: JsonField,
- private val topLogprobs: JsonField>,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(),
- @JsonProperty("bytes") @ExcludeMissing bytes: JsonField> = JsonMissing.of(),
- @JsonProperty("logprob") @ExcludeMissing logprob: JsonField = JsonMissing.of(),
- @JsonProperty("top_logprobs")
- @ExcludeMissing
- topLogprobs: JsonField> = JsonMissing.of(),
- ) : this(token, bytes, logprob, topLogprobs, mutableMapOf())
-
- /**
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun token(): String = token.getRequired("token")
-
- /**
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun bytes(): List = bytes.getRequired("bytes")
-
- /**
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun logprob(): Double = logprob.getRequired("logprob")
-
- /**
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun topLogprobs(): List = topLogprobs.getRequired("top_logprobs")
-
- /**
- * Returns the raw JSON value of [token].
- *
- * Unlike [token], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token
-
- /**
- * Returns the raw JSON value of [bytes].
- *
- * Unlike [bytes], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("bytes") @ExcludeMissing fun _bytes(): JsonField> = bytes
-
- /**
- * Returns the raw JSON value of [logprob].
- *
- * Unlike [logprob], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("logprob") @ExcludeMissing fun _logprob(): JsonField = logprob
-
- /**
- * Returns the raw JSON value of [topLogprobs].
- *
- * Unlike [topLogprobs], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("top_logprobs")
- @ExcludeMissing
- fun _topLogprobs(): JsonField> = topLogprobs
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [LobProb].
- *
- * The following fields are required:
- * ```java
- * .token()
- * .bytes()
- * .logprob()
- * .topLogprobs()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [LobProb]. */
- class Builder internal constructor() {
-
- private var token: JsonField? = null
- private var bytes: JsonField>? = null
- private var logprob: JsonField? = null
- private var topLogprobs: JsonField>? = null
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(lobProb: LobProb) = apply {
- token = lobProb.token
- bytes = lobProb.bytes.map { it.toMutableList() }
- logprob = lobProb.logprob
- topLogprobs = lobProb.topLogprobs.map { it.toMutableList() }
- additionalProperties = lobProb.additionalProperties.toMutableMap()
- }
-
- fun token(token: String) = token(JsonField.of(token))
-
- /**
- * Sets [Builder.token] to an arbitrary JSON value.
- *
- * You should usually call [Builder.token] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun token(token: JsonField) = apply { this.token = token }
-
- fun bytes(bytes: List) = bytes(JsonField.of(bytes))
-
- /**
- * Sets [Builder.bytes] to an arbitrary JSON value.
- *
- * You should usually call [Builder.bytes] with a well-typed `List` value instead.
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun bytes(bytes: JsonField>) = apply {
- this.bytes = bytes.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [Long] to [bytes].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addByte(byte_: Long) = apply {
- bytes =
- (bytes ?: JsonField.of(mutableListOf())).also { checkKnown("bytes", it).add(byte_) }
- }
-
- fun logprob(logprob: Double) = logprob(JsonField.of(logprob))
-
- /**
- * Sets [Builder.logprob] to an arbitrary JSON value.
- *
- * You should usually call [Builder.logprob] with a well-typed [Double] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun logprob(logprob: JsonField) = apply { this.logprob = logprob }
-
- fun topLogprobs(topLogprobs: List) = topLogprobs(JsonField.of(topLogprobs))
-
- /**
- * Sets [Builder.topLogprobs] to an arbitrary JSON value.
- *
- * You should usually call [Builder.topLogprobs] with a well-typed `List` value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun topLogprobs(topLogprobs: JsonField>) = apply {
- this.topLogprobs = topLogprobs.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [TopLogProb] to [topLogprobs].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addTopLogprob(topLogprob: TopLogProb) = apply {
- topLogprobs =
- (topLogprobs ?: JsonField.of(mutableListOf())).also {
- checkKnown("topLogprobs", it).add(topLogprob)
- }
- }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [LobProb].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .token()
- * .bytes()
- * .logprob()
- * .topLogprobs()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): LobProb =
- LobProb(
- checkRequired("token", token),
- checkRequired("bytes", bytes).map { it.toImmutable() },
- checkRequired("logprob", logprob),
- checkRequired("topLogprobs", topLogprobs).map { it.toImmutable() },
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): LobProb = apply {
- if (validated) {
- return@apply
- }
-
- token()
- bytes()
- logprob()
- topLogprobs().forEach { it.validate() }
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (token.asKnown().isPresent) 1 else 0) +
- (bytes.asKnown().getOrNull()?.size ?: 0) +
- (if (logprob.asKnown().isPresent) 1 else 0) +
- (topLogprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is LobProb &&
- token == other.token &&
- bytes == other.bytes &&
- logprob == other.logprob &&
- topLogprobs == other.topLogprobs &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy {
- Objects.hash(token, bytes, logprob, topLogprobs, additionalProperties)
- }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "LobProb{token=$token, bytes=$bytes, logprob=$logprob, topLogprobs=$topLogprobs, additionalProperties=$additionalProperties}"
-}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/Message.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/Message.kt
index f9fdc5a1f..b6ee32bf6 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/Message.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/Message.kt
@@ -25,11 +25,17 @@ import com.openai.core.checkRequired
import com.openai.core.getOrThrow
import com.openai.core.toImmutable
import com.openai.errors.OpenAIInvalidDataException
+import com.openai.models.responses.ResponseInputFile
+import com.openai.models.responses.ResponseInputImage
+import com.openai.models.responses.ResponseInputText
+import com.openai.models.responses.ResponseOutputRefusal
+import com.openai.models.responses.ResponseOutputText
import java.util.Collections
import java.util.Objects
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
+/** A message to or from the model. */
class Message
private constructor(
private val id: JsonField,
@@ -212,21 +218,22 @@ private constructor(
}
/** Alias for calling [addContent] with `Content.ofInputText(inputText)`. */
- fun addContent(inputText: InputTextContent) = addContent(Content.ofInputText(inputText))
+ fun addContent(inputText: ResponseInputText) = addContent(Content.ofInputText(inputText))
/**
* Alias for calling [addContent] with the following:
* ```java
- * InputTextContent.builder()
+ * ResponseInputText.builder()
* .text(text)
* .build()
* ```
*/
fun addInputTextContent(text: String) =
- addContent(InputTextContent.builder().text(text).build())
+ addContent(ResponseInputText.builder().text(text).build())
/** Alias for calling [addContent] with `Content.ofOutputText(outputText)`. */
- fun addContent(outputText: OutputTextContent) = addContent(Content.ofOutputText(outputText))
+ fun addContent(outputText: ResponseOutputText) =
+ addContent(Content.ofOutputText(outputText))
/** Alias for calling [addContent] with `Content.ofText(text)`. */
fun addContent(text: TextContent) = addContent(Content.ofText(text))
@@ -256,45 +263,58 @@ private constructor(
fun addSummaryTextContent(text: String) =
addContent(SummaryTextContent.builder().text(text).build())
- /** Alias for calling [addContent] with `Content.ofRefusal(refusal)`. */
- fun addContent(refusal: RefusalContent) = addContent(Content.ofRefusal(refusal))
+ /** Alias for calling [addContent] with `Content.ofReasoningText(reasoningText)`. */
+ fun addContent(reasoningText: Content.ReasoningText) =
+ addContent(Content.ofReasoningText(reasoningText))
/**
* Alias for calling [addContent] with the following:
* ```java
- * RefusalContent.builder()
- * .refusal(refusal)
+ * Content.ReasoningText.builder()
+ * .text(text)
* .build()
* ```
*/
- fun addRefusalContent(refusal: String) =
- addContent(RefusalContent.builder().refusal(refusal).build())
+ fun addReasoningTextContent(text: String) =
+ addContent(Content.ReasoningText.builder().text(text).build())
- /** Alias for calling [addContent] with `Content.ofInputImage(inputImage)`. */
- fun addContent(inputImage: InputImageContent) = addContent(Content.ofInputImage(inputImage))
+ /** Alias for calling [addContent] with `Content.ofRefusal(refusal)`. */
+ fun addContent(refusal: ResponseOutputRefusal) = addContent(Content.ofRefusal(refusal))
/**
- * Alias for calling [addContent] with `Content.ofComputerScreenshot(computerScreenshot)`.
+ * Alias for calling [addContent] with the following:
+ * ```java
+ * ResponseOutputRefusal.builder()
+ * .refusal(refusal)
+ * .build()
+ * ```
*/
- fun addContent(computerScreenshot: ComputerScreenshotContent) =
- addContent(Content.ofComputerScreenshot(computerScreenshot))
+ fun addRefusalContent(refusal: String) =
+ addContent(ResponseOutputRefusal.builder().refusal(refusal).build())
- /** Alias for calling [addContent] with `Content.ofInputFile(inputFile)`. */
- fun addContent(inputFile: InputFileContent) = addContent(Content.ofInputFile(inputFile))
+ /** Alias for calling [addContent] with `Content.ofInputImage(inputImage)`. */
+ fun addContent(inputImage: ResponseInputImage) =
+ addContent(Content.ofInputImage(inputImage))
/**
* Alias for calling [addContent] with the following:
* ```java
- * InputFileContent.builder()
- * .fileId(fileId)
+ * ResponseInputImage.builder()
+ * .detail(detail)
* .build()
* ```
*/
- fun addInputFileContent(fileId: String?) =
- addContent(InputFileContent.builder().fileId(fileId).build())
+ fun addInputImageContent(detail: ResponseInputImage.Detail) =
+ addContent(ResponseInputImage.builder().detail(detail).build())
- /** Alias for calling [addInputFileContent] with `fileId.orElse(null)`. */
- fun addInputFileContent(fileId: Optional) = addInputFileContent(fileId.getOrNull())
+ /**
+ * Alias for calling [addContent] with `Content.ofComputerScreenshot(computerScreenshot)`.
+ */
+ fun addContent(computerScreenshot: ComputerScreenshotContent) =
+ addContent(Content.ofComputerScreenshot(computerScreenshot))
+
+ /** Alias for calling [addContent] with `Content.ofInputFile(inputFile)`. */
+ fun addContent(inputFile: ResponseInputFile) = addContent(Content.ofInputFile(inputFile))
/**
* The role of the message. One of `unknown`, `user`, `assistant`, `system`, `critic`,
@@ -423,37 +443,53 @@ private constructor(
(status.asKnown().getOrNull()?.validity() ?: 0) +
type.let { if (it == JsonValue.from("message")) 1 else 0 }
+ /** A text input to the model. */
@JsonDeserialize(using = Content.Deserializer::class)
@JsonSerialize(using = Content.Serializer::class)
class Content
private constructor(
- private val inputText: InputTextContent? = null,
- private val outputText: OutputTextContent? = null,
+ private val inputText: ResponseInputText? = null,
+ private val outputText: ResponseOutputText? = null,
private val text: TextContent? = null,
private val summaryText: SummaryTextContent? = null,
- private val refusal: RefusalContent? = null,
- private val inputImage: InputImageContent? = null,
+ private val reasoningText: ReasoningText? = null,
+ private val refusal: ResponseOutputRefusal? = null,
+ private val inputImage: ResponseInputImage? = null,
private val computerScreenshot: ComputerScreenshotContent? = null,
- private val inputFile: InputFileContent? = null,
+ private val inputFile: ResponseInputFile? = null,
private val _json: JsonValue? = null,
) {
- fun inputText(): Optional = Optional.ofNullable(inputText)
+ /** A text input to the model. */
+ fun inputText(): Optional = Optional.ofNullable(inputText)
- fun outputText(): Optional = Optional.ofNullable(outputText)
+ /** A text output from the model. */
+ fun outputText(): Optional = Optional.ofNullable(outputText)
+ /** A text content. */
fun text(): Optional = Optional.ofNullable(text)
+ /** A summary text from the model. */
fun summaryText(): Optional = Optional.ofNullable(summaryText)
- fun refusal(): Optional = Optional.ofNullable(refusal)
+ /** Reasoning text from the model. */
+ fun reasoningText(): Optional = Optional.ofNullable(reasoningText)
+
+ /** A refusal from the model. */
+ fun refusal(): Optional = Optional.ofNullable(refusal)
- fun inputImage(): Optional = Optional.ofNullable(inputImage)
+ /**
+ * An image input to the model. Learn about
+ * [image inputs](https://platform.openai.com/docs/guides/vision).
+ */
+ fun inputImage(): Optional = Optional.ofNullable(inputImage)
+ /** A screenshot of a computer. */
fun computerScreenshot(): Optional =
Optional.ofNullable(computerScreenshot)
- fun inputFile(): Optional = Optional.ofNullable(inputFile)
+ /** A file input to the model. */
+ fun inputFile(): Optional = Optional.ofNullable(inputFile)
fun isInputText(): Boolean = inputText != null
@@ -463,6 +499,8 @@ private constructor(
fun isSummaryText(): Boolean = summaryText != null
+ fun isReasoningText(): Boolean = reasoningText != null
+
fun isRefusal(): Boolean = refusal != null
fun isInputImage(): Boolean = inputImage != null
@@ -471,22 +509,36 @@ private constructor(
fun isInputFile(): Boolean = inputFile != null
- fun asInputText(): InputTextContent = inputText.getOrThrow("inputText")
+ /** A text input to the model. */
+ fun asInputText(): ResponseInputText = inputText.getOrThrow("inputText")
- fun asOutputText(): OutputTextContent = outputText.getOrThrow("outputText")
+ /** A text output from the model. */
+ fun asOutputText(): ResponseOutputText = outputText.getOrThrow("outputText")
+ /** A text content. */
fun asText(): TextContent = text.getOrThrow("text")
+ /** A summary text from the model. */
fun asSummaryText(): SummaryTextContent = summaryText.getOrThrow("summaryText")
- fun asRefusal(): RefusalContent = refusal.getOrThrow("refusal")
+ /** Reasoning text from the model. */
+ fun asReasoningText(): ReasoningText = reasoningText.getOrThrow("reasoningText")
- fun asInputImage(): InputImageContent = inputImage.getOrThrow("inputImage")
+ /** A refusal from the model. */
+ fun asRefusal(): ResponseOutputRefusal = refusal.getOrThrow("refusal")
+ /**
+ * An image input to the model. Learn about
+ * [image inputs](https://platform.openai.com/docs/guides/vision).
+ */
+ fun asInputImage(): ResponseInputImage = inputImage.getOrThrow("inputImage")
+
+ /** A screenshot of a computer. */
fun asComputerScreenshot(): ComputerScreenshotContent =
computerScreenshot.getOrThrow("computerScreenshot")
- fun asInputFile(): InputFileContent = inputFile.getOrThrow("inputFile")
+ /** A file input to the model. */
+ fun asInputFile(): ResponseInputFile = inputFile.getOrThrow("inputFile")
fun _json(): Optional = Optional.ofNullable(_json)
@@ -496,6 +548,7 @@ private constructor(
outputText != null -> visitor.visitOutputText(outputText)
text != null -> visitor.visitText(text)
summaryText != null -> visitor.visitSummaryText(summaryText)
+ reasoningText != null -> visitor.visitReasoningText(reasoningText)
refusal != null -> visitor.visitRefusal(refusal)
inputImage != null -> visitor.visitInputImage(inputImage)
computerScreenshot != null -> visitor.visitComputerScreenshot(computerScreenshot)
@@ -512,11 +565,11 @@ private constructor(
accept(
object : Visitor {
- override fun visitInputText(inputText: InputTextContent) {
+ override fun visitInputText(inputText: ResponseInputText) {
inputText.validate()
}
- override fun visitOutputText(outputText: OutputTextContent) {
+ override fun visitOutputText(outputText: ResponseOutputText) {
outputText.validate()
}
@@ -528,11 +581,15 @@ private constructor(
summaryText.validate()
}
- override fun visitRefusal(refusal: RefusalContent) {
+ override fun visitReasoningText(reasoningText: ReasoningText) {
+ reasoningText.validate()
+ }
+
+ override fun visitRefusal(refusal: ResponseOutputRefusal) {
refusal.validate()
}
- override fun visitInputImage(inputImage: InputImageContent) {
+ override fun visitInputImage(inputImage: ResponseInputImage) {
inputImage.validate()
}
@@ -542,7 +599,7 @@ private constructor(
computerScreenshot.validate()
}
- override fun visitInputFile(inputFile: InputFileContent) {
+ override fun visitInputFile(inputFile: ResponseInputFile) {
inputFile.validate()
}
}
@@ -568,9 +625,9 @@ private constructor(
internal fun validity(): Int =
accept(
object : Visitor {
- override fun visitInputText(inputText: InputTextContent) = inputText.validity()
+ override fun visitInputText(inputText: ResponseInputText) = inputText.validity()
- override fun visitOutputText(outputText: OutputTextContent) =
+ override fun visitOutputText(outputText: ResponseOutputText) =
outputText.validity()
override fun visitText(text: TextContent) = text.validity()
@@ -578,16 +635,19 @@ private constructor(
override fun visitSummaryText(summaryText: SummaryTextContent) =
summaryText.validity()
- override fun visitRefusal(refusal: RefusalContent) = refusal.validity()
+ override fun visitReasoningText(reasoningText: ReasoningText) =
+ reasoningText.validity()
- override fun visitInputImage(inputImage: InputImageContent) =
+ override fun visitRefusal(refusal: ResponseOutputRefusal) = refusal.validity()
+
+ override fun visitInputImage(inputImage: ResponseInputImage) =
inputImage.validity()
override fun visitComputerScreenshot(
computerScreenshot: ComputerScreenshotContent
) = computerScreenshot.validity()
- override fun visitInputFile(inputFile: InputFileContent) = inputFile.validity()
+ override fun visitInputFile(inputFile: ResponseInputFile) = inputFile.validity()
override fun unknown(json: JsonValue?) = 0
}
@@ -603,6 +663,7 @@ private constructor(
outputText == other.outputText &&
text == other.text &&
summaryText == other.summaryText &&
+ reasoningText == other.reasoningText &&
refusal == other.refusal &&
inputImage == other.inputImage &&
computerScreenshot == other.computerScreenshot &&
@@ -615,6 +676,7 @@ private constructor(
outputText,
text,
summaryText,
+ reasoningText,
refusal,
inputImage,
computerScreenshot,
@@ -627,6 +689,7 @@ private constructor(
outputText != null -> "Content{outputText=$outputText}"
text != null -> "Content{text=$text}"
summaryText != null -> "Content{summaryText=$summaryText}"
+ reasoningText != null -> "Content{reasoningText=$reasoningText}"
refusal != null -> "Content{refusal=$refusal}"
inputImage != null -> "Content{inputImage=$inputImage}"
computerScreenshot != null -> "Content{computerScreenshot=$computerScreenshot}"
@@ -637,26 +700,44 @@ private constructor(
companion object {
- @JvmStatic fun ofInputText(inputText: InputTextContent) = Content(inputText = inputText)
+ /** A text input to the model. */
+ @JvmStatic
+ fun ofInputText(inputText: ResponseInputText) = Content(inputText = inputText)
+ /** A text output from the model. */
@JvmStatic
- fun ofOutputText(outputText: OutputTextContent) = Content(outputText = outputText)
+ fun ofOutputText(outputText: ResponseOutputText) = Content(outputText = outputText)
+ /** A text content. */
@JvmStatic fun ofText(text: TextContent) = Content(text = text)
+ /** A summary text from the model. */
@JvmStatic
fun ofSummaryText(summaryText: SummaryTextContent) = Content(summaryText = summaryText)
- @JvmStatic fun ofRefusal(refusal: RefusalContent) = Content(refusal = refusal)
+ /** Reasoning text from the model. */
+ @JvmStatic
+ fun ofReasoningText(reasoningText: ReasoningText) =
+ Content(reasoningText = reasoningText)
+
+ /** A refusal from the model. */
+ @JvmStatic fun ofRefusal(refusal: ResponseOutputRefusal) = Content(refusal = refusal)
+ /**
+ * An image input to the model. Learn about
+ * [image inputs](https://platform.openai.com/docs/guides/vision).
+ */
@JvmStatic
- fun ofInputImage(inputImage: InputImageContent) = Content(inputImage = inputImage)
+ fun ofInputImage(inputImage: ResponseInputImage) = Content(inputImage = inputImage)
+ /** A screenshot of a computer. */
@JvmStatic
fun ofComputerScreenshot(computerScreenshot: ComputerScreenshotContent) =
Content(computerScreenshot = computerScreenshot)
- @JvmStatic fun ofInputFile(inputFile: InputFileContent) = Content(inputFile = inputFile)
+ /** A file input to the model. */
+ @JvmStatic
+ fun ofInputFile(inputFile: ResponseInputFile) = Content(inputFile = inputFile)
}
/**
@@ -664,21 +745,35 @@ private constructor(
*/
interface Visitor {
- fun visitInputText(inputText: InputTextContent): T
+ /** A text input to the model. */
+ fun visitInputText(inputText: ResponseInputText): T
- fun visitOutputText(outputText: OutputTextContent): T
+ /** A text output from the model. */
+ fun visitOutputText(outputText: ResponseOutputText): T
+ /** A text content. */
fun visitText(text: TextContent): T
+ /** A summary text from the model. */
fun visitSummaryText(summaryText: SummaryTextContent): T
- fun visitRefusal(refusal: RefusalContent): T
+ /** Reasoning text from the model. */
+ fun visitReasoningText(reasoningText: ReasoningText): T
+
+ /** A refusal from the model. */
+ fun visitRefusal(refusal: ResponseOutputRefusal): T
- fun visitInputImage(inputImage: InputImageContent): T
+ /**
+ * An image input to the model. Learn about
+ * [image inputs](https://platform.openai.com/docs/guides/vision).
+ */
+ fun visitInputImage(inputImage: ResponseInputImage): T
+ /** A screenshot of a computer. */
fun visitComputerScreenshot(computerScreenshot: ComputerScreenshotContent): T
- fun visitInputFile(inputFile: InputFileContent): T
+ /** A file input to the model. */
+ fun visitInputFile(inputFile: ResponseInputFile): T
/**
* Maps an unknown variant of [Content] to a value of type [T].
@@ -703,12 +798,12 @@ private constructor(
when (type) {
"input_text" -> {
- return tryDeserialize(node, jacksonTypeRef())?.let {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
Content(inputText = it, _json = json)
} ?: Content(_json = json)
}
"output_text" -> {
- return tryDeserialize(node, jacksonTypeRef())?.let {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
Content(outputText = it, _json = json)
} ?: Content(_json = json)
}
@@ -722,13 +817,18 @@ private constructor(
Content(summaryText = it, _json = json)
} ?: Content(_json = json)
}
+ "reasoning_text" -> {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
+ Content(reasoningText = it, _json = json)
+ } ?: Content(_json = json)
+ }
"refusal" -> {
- return tryDeserialize(node, jacksonTypeRef())?.let {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
Content(refusal = it, _json = json)
} ?: Content(_json = json)
}
"input_image" -> {
- return tryDeserialize(node, jacksonTypeRef())?.let {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
Content(inputImage = it, _json = json)
} ?: Content(_json = json)
}
@@ -738,7 +838,7 @@ private constructor(
?: Content(_json = json)
}
"input_file" -> {
- return tryDeserialize(node, jacksonTypeRef())?.let {
+ return tryDeserialize(node, jacksonTypeRef())?.let {
Content(inputFile = it, _json = json)
} ?: Content(_json = json)
}
@@ -760,6 +860,7 @@ private constructor(
value.outputText != null -> generator.writeObject(value.outputText)
value.text != null -> generator.writeObject(value.text)
value.summaryText != null -> generator.writeObject(value.summaryText)
+ value.reasoningText != null -> generator.writeObject(value.reasoningText)
value.refusal != null -> generator.writeObject(value.refusal)
value.inputImage != null -> generator.writeObject(value.inputImage)
value.computerScreenshot != null ->
@@ -770,6 +871,210 @@ private constructor(
}
}
}
+
+ /** Reasoning text from the model. */
+ class ReasoningText
+ private constructor(
+ private val text: JsonField,
+ private val type: JsonValue,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(),
+ @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
+ ) : this(text, type, mutableMapOf())
+
+ /**
+ * The reasoning text from the model.
+ *
+ * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
+ * unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun text(): String = text.getRequired("text")
+
+ /**
+ * The type of the reasoning text. Always `reasoning_text`.
+ *
+ * Expected to always return the following:
+ * ```java
+ * JsonValue.from("reasoning_text")
+ * ```
+ *
+ * However, this method can be useful for debugging and logging (e.g. if the server
+ * responded with an unexpected value).
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
+
+ /**
+ * Returns the raw JSON value of [text].
+ *
+ * Unlike [text], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [ReasoningText].
+ *
+ * The following fields are required:
+ * ```java
+ * .text()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [ReasoningText]. */
+ class Builder internal constructor() {
+
+ private var text: JsonField? = null
+ private var type: JsonValue = JsonValue.from("reasoning_text")
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(reasoningText: ReasoningText) = apply {
+ text = reasoningText.text
+ type = reasoningText.type
+ additionalProperties = reasoningText.additionalProperties.toMutableMap()
+ }
+
+ /** The reasoning text from the model. */
+ fun text(text: String) = text(JsonField.of(text))
+
+ /**
+ * Sets [Builder.text] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.text] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun text(text: JsonField) = apply { this.text = text }
+
+ /**
+ * Sets the field to an arbitrary JSON value.
+ *
+ * It is usually unnecessary to call this method because the field defaults to the
+ * following:
+ * ```java
+ * JsonValue.from("reasoning_text")
+ * ```
+ *
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun type(type: JsonValue) = apply { this.type = type }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [ReasoningText].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .text()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): ReasoningText =
+ ReasoningText(
+ checkRequired("text", text),
+ type,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): ReasoningText = apply {
+ if (validated) {
+ return@apply
+ }
+
+ text()
+ _type().let {
+ if (it != JsonValue.from("reasoning_text")) {
+ throw OpenAIInvalidDataException("'type' is invalid, received $it")
+ }
+ }
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: OpenAIInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (text.asKnown().isPresent) 1 else 0) +
+ type.let { if (it == JsonValue.from("reasoning_text")) 1 else 0 }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is ReasoningText &&
+ text == other.text &&
+ type == other.type &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy { Objects.hash(text, type, additionalProperties) }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "ReasoningText{text=$text, type=$type, additionalProperties=$additionalProperties}"
+ }
}
/**
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/OutputTextContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/OutputTextContent.kt
deleted file mode 100644
index 1fe6ccb72..000000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/OutputTextContent.kt
+++ /dev/null
@@ -1,558 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.conversations
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.fasterxml.jackson.core.JsonGenerator
-import com.fasterxml.jackson.core.ObjectCodec
-import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.SerializerProvider
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize
-import com.fasterxml.jackson.databind.annotation.JsonSerialize
-import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
-import com.openai.core.BaseDeserializer
-import com.openai.core.BaseSerializer
-import com.openai.core.ExcludeMissing
-import com.openai.core.JsonField
-import com.openai.core.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.core.checkKnown
-import com.openai.core.checkRequired
-import com.openai.core.getOrThrow
-import com.openai.core.toImmutable
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-import java.util.Optional
-import kotlin.jvm.optionals.getOrNull
-
-class OutputTextContent
-private constructor(
- private val annotations: JsonField>,
- private val text: JsonField,
- private val type: JsonValue,
- private val logprobs: JsonField>,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("annotations")
- @ExcludeMissing
- annotations: JsonField> = JsonMissing.of(),
- @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- @JsonProperty("logprobs")
- @ExcludeMissing
- logprobs: JsonField> = JsonMissing.of(),
- ) : this(annotations, text, type, logprobs, mutableMapOf())
-
- /**
- * The annotations of the text output.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun annotations(): List = annotations.getRequired("annotations")
-
- /**
- * The text output from the model.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun text(): String = text.getRequired("text")
-
- /**
- * The type of the output text. Always `output_text`.
- *
- * Expected to always return the following:
- * ```java
- * JsonValue.from("output_text")
- * ```
- *
- * However, this method can be useful for debugging and logging (e.g. if the server responded
- * with an unexpected value).
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
-
- /**
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the
- * server responded with an unexpected value).
- */
- fun logprobs(): Optional> = logprobs.getOptional("logprobs")
-
- /**
- * Returns the raw JSON value of [annotations].
- *
- * Unlike [annotations], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("annotations")
- @ExcludeMissing
- fun _annotations(): JsonField> = annotations
-
- /**
- * Returns the raw JSON value of [text].
- *
- * Unlike [text], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text
-
- /**
- * Returns the raw JSON value of [logprobs].
- *
- * Unlike [logprobs], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("logprobs") @ExcludeMissing fun _logprobs(): JsonField> = logprobs
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [OutputTextContent].
- *
- * The following fields are required:
- * ```java
- * .annotations()
- * .text()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [OutputTextContent]. */
- class Builder internal constructor() {
-
- private var annotations: JsonField>? = null
- private var text: JsonField? = null
- private var type: JsonValue = JsonValue.from("output_text")
- private var logprobs: JsonField>? = null
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(outputTextContent: OutputTextContent) = apply {
- annotations = outputTextContent.annotations.map { it.toMutableList() }
- text = outputTextContent.text
- type = outputTextContent.type
- logprobs = outputTextContent.logprobs.map { it.toMutableList() }
- additionalProperties = outputTextContent.additionalProperties.toMutableMap()
- }
-
- /** The annotations of the text output. */
- fun annotations(annotations: List) = annotations(JsonField.of(annotations))
-
- /**
- * Sets [Builder.annotations] to an arbitrary JSON value.
- *
- * You should usually call [Builder.annotations] with a well-typed `List` value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun annotations(annotations: JsonField>) = apply {
- this.annotations = annotations.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [Annotation] to [annotations].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addAnnotation(annotation: Annotation) = apply {
- annotations =
- (annotations ?: JsonField.of(mutableListOf())).also {
- checkKnown("annotations", it).add(annotation)
- }
- }
-
- /** Alias for calling [addAnnotation] with `Annotation.ofFileCitation(fileCitation)`. */
- fun addAnnotation(fileCitation: FileCitationBody) =
- addAnnotation(Annotation.ofFileCitation(fileCitation))
-
- /** Alias for calling [addAnnotation] with `Annotation.ofUrlCitation(urlCitation)`. */
- fun addAnnotation(urlCitation: UrlCitationBody) =
- addAnnotation(Annotation.ofUrlCitation(urlCitation))
-
- /**
- * Alias for calling [addAnnotation] with
- * `Annotation.ofContainerFileCitation(containerFileCitation)`.
- */
- fun addAnnotation(containerFileCitation: ContainerFileCitationBody) =
- addAnnotation(Annotation.ofContainerFileCitation(containerFileCitation))
-
- /** The text output from the model. */
- fun text(text: String) = text(JsonField.of(text))
-
- /**
- * Sets [Builder.text] to an arbitrary JSON value.
- *
- * You should usually call [Builder.text] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun text(text: JsonField) = apply { this.text = text }
-
- /**
- * Sets the field to an arbitrary JSON value.
- *
- * It is usually unnecessary to call this method because the field defaults to the
- * following:
- * ```java
- * JsonValue.from("output_text")
- * ```
- *
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonValue) = apply { this.type = type }
-
- fun logprobs(logprobs: List) = logprobs(JsonField.of(logprobs))
-
- /**
- * Sets [Builder.logprobs] to an arbitrary JSON value.
- *
- * You should usually call [Builder.logprobs] with a well-typed `List` value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun logprobs(logprobs: JsonField>) = apply {
- this.logprobs = logprobs.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [LobProb] to [logprobs].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addLogprob(logprob: LobProb) = apply {
- logprobs =
- (logprobs ?: JsonField.of(mutableListOf())).also {
- checkKnown("logprobs", it).add(logprob)
- }
- }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [OutputTextContent].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .annotations()
- * .text()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): OutputTextContent =
- OutputTextContent(
- checkRequired("annotations", annotations).map { it.toImmutable() },
- checkRequired("text", text),
- type,
- (logprobs ?: JsonMissing.of()).map { it.toImmutable() },
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): OutputTextContent = apply {
- if (validated) {
- return@apply
- }
-
- annotations().forEach { it.validate() }
- text()
- _type().let {
- if (it != JsonValue.from("output_text")) {
- throw OpenAIInvalidDataException("'type' is invalid, received $it")
- }
- }
- logprobs().ifPresent { it.forEach { it.validate() } }
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (annotations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) +
- (if (text.asKnown().isPresent) 1 else 0) +
- type.let { if (it == JsonValue.from("output_text")) 1 else 0 } +
- (logprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
-
- @JsonDeserialize(using = Annotation.Deserializer::class)
- @JsonSerialize(using = Annotation.Serializer::class)
- class Annotation
- private constructor(
- private val fileCitation: FileCitationBody? = null,
- private val urlCitation: UrlCitationBody? = null,
- private val containerFileCitation: ContainerFileCitationBody? = null,
- private val _json: JsonValue? = null,
- ) {
-
- fun fileCitation(): Optional = Optional.ofNullable(fileCitation)
-
- fun urlCitation(): Optional = Optional.ofNullable(urlCitation)
-
- fun containerFileCitation(): Optional =
- Optional.ofNullable(containerFileCitation)
-
- fun isFileCitation(): Boolean = fileCitation != null
-
- fun isUrlCitation(): Boolean = urlCitation != null
-
- fun isContainerFileCitation(): Boolean = containerFileCitation != null
-
- fun asFileCitation(): FileCitationBody = fileCitation.getOrThrow("fileCitation")
-
- fun asUrlCitation(): UrlCitationBody = urlCitation.getOrThrow("urlCitation")
-
- fun asContainerFileCitation(): ContainerFileCitationBody =
- containerFileCitation.getOrThrow("containerFileCitation")
-
- fun _json(): Optional = Optional.ofNullable(_json)
-
- fun accept(visitor: Visitor): T =
- when {
- fileCitation != null -> visitor.visitFileCitation(fileCitation)
- urlCitation != null -> visitor.visitUrlCitation(urlCitation)
- containerFileCitation != null ->
- visitor.visitContainerFileCitation(containerFileCitation)
- else -> visitor.unknown(_json)
- }
-
- private var validated: Boolean = false
-
- fun validate(): Annotation = apply {
- if (validated) {
- return@apply
- }
-
- accept(
- object : Visitor {
- override fun visitFileCitation(fileCitation: FileCitationBody) {
- fileCitation.validate()
- }
-
- override fun visitUrlCitation(urlCitation: UrlCitationBody) {
- urlCitation.validate()
- }
-
- override fun visitContainerFileCitation(
- containerFileCitation: ContainerFileCitationBody
- ) {
- containerFileCitation.validate()
- }
- }
- )
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object
- * recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- accept(
- object : Visitor {
- override fun visitFileCitation(fileCitation: FileCitationBody) =
- fileCitation.validity()
-
- override fun visitUrlCitation(urlCitation: UrlCitationBody) =
- urlCitation.validity()
-
- override fun visitContainerFileCitation(
- containerFileCitation: ContainerFileCitationBody
- ) = containerFileCitation.validity()
-
- override fun unknown(json: JsonValue?) = 0
- }
- )
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is Annotation &&
- fileCitation == other.fileCitation &&
- urlCitation == other.urlCitation &&
- containerFileCitation == other.containerFileCitation
- }
-
- override fun hashCode(): Int =
- Objects.hash(fileCitation, urlCitation, containerFileCitation)
-
- override fun toString(): String =
- when {
- fileCitation != null -> "Annotation{fileCitation=$fileCitation}"
- urlCitation != null -> "Annotation{urlCitation=$urlCitation}"
- containerFileCitation != null ->
- "Annotation{containerFileCitation=$containerFileCitation}"
- _json != null -> "Annotation{_unknown=$_json}"
- else -> throw IllegalStateException("Invalid Annotation")
- }
-
- companion object {
-
- @JvmStatic
- fun ofFileCitation(fileCitation: FileCitationBody) =
- Annotation(fileCitation = fileCitation)
-
- @JvmStatic
- fun ofUrlCitation(urlCitation: UrlCitationBody) = Annotation(urlCitation = urlCitation)
-
- @JvmStatic
- fun ofContainerFileCitation(containerFileCitation: ContainerFileCitationBody) =
- Annotation(containerFileCitation = containerFileCitation)
- }
-
- /**
- * An interface that defines how to map each variant of [Annotation] to a value of type [T].
- */
- interface Visitor {
-
- fun visitFileCitation(fileCitation: FileCitationBody): T
-
- fun visitUrlCitation(urlCitation: UrlCitationBody): T
-
- fun visitContainerFileCitation(containerFileCitation: ContainerFileCitationBody): T
-
- /**
- * Maps an unknown variant of [Annotation] to a value of type [T].
- *
- * An instance of [Annotation] can contain an unknown variant if it was deserialized
- * from data that doesn't match any known variant. For example, if the SDK is on an
- * older version than the API, then the API may respond with new variants that the SDK
- * is unaware of.
- *
- * @throws OpenAIInvalidDataException in the default implementation.
- */
- fun unknown(json: JsonValue?): T {
- throw OpenAIInvalidDataException("Unknown Annotation: $json")
- }
- }
-
- internal class Deserializer : BaseDeserializer(Annotation::class) {
-
- override fun ObjectCodec.deserialize(node: JsonNode): Annotation {
- val json = JsonValue.fromJsonNode(node)
- val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull()
-
- when (type) {
- "file_citation" -> {
- return tryDeserialize(node, jacksonTypeRef())?.let {
- Annotation(fileCitation = it, _json = json)
- } ?: Annotation(_json = json)
- }
- "url_citation" -> {
- return tryDeserialize(node, jacksonTypeRef())?.let {
- Annotation(urlCitation = it, _json = json)
- } ?: Annotation(_json = json)
- }
- "container_file_citation" -> {
- return tryDeserialize(node, jacksonTypeRef())
- ?.let { Annotation(containerFileCitation = it, _json = json) }
- ?: Annotation(_json = json)
- }
- }
-
- return Annotation(_json = json)
- }
- }
-
- internal class Serializer : BaseSerializer(Annotation::class) {
-
- override fun serialize(
- value: Annotation,
- generator: JsonGenerator,
- provider: SerializerProvider,
- ) {
- when {
- value.fileCitation != null -> generator.writeObject(value.fileCitation)
- value.urlCitation != null -> generator.writeObject(value.urlCitation)
- value.containerFileCitation != null ->
- generator.writeObject(value.containerFileCitation)
- value._json != null -> generator.writeObject(value._json)
- else -> throw IllegalStateException("Invalid Annotation")
- }
- }
- }
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is OutputTextContent &&
- annotations == other.annotations &&
- text == other.text &&
- type == other.type &&
- logprobs == other.logprobs &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy {
- Objects.hash(annotations, text, type, logprobs, additionalProperties)
- }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "OutputTextContent{annotations=$annotations, text=$text, type=$type, logprobs=$logprobs, additionalProperties=$additionalProperties}"
-}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/RefusalContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/RefusalContent.kt
deleted file mode 100644
index 6cc73948e..000000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/RefusalContent.kt
+++ /dev/null
@@ -1,213 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.conversations
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.openai.core.ExcludeMissing
-import com.openai.core.JsonField
-import com.openai.core.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.core.checkRequired
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-
-class RefusalContent
-private constructor(
- private val refusal: JsonField,
- private val type: JsonValue,
- private val additionalProperties: MutableMap,
-) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("refusal") @ExcludeMissing refusal: JsonField = JsonMissing.of(),
- @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- ) : this(refusal, type, mutableMapOf())
-
- /**
- * The refusal explanation from the model.
- *
- * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
- * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
- */
- fun refusal(): String = refusal.getRequired("refusal")
-
- /**
- * The type of the refusal. Always `refusal`.
- *
- * Expected to always return the following:
- * ```java
- * JsonValue.from("refusal")
- * ```
- *
- * However, this method can be useful for debugging and logging (e.g. if the server responded
- * with an unexpected value).
- */
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type
-
- /**
- * Returns the raw JSON value of [refusal].
- *
- * Unlike [refusal], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("refusal") @ExcludeMissing fun _refusal(): JsonField = refusal
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of [RefusalContent].
- *
- * The following fields are required:
- * ```java
- * .refusal()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [RefusalContent]. */
- class Builder internal constructor() {
-
- private var refusal: JsonField? = null
- private var type: JsonValue = JsonValue.from("refusal")
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(refusalContent: RefusalContent) = apply {
- refusal = refusalContent.refusal
- type = refusalContent.type
- additionalProperties = refusalContent.additionalProperties.toMutableMap()
- }
-
- /** The refusal explanation from the model. */
- fun refusal(refusal: String) = refusal(JsonField.of(refusal))
-
- /**
- * Sets [Builder.refusal] to an arbitrary JSON value.
- *
- * You should usually call [Builder.refusal] with a well-typed [String] value instead. This
- * method is primarily for setting the field to an undocumented or not yet supported value.
- */
- fun refusal(refusal: JsonField) = apply { this.refusal = refusal }
-
- /**
- * Sets the field to an arbitrary JSON value.
- *
- * It is usually unnecessary to call this method because the field defaults to the
- * following:
- * ```java
- * JsonValue.from("refusal")
- * ```
- *
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
- */
- fun type(type: JsonValue) = apply { this.type = type }
-
- fun additionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
-
- fun putAllAdditionalProperties(additionalProperties: Map) = apply {
- this.additionalProperties.putAll(additionalProperties)
- }
-
- fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
-
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
-
- /**
- * Returns an immutable instance of [RefusalContent].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .refusal()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): RefusalContent =
- RefusalContent(
- checkRequired("refusal", refusal),
- type,
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): RefusalContent = apply {
- if (validated) {
- return@apply
- }
-
- refusal()
- _type().let {
- if (it != JsonValue.from("refusal")) {
- throw OpenAIInvalidDataException("'type' is invalid, received $it")
- }
- }
- validated = true
- }
-
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: OpenAIInvalidDataException) {
- false
- }
-
- /**
- * Returns a score indicating how many valid values are contained in this object recursively.
- *
- * Used for best match union deserialization.
- */
- @JvmSynthetic
- internal fun validity(): Int =
- (if (refusal.asKnown().isPresent) 1 else 0) +
- type.let { if (it == JsonValue.from("refusal")) 1 else 0 }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return other is RefusalContent &&
- refusal == other.refusal &&
- type == other.type &&
- additionalProperties == other.additionalProperties
- }
-
- private val hashCode: Int by lazy { Objects.hash(refusal, type, additionalProperties) }
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "RefusalContent{refusal=$refusal, type=$type, additionalProperties=$additionalProperties}"
-}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/SummaryTextContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/SummaryTextContent.kt
index 263a247c3..a00fb944c 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/SummaryTextContent.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/SummaryTextContent.kt
@@ -15,6 +15,7 @@ import com.openai.errors.OpenAIInvalidDataException
import java.util.Collections
import java.util.Objects
+/** A summary text from the model. */
class SummaryTextContent
private constructor(
private val text: JsonField,
@@ -29,12 +30,16 @@ private constructor(
) : this(text, type, mutableMapOf())
/**
+ * A summary of the reasoning output from the model so far.
+ *
* @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
fun text(): String = text.getRequired("text")
/**
+ * The type of the object. Always `summary_text`.
+ *
* Expected to always return the following:
* ```java
* JsonValue.from("summary_text")
@@ -91,6 +96,7 @@ private constructor(
additionalProperties = summaryTextContent.additionalProperties.toMutableMap()
}
+ /** A summary of the reasoning output from the model so far. */
fun text(text: String) = text(JsonField.of(text))
/**
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/TextContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/TextContent.kt
index 120f1488b..3f5286528 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/TextContent.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/TextContent.kt
@@ -15,6 +15,7 @@ import com.openai.errors.OpenAIInvalidDataException
import java.util.Collections
import java.util.Objects
+/** A text content. */
class TextContent
private constructor(
private val text: JsonField,
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/TopLogProb.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/TopLogProb.kt
deleted file mode 100644
index c9750659f..000000000
--- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/TopLogProb.kt
+++ /dev/null
@@ -1,253 +0,0 @@
-// File generated from our OpenAPI spec by Stainless.
-
-package com.openai.models.conversations
-
-import com.fasterxml.jackson.annotation.JsonAnyGetter
-import com.fasterxml.jackson.annotation.JsonAnySetter
-import com.fasterxml.jackson.annotation.JsonCreator
-import com.fasterxml.jackson.annotation.JsonProperty
-import com.openai.core.ExcludeMissing
-import com.openai.core.JsonField
-import com.openai.core.JsonMissing
-import com.openai.core.JsonValue
-import com.openai.core.checkKnown
-import com.openai.core.checkRequired
-import com.openai.core.toImmutable
-import com.openai.errors.OpenAIInvalidDataException
-import java.util.Collections
-import java.util.Objects
-import kotlin.jvm.optionals.getOrNull
-
-class TopLogProb
-private constructor(
- private val token: JsonField,
- private val bytes: JsonField>,
- private val logprob: JsonField,
- private val additionalProperties: MutableMap