🔧 fix(custom_component.py): fix import statements and refactor load_flow method to use UUID and improve code readability
🔀 merge(custom_component.py): merge changes from langflow.processing.process module to load_flow method to improve performance and data retrieval
This commit is contained in:
parent
eb7158ad26
commit
c5bf15a2c4
1 changed files with 9 additions and 5 deletions
|
|
@ -5,7 +5,9 @@ from langflow.interface.custom.component import Component
|
||||||
|
|
||||||
from langflow.utils import validate
|
from langflow.utils import validate
|
||||||
|
|
||||||
from langflow.api.v1.endpoints import process_flow
|
from uuid import UUID
|
||||||
|
from langflow.database.base import get_session
|
||||||
|
from langflow.database.models.flow import Flow
|
||||||
|
|
||||||
|
|
||||||
class CustomComponent(Component):
|
class CustomComponent(Component):
|
||||||
|
|
@ -128,10 +130,12 @@ class CustomComponent(Component):
|
||||||
def get_function(self):
|
def get_function(self):
|
||||||
return validate.create_function(self.code, self.function_entrypoint_name)
|
return validate.create_function(self.code, self.function_entrypoint_name)
|
||||||
|
|
||||||
def load_flow(
|
def load_flow(self, flow_id: UUID = None):
|
||||||
self, flow_id: str, inputs: Optional[dict] = None, tweaks: Optional[dict] = None
|
from langflow.processing.process import build_sorted_vertices_with_caching
|
||||||
):
|
|
||||||
return process_flow(flow_id, inputs, tweaks)
|
session = next(get_session())
|
||||||
|
data_graph = flow.data if (flow := session.get(Flow, flow_id)) else None
|
||||||
|
return build_sorted_vertices_with_caching(data_graph)
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue