Replace import statement with langflow.custom

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-27 16:09:33 -03:00
commit 868d5fbb52

View file

@ -157,6 +157,9 @@ def create_class(code, class_name):
if not hasattr(ast, "TypeIgnore"):
ast.TypeIgnore = create_type_ignore_class()
# Replace from langflow import CustomComponent with from langflow.custom import CustomComponent
code = code.replace("from langflow import CustomComponent", "from langflow.custom import CustomComponent")
module = ast.parse(code)
exec_globals = prepare_global_scope(code, module)