diff --git a/src/backend/langflow/utils/util.py b/src/backend/langflow/utils/util.py index 9dddde032..1c7a7f094 100644 --- a/src/backend/langflow/utils/util.py +++ b/src/backend/langflow/utils/util.py @@ -276,6 +276,7 @@ def format_dict( _type = remove_optional_wrapper(_type) _type = check_list_type(_type, value) _type = replace_mapping_with_dict(_type) + _type = get_type_from_union_literal(_type) value["type"] = get_formatted_type(key, _type) value["show"] = should_show_field(value, key) @@ -295,6 +296,15 @@ def format_dict( return dictionary +# "Union[Literal['f-string'], Literal['jinja2']]" -> "str" +def get_type_from_union_literal(union_literal: str) -> str: + # if types are literal strings + # the type is a string + if "Literal" in union_literal: + return "str" + return union_literal + + def get_type(value: Any) -> Union[str, type]: """ Retrieves the type value from the dictionary. diff --git a/tests/test_prompts_template.py b/tests/test_prompts_template.py index bc2e935e9..2fc161c6d 100644 --- a/tests/test_prompts_template.py +++ b/tests/test_prompts_template.py @@ -96,7 +96,7 @@ def test_prompt_template(client: TestClient, logged_in_headers): "placeholder": "", "show": False, "multiline": False, - "value": True, + "value": False, "password": False, "name": "validate_template", "type": "bool",