Skip to content

release: 0.22.0 #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.21.1"
".": "0.22.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 61
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-fc5dbc19505b0035f9e7f88868619f4fb519b048bde011f6154f3132d4be71fb.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-dfb00c627f58e5180af7a9b29ed2f2aa0764a3b9daa6a32a1cc45bc8e48dfe15.yml
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 0.22.0 (2025-02-06)

Full Changelog: [v0.21.1...v0.22.0](https://github.com/openai/openai-java/compare/v0.21.1...v0.22.0)

### Features

* **api:** Add more new Azure service versions ([#208](https://github.com/openai/openai-java/issues/208)) ([a117892](https://github.com/openai/openai-java/commit/a11789220599540173f09d6cc9583365abe5f4e0))
* **pagination:** avoid fetching when has_more: false ([#209](https://github.com/openai/openai-java/issues/209)) ([183b132](https://github.com/openai/openai-java/commit/183b132bba24beb90168fa77df84a93f0ea92fbe))


### Bug Fixes

* **api:** add missing `@MustBeClosed` annotations ([#205](https://github.com/openai/openai-java/issues/205)) ([0a60b9a](https://github.com/openai/openai-java/commit/0a60b9a40ad7f97ed51be3f6a70d674a6a9f1854))
* **api:** add missing reasoning effort + model enums ([#207](https://github.com/openai/openai-java/issues/207)) ([8eb2394](https://github.com/openai/openai-java/commit/8eb2394b4ea937b19720d97dae84ed56660845c0))
* **api:** switch `CompletableFuture&lt;Void&gt;` to `CompletableFuture<Void?>` ([0a60b9a](https://github.com/openai/openai-java/commit/0a60b9a40ad7f97ed51be3f6a70d674a6a9f1854))
* **client:** add missing validation calls on response ([0a60b9a](https://github.com/openai/openai-java/commit/0a60b9a40ad7f97ed51be3f6a70d674a6a9f1854))
* **client:** always provide a body for `PATCH` methods ([0a60b9a](https://github.com/openai/openai-java/commit/0a60b9a40ad7f97ed51be3f6a70d674a6a9f1854))
* deploymentModel arg ([3ab4110](https://github.com/openai/openai-java/commit/3ab41105d8b3fbb3db24ee96e825611f27713bb2))


### Chores

* **internal:** minor formatting/style changes ([0a60b9a](https://github.com/openai/openai-java/commit/0a60b9a40ad7f97ed51be3f6a70d674a6a9f1854))
* **internal:** rename some tests ([0a60b9a](https://github.com/openai/openai-java/commit/0a60b9a40ad7f97ed51be3f6a70d674a6a9f1854))

## 0.21.1 (2025-02-05)

Full Changelog: [v0.21.0...v0.21.1](https://github.com/openai/openai-java/compare/v0.21.0...v0.21.1)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.21.1)
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.21.1/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.21.1)
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.22.0)
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.22.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.22.0)

<!-- x-release-please-end -->

Expand All @@ -25,7 +25,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
### Gradle

```kotlin
implementation("com.openai:openai-java:0.21.1")
implementation("com.openai:openai-java:0.22.0")
```

### Maven
Expand All @@ -34,7 +34,7 @@ implementation("com.openai:openai-java:0.21.1")
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>0.21.1</version>
<version>0.22.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {

allprojects {
group = "com.openai"
version = "0.21.1" // x-release-please-version
version = "0.22.0" // x-release-please-version
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val

private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request {
var body: RequestBody? = body?.toRequestBody()
// OkHttpClient always requires a request body for PUT and POST methods.
if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) {
if (body == null && requiresBody(method)) {
body = "".toRequestBody()
}

Expand All @@ -134,6 +133,15 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
return builder.build()
}

/** `OkHttpClient` always requires a request body for some methods. */
private fun requiresBody(method: HttpMethod): Boolean =
when (method) {
HttpMethod.POST,
HttpMethod.PUT,
HttpMethod.PATCH -> true
else -> false
}

private fun HttpRequest.toUrl(): String {
url?.let {
return it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class AzureOpenAIServiceVersion private constructor(@get:JvmName("value") val va
@JvmStatic val V2023_05_15 = fromString("2023-05-15")
@JvmStatic val V2024_02_01 = fromString("2024-02-01")
@JvmStatic val V2024_06_01 = fromString("2024-06-01")
@JvmStatic val V2024_10_21 = fromString("2024-10-21")
@JvmStatic val V2023_06_01_PREVIEW = fromString("2023-06-01-preview")
@JvmStatic val V2023_07_01_PREVIEW = fromString("2023-07-01-preview")
@JvmStatic val V2024_02_15_PREVIEW = fromString("2024-02-15-preview")
Expand All @@ -25,6 +26,9 @@ class AzureOpenAIServiceVersion private constructor(@get:JvmName("value") val va
@JvmStatic val V2024_07_01_PREVIEW = fromString("2024-07-01-preview")
@JvmStatic val V2024_08_01_PREVIEW = fromString("2024-08-01-preview")
@JvmStatic val V2024_09_01_PREVIEW = fromString("2024-09-01-preview")
@JvmStatic val V2024_10_01_PREVIEW = fromString("2024-10-01-preview")
@JvmStatic val V2024_12_01_PREVIEW = fromString("2024-12-01-preview")
@JvmStatic val V2025_01_01_PREVIEW = fromString("2025-01-01-preview")
}

override fun equals(other: Any?): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package com.openai.core

import com.fasterxml.jackson.databind.json.JsonMapper
import com.openai.azure.AzureOpenAIServiceVersion
import com.openai.azure.AzureOpenAIServiceVersion.Companion.V2024_06_01
import com.openai.azure.AzureOpenAIServiceVersion.Companion.V2024_10_21
import com.openai.azure.credential.AzureApiKeyCredential
import com.openai.core.http.Headers
import com.openai.core.http.HttpClient
Expand Down Expand Up @@ -262,7 +262,7 @@ private constructor(
// Default Azure OpenAI version is used if Azure user doesn't
// specific a service API version in 'queryParams'.
// We can update the default value every major announcement if needed.
replaceQueryParams("api-version", (azureServiceVersion ?: V2024_06_01).value)
replaceQueryParams("api-version", (azureServiceVersion ?: V2024_10_21).value)
}

headers.replaceAll(this.headers.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ private constructor(

fun data(): List<Batch> = response().data()

fun hasMore(): Optional<Boolean> = response().hasMore()

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
Expand Down Expand Up @@ -78,15 +80,21 @@ private constructor(
@JsonCreator
constructor(
@JsonProperty("data") private val data: JsonField<List<Batch>> = JsonMissing.of(),
@JsonProperty("has_more") private val hasMore: JsonField<Boolean> = JsonMissing.of(),
@JsonAnySetter
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

fun data(): List<Batch> = data.getNullable("data") ?: listOf()

fun hasMore(): Optional<Boolean> = Optional.ofNullable(hasMore.getNullable("has_more"))

@JsonProperty("data")
fun _data(): Optional<JsonField<List<Batch>>> = Optional.ofNullable(data)

@JsonProperty("has_more")
fun _hasMore(): Optional<JsonField<Boolean>> = Optional.ofNullable(hasMore)

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
Expand All @@ -99,6 +107,7 @@ private constructor(
}

data().map { it.validate() }
hasMore()
validated = true
}

Expand All @@ -109,12 +118,13 @@ private constructor(
return true
}

return /* spotless:off */ other is Response && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */
return /* spotless:off */ other is Response && data == other.data && hasMore == other.hasMore && additionalProperties == other.additionalProperties /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(data, additionalProperties) /* spotless:on */
override fun hashCode(): Int = /* spotless:off */ Objects.hash(data, hasMore, additionalProperties) /* spotless:on */

override fun toString() = "Response{data=$data, additionalProperties=$additionalProperties}"
override fun toString() =
"Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}"

companion object {

Expand All @@ -124,23 +134,34 @@ private constructor(
class Builder {

private var data: JsonField<List<Batch>> = JsonMissing.of()
private var hasMore: JsonField<Boolean> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(page: Response) = apply {
this.data = page.data
this.hasMore = page.hasMore
this.additionalProperties.putAll(page.additionalProperties)
}

fun data(data: List<Batch>) = data(JsonField.of(data))

fun data(data: JsonField<List<Batch>>) = apply { this.data = data }

fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore))

fun hasMore(hasMore: JsonField<Boolean>) = apply { this.hasMore = hasMore }

fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}

fun build() = Response(data, additionalProperties.toImmutable())
fun build() =
Response(
data,
hasMore,
additionalProperties.toImmutable(),
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ private constructor(

fun data(): List<Batch> = response().data()

fun hasMore(): Optional<Boolean> = response().hasMore()

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
Expand Down Expand Up @@ -81,15 +83,21 @@ private constructor(
@JsonCreator
constructor(
@JsonProperty("data") private val data: JsonField<List<Batch>> = JsonMissing.of(),
@JsonProperty("has_more") private val hasMore: JsonField<Boolean> = JsonMissing.of(),
@JsonAnySetter
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
) {

fun data(): List<Batch> = data.getNullable("data") ?: listOf()

fun hasMore(): Optional<Boolean> = Optional.ofNullable(hasMore.getNullable("has_more"))

@JsonProperty("data")
fun _data(): Optional<JsonField<List<Batch>>> = Optional.ofNullable(data)

@JsonProperty("has_more")
fun _hasMore(): Optional<JsonField<Boolean>> = Optional.ofNullable(hasMore)

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
Expand All @@ -102,6 +110,7 @@ private constructor(
}

data().map { it.validate() }
hasMore()
validated = true
}

Expand All @@ -112,12 +121,13 @@ private constructor(
return true
}

return /* spotless:off */ other is Response && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */
return /* spotless:off */ other is Response && data == other.data && hasMore == other.hasMore && additionalProperties == other.additionalProperties /* spotless:on */
}

override fun hashCode(): Int = /* spotless:off */ Objects.hash(data, additionalProperties) /* spotless:on */
override fun hashCode(): Int = /* spotless:off */ Objects.hash(data, hasMore, additionalProperties) /* spotless:on */

override fun toString() = "Response{data=$data, additionalProperties=$additionalProperties}"
override fun toString() =
"Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}"

companion object {

Expand All @@ -127,23 +137,34 @@ private constructor(
class Builder {

private var data: JsonField<List<Batch>> = JsonMissing.of()
private var hasMore: JsonField<Boolean> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

@JvmSynthetic
internal fun from(page: Response) = apply {
this.data = page.data
this.hasMore = page.hasMore
this.additionalProperties.putAll(page.additionalProperties)
}

fun data(data: List<Batch>) = data(JsonField.of(data))

fun data(data: JsonField<List<Batch>>) = apply { this.data = data }

fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore))

fun hasMore(hasMore: JsonField<Boolean>) = apply { this.hasMore = hasMore }

fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}

fun build() = Response(data, additionalProperties.toImmutable())
fun build() =
Response(
data,
hasMore,
additionalProperties.toImmutable(),
)
}
}

Expand Down
Loading