Skip to content

Commit d5914b0

Browse files
committed
feat: allow user ignore azure api version check
1 parent af87566 commit d5914b0

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

models/azure/azure.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,22 @@ func Init() (err error) {
3434

3535
// azure openai api version
3636
apiVersion := fn.GetStringOrDefaultFromEnv(ENV_AZURE_API_VER, DEFAULT_AZURE_API_VER)
37-
// azure openai api versions supported
38-
// https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
39-
if apiVersion != "2022-12-01" &&
40-
apiVersion != "2023-03-15-preview" &&
41-
apiVersion != "2023-05-15" &&
42-
apiVersion != "2023-06-01-preview" &&
43-
apiVersion != "2023-07-01-preview" &&
44-
apiVersion != "2023-08-01-preview" &&
45-
apiVersion != "2023-09-01-preview" &&
46-
apiVersion != "2023-12-01-preview" &&
47-
apiVersion != "2024-02-15-preview" {
48-
apiVersion = DEFAULT_AZURE_API_VER
37+
38+
ignoreAPIVersionCheck := fn.GetBoolOrDefaultFromEnv(ENV_IGNORE_API_VERSION_CHECK, false)
39+
if !ignoreAPIVersionCheck {
40+
// azure openai api versions supported
41+
// https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
42+
if apiVersion != "2022-12-01" &&
43+
apiVersion != "2023-03-15-preview" &&
44+
apiVersion != "2023-05-15" &&
45+
apiVersion != "2023-06-01-preview" &&
46+
apiVersion != "2023-07-01-preview" &&
47+
apiVersion != "2023-08-01-preview" &&
48+
apiVersion != "2023-09-01-preview" &&
49+
apiVersion != "2023-12-01-preview" &&
50+
apiVersion != "2024-02-15-preview" {
51+
apiVersion = DEFAULT_AZURE_API_VER
52+
}
4953
}
5054
modelConfig.Version = apiVersion
5155

models/azure/define.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const (
88
ENV_AZURE_MODEL = "AZURE_MODEL"
99
ENV_AZURE_VISION = "AZURE_VISION"
1010

11+
ENV_IGNORE_API_VERSION_CHECK = "AZURE_IGNORE_API_VERSION_CHECK"
12+
1113
ENV_AZURE_HTTP_PROXY = "AZURE_HTTP_PROXY"
1214
ENV_AZURE_SOCKS_PROXY = "AZURE_SOCKS_PROXY"
1315
)

0 commit comments

Comments
 (0)