🔨 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:
parent
a4cfe9e1e4
commit
eb7158ad26
1 changed files with 5 additions and 7 deletions
|
|
@ -5,11 +5,7 @@ from langflow.interface.custom.component import Component
|
||||||
|
|
||||||
from langflow.utils import validate
|
from langflow.utils import validate
|
||||||
|
|
||||||
from uuid import UUID
|
from langflow.api.v1.endpoints import process_flow
|
||||||
from sqlmodel import Session
|
|
||||||
from fastapi import Depends, HTTPException
|
|
||||||
from langflow.database.base import get_session
|
|
||||||
from langflow.database.models.flow import Flow
|
|
||||||
|
|
||||||
|
|
||||||
class CustomComponent(Component):
|
class CustomComponent(Component):
|
||||||
|
|
@ -132,8 +128,10 @@ 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(self, session: Session = Depends(get_session), flow_id: UUID = None):
|
def load_flow(
|
||||||
return flow if (flow := session.get(Flow, flow_id)) else "Flow not found"
|
self, flow_id: str, inputs: Optional[dict] = None, tweaks: Optional[dict] = None
|
||||||
|
):
|
||||||
|
return process_flow(flow_id, inputs, tweaks)
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue