🐛 fix(flow-runner.mdx): handle case where document is a list and extract the first element to ensure compatibility with the flow
🔨 refactor(flow-runner.mdx): remove unnecessary comment and unused variable to improve code readability and maintainability
This commit is contained in:
parent
8a6a953179
commit
2f9ffd1d48
1 changed files with 6 additions and 2 deletions
|
|
@ -60,6 +60,8 @@ description = "Run other flows using a document as input."
|
||||||
tweaks = {}
|
tweaks = {}
|
||||||
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
||||||
# Get the page_content from the document
|
# Get the page_content from the document
|
||||||
|
if document and isinstance(document, list):
|
||||||
|
document = document[0]
|
||||||
page_content = document.page_content
|
page_content = document.page_content
|
||||||
# Use it in the flow
|
# Use it in the flow
|
||||||
result = flow(page_content)
|
result = flow(page_content)
|
||||||
|
|
@ -267,6 +269,8 @@ class FlowRunner(CustomComponent):
|
||||||
tweaks = {}
|
tweaks = {}
|
||||||
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
||||||
# Get the page_content from the document
|
# Get the page_content from the document
|
||||||
|
if document and isinstance(document, list):
|
||||||
|
document = document[0]
|
||||||
page_content = document.page_content
|
page_content = document.page_content
|
||||||
# Use it in the flow
|
# Use it in the flow
|
||||||
result = flow(page_content)
|
result = flow(page_content)
|
||||||
|
|
@ -299,17 +303,17 @@ class FlowRunner(CustomComponent):
|
||||||
"document": {"display_name": "Document"}
|
"document": {"display_name": "Document"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def build(self, flow_name: str, document: Document) -> Document:
|
def build(self, flow_name: str, document: Document) -> Document:
|
||||||
# List the flows
|
# List the flows
|
||||||
flows = self.list_flows()
|
flows = self.list_flows()
|
||||||
# Get the flow that matches the selected name
|
# Get the flow that matches the selected name
|
||||||
# You can also get the flow by id
|
# You can also get the flow by id
|
||||||
# using self.get_flow(flow_id=flow_id)
|
# using self.get_flow(flow_id=flow_id)
|
||||||
# Load the flow
|
|
||||||
tweaks = {}
|
tweaks = {}
|
||||||
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
flow = self.get_flow(flow_name=flow_name, tweaks=tweaks)
|
||||||
# Get the page_content from the document
|
# Get the page_content from the document
|
||||||
|
if document and isinstance(document, list):
|
||||||
|
document = document[0]
|
||||||
page_content = document.page_content
|
page_content = document.page_content
|
||||||
# Use it in the flow
|
# Use it in the flow
|
||||||
result = flow(page_content)
|
result = flow(page_content)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue