From ecf947258a148e71a938c97fc094b4b9fc1f6a5e Mon Sep 17 00:00:00 2001 From: Honora Green <749553@qq.com> Date: Fri, 2 Feb 2024 12:56:48 +0800 Subject: [PATCH] fix [baichuan] Error: argument of type 'NoneType' is not iterable (#2351) Co-authored-by: baiyansong --- .../model_providers/baichuan/llm/baichuan2-53b.yaml | 3 +++ .../model_providers/baichuan/llm/baichuan2-turbo-192k.yaml | 3 +++ .../model_providers/baichuan/llm/baichuan2-turbo.yaml | 3 +++ .../model_providers/baichuan/llm/baichuan_turbo.py | 3 +++ 4 files changed, 12 insertions(+) diff --git a/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-53b.yaml b/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-53b.yaml index 27a7b487c9..e7cf059ea5 100644 --- a/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-53b.yaml +++ b/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-53b.yaml @@ -31,6 +31,9 @@ parameter_rules: use_template: presence_penalty - name: frequency_penalty use_template: frequency_penalty + default: 1 + min: 1 + max: 2 - name: with_search_enhance label: zh_Hans: 搜索增强 diff --git a/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-turbo-192k.yaml b/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-turbo-192k.yaml index 34fee89ba1..c8156c152b 100644 --- a/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-turbo-192k.yaml +++ b/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-turbo-192k.yaml @@ -31,6 +31,9 @@ parameter_rules: use_template: presence_penalty - name: frequency_penalty use_template: frequency_penalty + default: 1 + min: 1 + max: 2 - name: with_search_enhance label: zh_Hans: 搜索增强 diff --git a/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-turbo.yaml b/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-turbo.yaml index 046d4132ef..fb5d73b068 100644 --- a/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-turbo.yaml +++ b/api/core/model_runtime/model_providers/baichuan/llm/baichuan2-turbo.yaml @@ -31,6 +31,9 @@ parameter_rules: use_template: presence_penalty - name: frequency_penalty use_template: frequency_penalty + default: 1 + min: 1 + max: 2 - name: with_search_enhance label: zh_Hans: 搜索增强 diff --git a/api/core/model_runtime/model_providers/baichuan/llm/baichuan_turbo.py b/api/core/model_runtime/model_providers/baichuan/llm/baichuan_turbo.py index 73081e67d4..48ed86f66b 100644 --- a/api/core/model_runtime/model_providers/baichuan/llm/baichuan_turbo.py +++ b/api/core/model_runtime/model_providers/baichuan/llm/baichuan_turbo.py @@ -125,6 +125,9 @@ class BaichuanModel(object): 'content': message.content, 'role': message.role, }) + # [baichuan] frequency_penalty must be between 1 and 2 + if parameters['frequency_penalty'] < 1 or parameters['frequency_penalty'] > 2: + parameters['frequency_penalty'] = 1 # turbo api accepts flat parameters return { 'model': self._model_mapping(model),