Add flow_records attribute and update build method in RunFlowComponent
This commit is contained in:
parent
82bb7dc415
commit
46520e84a3
1 changed files with 12 additions and 4 deletions
|
|
@ -12,6 +12,7 @@ class RunFlowComponent(CustomComponent):
|
|||
|
||||
def get_flow_names(self) -> List[str]:
|
||||
flow_records = self.list_flows()
|
||||
self.flow_records = flow_records
|
||||
return [flow_record.data["name"] for flow_record in flow_records]
|
||||
|
||||
def build_config(self):
|
||||
|
|
@ -20,7 +21,7 @@ class RunFlowComponent(CustomComponent):
|
|||
"display_name": "Input Value",
|
||||
"multiline": True,
|
||||
},
|
||||
"flow_id": {
|
||||
"flow": {
|
||||
"display_name": "Flow ID",
|
||||
"info": "The ID of the flow to run.",
|
||||
"options": self.get_flow_names,
|
||||
|
|
@ -31,10 +32,17 @@ class RunFlowComponent(CustomComponent):
|
|||
},
|
||||
}
|
||||
|
||||
async def build(
|
||||
self, input_value: Text, flow_id: str, tweaks: NestedDict
|
||||
) -> Record:
|
||||
async def build(self, input_value: Text, flow: str, tweaks: NestedDict) -> Record:
|
||||
input_dict = {"input_value": input_value}
|
||||
flow_ids = [
|
||||
flow_record.data["id"]
|
||||
for flow_record in self.flow_records
|
||||
if flow_record.data["name"] == flow
|
||||
]
|
||||
if not flow_ids:
|
||||
raise ValueError(f"Flow {flow} not found.")
|
||||
flow_id = flow_ids[0]
|
||||
|
||||
result: List[Optional[ResultData]] = await self.run_flow(
|
||||
input_value=input_dict, flow_id=flow_id, tweaks=tweaks
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue