Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Runflow component output error #6942

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeevic
Copy link

@jeevic jeevic commented Mar 6, 2025

bug description

use Runflow component in workflow or tool model exception below:
WeChat044a0e6e07ba31bc9107d2be77858e85

Related code:

_base_outputs: list[Output] = [
        Output(name="flow_outputs_data", display_name="Flow Data Output", method="data_output", hidden=True),
        Output(
            name="flow_outputs_dataframe", display_name="Flow Dataframe Output", method="dataframe_output", hidden=True
        ),
        Output(name="flow_outputs_message", display_name="Flow Message Output", method="message_output"),
    ]
    default_keys = ["code", "_type", "flow_name_selected", "session_id"]
    FLOW_INPUTS: list[dotdict] = []
    flow_tweak_data: dict = {}

    @abstractmethod
    async def run_flow_with_tweaks(self) -> list[Data]:
        """Run the flow with tweaks."""

    async def data_output(self) -> Data:
        """Return the data output."""
        run_outputs = await self.run_flow_with_tweaks()
        first_output = run_outputs[0]

        if isinstance(first_output, Data):
            return first_output

        message_data = first_output.outputs[0].results["message"].data
        return Data(data=message_data)

    async def dataframe_output(self) -> DataFrame:
        """Return the dataframe output."""
        run_outputs = await self.run_flow_with_tweaks()
        first_output = run_outputs[0]

        if isinstance(first_output, DataFrame):
            return first_output

        message_data = first_output.outputs[0].results["message"].data
        return DataFrame(data=message_data if isinstance(message_data, list) else [message_data])

    async def message_output(self) -> Message:
        """Return the message output."""
        run_outputs = await self.run_flow_with_tweaks()
        message_result = run_outputs[0].outputs[0].results["message"]

        if isinstance(message_result, Message):
            return message_result

        if isinstance(message_result, str):
            return Message(content=message_result)

        return Message(content=message_result.data["text"])

debugger and fix

debugger found get run_outputs result not correctly

WeChat0194768c512e2708499c9a05b5ec9341

  1. run_outputs[0].outputs.results is dict type without message attribute 。 so use code get flow result
    _, message_result = next(iter(run_outputs[0].outputs[0].results.items()))

  2. return Message Object have text attribute not content attribute

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Mar 6, 2025
@github-actions github-actions bot added bug Something isn't working and removed bug Something isn't working labels Mar 6, 2025
Copy link

codspeed-hq bot commented Mar 6, 2025

CodSpeed Performance Report

Merging #6942 will degrade performances by 28.7%

Comparing qifu-llm:fix_runflow_component (84a2b19) with main (faac4db)

Summary

❌ 2 regressions
✅ 17 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_build_flow_invalid_job_id 8.1 ms 11.4 ms -28.7%
test_cancel_nonexistent_build 9.4 ms 10.5 ms -10.54%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant