Update RunFlowComponent to include a method for updating build config
This commit is contained in:
parent
df29e9ce98
commit
2b17919883
1 changed files with 11 additions and 4 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
from typing import List, Optional
|
from typing import Any, List, Optional
|
||||||
|
|
||||||
from langflow import CustomComponent
|
from langflow import CustomComponent
|
||||||
from langflow.field_typing import NestedDict, Text
|
from langflow.field_typing import NestedDict, Text
|
||||||
from langflow.graph.schema import ResultData
|
from langflow.graph.schema import ResultData
|
||||||
from langflow.schema import Record
|
from langflow.schema import Record, dotdict
|
||||||
|
|
||||||
|
|
||||||
class RunFlowComponent(CustomComponent):
|
class RunFlowComponent(CustomComponent):
|
||||||
|
|
@ -15,6 +15,12 @@ class RunFlowComponent(CustomComponent):
|
||||||
flow_records = self.list_flows()
|
flow_records = self.list_flows()
|
||||||
return [flow_record.data["name"] for flow_record in flow_records]
|
return [flow_record.data["name"] for flow_record in flow_records]
|
||||||
|
|
||||||
|
def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None):
|
||||||
|
if field_name == "flow_name":
|
||||||
|
build_config["flow_name"]["options"] = self.get_flow_names()
|
||||||
|
|
||||||
|
return build_config
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {
|
return {
|
||||||
"input_value": {
|
"input_value": {
|
||||||
|
|
@ -24,7 +30,8 @@ class RunFlowComponent(CustomComponent):
|
||||||
"flow_name": {
|
"flow_name": {
|
||||||
"display_name": "Flow Name",
|
"display_name": "Flow Name",
|
||||||
"info": "The name of the flow to run.",
|
"info": "The name of the flow to run.",
|
||||||
"options": self.get_flow_names,
|
"options": [],
|
||||||
|
"refresh_button": True,
|
||||||
},
|
},
|
||||||
"tweaks": {
|
"tweaks": {
|
||||||
"display_name": "Tweaks",
|
"display_name": "Tweaks",
|
||||||
|
|
@ -45,7 +52,7 @@ class RunFlowComponent(CustomComponent):
|
||||||
|
|
||||||
async def build(self, input_value: Text, flow_name: str, tweaks: NestedDict) -> List[Record]:
|
async def build(self, input_value: Text, flow_name: str, tweaks: NestedDict) -> List[Record]:
|
||||||
results: List[Optional[ResultData]] = await self.run_flow(
|
results: List[Optional[ResultData]] = await self.run_flow(
|
||||||
input_value=input_value, flow_name=flow_name, tweaks=tweaks
|
inputs={"input_value": input_value}, flow_name=flow_name, tweaks=tweaks
|
||||||
)
|
)
|
||||||
if isinstance(results, list):
|
if isinstance(results, list):
|
||||||
records = []
|
records = []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue