From bf7045566db8f160478d3f63b0b89a9bf1355afb Mon Sep 17 00:00:00 2001 From: takatost Date: Thu, 11 Jan 2024 10:49:35 +0800 Subject: [PATCH] fix: azure openai model parameters wrong when using hosting credentials (#1993) --- api/core/entities/provider_configuration.py | 17 ++++++++++++++++- .../model_providers/azure_openai/_constant.py | 4 ++-- .../openai/llm/gpt-4-1106-preview.yaml | 2 +- .../openai/llm/gpt-4-vision-preview.yaml | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/api/core/entities/provider_configuration.py b/api/core/entities/provider_configuration.py index be1d71ff51..3af0c2b4d9 100644 --- a/api/core/entities/provider_configuration.py +++ b/api/core/entities/provider_configuration.py @@ -60,7 +60,22 @@ class ProviderConfiguration(BaseModel): :return: """ if self.using_provider_type == ProviderType.SYSTEM: - return self.system_configuration.credentials + restrict_models = [] + for quota_configuration in self.system_configuration.quota_configurations: + if self.system_configuration.current_quota_type != quota_configuration.quota_type: + continue + + restrict_models = quota_configuration.restrict_models + + copy_credentials = self.system_configuration.credentials.copy() + if restrict_models: + for restrict_model in restrict_models: + if (restrict_model.model_type == model_type + and restrict_model.model == model + and restrict_model.base_model_name): + copy_credentials['base_model_name'] = restrict_model.base_model_name + + return copy_credentials else: if self.custom_configuration.models: for model_configuration in self.custom_configuration.models: diff --git a/api/core/model_runtime/model_providers/azure_openai/_constant.py b/api/core/model_runtime/model_providers/azure_openai/_constant.py index f9d94c9612..0ccac24a1e 100644 --- a/api/core/model_runtime/model_providers/azure_openai/_constant.py +++ b/api/core/model_runtime/model_providers/azure_openai/_constant.py @@ -296,7 +296,7 @@ LLM_BASE_MODELS = [ name='frequency_penalty', **PARAMETER_RULE_TEMPLATE[DefaultParameterName.FREQUENCY_PENALTY], ), - _get_max_tokens(default=512, min_val=1, max_val=128000), + _get_max_tokens(default=512, min_val=1, max_val=4096), ParameterRule( name='seed', label=I18nObject( @@ -369,7 +369,7 @@ LLM_BASE_MODELS = [ name='frequency_penalty', **PARAMETER_RULE_TEMPLATE[DefaultParameterName.FREQUENCY_PENALTY], ), - _get_max_tokens(default=512, min_val=1, max_val=128000), + _get_max_tokens(default=512, min_val=1, max_val=4096), ParameterRule( name='seed', label=I18nObject( diff --git a/api/core/model_runtime/model_providers/openai/llm/gpt-4-1106-preview.yaml b/api/core/model_runtime/model_providers/openai/llm/gpt-4-1106-preview.yaml index 8adc77c380..73258fedae 100644 --- a/api/core/model_runtime/model_providers/openai/llm/gpt-4-1106-preview.yaml +++ b/api/core/model_runtime/model_providers/openai/llm/gpt-4-1106-preview.yaml @@ -22,7 +22,7 @@ parameter_rules: use_template: max_tokens default: 512 min: 1 - max: 128000 + max: 4096 - name: seed label: zh_Hans: 种子 diff --git a/api/core/model_runtime/model_providers/openai/llm/gpt-4-vision-preview.yaml b/api/core/model_runtime/model_providers/openai/llm/gpt-4-vision-preview.yaml index 13aec8ef53..b7044d2066 100644 --- a/api/core/model_runtime/model_providers/openai/llm/gpt-4-vision-preview.yaml +++ b/api/core/model_runtime/model_providers/openai/llm/gpt-4-vision-preview.yaml @@ -21,7 +21,7 @@ parameter_rules: use_template: max_tokens default: 512 min: 1 - max: 128000 + max: 4096 - name: seed label: zh_Hans: 种子