From 2f9ffd1d484536253c47198a2a2ba180153e861b Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 31 Jul 2023 21:42:08 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(flow-runner.mdx):=20handle?= =?UTF-8?q?=20case=20where=20document=20is=20a=20list=20and=20extract=20th?= =?UTF-8?q?e=20first=20element=20to=20ensure=20compatibility=20with=20the?= =?UTF-8?q?=20flow=20=F0=9F=94=A8=20refactor(flow-runner.mdx):=20remove=20?= =?UTF-8?q?unnecessary=20comment=20and=20unused=20variable=20to=20improve?= =?UTF-8?q?=20code=20readability=20and=20maintainability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/examples/flow-runner.mdx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/docs/examples/flow-runner.mdx b/docs/docs/examples/flow-runner.mdx index eca31d21e..151c7d182 100644 --- a/docs/docs/examples/flow-runner.mdx +++ b/docs/docs/examples/flow-runner.mdx @@ -60,6 +60,8 @@ description = "Run other flows using a document as input." tweaks = {} flow = self.get_flow(flow_name=flow_name, tweaks=tweaks) # Get the page_content from the document + if document and isinstance(document, list): + document = document[0] page_content = document.page_content # Use it in the flow result = flow(page_content) @@ -267,6 +269,8 @@ class FlowRunner(CustomComponent): tweaks = {} flow = self.get_flow(flow_name=flow_name, tweaks=tweaks) # Get the page_content from the document + if document and isinstance(document, list): + document = document[0] page_content = document.page_content # Use it in the flow result = flow(page_content) @@ -299,17 +303,17 @@ class FlowRunner(CustomComponent): "document": {"display_name": "Document"} } - def build(self, flow_name: str, document: Document) -> Document: # List the flows flows = self.list_flows() # Get the flow that matches the selected name # You can also get the flow by id # using self.get_flow(flow_id=flow_id) - # Load the flow tweaks = {} flow = self.get_flow(flow_name=flow_name, tweaks=tweaks) # Get the page_content from the document + if document and isinstance(document, list): + document = document[0] page_content = document.page_content # Use it in the flow result = flow(page_content)