From b8c2e5359bb8340e4eed05edf536685fb2eacb68 Mon Sep 17 00:00:00 2001 From: JasonVV Date: Wed, 30 Oct 2024 21:56:38 +0800 Subject: [PATCH] Fixed the issue where recall the knowledge base in the iteration of the workflow and report errors when executing (#10060) --- api/factories/variable_factory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/factories/variable_factory.py b/api/factories/variable_factory.py index a758f9981f..d0c8c7e84f 100644 --- a/api/factories/variable_factory.py +++ b/api/factories/variable_factory.py @@ -10,6 +10,7 @@ from core.variables import ( ArrayNumberVariable, ArrayObjectSegment, ArrayObjectVariable, + ArraySegment, ArrayStringSegment, ArrayStringVariable, FileSegment, @@ -79,7 +80,7 @@ def build_segment(value: Any, /) -> Segment: if isinstance(value, list): items = [build_segment(item) for item in value] types = {item.value_type for item in items} - if len(types) != 1: + if len(types) != 1 or all(isinstance(item, ArraySegment) for item in items): return ArrayAnySegment(value=value) match types.pop(): case SegmentType.STRING: