🐛 fix(flow-runner.mdx): remove unnecessary load_flow calls and update get_flow method signature to include tweaks parameter
🚚 chore(flow-runner.mdx): update load_flow references to get_flow 🚚 chore(flow-runner.mdx): remove commented out code 🚚 chore(flow-runner.mdx): update load_flow references to get_flow
This commit is contained in:
parent
95bf9ba233
commit
b2979bce17
2 changed files with 19 additions and 18 deletions
|
|
@ -57,10 +57,8 @@ description = "Run other flows using a document as input."
|
|||
# Get the flow that matches the selected name
|
||||
# You can also get the flow by id
|
||||
# using self.get_flow(flow_id=flow_id)
|
||||
flow = self.get_flow(flow_name=flow_name)
|
||||
# Load the flow
|
||||
tweaks = {}
|
||||
flow = self.load_flow(flow.id, tweaks)
|
||||
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
||||
# Get the page_content from the document
|
||||
page_content = document.page_content
|
||||
# Use it in the flow
|
||||
|
|
@ -205,7 +203,8 @@ class FlowRunner(CustomComponent):
|
|||
# Get the flow that matches the selected name
|
||||
# You can also get the flow by id
|
||||
# using self.get_flow(flow_id=flow_id)
|
||||
flow = self.get_flow(flow_name=flow_name)
|
||||
tweaks = {}
|
||||
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
||||
|
||||
```
|
||||
|
||||
|
|
@ -237,17 +236,13 @@ class FlowRunner(CustomComponent):
|
|||
# Get the flow that matches the selected name
|
||||
# You can also get the flow by id
|
||||
# using self.get_flow(flow_id=flow_id)
|
||||
flow = self.get_flow(flow_name=flow_name)
|
||||
# focus
|
||||
# Load the flow
|
||||
# focus
|
||||
tweaks = {}
|
||||
# focus
|
||||
flow = self.load_flow(flow.id, tweaks)
|
||||
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
||||
|
||||
|
||||
```
|
||||
|
||||
You can load this flow using _`load_flow`_ and set a _`tweaks`_ dictionary to customize it. Find more about tweaks in our [features guidelines](../guidelines/features#code).
|
||||
You can load this flow using _`get_flow`_ and set a _`tweaks`_ dictionary to customize it. Find more about tweaks in our [features guidelines](../guidelines/features#code).
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -269,10 +264,8 @@ class FlowRunner(CustomComponent):
|
|||
# Get the flow that matches the selected name
|
||||
# You can also get the flow by id
|
||||
# using self.get_flow(flow_id=flow_id)
|
||||
flow = self.get_flow(flow_name=flow_name)
|
||||
# Load the flow
|
||||
tweaks = {}
|
||||
flow = self.load_flow(flow.id, tweaks)
|
||||
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
||||
# Get the page_content from the document
|
||||
page_content = document.page_content
|
||||
# Use it in the flow
|
||||
|
|
@ -313,10 +306,9 @@ class FlowRunner(CustomComponent):
|
|||
# Get the flow that matches the selected name
|
||||
# You can also get the flow by id
|
||||
# using self.get_flow(flow_id=flow_id)
|
||||
flow = self.get_flow(flow_name=flow_name)
|
||||
# Load the flow
|
||||
tweaks = {}
|
||||
flow = self.load_flow(flow.id, tweaks)
|
||||
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
||||
# Get the page_content from the document
|
||||
page_content = document.page_content
|
||||
# Use it in the flow
|
||||
|
|
|
|||
|
|
@ -159,14 +159,23 @@ class CustomComponent(Component, extra=Extra.allow):
|
|||
return flows
|
||||
|
||||
def get_flow(
|
||||
self, *, flow_name: Optional[str] = None, flow_id: Optional[str] = None
|
||||
self,
|
||||
*,
|
||||
flow_name: Optional[str] = None,
|
||||
flow_id: Optional[str] = None,
|
||||
tweaks: Optional[dict] = None,
|
||||
) -> Flow:
|
||||
with session_getter() as session:
|
||||
if flow_id:
|
||||
flow = session.query(Flow).get(flow_id)
|
||||
elif flow_name:
|
||||
flow = session.query(Flow).filter(Flow.name == flow_name).first()
|
||||
return flow
|
||||
else:
|
||||
raise ValueError("Either flow_name or flow_id must be provided")
|
||||
|
||||
if not flow:
|
||||
raise ValueError(f"Flow {flow_name or flow_id} not found")
|
||||
return self.load_flow(flow.id, tweaks)
|
||||
|
||||
def build(self):
|
||||
raise NotImplementedError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue