Skip to content

Commit

Permalink
Added sys.files support to the if-else condition, fixed the issue whe…
Browse files Browse the repository at this point in the history
…re mixing VL models and text models caused an error.
  • Loading branch information
svcvit committed Sep 27, 2024
1 parent 0603359 commit 729a77d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
8 changes: 8 additions & 0 deletions api/core/model_runtime/entities/message_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ class TextPromptMessageContent(PromptMessageContent):

type: PromptMessageContentType = PromptMessageContentType.TEXT

@property
def text(self) -> str:
return self.data

@text.setter
def text(self, value: str):
self.data = value


class ImagePromptMessageContent(PromptMessageContent):
"""
Expand Down
26 changes: 10 additions & 16 deletions api/core/workflow/workflow_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,16 @@ def handle_special_values(cls, value: Optional[Mapping[str, Any]]) -> Optional[d
if not value:
return None

new_value = dict(value) if value else {}
if isinstance(new_value, dict):
for key, val in new_value.items():
if isinstance(val, FileVar):
new_value[key] = val.to_dict()
elif isinstance(val, list):
new_val = []
for v in val:
if isinstance(v, FileVar):
new_val.append(v.to_dict())
else:
new_val.append(v)

new_value[key] = new_val

return new_value
def convert_value(v):
if isinstance(v, FileVar):
return v.to_dict()
elif isinstance(v, list):
return [convert_value(item) for item in v]
elif isinstance(v, dict):
return {k: convert_value(v) for k, v in v.items()}
return v

return {k: convert_value(v) for k, v in value.items()}

@classmethod
def mapping_user_inputs_to_variable_pool(
Expand Down
5 changes: 5 additions & 0 deletions web/app/components/workflow/nodes/if-else/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ export const getOperators = (type?: VarType) => {
ComparisonOperator.empty,
ComparisonOperator.notEmpty,
]
case VarType.arrayFile:
return [
ComparisonOperator.empty,
ComparisonOperator.notEmpty,
]
default:
return [
ComparisonOperator.is,
Expand Down

0 comments on commit 729a77d

Please sign in to comment.