fix(workflow): refine variable type checks in LLMNode (#10051)

This commit is contained in:
-LAN- 2024-10-30 16:23:12 +08:00 • committed by GitHub
commit 3b53e06e0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 128 additions and 5 deletions

View file

@ -349,13 +349,11 @@ class LLMNode(BaseNode[LLMNodeData]):
variable = self.graph_runtime_state.variable_pool.get(selector)
if variable is None:
return []
if isinstance(variable, FileSegment):
elif isinstance(variable, FileSegment):
return [variable.value]
if isinstance(variable, ArrayFileSegment):
elif isinstance(variable, ArrayFileSegment):
return variable.value
# FIXME: Temporary fix for empty array,
# all variables added to variable pool should be a Segment instance.
if isinstance(variable, ArrayAnySegment) and len(variable.value) == 0:
elif isinstance(variable, NoneSegment | ArrayAnySegment):
return []
raise ValueError(f"Invalid variable type: {type(variable)}")