🐛 fix(util.py): add logic to extract type from Union[Literal['f-string'], Literal['jinja2']] to improve type formatting
🐛 fix(test_prompts_template.py): fix incorrect value for "validate_template" field in test case
This commit is contained in:
parent
71aeda669e
commit
8887b5ca28
2 changed files with 11 additions and 1 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue