Comments (6)
The Run Flow
component in Langflow 1.0 a44 (docker) using Arc Version 1.44.2 (50412), Chromium Engine Version 125.0.6422.112 might not be returning any outputs because the build
method does not handle the case where results
is None
or an empty list.
Here is the relevant part of the code:
async def build(self, input_value: Text, flow_name: str, tweaks: NestedDict) -> List[Record]:
results: List[Optional[ResultData]] = await self.run_flow(
inputs={"input_value": input_value}, flow_name=flow_name, tweaks=tweaks
)
if isinstance(results, list):
records = []
for result in results:
if result:
records.extend(self.build_records_from_result_data(result))
else:
records = self.build_records_from_result_data(results)
self.status = records
return records
If results
is None
or an empty list, records
will not be populated, leading to no outputs being returned.
To fix this, you can add a check to handle the case where results
is None
or an empty list:
async def build(self, input_value: Text, flow_name: str, tweaks: NestedDict) -> List[Record]:
results: List[Optional[ResultData]] = await self.run_flow(
inputs={"input_value": input_value}, flow_name=flow_name, tweaks=tweaks
)
records = []
if results:
if isinstance(results, list):
for result in results:
if result:
records.extend(self.build_records_from_result_data(result))
else:
records = self.build_records_from_result_data(results)
self.status = records
return records
This ensures that records
is always initialized and returned, even if results
is None
or an empty list [1][2].
Additionally, ensure that the run_flow
function in langflow/helpers/flow.py
is correctly returning the ResultData
and that the graph.arun
method is properly executed. If there are issues with the flow execution, it might result in None
or empty results being returned [3][4].
To continue talking to Dosu, mention @dosu.
from langflow.
- I also tested the sub flow component and confirmed the same problem.
- I dug around the code and without getting a full development environment setup, it was hard to tell much
- One thing i thought was odd was that the inputs into the run flow/sub flow component are passed as tweaks, rather than inputs. It seems like tweaks would be for constant values, not for more dynamic input values into a flow.
References:
- run_flow helper function
- CustomComponent.run_flow method - This is how the Sub Flow and Run Flow component calls the run_flow helper function
- Sub Flow Component Build method, where it is building the inputs to call CustomComponent.run_flow
The suggestions by @dosu aren't relevant. The build method of the Sub Flow component isn't getting any results back from run_flow, which is the whole problem. The results are empty, which implies the sub flow isn't being called with the inputs correctly.
Here are some logs I found in the application, which might point to another issue, but can't tell if it is a consequence or cause of this issue. Here is a link to where this error is originating.
[06/04/24 18:29:18] ERROR 2024-06-04 18:29:18 - ERROR - utils utils.py:200
- Error logging transaction: 4
validation errors for TransactionModel
flow_id
Field required
For further information visit
https://errors.pydantic.dev/2.7/v/miss
ing
source
Field required
For further information visit
https://errors.pydantic.dev/2.7/v/miss
ing
target
Field required
For further information visit
https://errors.pydantic.dev/2.7/v/miss
ing
target_args
Field required
For further information visit
https://errors.pydantic.dev/2.7/v/miss
ing
from langflow.
The issue you're encountering with the Run Flow
and Sub Flow
components not returning outputs likely stems from how inputs are being handled and passed to the run_flow
method. Here are some key points and suggestions to address the problem:
-
Inputs Handling:
- You mentioned that inputs are passed as tweaks rather than direct inputs. This could indeed be causing the issue if the
run_flow
method is not correctly processing these tweaks as dynamic inputs.
- You mentioned that inputs are passed as tweaks rather than direct inputs. This could indeed be causing the issue if the
-
Implementation Details:
- Ensure that the
run_flow
method in theCustomComponent
class is correctly handling the inputs. Here is the relevant part of therun_flow
method:
async def run_flow( self, inputs: Optional[Union[dict, List[dict]]] = None, tweaks: Optional[dict] = None, flow_id: Optional[str] = None, flow_name: Optional[str] = None, user_id: Optional[str] = None, ) -> Any: if user_id is None: raise ValueError("Session is invalid") graph = await load_flow(user_id, flow_id, flow_name, tweaks) if inputs is None: inputs = [] inputs_list = [] inputs_components = [] types = [] for input_dict in inputs: inputs_list.append({INPUT_FIELD_NAME: cast(str, input_dict.get("input_value"))}) inputs_components.append(input_dict.get("components", [])) types.append(input_dict.get("type", [])) return await graph.arun(inputs_list, inputs_components=inputs_components, types=types)
- Ensure that the
-
Debugging Steps:
- Verify that the
inputs
parameter is correctly populated and passed to therun_flow
method. - Check the
load_flow
function to ensure it correctly loads the flow and processes the tweaks.
- Verify that the
-
Error Logs:
- The error logs you provided indicate missing required fields (
flow_id
,source
,target
,target_args
) in theTransactionModel
. This might be related to the issue if these fields are essential for the flow execution. Ensure that these fields are correctly populated when logging transactions.
- The error logs you provided indicate missing required fields (
-
Code Adjustments:
- Modify the
build
method in theSubFlowComponent
to ensure inputs are correctly passed and processed:
async def build(self, flow_name: str, **kwargs) -> List[Record]: tweaks = {key: {"input_value": value} for key, value in kwargs.items()} run_outputs: List[Optional[RunOutputs]] = await self.run_flow( tweaks=tweaks, flow_name=flow_name, ) if not run_outputs: return [] run_output = run_outputs[0] records = [] if run_output is not None: for output in run_output.outputs: if output: records.extend(self.build_records_from_result_data(output)) self.status = records return records
- Modify the
-
Ensure Correct Flow Execution:
By addressing these points, you should be able to resolve the issue with the Run Flow
and Sub Flow
components not returning outputs. If the problem persists, further debugging of the run_flow
method and the Graph
execution might be necessary.
To continue talking to Dosu, mention @dosu.
from langflow.
This issue still exists and I would think it is something that needs to be working as part of 1.0, since it makes the composition of flows possible. Multiple people in discord have also reported this issue. Any comments from the team?
from langflow.
Just updated and confirmed this issue still exists for v1.0.0a55.
from langflow.
@rothnic 1.0.x is way more stable. Can you give it a try and reopen the issue if it has not been fixed?
from langflow.
Related Issues (20)
- The createData component is unavailable HOT 5
- "Sorry, we found an unexpected error! " message HOT 5
- Missing transformers HOT 2
- Error - Edge between CrewAIAgentComponent HOT 2
- Low level of contrast between text and background while editing - IA Devs HOT 1
- v1.0.15 - Not able to Sign Up new users HOT 4
- Not working the IDE HOT 2
- Cannot enlarge LLM output blocks in UI HOT 1
- Langflow API error HOT 2
- Wrong docker hub version tag HOT 1
- Whole flows disappearing when opened, then disappearing from the folder completely HOT 11
- Permanent loading login page after one day from the first deployment also in the last version 1.0.15 HOT 2
- Installation error HOT 4
- Langflow UI stuck on loading page while running flows HOT 4
- ERROR - setup - Edge between Component and CrewAIAgentComponent has invalid handles # setup.py:580 HOT 2
- Composio Tools does not connect to crewai agent HOT 1
- Composio Tools does not connect to crewai agent HOT 2
- unable to install Langflow on macOS reopening #3214 HOT 2
- In the component code, I imported openai, but it does not work. HOT 4
- Custom class defined in the component can not be found when build HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from langflow.