refactor(loading.py): process params before instantiating class object
This commit is contained in:
parent
5f796368ac
commit
7a50129149
1 changed files with 10 additions and 1 deletions
|
|
@ -33,7 +33,7 @@ def instantiate_class(node_type: str, base_type: str, params: Dict) -> Any:
|
||||||
if node_type in CUSTOM_AGENTS:
|
if node_type in CUSTOM_AGENTS:
|
||||||
if custom_agent := CUSTOM_AGENTS.get(node_type):
|
if custom_agent := CUSTOM_AGENTS.get(node_type):
|
||||||
return custom_agent.initialize(**params) # type: ignore
|
return custom_agent.initialize(**params) # type: ignore
|
||||||
|
params = process_params(params)
|
||||||
class_object = import_by_type(_type=base_type, name=node_type)
|
class_object = import_by_type(_type=base_type, name=node_type)
|
||||||
# check if it is a class before using issubclass
|
# check if it is a class before using issubclass
|
||||||
|
|
||||||
|
|
@ -107,6 +107,15 @@ def instantiate_class(node_type: str, base_type: str, params: Dict) -> Any:
|
||||||
return class_object(**params)
|
return class_object(**params)
|
||||||
|
|
||||||
|
|
||||||
|
def process_params(params):
|
||||||
|
"""Process params"""
|
||||||
|
if "allowed_special" in params:
|
||||||
|
params["allowed_special"] = set(params["allowed_special"])
|
||||||
|
if "disallowed_special" in params:
|
||||||
|
params["disallowed_special"] = set(params["disallowed_special"])
|
||||||
|
return params
|
||||||
|
|
||||||
|
|
||||||
def load_flow_from_json(path: str, build=True):
|
def load_flow_from_json(path: str, build=True):
|
||||||
# This is done to avoid circular imports
|
# This is done to avoid circular imports
|
||||||
from langflow.graph import Graph
|
from langflow.graph import Graph
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue