mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 04:25:59 +08:00
fix: add handling for non-string type in variable template parser (#4996)
This commit is contained in:
parent
efecdccf35
commit
73dee84cab
@ -45,7 +45,11 @@ class VariableTemplateParser:
|
|||||||
def replacer(match):
|
def replacer(match):
|
||||||
key = match.group(1)
|
key = match.group(1)
|
||||||
value = inputs.get(key, match.group(0)) # return original matched string if key not found
|
value = inputs.get(key, match.group(0)) # return original matched string if key not found
|
||||||
|
# convert the value to string
|
||||||
|
if isinstance(value, list | dict | bool | int | float):
|
||||||
|
value = str(value)
|
||||||
|
|
||||||
|
# remove template variables if required
|
||||||
if remove_template_variables:
|
if remove_template_variables:
|
||||||
return VariableTemplateParser.remove_template_variables(value)
|
return VariableTemplateParser.remove_template_variables(value)
|
||||||
return value
|
return value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user