🔨 refactor(custom_component.py): remove unused imports and unused load_flow method parameters for better code cleanliness

🔨 refactor(custom_component.py): update load_flow method to use the process_flow function from the api endpoints module for improved modularity and separation of concerns
This commit is contained in:
gustavoschaedler 2023-07-20 18:56:46 +01:00
commit eb7158ad26

View file

@ -5,11 +5,7 @@ from langflow.interface.custom.component import Component
from langflow.utils import validate
from uuid import UUID
from sqlmodel import Session
from fastapi import Depends, HTTPException
from langflow.database.base import get_session
from langflow.database.models.flow import Flow
from langflow.api.v1.endpoints import process_flow
class CustomComponent(Component):
@ -132,8 +128,10 @@ class CustomComponent(Component):
def get_function(self):
return validate.create_function(self.code, self.function_entrypoint_name)
def load_flow(self, session: Session = Depends(get_session), flow_id: UUID = None):
return flow if (flow := session.get(Flow, flow_id)) else "Flow not found"
def load_flow(
self, flow_id: str, inputs: Optional[dict] = None, tweaks: Optional[dict] = None
):
return process_flow(flow_id, inputs, tweaks)
def build(self):
raise NotImplementedError