Giter Club home page Giter Club logo

Comments (3)

dosubot avatar dosubot commented on July 19, 2024 3

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.

rothnic avatar rothnic commented on July 19, 2024 2
  • 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:

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.

dosubot avatar dosubot commented on July 19, 2024 2

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:

  1. 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.
  2. Implementation Details:

    • Ensure that the run_flow method in the CustomComponent class is correctly handling the inputs. Here is the relevant part of the run_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)
  3. Debugging Steps:

    • Verify that the inputs parameter is correctly populated and passed to the run_flow method.
    • Check the load_flow function to ensure it correctly loads the flow and processes the tweaks.
  4. Error Logs:

    • The error logs you provided indicate missing required fields (flow_id, source, target, target_args) in the TransactionModel. 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.
  5. Code Adjustments:

    • Modify the build method in the SubFlowComponent 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
  6. Ensure Correct Flow Execution:

    • Make sure the Graph object and its arun method are correctly implemented to handle the inputs and produce the expected outputs [1][2].

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.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.