🔧 chore(UpdateRequest.py): change field_type from "code" to "NestedDict" to improve clarity and semantics
🔧 chore(base.py): handle "dict" and "NestedDict" types in params parsing to ensure correct conversion from frontend data 🔧 chore(llms.py): change field_type from "code" to "dict" for model_kwargs field to improve semantics 🔧 chore(utilities.py): remove field_type "code" for fields with dict values to improve consistency 🔧 chore(constants.py): add "dict" and "NestedDict" to DIRECT_TYPES list to reflect available field types 🔧 chore(util.py): remove replace_dict_type_with_code function as it is no longer needed
This commit is contained in:
parent
6521152184
commit
3ae51da36e
6 changed files with 25 additions and 6 deletions
|
|
@ -15,7 +15,7 @@ class UpdateRequest(CustomComponent):
|
||||||
"url": {"display_name": "URL", "info": "The URL to make the request to."},
|
"url": {"display_name": "URL", "info": "The URL to make the request to."},
|
||||||
"headers": {
|
"headers": {
|
||||||
"display_name": "Headers",
|
"display_name": "Headers",
|
||||||
"field_type": "code",
|
"field_type": "NestedDict",
|
||||||
"info": "The headers to send with the request.",
|
"info": "The headers to send with the request.",
|
||||||
},
|
},
|
||||||
"code": {"show": False},
|
"code": {"show": False},
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,18 @@ class Vertex:
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.debug(f"Error parsing code: {exc}")
|
logger.debug(f"Error parsing code: {exc}")
|
||||||
params[key] = value.get("value")
|
params[key] = value.get("value")
|
||||||
|
elif value.get("type") in ["dict", "NestedDict"]:
|
||||||
|
# When dict comes from the frontend it comes as a
|
||||||
|
# list of dicts, so we need to convert it to a dict
|
||||||
|
# before passing it to the build method
|
||||||
|
_value = value.get("value")
|
||||||
|
if isinstance(_value, list):
|
||||||
|
params[key] = {
|
||||||
|
item["key"]: item["value"]
|
||||||
|
for item in value.get("value", [])
|
||||||
|
}
|
||||||
|
elif isinstance(_value, dict):
|
||||||
|
params[key] = _value
|
||||||
else:
|
else:
|
||||||
params[key] = value.get("value")
|
params[key] = value.get("value")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ class LLMFrontendNode(FrontendNode):
|
||||||
if display_name := display_names_dict.get(field.name):
|
if display_name := display_names_dict.get(field.name):
|
||||||
field.display_name = display_name
|
field.display_name = display_name
|
||||||
if field.name == "model_kwargs":
|
if field.name == "model_kwargs":
|
||||||
field.field_type = "code"
|
field.field_type = "dict"
|
||||||
field.advanced = True
|
field.advanced = True
|
||||||
field.show = True
|
field.show = True
|
||||||
elif field.name in [
|
elif field.name in [
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,4 @@ class UtilitiesFrontendNode(FrontendNode):
|
||||||
field.field_type = "str"
|
field.field_type = "str"
|
||||||
|
|
||||||
if isinstance(field.value, dict):
|
if isinstance(field.value, dict):
|
||||||
field.field_type = "code"
|
|
||||||
field.value = orjson_dumps(field.value)
|
field.value = orjson_dumps(field.value)
|
||||||
|
|
|
||||||
|
|
@ -48,4 +48,14 @@ def python_function(text: str) -> str:
|
||||||
return text
|
return text
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DIRECT_TYPES = ["str", "bool", "code", "int", "float", "Any", "prompt"]
|
DIRECT_TYPES = [
|
||||||
|
"str",
|
||||||
|
"bool",
|
||||||
|
"dict",
|
||||||
|
"int",
|
||||||
|
"float",
|
||||||
|
"Any",
|
||||||
|
"prompt",
|
||||||
|
"code",
|
||||||
|
"NestedDict",
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -276,8 +276,6 @@ def format_dict(
|
||||||
value["password"] = is_password_field(key)
|
value["password"] = is_password_field(key)
|
||||||
value["multiline"] = is_multiline_field(key)
|
value["multiline"] = is_multiline_field(key)
|
||||||
|
|
||||||
replace_dict_type_with_code(value)
|
|
||||||
|
|
||||||
if key == "dict_":
|
if key == "dict_":
|
||||||
set_dict_file_attributes(value)
|
set_dict_file_attributes(value)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue