Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix [baichuan] Error: argument of type 'NoneType' is not iterable (#2351)

Honora Greenecf947258a14
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 27a7b487c98..e7cf059ea51 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 34fee89ba14..c8156c152b1 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 046d4132efd..fb5d73b0682 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 73081e67d47..48ed86f66be 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),