🐛 fix(validate.py): set new field value with the old value if variable already exists in the template

The code now checks if the variable already exists in the template and if so, sets the new field value with the old value. This ensures that the existing value is preserved when adding new variables to the template.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-04 23:32:25 -03:00
commit 5445adbbce

View file

@ -74,7 +74,11 @@ def add_new_variables_to_template(input_variables, prompt_request):
multiline=True,
input_types=["Document", "BaseOutputParser"],
)
if variable in prompt_request.frontend_node.template:
# Set the new field with the old value
template_field.value = prompt_request.frontend_node.template[variable][
"value"
]
prompt_request.frontend_node.template[variable] = template_field.to_dict()
# Check if variable is not already in the list before appending