From d954bec8e0545673b35ac3fc2d4f23c49bdd3066 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Wed, 28 May 2025 18:58:02 +0800 Subject: [PATCH] feat: Refactors model feature removal logic Signed-off-by: -LAN- --- api/core/workflow/nodes/agent/agent_node.py | 6 ++++-- api/core/workflow/nodes/agent/entities.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/core/workflow/nodes/agent/agent_node.py b/api/core/workflow/nodes/agent/agent_node.py index 771e0ca7a5..754b473a42 100644 --- a/api/core/workflow/nodes/agent/agent_node.py +++ b/api/core/workflow/nodes/agent/agent_node.py @@ -356,7 +356,9 @@ class AgentNode(ToolNode): def _remove_unsupported_model_features_for_old_version(self, model_schema: AIModelEntity) -> AIModelEntity: if model_schema.features: - for feature in model_schema.features: - if feature.value not in AgentOldVersionModelFeatures: + for feature in model_schema.features[:]: # Create a copy to safely modify during iteration + try: + AgentOldVersionModelFeatures(feature) # Try to create enum member from value + except ValueError: model_schema.features.remove(feature) return model_schema diff --git a/api/core/workflow/nodes/agent/entities.py b/api/core/workflow/nodes/agent/entities.py index 77e94375bf..075a41fb2f 100644 --- a/api/core/workflow/nodes/agent/entities.py +++ b/api/core/workflow/nodes/agent/entities.py @@ -1,4 +1,4 @@ -from enum import Enum +from enum import Enum, StrEnum from typing import Any, Literal, Union from pydantic import BaseModel @@ -26,7 +26,7 @@ class ParamsAutoGenerated(Enum): OPEN = 1 -class AgentOldVersionModelFeatures(Enum): +class AgentOldVersionModelFeatures(StrEnum): """ Enum class for old SDK version llm feature. """