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

feat: run flow component with tool mode option to run a flow as a tool #5518

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

edwinjosechittilappilly
Copy link
Collaborator

This pull request introduces several significant changes across multiple files to enhance the functionality and performance of the Langflow backend. The key changes include converting several synchronous methods to asynchronous, adding new imports, and restructuring the RunFlowComponent class.

Asynchronous Method Updates:

  • Converted run_and_validate_update_outputs method to asynchronous in src/backend/base/langflow/api/v1/endpoints.py.
  • Changed to_toolkit method to asynchronous in src/backend/base/langflow/base/agents/agent.py.
  • Updated run_and_validate_update_outputs and _append_tool_to_outputs_map methods to asynchronous in src/backend/base/langflow/custom/custom_component/component.py. [1] [2]

New Imports:

  • Added create_input_schema_from_dict and dotdict imports in src/backend/base/langflow/base/tools/component_tool.py. [1] [2]

RunFlowComponent Refactor:

  • Removed the old RunFlowComponent class and replaced it with a new implementation in src/backend/base/langflow/components/logic/runflow.py. The new class inherits from RunFlowBase and includes methods to handle flow execution with tweaks and updating build configurations. [1] [2]

Other Changes:

  • Fixed a typo in the import statement for RunFlowComponent in src/backend/base/langflow/components/logic/__init__.py.
  • Added a new method run_flow_with_tweaks to handle running flows with specific tweaks in RunFlowBase.

@github-actions github-actions bot added the enhancement New feature or request label Jan 2, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 2, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 2, 2025
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jan 3, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 3, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jan 3, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 3, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 3, 2025
…field_template for improved input validation
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 7, 2025
@edwinjosechittilappilly
Copy link
Collaborator Author

outputs = [
Output(display_name="Run Outputs", name="run_outputs", method="generate_results"),
]
async def run_flow_with_tweaks(self) -> list[Data]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have two or three outputs in this component. One for Data, one for DataFrame and possibly one for the first Message. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data and Dataframe sure I could add that.
Can you clarify "" possibly one for the first Message""" Means?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I had assumed that there is only one output function in the tool mode of runflow.

Can I proceed in such a way that the in tool mode the output/method from the data output is utilised, we need not have multiple tools for each outputs right?

for output in run_output.outputs:
if output:
data.extend(build_data_from_result_data(output))
return Data(data=data[-1].data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants