Skip to content

Commit 1ea70a3

Browse files
mssfangstainless-app[bot]
authored andcommitted
feat(api): add latest stable/preview version helper methods (#226)
* feat(api): add latest stable/preview version helper method * add latestVersion to support the latest date version * revert last commit with latest date changes * fix the lint error
1 parent 6633c38 commit 1ea70a3

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

openai-java-core/src/main/kotlin/com/openai/azure/AzureOpenAIServiceVersion.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ class AzureOpenAIServiceVersion private constructor(@get:JvmName("value") val va
88
private val values: ConcurrentHashMap<String, AzureOpenAIServiceVersion> =
99
ConcurrentHashMap()
1010

11+
@JvmStatic
12+
fun latestStableVersion(): AzureOpenAIServiceVersion {
13+
// We can update the value every general available(GA)/stable announcement.
14+
return V2024_10_21
15+
}
16+
17+
@JvmStatic
18+
fun latestPreviewVersion(): AzureOpenAIServiceVersion {
19+
// We can update the value every preview announcement.
20+
return V2025_01_01_PREVIEW
21+
}
22+
1123
@JvmStatic
1224
fun fromString(version: String): AzureOpenAIServiceVersion =
1325
values.computeIfAbsent(version) { AzureOpenAIServiceVersion(version) }

openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package com.openai.core
44

55
import com.fasterxml.jackson.databind.json.JsonMapper
66
import com.openai.azure.AzureOpenAIServiceVersion
7-
import com.openai.azure.AzureOpenAIServiceVersion.Companion.V2024_10_21
87
import com.openai.azure.credential.AzureApiKeyCredential
98
import com.openai.core.http.Headers
109
import com.openai.core.http.HttpClient
@@ -261,8 +260,10 @@ private constructor(
261260
if (isAzureEndpoint(baseUrl)) {
262261
// Default Azure OpenAI version is used if Azure user doesn't
263262
// specific a service API version in 'queryParams'.
264-
// We can update the default value every major announcement if needed.
265-
replaceQueryParams("api-version", (azureServiceVersion ?: V2024_10_21).value)
263+
replaceQueryParams(
264+
"api-version",
265+
(azureServiceVersion ?: AzureOpenAIServiceVersion.latestStableVersion()).value,
266+
)
266267
}
267268

268269
headers.replaceAll(this.headers.build())

0 commit comments

Comments
 (0)