fix(workflow): add backward compatibility for old dify configs

This commit is contained in:
Eternity
2026-03-05 11:18:48 +08:00
parent 16c1cbe24f
commit a72d5d2c77
2 changed files with 5 additions and 3 deletions

View File

@@ -98,7 +98,7 @@ class DifyConverter(BaseConverter):
if not var_selector:
return ""
selector = var_selector.split('.')
if len(selector) not in [2, 3]:
if len(selector) not in [2, 3] and var_selector != "context":
raise Exception(f"invalid variable selector: {var_selector}")
if len(selector) == 3:
selector = selector[1:]
@@ -332,7 +332,9 @@ class DifyConverter(BaseConverter):
messages.append(
MessageConfig(
role="user",
content=self.trans_variable_format(node_data["memory"]["query_prompt_template"])
content=self.trans_variable_format(
node_data["memory"].get("query_prompt_template", "{{#sys.query#}}")
)
)
)
vision = node_data["vision"]["enabled"]

View File

@@ -80,7 +80,7 @@ class DifyAdapter(BasePlatformAdapter, DifyConverter):
return True
def validate_config(self) -> bool:
require_fields = frozenset({'app', 'dependencies', 'kind', 'version', 'workflow'})
require_fields = frozenset({'app', 'kind', 'version', 'workflow'})
if not all(field in self.config for field in require_fields):
return False