feat(utils.py): add error handling for missing template_config in build_custom_component_template (#2491)
This commit is contained in:
parent
15ae185ead
commit
2eb786cdd9
1 changed files with 11 additions and 0 deletions
|
|
@ -388,6 +388,17 @@ def build_custom_component_template(
|
||||||
) -> Tuple[Dict[str, Any], CustomComponent | Component]:
|
) -> Tuple[Dict[str, Any], CustomComponent | Component]:
|
||||||
"""Build a custom component template"""
|
"""Build a custom component template"""
|
||||||
try:
|
try:
|
||||||
|
if not hasattr(custom_component, "template_config"):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail={
|
||||||
|
"error": (
|
||||||
|
"Please check if you are importing Component correctly."
|
||||||
|
" It should be `from langflow.custom import Component`"
|
||||||
|
),
|
||||||
|
"traceback": traceback.format_exc(),
|
||||||
|
},
|
||||||
|
)
|
||||||
if "inputs" in custom_component.template_config:
|
if "inputs" in custom_component.template_config:
|
||||||
return build_custom_component_template_from_inputs(custom_component, user_id=user_id)
|
return build_custom_component_template_from_inputs(custom_component, user_id=user_id)
|
||||||
frontend_node = CustomComponentFrontendNode(**custom_component.template_config)
|
frontend_node = CustomComponentFrontendNode(**custom_component.template_config)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue