diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 89d8ff81..75ec52fc 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "2.2.1"
+ ".": "2.3.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 0e0b9636..9aad2898 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 86
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fc64d7c2c8f51f750813375356c3f3fdfc7fc1b1b34f19c20a5410279d445d37.yml
-openapi_spec_hash: 618285fc70199ee32b9ebe4bf72f7e4c
-config_hash: 535b6e5f26a295d609b259c8cb8f656c
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-d4bcffecf0cdadf746faa6708ed1ec81fac451f9b857deabbab26f0a343b9314.yml
+openapi_spec_hash: 7c54a18b4381248bda7cc34c52142615
+config_hash: d23f847b9ebb3f427d0f198035bd3e9f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d2dcf3f9..27bc5ecf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,22 @@
# Changelog
+## 2.3.0 (2025-05-29)
+
+Full Changelog: [v2.2.1...v2.3.0](https://github.com/openai/openai-java/compare/v2.2.1...v2.3.0)
+
+### Features
+
+* **api:** Config update for pakrym-stream-param ([55ae767](https://github.com/openai/openai-java/commit/55ae767021a1d03a2c8bc4184163acd56ee64d41))
+
+
+### Bug Fixes
+
+* **client:** add missing deployment model param ([#704](https://github.com/openai/openai-java/issues/704)) ([37aa563](https://github.com/openai/openai-java/commit/37aa563789f34de917758519d859f17d9c1a98fc))
+* **client:** correctly send streaming discriminator param ([b27559f](https://github.com/openai/openai-java/commit/b27559fa7d1c097ada40da12e55d1def372f5dce))
+* **client:** optional image deployment model param ([a507f84](https://github.com/openai/openai-java/commit/a507f8446a2270ee3e9c5e5295a9a57b59c633eb))
+* **client:** remove `@MustBeClosed` for future returning methods ([2988157](https://github.com/openai/openai-java/commit/2988157933dfe2ec7f9f2b626d0fa9eb184db27d))
+* **client:** return binary content from `get /containers/{container_id}/files/{file_id}/content` ([787e12b](https://github.com/openai/openai-java/commit/787e12b4ac3d33f46aa31c165241c26f927e92dc))
+
## 2.2.1 (2025-05-27)
Full Changelog: [v2.2.0...v2.2.1](https://github.com/openai/openai-java/compare/v2.2.0...v2.2.1)
diff --git a/README.md b/README.md
index 411b0949..f5caddb7 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.openai/openai-java/2.2.1)
-[](https://javadoc.io/doc/com.openai/openai-java/2.2.1)
+[](https://central.sonatype.com/artifact/com.openai/openai-java/2.3.0)
+[](https://javadoc.io/doc/com.openai/openai-java/2.3.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/2.2.1).
+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/2.3.0).
@@ -22,7 +22,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
### Gradle
```kotlin
-implementation("com.openai:openai-java:2.2.1")
+implementation("com.openai:openai-java:2.3.0")
```
### Maven
@@ -31,7 +31,7 @@ implementation("com.openai:openai-java:2.2.1")
com.openai
openai-java
- 2.2.1
+ 2.3.0
```
diff --git a/build.gradle.kts b/build.gradle.kts
index cbf7d4ab..fb9792f5 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.openai"
- version = "2.2.1" // x-release-please-version
+ version = "2.3.0" // x-release-please-version
}
subprojects {
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputText.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputText.kt
index fc110417..261bd1a9 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputText.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseOutputText.kt
@@ -35,6 +35,7 @@ private constructor(
private val annotations: JsonField>,
private val text: JsonField,
private val type: JsonValue,
+ private val logprobs: JsonField>,
private val additionalProperties: MutableMap,
) {
@@ -45,7 +46,10 @@ private constructor(
annotations: JsonField> = JsonMissing.of(),
@JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(),
@JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(),
- ) : this(annotations, text, type, mutableMapOf())
+ @JsonProperty("logprobs")
+ @ExcludeMissing
+ logprobs: JsonField> = JsonMissing.of(),
+ ) : this(annotations, text, type, logprobs, mutableMapOf())
/**
* The annotations of the text output.
@@ -76,6 +80,12 @@ private constructor(
*/
@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].
*
@@ -92,6 +102,13 @@ private constructor(
*/
@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)
@@ -124,6 +141,7 @@ private 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
@@ -131,6 +149,7 @@ private constructor(
annotations = responseOutputText.annotations.map { it.toMutableList() }
text = responseOutputText.text
type = responseOutputText.type
+ logprobs = responseOutputText.logprobs.map { it.toMutableList() }
additionalProperties = responseOutputText.additionalProperties.toMutableMap()
}
@@ -197,6 +216,31 @@ private constructor(
*/
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 [Logprob] to [logprobs].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addLogprob(logprob: Logprob) = apply {
+ logprobs =
+ (logprobs ?: JsonField.of(mutableListOf())).also {
+ checkKnown("logprobs", it).add(logprob)
+ }
+ }
+
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
@@ -234,6 +278,7 @@ private constructor(
checkRequired("annotations", annotations).map { it.toImmutable() },
checkRequired("text", text),
type,
+ (logprobs ?: JsonMissing.of()).map { it.toImmutable() },
additionalProperties.toMutableMap(),
)
}
@@ -252,6 +297,7 @@ private constructor(
throw OpenAIInvalidDataException("'type' is invalid, received $it")
}
}
+ logprobs().ifPresent { it.forEach { it.validate() } }
validated = true
}
@@ -272,7 +318,8 @@ private constructor(
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 }
+ type.let { if (it == JsonValue.from("output_text")) 1 else 0 } +
+ (logprobs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
/** A citation to a file. */
@JsonDeserialize(using = Annotation.Deserializer::class)
@@ -1287,20 +1334,557 @@ private constructor(
}
}
+ /** The log probability of a token. */
+ class Logprob
+ 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 [Logprob].
+ *
+ * The following fields are required:
+ * ```java
+ * .token()
+ * .bytes()
+ * .logprob()
+ * .topLogprobs()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Logprob]. */
+ 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(logprob: Logprob) = apply {
+ token = logprob.token
+ bytes = logprob.bytes.map { it.toMutableList() }
+ this.logprob = logprob.logprob
+ topLogprobs = logprob.topLogprobs.map { it.toMutableList() }
+ additionalProperties = logprob.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 [Logprob].
+ *
+ * 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(): Logprob =
+ Logprob(
+ 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(): Logprob = 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)
+
+ /** The top log probability of a token. */
+ class TopLogprob
+ private constructor(
+ private val token: JsonField,
+ private val bytes: JsonField>,
+ private val logprob: 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(),
+ ) : this(token, bytes, logprob, 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")
+
+ /**
+ * 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
+
+ @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 [TopLogprob].
+ *
+ * The following fields are required:
+ * ```java
+ * .token()
+ * .bytes()
+ * .logprob()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [TopLogprob]. */
+ class Builder internal constructor() {
+
+ private var token: JsonField? = null
+ private var bytes: JsonField>? = null
+ private var logprob: JsonField? = null
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(topLogprob: TopLogprob) = apply {
+ token = topLogprob.token
+ bytes = topLogprob.bytes.map { it.toMutableList() }
+ logprob = topLogprob.logprob
+ additionalProperties = topLogprob.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 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 [TopLogprob].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .token()
+ * .bytes()
+ * .logprob()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): TopLogprob =
+ TopLogprob(
+ checkRequired("token", token),
+ checkRequired("bytes", bytes).map { it.toImmutable() },
+ checkRequired("logprob", logprob),
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): TopLogprob = apply {
+ if (validated) {
+ return@apply
+ }
+
+ token()
+ bytes()
+ logprob()
+ 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)
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return /* spotless:off */ other is TopLogprob && token == other.token && bytes == other.bytes && logprob == other.logprob && additionalProperties == other.additionalProperties /* spotless:on */
+ }
+
+ /* spotless:off */
+ private val hashCode: Int by lazy { Objects.hash(token, bytes, logprob, additionalProperties) }
+ /* spotless:on */
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "TopLogprob{token=$token, bytes=$bytes, logprob=$logprob, additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return /* spotless:off */ other is Logprob && token == other.token && bytes == other.bytes && logprob == other.logprob && topLogprobs == other.topLogprobs && additionalProperties == other.additionalProperties /* spotless:on */
+ }
+
+ /* spotless:off */
+ private val hashCode: Int by lazy { Objects.hash(token, bytes, logprob, topLogprobs, additionalProperties) }
+ /* spotless:on */
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Logprob{token=$token, bytes=$bytes, logprob=$logprob, topLogprobs=$topLogprobs, additionalProperties=$additionalProperties}"
+ }
+
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
- return /* spotless:off */ other is ResponseOutputText && annotations == other.annotations && text == other.text && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */
+ return /* spotless:off */ other is ResponseOutputText && annotations == other.annotations && text == other.text && type == other.type && logprobs == other.logprobs && additionalProperties == other.additionalProperties /* spotless:on */
}
/* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(annotations, text, type, additionalProperties) }
+ private val hashCode: Int by lazy { Objects.hash(annotations, text, type, logprobs, additionalProperties) }
/* spotless:on */
override fun hashCode(): Int = hashCode
override fun toString() =
- "ResponseOutputText{annotations=$annotations, text=$text, type=$type, additionalProperties=$additionalProperties}"
+ "ResponseOutputText{annotations=$annotations, text=$text, type=$type, logprobs=$logprobs, additionalProperties=$additionalProperties}"
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseRetrieveParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseRetrieveParams.kt
index bc158949..9953401d 100644
--- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseRetrieveParams.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseRetrieveParams.kt
@@ -15,6 +15,7 @@ class ResponseRetrieveParams
private constructor(
private val responseId: String?,
private val include: List?,
+ private val startingAfter: Long?,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
) : Params {
@@ -27,6 +28,9 @@ private constructor(
*/
fun include(): Optional> = Optional.ofNullable(include)
+ /** The sequence number of the event after which to start streaming. */
+ fun startingAfter(): Optional = Optional.ofNullable(startingAfter)
+
fun _additionalHeaders(): Headers = additionalHeaders
fun _additionalQueryParams(): QueryParams = additionalQueryParams
@@ -46,6 +50,7 @@ private constructor(
private var responseId: String? = null
private var include: MutableList? = null
+ private var startingAfter: Long? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
@@ -53,6 +58,7 @@ private constructor(
internal fun from(responseRetrieveParams: ResponseRetrieveParams) = apply {
responseId = responseRetrieveParams.responseId
include = responseRetrieveParams.include?.toMutableList()
+ startingAfter = responseRetrieveParams.startingAfter
additionalHeaders = responseRetrieveParams.additionalHeaders.toBuilder()
additionalQueryParams = responseRetrieveParams.additionalQueryParams.toBuilder()
}
@@ -82,6 +88,19 @@ private constructor(
this.include = (this.include ?: mutableListOf()).apply { add(include) }
}
+ /** The sequence number of the event after which to start streaming. */
+ fun startingAfter(startingAfter: Long?) = apply { this.startingAfter = startingAfter }
+
+ /**
+ * Alias for [Builder.startingAfter].
+ *
+ * This unboxed primitive overload exists for backwards compatibility.
+ */
+ fun startingAfter(startingAfter: Long) = startingAfter(startingAfter as Long?)
+
+ /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */
+ fun startingAfter(startingAfter: Optional) = startingAfter(startingAfter.getOrNull())
+
fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
@@ -189,6 +208,7 @@ private constructor(
ResponseRetrieveParams(
responseId,
include?.toImmutable(),
+ startingAfter,
additionalHeaders.build(),
additionalQueryParams.build(),
)
@@ -206,6 +226,7 @@ private constructor(
QueryParams.builder()
.apply {
include?.forEach { put("include[]", it.toString()) }
+ startingAfter?.let { put("starting_after", it.toString()) }
putAll(additionalQueryParams)
}
.build()
@@ -215,11 +236,11 @@ private constructor(
return true
}
- return /* spotless:off */ other is ResponseRetrieveParams && responseId == other.responseId && include == other.include && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
+ return /* spotless:off */ other is ResponseRetrieveParams && responseId == other.responseId && include == other.include && startingAfter == other.startingAfter && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
}
- override fun hashCode(): Int = /* spotless:off */ Objects.hash(responseId, include, additionalHeaders, additionalQueryParams) /* spotless:on */
+ override fun hashCode(): Int = /* spotless:off */ Objects.hash(responseId, include, startingAfter, additionalHeaders, additionalQueryParams) /* spotless:on */
override fun toString() =
- "ResponseRetrieveParams{responseId=$responseId, include=$include, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
+ "ResponseRetrieveParams{responseId=$responseId, include=$include, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsync.kt
index 84bc4043..cfe253af 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/BatchServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.batches.Batch
@@ -123,12 +122,10 @@ interface BatchServiceAsync {
* Returns a raw HTTP response for `post /batches`, but is otherwise the same as
* [BatchServiceAsync.create].
*/
- @MustBeClosed
fun create(params: BatchCreateParams): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: BatchCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -138,12 +135,10 @@ interface BatchServiceAsync {
* Returns a raw HTTP response for `get /batches/{batch_id}`, but is otherwise the same as
* [BatchServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(batchId: String): CompletableFuture> =
retrieve(batchId, BatchRetrieveParams.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
batchId: String,
params: BatchRetrieveParams = BatchRetrieveParams.none(),
@@ -152,7 +147,6 @@ interface BatchServiceAsync {
retrieve(params.toBuilder().batchId(batchId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
batchId: String,
params: BatchRetrieveParams = BatchRetrieveParams.none(),
@@ -160,19 +154,16 @@ interface BatchServiceAsync {
retrieve(batchId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: BatchRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(params: BatchRetrieveParams): CompletableFuture> =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
batchId: String,
requestOptions: RequestOptions,
@@ -183,26 +174,22 @@ interface BatchServiceAsync {
* Returns a raw HTTP response for `get /batches`, but is otherwise the same as
* [BatchServiceAsync.list].
*/
- @MustBeClosed
fun list(): CompletableFuture> =
list(BatchListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: BatchListParams = BatchListParams.none(),
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(
params: BatchListParams = BatchListParams.none()
): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
requestOptions: RequestOptions
): CompletableFuture> =
@@ -212,12 +199,10 @@ interface BatchServiceAsync {
* Returns a raw HTTP response for `post /batches/{batch_id}/cancel`, but is otherwise the
* same as [BatchServiceAsync.cancel].
*/
- @MustBeClosed
fun cancel(batchId: String): CompletableFuture> =
cancel(batchId, BatchCancelParams.none())
/** @see [cancel] */
- @MustBeClosed
fun cancel(
batchId: String,
params: BatchCancelParams = BatchCancelParams.none(),
@@ -226,7 +211,6 @@ interface BatchServiceAsync {
cancel(params.toBuilder().batchId(batchId).build(), requestOptions)
/** @see [cancel] */
- @MustBeClosed
fun cancel(
batchId: String,
params: BatchCancelParams = BatchCancelParams.none(),
@@ -234,19 +218,16 @@ interface BatchServiceAsync {
cancel(batchId, params, RequestOptions.none())
/** @see [cancel] */
- @MustBeClosed
fun cancel(
params: BatchCancelParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [cancel] */
- @MustBeClosed
fun cancel(params: BatchCancelParams): CompletableFuture> =
cancel(params, RequestOptions.none())
/** @see [cancel] */
- @MustBeClosed
fun cancel(
batchId: String,
requestOptions: RequestOptions,
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsync.kt
index a0ba3aa9..30b3eba1 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/CompletionServiceAsync.kt
@@ -48,12 +48,10 @@ interface CompletionServiceAsync {
* Returns a raw HTTP response for `post /completions`, but is otherwise the same as
* [CompletionServiceAsync.create].
*/
- @MustBeClosed
fun create(params: CompletionCreateParams): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: CompletionCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsync.kt
index 3460fb8b..f4ba5ccb 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ContainerServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponse
import com.openai.core.http.HttpResponseFor
@@ -132,14 +131,12 @@ interface ContainerServiceAsync {
* Returns a raw HTTP response for `post /containers`, but is otherwise the same as
* [ContainerServiceAsync.create].
*/
- @MustBeClosed
fun create(
params: ContainerCreateParams
): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: ContainerCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -149,14 +146,12 @@ interface ContainerServiceAsync {
* Returns a raw HTTP response for `get /containers/{container_id}`, but is otherwise the
* same as [ContainerServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(
containerId: String
): CompletableFuture> =
retrieve(containerId, ContainerRetrieveParams.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
containerId: String,
params: ContainerRetrieveParams = ContainerRetrieveParams.none(),
@@ -165,7 +160,6 @@ interface ContainerServiceAsync {
retrieve(params.toBuilder().containerId(containerId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
containerId: String,
params: ContainerRetrieveParams = ContainerRetrieveParams.none(),
@@ -173,21 +167,18 @@ interface ContainerServiceAsync {
retrieve(containerId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: ContainerRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: ContainerRetrieveParams
): CompletableFuture> =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
containerId: String,
requestOptions: RequestOptions,
@@ -198,26 +189,22 @@ interface ContainerServiceAsync {
* Returns a raw HTTP response for `get /containers`, but is otherwise the same as
* [ContainerServiceAsync.list].
*/
- @MustBeClosed
fun list(): CompletableFuture> =
list(ContainerListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: ContainerListParams = ContainerListParams.none(),
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(
params: ContainerListParams = ContainerListParams.none()
): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
requestOptions: RequestOptions
): CompletableFuture> =
@@ -227,12 +214,10 @@ interface ContainerServiceAsync {
* Returns a raw HTTP response for `delete /containers/{container_id}`, but is otherwise the
* same as [ContainerServiceAsync.delete].
*/
- @MustBeClosed
fun delete(containerId: String): CompletableFuture =
delete(containerId, ContainerDeleteParams.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
containerId: String,
params: ContainerDeleteParams = ContainerDeleteParams.none(),
@@ -241,26 +226,22 @@ interface ContainerServiceAsync {
delete(params.toBuilder().containerId(containerId).build(), requestOptions)
/** @see [delete] */
- @MustBeClosed
fun delete(
containerId: String,
params: ContainerDeleteParams = ContainerDeleteParams.none(),
): CompletableFuture = delete(containerId, params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
params: ContainerDeleteParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture
/** @see [delete] */
- @MustBeClosed
fun delete(params: ContainerDeleteParams): CompletableFuture =
delete(params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
containerId: String,
requestOptions: RequestOptions,
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsync.kt
index 1186a656..94582f88 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/EmbeddingServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.embeddings.CreateEmbeddingResponse
@@ -35,14 +34,12 @@ interface EmbeddingServiceAsync {
* Returns a raw HTTP response for `post /embeddings`, but is otherwise the same as
* [EmbeddingServiceAsync.create].
*/
- @MustBeClosed
fun create(
params: EmbeddingCreateParams
): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: EmbeddingCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsync.kt
index 503416d5..7ca10a5e 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/EvalServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.evals.EvalCreateParams
@@ -174,14 +173,12 @@ interface EvalServiceAsync {
* Returns a raw HTTP response for `post /evals`, but is otherwise the same as
* [EvalServiceAsync.create].
*/
- @MustBeClosed
fun create(
params: EvalCreateParams
): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: EvalCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -191,12 +188,10 @@ interface EvalServiceAsync {
* Returns a raw HTTP response for `get /evals/{eval_id}`, but is otherwise the same as
* [EvalServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(evalId: String): CompletableFuture> =
retrieve(evalId, EvalRetrieveParams.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
evalId: String,
params: EvalRetrieveParams = EvalRetrieveParams.none(),
@@ -205,7 +200,6 @@ interface EvalServiceAsync {
retrieve(params.toBuilder().evalId(evalId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
evalId: String,
params: EvalRetrieveParams = EvalRetrieveParams.none(),
@@ -213,21 +207,18 @@ interface EvalServiceAsync {
retrieve(evalId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: EvalRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: EvalRetrieveParams
): CompletableFuture> =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
evalId: String,
requestOptions: RequestOptions,
@@ -238,12 +229,10 @@ interface EvalServiceAsync {
* Returns a raw HTTP response for `post /evals/{eval_id}`, but is otherwise the same as
* [EvalServiceAsync.update].
*/
- @MustBeClosed
fun update(evalId: String): CompletableFuture> =
update(evalId, EvalUpdateParams.none())
/** @see [update] */
- @MustBeClosed
fun update(
evalId: String,
params: EvalUpdateParams = EvalUpdateParams.none(),
@@ -252,7 +241,6 @@ interface EvalServiceAsync {
update(params.toBuilder().evalId(evalId).build(), requestOptions)
/** @see [update] */
- @MustBeClosed
fun update(
evalId: String,
params: EvalUpdateParams = EvalUpdateParams.none(),
@@ -260,21 +248,18 @@ interface EvalServiceAsync {
update(evalId, params, RequestOptions.none())
/** @see [update] */
- @MustBeClosed
fun update(
params: EvalUpdateParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [update] */
- @MustBeClosed
fun update(
params: EvalUpdateParams
): CompletableFuture> =
update(params, RequestOptions.none())
/** @see [update] */
- @MustBeClosed
fun update(
evalId: String,
requestOptions: RequestOptions,
@@ -285,26 +270,22 @@ interface EvalServiceAsync {
* Returns a raw HTTP response for `get /evals`, but is otherwise the same as
* [EvalServiceAsync.list].
*/
- @MustBeClosed
fun list(): CompletableFuture> =
list(EvalListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: EvalListParams = EvalListParams.none(),
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(
params: EvalListParams = EvalListParams.none()
): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
requestOptions: RequestOptions
): CompletableFuture> =
@@ -314,12 +295,10 @@ interface EvalServiceAsync {
* Returns a raw HTTP response for `delete /evals/{eval_id}`, but is otherwise the same as
* [EvalServiceAsync.delete].
*/
- @MustBeClosed
fun delete(evalId: String): CompletableFuture> =
delete(evalId, EvalDeleteParams.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
evalId: String,
params: EvalDeleteParams = EvalDeleteParams.none(),
@@ -328,7 +307,6 @@ interface EvalServiceAsync {
delete(params.toBuilder().evalId(evalId).build(), requestOptions)
/** @see [delete] */
- @MustBeClosed
fun delete(
evalId: String,
params: EvalDeleteParams = EvalDeleteParams.none(),
@@ -336,21 +314,18 @@ interface EvalServiceAsync {
delete(evalId, params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
params: EvalDeleteParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [delete] */
- @MustBeClosed
fun delete(
params: EvalDeleteParams
): CompletableFuture> =
delete(params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
evalId: String,
requestOptions: RequestOptions,
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt
index 6cc13c80..7a871e76 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/FileServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponse
import com.openai.core.http.HttpResponseFor
@@ -133,12 +132,10 @@ interface FileServiceAsync {
delete(fileId, FileDeleteParams.none(), requestOptions)
/** Returns the contents of the specified file. */
- @MustBeClosed
fun content(fileId: String): CompletableFuture =
content(fileId, FileContentParams.none())
/** @see [content] */
- @MustBeClosed
fun content(
fileId: String,
params: FileContentParams = FileContentParams.none(),
@@ -147,26 +144,22 @@ interface FileServiceAsync {
content(params.toBuilder().fileId(fileId).build(), requestOptions)
/** @see [content] */
- @MustBeClosed
fun content(
fileId: String,
params: FileContentParams = FileContentParams.none(),
): CompletableFuture = content(fileId, params, RequestOptions.none())
/** @see [content] */
- @MustBeClosed
fun content(
params: FileContentParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture
/** @see [content] */
- @MustBeClosed
fun content(params: FileContentParams): CompletableFuture =
content(params, RequestOptions.none())
/** @see [content] */
- @MustBeClosed
fun content(fileId: String, requestOptions: RequestOptions): CompletableFuture =
content(fileId, FileContentParams.none(), requestOptions)
@@ -177,12 +170,10 @@ interface FileServiceAsync {
* Returns a raw HTTP response for `post /files`, but is otherwise the same as
* [FileServiceAsync.create].
*/
- @MustBeClosed
fun create(params: FileCreateParams): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: FileCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -192,12 +183,10 @@ interface FileServiceAsync {
* Returns a raw HTTP response for `get /files/{file_id}`, but is otherwise the same as
* [FileServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(fileId: String): CompletableFuture> =
retrieve(fileId, FileRetrieveParams.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
fileId: String,
params: FileRetrieveParams = FileRetrieveParams.none(),
@@ -206,7 +195,6 @@ interface FileServiceAsync {
retrieve(params.toBuilder().fileId(fileId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
fileId: String,
params: FileRetrieveParams = FileRetrieveParams.none(),
@@ -214,19 +202,16 @@ interface FileServiceAsync {
retrieve(fileId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: FileRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(params: FileRetrieveParams): CompletableFuture> =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
fileId: String,
requestOptions: RequestOptions,
@@ -237,26 +222,22 @@ interface FileServiceAsync {
* Returns a raw HTTP response for `get /files`, but is otherwise the same as
* [FileServiceAsync.list].
*/
- @MustBeClosed
fun list(): CompletableFuture> =
list(FileListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: FileListParams = FileListParams.none(),
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(
params: FileListParams = FileListParams.none()
): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
requestOptions: RequestOptions
): CompletableFuture> =
@@ -266,12 +247,10 @@ interface FileServiceAsync {
* Returns a raw HTTP response for `delete /files/{file_id}`, but is otherwise the same as
* [FileServiceAsync.delete].
*/
- @MustBeClosed
fun delete(fileId: String): CompletableFuture> =
delete(fileId, FileDeleteParams.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
fileId: String,
params: FileDeleteParams = FileDeleteParams.none(),
@@ -280,7 +259,6 @@ interface FileServiceAsync {
delete(params.toBuilder().fileId(fileId).build(), requestOptions)
/** @see [delete] */
- @MustBeClosed
fun delete(
fileId: String,
params: FileDeleteParams = FileDeleteParams.none(),
@@ -288,19 +266,16 @@ interface FileServiceAsync {
delete(fileId, params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
params: FileDeleteParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [delete] */
- @MustBeClosed
fun delete(params: FileDeleteParams): CompletableFuture> =
delete(params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
fileId: String,
requestOptions: RequestOptions,
@@ -311,12 +286,10 @@ interface FileServiceAsync {
* Returns a raw HTTP response for `get /files/{file_id}/content`, but is otherwise the same
* as [FileServiceAsync.content].
*/
- @MustBeClosed
fun content(fileId: String): CompletableFuture =
content(fileId, FileContentParams.none())
/** @see [content] */
- @MustBeClosed
fun content(
fileId: String,
params: FileContentParams = FileContentParams.none(),
@@ -325,26 +298,22 @@ interface FileServiceAsync {
content(params.toBuilder().fileId(fileId).build(), requestOptions)
/** @see [content] */
- @MustBeClosed
fun content(
fileId: String,
params: FileContentParams = FileContentParams.none(),
): CompletableFuture = content(fileId, params, RequestOptions.none())
/** @see [content] */
- @MustBeClosed
fun content(
params: FileContentParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture
/** @see [content] */
- @MustBeClosed
fun content(params: FileContentParams): CompletableFuture =
content(params, RequestOptions.none())
/** @see [content] */
- @MustBeClosed
fun content(
fileId: String,
requestOptions: RequestOptions,
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsync.kt
index 0494197b..e1a9975f 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.images.ImageCreateVariationParams
@@ -61,14 +60,12 @@ interface ImageServiceAsync {
* Returns a raw HTTP response for `post /images/variations`, but is otherwise the same as
* [ImageServiceAsync.createVariation].
*/
- @MustBeClosed
fun createVariation(
params: ImageCreateVariationParams
): CompletableFuture> =
createVariation(params, RequestOptions.none())
/** @see [createVariation] */
- @MustBeClosed
fun createVariation(
params: ImageCreateVariationParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -78,12 +75,10 @@ interface ImageServiceAsync {
* Returns a raw HTTP response for `post /images/edits`, but is otherwise the same as
* [ImageServiceAsync.edit].
*/
- @MustBeClosed
fun edit(params: ImageEditParams): CompletableFuture> =
edit(params, RequestOptions.none())
/** @see [edit] */
- @MustBeClosed
fun edit(
params: ImageEditParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -93,14 +88,12 @@ interface ImageServiceAsync {
* Returns a raw HTTP response for `post /images/generations`, but is otherwise the same as
* [ImageServiceAsync.generate].
*/
- @MustBeClosed
fun generate(
params: ImageGenerateParams
): CompletableFuture> =
generate(params, RequestOptions.none())
/** @see [generate] */
- @MustBeClosed
fun generate(
params: ImageGenerateParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt
index 744386c3..15108ece 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ImageServiceAsyncImpl.kt
@@ -138,7 +138,11 @@ class ImageServiceAsyncImpl internal constructor(private val clientOptions: Clie
.addPathSegments("images", "generations")
.body(json(clientOptions.jsonMapper, params._body()))
.build()
- .prepareAsync(clientOptions, params, params.model().toString())
+ .prepareAsync(
+ clientOptions,
+ params,
+ deploymentModel = params.model().map { it.toString() }.orElse(null),
+ )
val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsync.kt
index 993f48db..cc9d0a0c 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ModelServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.models.Model
@@ -117,12 +116,10 @@ interface ModelServiceAsync {
* Returns a raw HTTP response for `get /models/{model}`, but is otherwise the same as
* [ModelServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(model: String): CompletableFuture> =
retrieve(model, ModelRetrieveParams.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
model: String,
params: ModelRetrieveParams = ModelRetrieveParams.none(),
@@ -131,7 +128,6 @@ interface ModelServiceAsync {
retrieve(params.toBuilder().model(model).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
model: String,
params: ModelRetrieveParams = ModelRetrieveParams.none(),
@@ -139,19 +135,16 @@ interface ModelServiceAsync {
retrieve(model, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: ModelRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(params: ModelRetrieveParams): CompletableFuture> =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
model: String,
requestOptions: RequestOptions,
@@ -162,26 +155,22 @@ interface ModelServiceAsync {
* Returns a raw HTTP response for `get /models`, but is otherwise the same as
* [ModelServiceAsync.list].
*/
- @MustBeClosed
fun list(): CompletableFuture> =
list(ModelListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: ModelListParams = ModelListParams.none(),
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(
params: ModelListParams = ModelListParams.none()
): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
requestOptions: RequestOptions
): CompletableFuture> =
@@ -191,12 +180,10 @@ interface ModelServiceAsync {
* Returns a raw HTTP response for `delete /models/{model}`, but is otherwise the same as
* [ModelServiceAsync.delete].
*/
- @MustBeClosed
fun delete(model: String): CompletableFuture> =
delete(model, ModelDeleteParams.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
model: String,
params: ModelDeleteParams = ModelDeleteParams.none(),
@@ -205,7 +192,6 @@ interface ModelServiceAsync {
delete(params.toBuilder().model(model).build(), requestOptions)
/** @see [delete] */
- @MustBeClosed
fun delete(
model: String,
params: ModelDeleteParams = ModelDeleteParams.none(),
@@ -213,19 +199,16 @@ interface ModelServiceAsync {
delete(model, params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
params: ModelDeleteParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [delete] */
- @MustBeClosed
fun delete(params: ModelDeleteParams): CompletableFuture> =
delete(params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
model: String,
requestOptions: RequestOptions,
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsync.kt
index 901ed8ce..0d598ccf 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ModerationServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.moderations.ModerationCreateParams
@@ -39,14 +38,12 @@ interface ModerationServiceAsync {
* Returns a raw HTTP response for `post /moderations`, but is otherwise the same as
* [ModerationServiceAsync.create].
*/
- @MustBeClosed
fun create(
params: ModerationCreateParams
): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: ModerationCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt
index f7a4a281..e4570c57 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsync.kt
@@ -98,6 +98,43 @@ interface ResponseServiceAsync {
fun retrieve(responseId: String, requestOptions: RequestOptions): CompletableFuture =
retrieve(responseId, ResponseRetrieveParams.none(), requestOptions)
+ /** Retrieves a model response with the given ID. */
+ fun retrieveStreaming(responseId: String): AsyncStreamResponse =
+ retrieveStreaming(responseId, ResponseRetrieveParams.none())
+
+ /** @see [retrieveStreaming] */
+ fun retrieveStreaming(
+ responseId: String,
+ params: ResponseRetrieveParams = ResponseRetrieveParams.none(),
+ requestOptions: RequestOptions = RequestOptions.none(),
+ ): AsyncStreamResponse =
+ retrieveStreaming(params.toBuilder().responseId(responseId).build(), requestOptions)
+
+ /** @see [retrieveStreaming] */
+ fun retrieveStreaming(
+ responseId: String,
+ params: ResponseRetrieveParams = ResponseRetrieveParams.none(),
+ ): AsyncStreamResponse =
+ retrieveStreaming(responseId, params, RequestOptions.none())
+
+ /** @see [retrieveStreaming] */
+ fun retrieveStreaming(
+ params: ResponseRetrieveParams,
+ requestOptions: RequestOptions = RequestOptions.none(),
+ ): AsyncStreamResponse
+
+ /** @see [retrieveStreaming] */
+ fun retrieveStreaming(
+ params: ResponseRetrieveParams
+ ): AsyncStreamResponse = retrieveStreaming(params, RequestOptions.none())
+
+ /** @see [retrieveStreaming] */
+ fun retrieveStreaming(
+ responseId: String,
+ requestOptions: RequestOptions,
+ ): AsyncStreamResponse =
+ retrieveStreaming(responseId, ResponseRetrieveParams.none(), requestOptions)
+
/** Deletes a model response with the given ID. */
fun delete(responseId: String): CompletableFuture =
delete(responseId, ResponseDeleteParams.none())
@@ -177,12 +214,10 @@ interface ResponseServiceAsync {
* Returns a raw HTTP response for `post /responses`, but is otherwise the same as
* [ResponseServiceAsync.create].
*/
- @MustBeClosed
fun create(params: ResponseCreateParams): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: ResponseCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -209,12 +244,10 @@ interface ResponseServiceAsync {
* Returns a raw HTTP response for `get /responses/{response_id}`, but is otherwise the same
* as [ResponseServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(responseId: String): CompletableFuture> =
retrieve(responseId, ResponseRetrieveParams.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
responseId: String,
params: ResponseRetrieveParams = ResponseRetrieveParams.none(),
@@ -223,7 +256,6 @@ interface ResponseServiceAsync {
retrieve(params.toBuilder().responseId(responseId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
responseId: String,
params: ResponseRetrieveParams = ResponseRetrieveParams.none(),
@@ -231,35 +263,79 @@ interface ResponseServiceAsync {
retrieve(responseId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: ResponseRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(params: ResponseRetrieveParams): CompletableFuture> =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
responseId: String,
requestOptions: RequestOptions,
): CompletableFuture> =
retrieve(responseId, ResponseRetrieveParams.none(), requestOptions)
+ /**
+ * Returns a raw HTTP response for `get /responses/{response_id}`, but is otherwise the same
+ * as [ResponseServiceAsync.retrieveStreaming].
+ */
+ @MustBeClosed
+ fun retrieveStreaming(
+ responseId: String
+ ): CompletableFuture>> =
+ retrieveStreaming(responseId, ResponseRetrieveParams.none())
+
+ /** @see [retrieveStreaming] */
+ @MustBeClosed
+ fun retrieveStreaming(
+ responseId: String,
+ params: ResponseRetrieveParams = ResponseRetrieveParams.none(),
+ requestOptions: RequestOptions = RequestOptions.none(),
+ ): CompletableFuture>> =
+ retrieveStreaming(params.toBuilder().responseId(responseId).build(), requestOptions)
+
+ /** @see [retrieveStreaming] */
+ @MustBeClosed
+ fun retrieveStreaming(
+ responseId: String,
+ params: ResponseRetrieveParams = ResponseRetrieveParams.none(),
+ ): CompletableFuture>> =
+ retrieveStreaming(responseId, params, RequestOptions.none())
+
+ /** @see [retrieveStreaming] */
+ @MustBeClosed
+ fun retrieveStreaming(
+ params: ResponseRetrieveParams,
+ requestOptions: RequestOptions = RequestOptions.none(),
+ ): CompletableFuture>>
+
+ /** @see [retrieveStreaming] */
+ @MustBeClosed
+ fun retrieveStreaming(
+ params: ResponseRetrieveParams
+ ): CompletableFuture>> =
+ retrieveStreaming(params, RequestOptions.none())
+
+ /** @see [retrieveStreaming] */
+ @MustBeClosed
+ fun retrieveStreaming(
+ responseId: String,
+ requestOptions: RequestOptions,
+ ): CompletableFuture>> =
+ retrieveStreaming(responseId, ResponseRetrieveParams.none(), requestOptions)
+
/**
* Returns a raw HTTP response for `delete /responses/{response_id}`, but is otherwise the
* same as [ResponseServiceAsync.delete].
*/
- @MustBeClosed
fun delete(responseId: String): CompletableFuture =
delete(responseId, ResponseDeleteParams.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
responseId: String,
params: ResponseDeleteParams = ResponseDeleteParams.none(),
@@ -268,26 +344,22 @@ interface ResponseServiceAsync {
delete(params.toBuilder().responseId(responseId).build(), requestOptions)
/** @see [delete] */
- @MustBeClosed
fun delete(
responseId: String,
params: ResponseDeleteParams = ResponseDeleteParams.none(),
): CompletableFuture = delete(responseId, params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
params: ResponseDeleteParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture
/** @see [delete] */
- @MustBeClosed
fun delete(params: ResponseDeleteParams): CompletableFuture =
delete(params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
responseId: String,
requestOptions: RequestOptions,
@@ -298,12 +370,10 @@ interface ResponseServiceAsync {
* Returns a raw HTTP response for `post /responses/{response_id}/cancel`, but is otherwise
* the same as [ResponseServiceAsync.cancel].
*/
- @MustBeClosed
fun cancel(responseId: String): CompletableFuture =
cancel(responseId, ResponseCancelParams.none())
/** @see [cancel] */
- @MustBeClosed
fun cancel(
responseId: String,
params: ResponseCancelParams = ResponseCancelParams.none(),
@@ -312,26 +382,22 @@ interface ResponseServiceAsync {
cancel(params.toBuilder().responseId(responseId).build(), requestOptions)
/** @see [cancel] */
- @MustBeClosed
fun cancel(
responseId: String,
params: ResponseCancelParams = ResponseCancelParams.none(),
): CompletableFuture = cancel(responseId, params, RequestOptions.none())
/** @see [cancel] */
- @MustBeClosed
fun cancel(
params: ResponseCancelParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture
/** @see [cancel] */
- @MustBeClosed
fun cancel(params: ResponseCancelParams): CompletableFuture =
cancel(params, RequestOptions.none())
/** @see [cancel] */
- @MustBeClosed
fun cancel(
responseId: String,
requestOptions: RequestOptions,
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt
index e767ed3f..1dd9a1f2 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/ResponseServiceAsyncImpl.kt
@@ -75,6 +75,16 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C
// get /responses/{response_id}
withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() }
+ override fun retrieveStreaming(
+ params: ResponseRetrieveParams,
+ requestOptions: RequestOptions,
+ ): AsyncStreamResponse =
+ // get /responses/{response_id}
+ withRawResponse()
+ .retrieveStreaming(params, requestOptions)
+ .thenApply { it.parse() }
+ .toAsync(clientOptions.streamHandlerExecutor)
+
override fun delete(
params: ResponseDeleteParams,
requestOptions: RequestOptions,
@@ -205,6 +215,43 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C
}
}
+ private val retrieveStreamingHandler: Handler> =
+ sseHandler(clientOptions.jsonMapper)
+ .mapJson()
+ .withErrorHandler(errorHandler)
+
+ override fun retrieveStreaming(
+ params: ResponseRetrieveParams,
+ requestOptions: RequestOptions,
+ ): CompletableFuture>> {
+ // We check here instead of in the params builder because this can be specified
+ // positionally or in the params class.
+ checkRequired("responseId", params.responseId().getOrNull())
+ val request =
+ HttpRequest.builder()
+ .method(HttpMethod.GET)
+ .addPathSegments("responses", params._pathParam(0))
+ .putQueryParam("stream", "true")
+ .build()
+ .prepareAsync(clientOptions, params, deploymentModel = null)
+ val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))
+ return request
+ .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
+ .thenApply { response ->
+ response.parseable {
+ response
+ .let { retrieveStreamingHandler.handle(it) }
+ .let { streamResponse ->
+ if (requestOptions.responseValidation!!) {
+ streamResponse.map { it.validate() }
+ } else {
+ streamResponse
+ }
+ }
+ }
+ }
+ }
+
private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler)
override fun delete(
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsync.kt
index 98218ac5..fb500d7f 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/UploadServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.uploads.Upload
@@ -127,12 +126,10 @@ interface UploadServiceAsync {
* Returns a raw HTTP response for `post /uploads`, but is otherwise the same as
* [UploadServiceAsync.create].
*/
- @MustBeClosed
fun create(params: UploadCreateParams): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: UploadCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -142,12 +139,10 @@ interface UploadServiceAsync {
* Returns a raw HTTP response for `post /uploads/{upload_id}/cancel`, but is otherwise the
* same as [UploadServiceAsync.cancel].
*/
- @MustBeClosed
fun cancel(uploadId: String): CompletableFuture> =
cancel(uploadId, UploadCancelParams.none())
/** @see [cancel] */
- @MustBeClosed
fun cancel(
uploadId: String,
params: UploadCancelParams = UploadCancelParams.none(),
@@ -156,7 +151,6 @@ interface UploadServiceAsync {
cancel(params.toBuilder().uploadId(uploadId).build(), requestOptions)
/** @see [cancel] */
- @MustBeClosed
fun cancel(
uploadId: String,
params: UploadCancelParams = UploadCancelParams.none(),
@@ -164,19 +158,16 @@ interface UploadServiceAsync {
cancel(uploadId, params, RequestOptions.none())
/** @see [cancel] */
- @MustBeClosed
fun cancel(
params: UploadCancelParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [cancel] */
- @MustBeClosed
fun cancel(params: UploadCancelParams): CompletableFuture> =
cancel(params, RequestOptions.none())
/** @see [cancel] */
- @MustBeClosed
fun cancel(
uploadId: String,
requestOptions: RequestOptions,
@@ -187,7 +178,6 @@ interface UploadServiceAsync {
* Returns a raw HTTP response for `post /uploads/{upload_id}/complete`, but is otherwise
* the same as [UploadServiceAsync.complete].
*/
- @MustBeClosed
fun complete(
uploadId: String,
params: UploadCompleteParams,
@@ -195,7 +185,6 @@ interface UploadServiceAsync {
complete(uploadId, params, RequestOptions.none())
/** @see [complete] */
- @MustBeClosed
fun complete(
uploadId: String,
params: UploadCompleteParams,
@@ -204,12 +193,10 @@ interface UploadServiceAsync {
complete(params.toBuilder().uploadId(uploadId).build(), requestOptions)
/** @see [complete] */
- @MustBeClosed
fun complete(params: UploadCompleteParams): CompletableFuture> =
complete(params, RequestOptions.none())
/** @see [complete] */
- @MustBeClosed
fun complete(
params: UploadCompleteParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsync.kt
index ff07354c..c6584162 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/VectorStoreServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.vectorstores.VectorStore
@@ -210,25 +209,21 @@ interface VectorStoreServiceAsync {
* Returns a raw HTTP response for `post /vector_stores`, but is otherwise the same as
* [VectorStoreServiceAsync.create].
*/
- @MustBeClosed
fun create(): CompletableFuture> =
create(VectorStoreCreateParams.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: VectorStoreCreateParams = VectorStoreCreateParams.none(),
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [create] */
- @MustBeClosed
fun create(
params: VectorStoreCreateParams = VectorStoreCreateParams.none()
): CompletableFuture> = create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
requestOptions: RequestOptions
): CompletableFuture> =
@@ -238,12 +233,10 @@ interface VectorStoreServiceAsync {
* Returns a raw HTTP response for `get /vector_stores/{vector_store_id}`, but is otherwise
* the same as [VectorStoreServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(vectorStoreId: String): CompletableFuture> =
retrieve(vectorStoreId, VectorStoreRetrieveParams.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
vectorStoreId: String,
params: VectorStoreRetrieveParams = VectorStoreRetrieveParams.none(),
@@ -252,7 +245,6 @@ interface VectorStoreServiceAsync {
retrieve(params.toBuilder().vectorStoreId(vectorStoreId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
vectorStoreId: String,
params: VectorStoreRetrieveParams = VectorStoreRetrieveParams.none(),
@@ -260,20 +252,17 @@ interface VectorStoreServiceAsync {
retrieve(vectorStoreId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: VectorStoreRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: VectorStoreRetrieveParams
): CompletableFuture> = retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
vectorStoreId: String,
requestOptions: RequestOptions,
@@ -284,12 +273,10 @@ interface VectorStoreServiceAsync {
* Returns a raw HTTP response for `post /vector_stores/{vector_store_id}`, but is otherwise
* the same as [VectorStoreServiceAsync.update].
*/
- @MustBeClosed
fun update(vectorStoreId: String): CompletableFuture> =
update(vectorStoreId, VectorStoreUpdateParams.none())
/** @see [update] */
- @MustBeClosed
fun update(
vectorStoreId: String,
params: VectorStoreUpdateParams = VectorStoreUpdateParams.none(),
@@ -298,7 +285,6 @@ interface VectorStoreServiceAsync {
update(params.toBuilder().vectorStoreId(vectorStoreId).build(), requestOptions)
/** @see [update] */
- @MustBeClosed
fun update(
vectorStoreId: String,
params: VectorStoreUpdateParams = VectorStoreUpdateParams.none(),
@@ -306,20 +292,17 @@ interface VectorStoreServiceAsync {
update(vectorStoreId, params, RequestOptions.none())
/** @see [update] */
- @MustBeClosed
fun update(
params: VectorStoreUpdateParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [update] */
- @MustBeClosed
fun update(
params: VectorStoreUpdateParams
): CompletableFuture> = update(params, RequestOptions.none())
/** @see [update] */
- @MustBeClosed
fun update(
vectorStoreId: String,
requestOptions: RequestOptions,
@@ -330,26 +313,22 @@ interface VectorStoreServiceAsync {
* Returns a raw HTTP response for `get /vector_stores`, but is otherwise the same as
* [VectorStoreServiceAsync.list].
*/
- @MustBeClosed
fun list(): CompletableFuture> =
list(VectorStoreListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: VectorStoreListParams = VectorStoreListParams.none(),
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(
params: VectorStoreListParams = VectorStoreListParams.none()
): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
requestOptions: RequestOptions
): CompletableFuture> =
@@ -359,12 +338,10 @@ interface VectorStoreServiceAsync {
* Returns a raw HTTP response for `delete /vector_stores/{vector_store_id}`, but is
* otherwise the same as [VectorStoreServiceAsync.delete].
*/
- @MustBeClosed
fun delete(vectorStoreId: String): CompletableFuture> =
delete(vectorStoreId, VectorStoreDeleteParams.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
vectorStoreId: String,
params: VectorStoreDeleteParams = VectorStoreDeleteParams.none(),
@@ -373,7 +350,6 @@ interface VectorStoreServiceAsync {
delete(params.toBuilder().vectorStoreId(vectorStoreId).build(), requestOptions)
/** @see [delete] */
- @MustBeClosed
fun delete(
vectorStoreId: String,
params: VectorStoreDeleteParams = VectorStoreDeleteParams.none(),
@@ -381,21 +357,18 @@ interface VectorStoreServiceAsync {
delete(vectorStoreId, params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
params: VectorStoreDeleteParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [delete] */
- @MustBeClosed
fun delete(
params: VectorStoreDeleteParams
): CompletableFuture> =
delete(params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
vectorStoreId: String,
requestOptions: RequestOptions,
@@ -406,7 +379,6 @@ interface VectorStoreServiceAsync {
* Returns a raw HTTP response for `post /vector_stores/{vector_store_id}/search`, but is
* otherwise the same as [VectorStoreServiceAsync.search].
*/
- @MustBeClosed
fun search(
vectorStoreId: String,
params: VectorStoreSearchParams,
@@ -414,7 +386,6 @@ interface VectorStoreServiceAsync {
search(vectorStoreId, params, RequestOptions.none())
/** @see [search] */
- @MustBeClosed
fun search(
vectorStoreId: String,
params: VectorStoreSearchParams,
@@ -423,14 +394,12 @@ interface VectorStoreServiceAsync {
search(params.toBuilder().vectorStoreId(vectorStoreId).build(), requestOptions)
/** @see [search] */
- @MustBeClosed
fun search(
params: VectorStoreSearchParams
): CompletableFuture> =
search(params, RequestOptions.none())
/** @see [search] */
- @MustBeClosed
fun search(
params: VectorStoreSearchParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsync.kt
index 95e2744d..8a2ab2ae 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/SpeechServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async.audio
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponse
import com.openai.models.audio.speech.SpeechCreateParams
@@ -16,12 +15,10 @@ interface SpeechServiceAsync {
fun withRawResponse(): WithRawResponse
/** Generates audio from the input text. */
- @MustBeClosed
fun create(params: SpeechCreateParams): CompletableFuture =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: SpeechCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -36,12 +33,10 @@ interface SpeechServiceAsync {
* Returns a raw HTTP response for `post /audio/speech`, but is otherwise the same as
* [SpeechServiceAsync.create].
*/
- @MustBeClosed
fun create(params: SpeechCreateParams): CompletableFuture =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: SpeechCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsync.kt
index 377a6f85..0a39d98f 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranscriptionServiceAsync.kt
@@ -51,14 +51,12 @@ interface TranscriptionServiceAsync {
* Returns a raw HTTP response for `post /audio/transcriptions`, but is otherwise the same
* as [TranscriptionServiceAsync.create].
*/
- @MustBeClosed
fun create(
params: TranscriptionCreateParams
): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: TranscriptionCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsync.kt
index c4528a0b..8685bf75 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/audio/TranslationServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async.audio
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.audio.translations.TranslationCreateParams
@@ -36,14 +35,12 @@ interface TranslationServiceAsync {
* Returns a raw HTTP response for `post /audio/translations`, but is otherwise the same as
* [TranslationServiceAsync.create].
*/
- @MustBeClosed
fun create(
params: TranslationCreateParams
): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: TranslationCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt
index 2890cb31..3df83562 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/ChatCompletionServiceAsync.kt
@@ -222,14 +222,12 @@ interface ChatCompletionServiceAsync {
* Returns a raw HTTP response for `post /chat/completions`, but is otherwise the same as
* [ChatCompletionServiceAsync.create].
*/
- @MustBeClosed
fun create(
params: ChatCompletionCreateParams
): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: ChatCompletionCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -256,12 +254,10 @@ interface ChatCompletionServiceAsync {
* Returns a raw HTTP response for `get /chat/completions/{completion_id}`, but is otherwise
* the same as [ChatCompletionServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(completionId: String): CompletableFuture> =
retrieve(completionId, ChatCompletionRetrieveParams.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
completionId: String,
params: ChatCompletionRetrieveParams = ChatCompletionRetrieveParams.none(),
@@ -270,7 +266,6 @@ interface ChatCompletionServiceAsync {
retrieve(params.toBuilder().completionId(completionId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
completionId: String,
params: ChatCompletionRetrieveParams = ChatCompletionRetrieveParams.none(),
@@ -278,21 +273,18 @@ interface ChatCompletionServiceAsync {
retrieve(completionId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: ChatCompletionRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: ChatCompletionRetrieveParams
): CompletableFuture> =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
completionId: String,
requestOptions: RequestOptions,
@@ -303,7 +295,6 @@ interface ChatCompletionServiceAsync {
* Returns a raw HTTP response for `post /chat/completions/{completion_id}`, but is
* otherwise the same as [ChatCompletionServiceAsync.update].
*/
- @MustBeClosed
fun update(
completionId: String,
params: ChatCompletionUpdateParams,
@@ -311,7 +302,6 @@ interface ChatCompletionServiceAsync {
update(completionId, params, RequestOptions.none())
/** @see [update] */
- @MustBeClosed
fun update(
completionId: String,
params: ChatCompletionUpdateParams,
@@ -320,14 +310,12 @@ interface ChatCompletionServiceAsync {
update(params.toBuilder().completionId(completionId).build(), requestOptions)
/** @see [update] */
- @MustBeClosed
fun update(
params: ChatCompletionUpdateParams
): CompletableFuture> =
update(params, RequestOptions.none())
/** @see [update] */
- @MustBeClosed
fun update(
params: ChatCompletionUpdateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -337,26 +325,22 @@ interface ChatCompletionServiceAsync {
* Returns a raw HTTP response for `get /chat/completions`, but is otherwise the same as
* [ChatCompletionServiceAsync.list].
*/
- @MustBeClosed
fun list(): CompletableFuture> =
list(ChatCompletionListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: ChatCompletionListParams = ChatCompletionListParams.none(),
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(
params: ChatCompletionListParams = ChatCompletionListParams.none()
): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
requestOptions: RequestOptions
): CompletableFuture> =
@@ -366,14 +350,12 @@ interface ChatCompletionServiceAsync {
* Returns a raw HTTP response for `delete /chat/completions/{completion_id}`, but is
* otherwise the same as [ChatCompletionServiceAsync.delete].
*/
- @MustBeClosed
fun delete(
completionId: String
): CompletableFuture> =
delete(completionId, ChatCompletionDeleteParams.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
completionId: String,
params: ChatCompletionDeleteParams = ChatCompletionDeleteParams.none(),
@@ -382,7 +364,6 @@ interface ChatCompletionServiceAsync {
delete(params.toBuilder().completionId(completionId).build(), requestOptions)
/** @see [delete] */
- @MustBeClosed
fun delete(
completionId: String,
params: ChatCompletionDeleteParams = ChatCompletionDeleteParams.none(),
@@ -390,21 +371,18 @@ interface ChatCompletionServiceAsync {
delete(completionId, params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
params: ChatCompletionDeleteParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [delete] */
- @MustBeClosed
fun delete(
params: ChatCompletionDeleteParams
): CompletableFuture> =
delete(params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
completionId: String,
requestOptions: RequestOptions,
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsync.kt
index 6edcc5a0..b6182dad 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/chat/completions/MessageServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async.chat.completions
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.chat.completions.messages.MessageListPageAsync
@@ -63,12 +62,10 @@ interface MessageServiceAsync {
* Returns a raw HTTP response for `get /chat/completions/{completion_id}/messages`, but is
* otherwise the same as [MessageServiceAsync.list].
*/
- @MustBeClosed
fun list(completionId: String): CompletableFuture> =
list(completionId, MessageListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
completionId: String,
params: MessageListParams = MessageListParams.none(),
@@ -77,7 +74,6 @@ interface MessageServiceAsync {
list(params.toBuilder().completionId(completionId).build(), requestOptions)
/** @see [list] */
- @MustBeClosed
fun list(
completionId: String,
params: MessageListParams = MessageListParams.none(),
@@ -85,21 +81,18 @@ interface MessageServiceAsync {
list(completionId, params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: MessageListParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(
params: MessageListParams
): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
completionId: String,
requestOptions: RequestOptions,
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsync.kt
index af6c4a7c..03f07130 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/FileServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async.containers
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponse
import com.openai.core.http.HttpResponseFor
@@ -154,12 +153,10 @@ interface FileServiceAsync {
* Returns a raw HTTP response for `post /containers/{container_id}/files`, but is otherwise
* the same as [FileServiceAsync.create].
*/
- @MustBeClosed
fun create(containerId: String): CompletableFuture> =
create(containerId, FileCreateParams.none())
/** @see [create] */
- @MustBeClosed
fun create(
containerId: String,
params: FileCreateParams = FileCreateParams.none(),
@@ -168,7 +165,6 @@ interface FileServiceAsync {
create(params.toBuilder().containerId(containerId).build(), requestOptions)
/** @see [create] */
- @MustBeClosed
fun create(
containerId: String,
params: FileCreateParams = FileCreateParams.none(),
@@ -176,21 +172,18 @@ interface FileServiceAsync {
create(containerId, params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: FileCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [create] */
- @MustBeClosed
fun create(
params: FileCreateParams
): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
containerId: String,
requestOptions: RequestOptions,
@@ -201,7 +194,6 @@ interface FileServiceAsync {
* Returns a raw HTTP response for `get /containers/{container_id}/files/{file_id}`, but is
* otherwise the same as [FileServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(
fileId: String,
params: FileRetrieveParams,
@@ -209,7 +201,6 @@ interface FileServiceAsync {
retrieve(fileId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
fileId: String,
params: FileRetrieveParams,
@@ -218,14 +209,12 @@ interface FileServiceAsync {
retrieve(params.toBuilder().fileId(fileId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: FileRetrieveParams
): CompletableFuture> =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: FileRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -235,12 +224,10 @@ interface FileServiceAsync {
* Returns a raw HTTP response for `get /containers/{container_id}/files`, but is otherwise
* the same as [FileServiceAsync.list].
*/
- @MustBeClosed
fun list(containerId: String): CompletableFuture> =
list(containerId, FileListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
containerId: String,
params: FileListParams = FileListParams.none(),
@@ -249,7 +236,6 @@ interface FileServiceAsync {
list(params.toBuilder().containerId(containerId).build(), requestOptions)
/** @see [list] */
- @MustBeClosed
fun list(
containerId: String,
params: FileListParams = FileListParams.none(),
@@ -257,19 +243,16 @@ interface FileServiceAsync {
list(containerId, params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: FileListParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(params: FileListParams): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
containerId: String,
requestOptions: RequestOptions,
@@ -280,12 +263,10 @@ interface FileServiceAsync {
* Returns a raw HTTP response for `delete /containers/{container_id}/files/{file_id}`, but
* is otherwise the same as [FileServiceAsync.delete].
*/
- @MustBeClosed
fun delete(fileId: String, params: FileDeleteParams): CompletableFuture =
delete(fileId, params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
fileId: String,
params: FileDeleteParams,
@@ -294,12 +275,10 @@ interface FileServiceAsync {
delete(params.toBuilder().fileId(fileId).build(), requestOptions)
/** @see [delete] */
- @MustBeClosed
fun delete(params: FileDeleteParams): CompletableFuture =
delete(params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
params: FileDeleteParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsync.kt
index de08b7c7..00298b94 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async.containers.files
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponse
import com.openai.models.containers.files.content.ContentRetrieveParams
@@ -16,7 +15,7 @@ interface ContentServiceAsync {
fun withRawResponse(): WithRawResponse
/** Retrieve Container File Content */
- fun retrieve(fileId: String, params: ContentRetrieveParams): CompletableFuture =
+ fun retrieve(fileId: String, params: ContentRetrieveParams): CompletableFuture =
retrieve(fileId, params, RequestOptions.none())
/** @see [retrieve] */
@@ -24,18 +23,18 @@ interface ContentServiceAsync {
fileId: String,
params: ContentRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
- ): CompletableFuture =
+ ): CompletableFuture =
retrieve(params.toBuilder().fileId(fileId).build(), requestOptions)
/** @see [retrieve] */
- fun retrieve(params: ContentRetrieveParams): CompletableFuture =
+ fun retrieve(params: ContentRetrieveParams): CompletableFuture =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
fun retrieve(
params: ContentRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
- ): CompletableFuture
+ ): CompletableFuture
/**
* A view of [ContentServiceAsync] that provides access to raw HTTP responses for each method.
@@ -46,14 +45,12 @@ interface ContentServiceAsync {
* Returns a raw HTTP response for `get /containers/{container_id}/files/{file_id}/content`,
* but is otherwise the same as [ContentServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(
fileId: String,
params: ContentRetrieveParams,
): CompletableFuture = retrieve(fileId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
fileId: String,
params: ContentRetrieveParams,
@@ -62,12 +59,10 @@ interface ContentServiceAsync {
retrieve(params.toBuilder().fileId(fileId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(params: ContentRetrieveParams): CompletableFuture =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: ContentRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt
index 15c9bb3b..7bb51987 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/containers/files/ContentServiceAsyncImpl.kt
@@ -5,14 +5,11 @@ package com.openai.services.async.containers.files
import com.openai.core.ClientOptions
import com.openai.core.RequestOptions
import com.openai.core.checkRequired
-import com.openai.core.handlers.emptyHandler
import com.openai.core.handlers.errorHandler
-import com.openai.core.handlers.withErrorHandler
import com.openai.core.http.HttpMethod
import com.openai.core.http.HttpRequest
import com.openai.core.http.HttpResponse
import com.openai.core.http.HttpResponse.Handler
-import com.openai.core.http.parseable
import com.openai.core.prepareAsync
import com.openai.models.ErrorObject
import com.openai.models.containers.files.content.ContentRetrieveParams
@@ -31,17 +28,15 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl
override fun retrieve(
params: ContentRetrieveParams,
requestOptions: RequestOptions,
- ): CompletableFuture =
+ ): CompletableFuture =
// get /containers/{container_id}/files/{file_id}/content
- withRawResponse().retrieve(params, requestOptions).thenAccept {}
+ withRawResponse().retrieve(params, requestOptions)
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
ContentServiceAsync.WithRawResponse {
private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper)
- private val retrieveHandler: Handler = emptyHandler().withErrorHandler(errorHandler)
-
override fun retrieve(
params: ContentRetrieveParams,
requestOptions: RequestOptions,
@@ -62,11 +57,9 @@ class ContentServiceAsyncImpl internal constructor(private val clientOptions: Cl
.build()
.prepareAsync(clientOptions, params, deploymentModel = null)
val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))
- return request
- .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
- .thenApply { response ->
- response.parseable { response.use { retrieveHandler.handle(it) } }
- }
+ return request.thenComposeAsync {
+ clientOptions.httpClient.executeAsync(it, requestOptions)
+ }
}
}
}
diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsync.kt
index 55f66db0..ba3b60c9 100644
--- a/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsync.kt
+++ b/openai-java-core/src/main/kotlin/com/openai/services/async/evals/RunServiceAsync.kt
@@ -2,7 +2,6 @@
package com.openai.services.async.evals
-import com.google.errorprone.annotations.MustBeClosed
import com.openai.core.RequestOptions
import com.openai.core.http.HttpResponseFor
import com.openai.models.evals.runs.RunCancelParams
@@ -160,7 +159,6 @@ interface RunServiceAsync {
* Returns a raw HTTP response for `post /evals/{eval_id}/runs`, but is otherwise the same
* as [RunServiceAsync.create].
*/
- @MustBeClosed
fun create(
evalId: String,
params: RunCreateParams,
@@ -168,7 +166,6 @@ interface RunServiceAsync {
create(evalId, params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
evalId: String,
params: RunCreateParams,
@@ -177,12 +174,10 @@ interface RunServiceAsync {
create(params.toBuilder().evalId(evalId).build(), requestOptions)
/** @see [create] */
- @MustBeClosed
fun create(params: RunCreateParams): CompletableFuture> =
create(params, RequestOptions.none())
/** @see [create] */
- @MustBeClosed
fun create(
params: RunCreateParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -192,7 +187,6 @@ interface RunServiceAsync {
* Returns a raw HTTP response for `get /evals/{eval_id}/runs/{run_id}`, but is otherwise
* the same as [RunServiceAsync.retrieve].
*/
- @MustBeClosed
fun retrieve(
runId: String,
params: RunRetrieveParams,
@@ -200,7 +194,6 @@ interface RunServiceAsync {
retrieve(runId, params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
runId: String,
params: RunRetrieveParams,
@@ -209,14 +202,12 @@ interface RunServiceAsync {
retrieve(params.toBuilder().runId(runId).build(), requestOptions)
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: RunRetrieveParams
): CompletableFuture> =
retrieve(params, RequestOptions.none())
/** @see [retrieve] */
- @MustBeClosed
fun retrieve(
params: RunRetrieveParams,
requestOptions: RequestOptions = RequestOptions.none(),
@@ -226,12 +217,10 @@ interface RunServiceAsync {
* Returns a raw HTTP response for `get /evals/{eval_id}/runs`, but is otherwise the same as
* [RunServiceAsync.list].
*/
- @MustBeClosed
fun list(evalId: String): CompletableFuture> =
list(evalId, RunListParams.none())
/** @see [list] */
- @MustBeClosed
fun list(
evalId: String,
params: RunListParams = RunListParams.none(),
@@ -240,7 +229,6 @@ interface RunServiceAsync {
list(params.toBuilder().evalId(evalId).build(), requestOptions)
/** @see [list] */
- @MustBeClosed
fun list(
evalId: String,
params: RunListParams = RunListParams.none(),
@@ -248,19 +236,16 @@ interface RunServiceAsync {
list(evalId, params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
params: RunListParams,
requestOptions: RequestOptions = RequestOptions.none(),
): CompletableFuture>
/** @see [list] */
- @MustBeClosed
fun list(params: RunListParams): CompletableFuture> =
list(params, RequestOptions.none())
/** @see [list] */
- @MustBeClosed
fun list(
evalId: String,
requestOptions: RequestOptions,
@@ -271,7 +256,6 @@ interface RunServiceAsync {
* Returns a raw HTTP response for `delete /evals/{eval_id}/runs/{run_id}`, but is otherwise
* the same as [RunServiceAsync.delete].
*/
- @MustBeClosed
fun delete(
runId: String,
params: RunDeleteParams,
@@ -279,7 +263,6 @@ interface RunServiceAsync {
delete(runId, params, RequestOptions.none())
/** @see [delete] */
- @MustBeClosed
fun delete(
runId: String,
params: RunDeleteParams,
@@ -288,12 +271,10 @@ interface RunServiceAsync {
delete(params.toBuilder().runId(runId).build(), requestOptions)
/** @see [delete] */
- @MustBeClosed
fun delete(params: RunDeleteParams): CompletableFuture