Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sys.files support to the if-else condition, fixed the issue whe… #8837

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading