From f7f09aa1a3dd77f5565083ece85f8056b53e2e54 Mon Sep 17 00:00:00 2001 From: Shawn Fang <45607042+mssfang@users.noreply.github.com> Date: Fri, 4 Apr 2025 10:05:02 -0700 Subject: [PATCH 1/2] fix(client): support responses API for Azure (#387) * response url support * add the missing azureServiceVersion param * add new Azure OpenAI service API version * update async client as well * Spotless: format * address feedbacks --- .../com/openai/azure/AzureOpenAIServiceVersion.kt | 4 +++- .../com/openai/azure/HttpRequestBuilderExtensions.kt | 5 +++-- .../src/main/kotlin/com/openai/core/ClientOptions.kt | 3 +++ .../services/async/ResponseServiceAsyncImpl.kt | 12 ++---------- .../openai/services/blocking/ResponseServiceImpl.kt | 4 ++-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/openai-java-core/src/main/kotlin/com/openai/azure/AzureOpenAIServiceVersion.kt b/openai-java-core/src/main/kotlin/com/openai/azure/AzureOpenAIServiceVersion.kt index e83b6ebc..3b08766f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/azure/AzureOpenAIServiceVersion.kt +++ b/openai-java-core/src/main/kotlin/com/openai/azure/AzureOpenAIServiceVersion.kt @@ -17,7 +17,7 @@ class AzureOpenAIServiceVersion private constructor(@get:JvmName("value") val va @JvmStatic fun latestPreviewVersion(): AzureOpenAIServiceVersion { // We can update the value every preview announcement. - return V2025_01_01_PREVIEW + return V2025_03_01_PREVIEW } @JvmStatic @@ -41,6 +41,8 @@ class AzureOpenAIServiceVersion private constructor(@get:JvmName("value") val va @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") + @JvmStatic val V2025_02_01_PREVIEW = fromString("2025-02-01-preview") + @JvmStatic val V2025_03_01_PREVIEW = fromString("2025-03-01-preview") } override fun equals(other: Any?): Boolean = diff --git a/openai-java-core/src/main/kotlin/com/openai/azure/HttpRequestBuilderExtensions.kt b/openai-java-core/src/main/kotlin/com/openai/azure/HttpRequestBuilderExtensions.kt index 2530d3a2..90511d49 100644 --- a/openai-java-core/src/main/kotlin/com/openai/azure/HttpRequestBuilderExtensions.kt +++ b/openai-java-core/src/main/kotlin/com/openai/azure/HttpRequestBuilderExtensions.kt @@ -10,8 +10,9 @@ internal fun HttpRequest.Builder.addPathSegmentsForAzure( clientOptions: ClientOptions, deploymentModel: String?, ): HttpRequest.Builder = apply { - if (isAzureEndpoint(clientOptions.baseUrl) && deploymentModel != null) { - addPathSegments("openai", "deployments", deploymentModel) + if (isAzureEndpoint(clientOptions.baseUrl)) { + addPathSegment("openai") + deploymentModel?.let { addPathSegments("deployments", it) } } } diff --git a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt index d81875f2..419073d7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt @@ -35,6 +35,7 @@ private constructor( @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, @get:JvmName("credential") val credential: Credential, + @get:JvmName("azureServiceVersion") val azureServiceVersion: AzureOpenAIServiceVersion?, private val organization: String?, private val project: String?, ) { @@ -102,6 +103,7 @@ private constructor( timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries credential = clientOptions.credential + azureServiceVersion = clientOptions.azureServiceVersion organization = clientOptions.organization project = clientOptions.project } @@ -350,6 +352,7 @@ private constructor( timeout, maxRetries, credential, + azureServiceVersion, organization, project, ) 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 1630bd57..122e68f4 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 @@ -103,11 +103,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C .addPathSegments("responses") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepareAsync( - clientOptions, - params, - deploymentModel = params.model().toString(), - ) + .prepareAsync(clientOptions, params, deploymentModel = null) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } @@ -148,11 +144,7 @@ class ResponseServiceAsyncImpl internal constructor(private val clientOptions: C ) ) .build() - .prepareAsync( - clientOptions, - params, - deploymentModel = params.model().toString(), - ) + .prepareAsync(clientOptions, params, deploymentModel = 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/blocking/ResponseServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt index 22f1b79f..b683a7d6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/ResponseServiceImpl.kt @@ -90,7 +90,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client .addPathSegments("responses") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepare(clientOptions, params, deploymentModel = params.model().toString()) + .prepare(clientOptions, params, deploymentModel = null) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response.parseable { @@ -128,7 +128,7 @@ class ResponseServiceImpl internal constructor(private val clientOptions: Client ) ) .build() - .prepare(clientOptions, params, deploymentModel = params.model().toString()) + .prepare(clientOptions, params, deploymentModel = null) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return response.parseable { From 19b788e2899a7c35fca0d58849d6f9901b69edff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 17:05:20 +0000 Subject: [PATCH 2/2] release: 0.44.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b7510e27..70deaf25 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.44.1" + ".": "0.44.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d0025b12..0fa9012d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.44.2 (2025-04-04) + +Full Changelog: [v0.44.1...v0.44.2](https://github.com/openai/openai-java/compare/v0.44.1...v0.44.2) + +### Bug Fixes + +* **client:** support responses API for Azure ([#387](https://github.com/openai/openai-java/issues/387)) ([f7f09aa](https://github.com/openai/openai-java/commit/f7f09aa1a3dd77f5565083ece85f8056b53e2e54)) + ## 0.44.1 (2025-04-04) Full Changelog: [v0.44.0...v0.44.1](https://github.com/openai/openai-java/compare/v0.44.0...v0.44.1) diff --git a/README.md b/README.md index c3db658a..1a1f0bdf 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.44.1) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.44.1/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.44.1) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/0.44.2) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/0.44.2/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/0.44.2) @@ -18,7 +18,7 @@ The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https:// -The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/0.44.1). +The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/0.44.2). @@ -29,7 +29,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor ### Gradle ```kotlin -implementation("com.openai:openai-java:0.44.1") +implementation("com.openai:openai-java:0.44.2") ``` ### Maven @@ -38,7 +38,7 @@ implementation("com.openai:openai-java:0.44.1") com.openai openai-java - 0.44.1 + 0.44.2 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 5a8702e3..cef16851 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "0.44.1" // x-release-please-version + version = "0.44.2" // x-release-please-version } subprojects {