mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 03:32:23 +08:00
feat:add api-version selection for azure openai APIs (#2821)
This commit is contained in:
parent
1f92b55f58
commit
e52448b84b
|
@ -15,10 +15,11 @@ from core.model_runtime.model_providers.azure_openai._constant import AZURE_OPEN
|
||||||
class _CommonAzureOpenAI:
|
class _CommonAzureOpenAI:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _to_credential_kwargs(credentials: dict) -> dict:
|
def _to_credential_kwargs(credentials: dict) -> dict:
|
||||||
|
api_version = credentials.get('openai_api_version', AZURE_OPENAI_API_VERSION)
|
||||||
credentials_kwargs = {
|
credentials_kwargs = {
|
||||||
"api_key": credentials['openai_api_key'],
|
"api_key": credentials['openai_api_key'],
|
||||||
"azure_endpoint": credentials['openai_api_base'],
|
"azure_endpoint": credentials['openai_api_base'],
|
||||||
"api_version": AZURE_OPENAI_API_VERSION,
|
"api_version": api_version,
|
||||||
"timeout": Timeout(315.0, read=300.0, write=10.0, connect=5.0),
|
"timeout": Timeout(315.0, read=300.0, write=10.0, connect=5.0),
|
||||||
"max_retries": 1,
|
"max_retries": 1,
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ from core.model_runtime.entities.model_entities import (
|
||||||
|
|
||||||
AZURE_OPENAI_API_VERSION = '2024-02-15-preview'
|
AZURE_OPENAI_API_VERSION = '2024-02-15-preview'
|
||||||
|
|
||||||
|
|
||||||
def _get_max_tokens(default: int, min_val: int, max_val: int) -> ParameterRule:
|
def _get_max_tokens(default: int, min_val: int, max_val: int) -> ParameterRule:
|
||||||
rule = ParameterRule(
|
rule = ParameterRule(
|
||||||
name='max_tokens',
|
name='max_tokens',
|
||||||
|
|
|
@ -46,6 +46,22 @@ model_credential_schema:
|
||||||
placeholder:
|
placeholder:
|
||||||
zh_Hans: 在此输入您的 API Key
|
zh_Hans: 在此输入您的 API Key
|
||||||
en_US: Enter your API key here
|
en_US: Enter your API key here
|
||||||
|
- variable: openai_api_version
|
||||||
|
label:
|
||||||
|
zh_Hans: API 版本
|
||||||
|
en_US: API Version
|
||||||
|
type: select
|
||||||
|
required: true
|
||||||
|
options:
|
||||||
|
- label:
|
||||||
|
en_US: 2024-02-15-preview
|
||||||
|
value: 2024-02-15-preview
|
||||||
|
- label:
|
||||||
|
en_US: 2023-12-01-preview
|
||||||
|
value: 2023-12-01-preview
|
||||||
|
placeholder:
|
||||||
|
zh_Hans: 在此选择您的 API 版本
|
||||||
|
en_US: Select your API Version here
|
||||||
- variable: base_model_name
|
- variable: base_model_name
|
||||||
label:
|
label:
|
||||||
en_US: Base Model
|
en_US: Base Model
|
||||||
|
|
Loading…
Reference in New Issue
Block a user