🔀 refactor(custom_component.py): rename load_flow method parameter flow_id to graph_id for clarity
🔀 refactor(custom_component.py): add optional `tweaks` parameter to `load_flow` method to allow for processing tweaks on the graph data 🔀 refactor(custom_component.py): rename `data_graph` variable to `graph_data` for consistency and clarity 🔀 refactor(custom_component.py): add logic to process tweaks on the `graph_data` if `tweaks` parameter is provided
This commit is contained in:
parent
e43f52dd7a
commit
2b55b0c3b3
1 changed files with 7 additions and 4 deletions
|
|
@ -141,14 +141,17 @@ class CustomComponent(Component, extra=Extra.allow):
|
|||
def get_function(self):
|
||||
return validate.create_function(self.code, self.function_entrypoint_name)
|
||||
|
||||
def load_flow(self, flow_id: str):
|
||||
def load_flow(self, flow_id: str, tweaks: Optional[dict] = None):
|
||||
from langflow.processing.process import build_sorted_vertices_with_caching
|
||||
from langflow.processing.process import process_tweaks
|
||||
|
||||
with session_getter() as session:
|
||||
data_graph = flow.data if (flow := session.get(Flow, flow_id)) else None
|
||||
if not data_graph:
|
||||
graph_data = flow.data if (flow := session.get(Flow, flow_id)) else None
|
||||
if not graph_data:
|
||||
raise ValueError(f"Flow {flow_id} not found")
|
||||
return build_sorted_vertices_with_caching(data_graph)
|
||||
if tweaks:
|
||||
graph_data = process_tweaks(graph_data=graph_data, tweaks=tweaks)
|
||||
return build_sorted_vertices_with_caching(graph_data)
|
||||
|
||||
def list_flows(self):
|
||||
with session_getter() as session:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue