🐛 fix(types.py): add error handling when building custom components to prevent crashes and log the error message

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-25 11:47:21 -03:00
commit aa387f89b3

View file

@ -261,6 +261,7 @@ def build_langchain_custom_component_list_from_path(path: str):
menu[menu_name] = {} menu[menu_name] = {}
for component in menu_item["components"]: for component in menu_item["components"]:
try:
component_name = component["name"] component_name = component["name"]
component_code = component["code"] component_code = component["code"]
@ -271,5 +272,7 @@ def build_langchain_custom_component_list_from_path(path: str):
) )
menu[menu_name][component_name] = component_template menu[menu_name][component_name] = component_template
except Exception as exc:
logger.error(f"Error while building custom component: {exc}")
return menu return menu