mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: illegal variable name in Jinja2 (#8348)
### What problem does this PR solve? Fix illegal variable name in Jinja2. #8316. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -78,6 +78,11 @@ class Template(ComponentBase):
|
|||||||
if p["key"] == key:
|
if p["key"] == key:
|
||||||
value = p.get("value", "")
|
value = p.get("value", "")
|
||||||
self.make_kwargs(para, kwargs, value)
|
self.make_kwargs(para, kwargs, value)
|
||||||
|
|
||||||
|
origin_pattern = "{begin@" + key + "}"
|
||||||
|
new_pattern = "begin_" + key
|
||||||
|
content = content.replace(origin_pattern, new_pattern)
|
||||||
|
kwargs[new_pattern] = kwargs.pop(origin_pattern, "")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
assert False, f"Can't find parameter '{key}' for {cpn_id}"
|
assert False, f"Can't find parameter '{key}' for {cpn_id}"
|
||||||
@ -92,6 +97,12 @@ class Template(ComponentBase):
|
|||||||
else:
|
else:
|
||||||
hist = ""
|
hist = ""
|
||||||
self.make_kwargs(para, kwargs, hist)
|
self.make_kwargs(para, kwargs, hist)
|
||||||
|
|
||||||
|
if ":" in component_id:
|
||||||
|
origin_pattern = "{" + component_id + "}"
|
||||||
|
new_pattern = component_id.replace(":", "_")
|
||||||
|
content = content.replace(origin_pattern, new_pattern)
|
||||||
|
kwargs[new_pattern] = kwargs.pop(component_id, "")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
_, out = cpn.output(allow_partial=False)
|
_, out = cpn.output(allow_partial=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user