Skip to content
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

feat(api): add latest stable/preview version helper methods #226

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ class AzureOpenAIServiceVersion private constructor(@get:JvmName("value") val va
private val values: ConcurrentHashMap<String, AzureOpenAIServiceVersion> =
ConcurrentHashMap()

@JvmStatic
fun latestStableVersion(): AzureOpenAIServiceVersion {
// We can update the value every general available(GA)/stable announcement.
return V2024_10_21
}

@JvmStatic
fun latestPreviewVersion(): AzureOpenAIServiceVersion {
// We can update the value every preview announcement.
return V2025_01_01_PREVIEW
}

@JvmStatic
fun fromString(version: String): AzureOpenAIServiceVersion =
values.computeIfAbsent(version) { AzureOpenAIServiceVersion(version) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package com.openai.core

import com.fasterxml.jackson.databind.json.JsonMapper
import com.openai.azure.AzureOpenAIServiceVersion
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 @@ -261,8 +260,10 @@ private constructor(
if (isAzureEndpoint(baseUrl)) {
// 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_10_21).value)
replaceQueryParams(
"api-version",
(azureServiceVersion ?: AzureOpenAIServiceVersion.latestStableVersion()).value
)
}

headers.replaceAll(this.headers.build())
Expand Down
Loading