From bb7af56e6900fe2f3bd5d23d69781f5c39c3a56b Mon Sep 17 00:00:00 2001 From: takatost Date: Thu, 4 Jan 2024 01:30:23 +0800 Subject: [PATCH] fix: zhipuai history format wrong (#1897) --- api/core/model_runtime/model_providers/zhipuai/llm/llm.py | 5 ++++- api/core/model_runtime/model_providers/zhipuai/zhipuai.yaml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/core/model_runtime/model_providers/zhipuai/llm/llm.py b/api/core/model_runtime/model_providers/zhipuai/llm/llm.py index 4540413897..4a6cd7d101 100644 --- a/api/core/model_runtime/model_providers/zhipuai/llm/llm.py +++ b/api/core/model_runtime/model_providers/zhipuai/llm/llm.py @@ -117,7 +117,10 @@ class ZhipuAILargeLanguageModel(_CommonZhipuaiAI, LargeLanguageModel): params = { 'model': model, - 'prompt': [{ 'role': prompt_message.role.value, 'content': prompt_message.content } for prompt_message in prompt_messages], + 'prompt': [{ + 'role': prompt_message.role.value if prompt_message.role.value != 'system' else 'user', + 'content': prompt_message.content + } for prompt_message in prompt_messages], **model_parameters } diff --git a/api/core/model_runtime/model_providers/zhipuai/zhipuai.yaml b/api/core/model_runtime/model_providers/zhipuai/zhipuai.yaml index cbee3717a3..608a765baf 100644 --- a/api/core/model_runtime/model_providers/zhipuai/zhipuai.yaml +++ b/api/core/model_runtime/model_providers/zhipuai/zhipuai.yaml @@ -24,7 +24,7 @@ provider_credential_schema: - variable: api_key label: en_US: APIKey - type: text-input + type: secret-input required: true placeholder: zh_Hans: 在此输入您的 APIKey