Skip to content

Commit e52448b

Browse files
authored
feat:add api-version selection for azure openai APIs (langgenius#2821)
1 parent 1f92b55 commit e52448b

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

api/core/model_runtime/model_providers/azure_openai/_common.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
class _CommonAzureOpenAI:
1616
@staticmethod
1717
def _to_credential_kwargs(credentials: dict) -> dict:
18+
api_version = credentials.get('openai_api_version', AZURE_OPENAI_API_VERSION)
1819
credentials_kwargs = {
1920
"api_key": credentials['openai_api_key'],
2021
"azure_endpoint": credentials['openai_api_base'],
21-
"api_version": AZURE_OPENAI_API_VERSION,
22+
"api_version": api_version,
2223
"timeout": Timeout(315.0, read=300.0, write=10.0, connect=5.0),
2324
"max_retries": 1,
2425
}

api/core/model_runtime/model_providers/azure_openai/_constant.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
AZURE_OPENAI_API_VERSION = '2024-02-15-preview'
1818

19-
2019
def _get_max_tokens(default: int, min_val: int, max_val: int) -> ParameterRule:
2120
rule = ParameterRule(
2221
name='max_tokens',

api/core/model_runtime/model_providers/azure_openai/azure_openai.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ model_credential_schema:
4646
placeholder:
4747
zh_Hans: 在此输入您的 API Key
4848
en_US: Enter your API key here
49+
- variable: openai_api_version
50+
label:
51+
zh_Hans: API 版本
52+
en_US: API Version
53+
type: select
54+
required: true
55+
options:
56+
- label:
57+
en_US: 2024-02-15-preview
58+
value: 2024-02-15-preview
59+
- label:
60+
en_US: 2023-12-01-preview
61+
value: 2023-12-01-preview
62+
placeholder:
63+
zh_Hans: 在此选择您的 API 版本
64+
en_US: Select your API Version here
4965
- variable: base_model_name
5066
label:
5167
en_US: Base Model

0 commit comments

Comments
 (0)