langflow icon indicating copy to clipboard operation
langflow copied to clipboard

fix: add data field to returned object on flowheader if flow is a component

Open lucaseduoli opened this issue 2 months ago • 1 comments

This pull request includes several changes to improve the code readability and functionality in the langflow backend. The most important changes include reformatting imports, updating the read_flows function to use FlowHeader.model_validate, adding model_validator to FlowHeader, and reformatting the FlowBase and Flow classes for better readability.

Code readability improvements:

  • src/backend/base/langflow/api/v1/flows.py: Reformatted imports to a single line for better readability.
  • src/backend/base/langflow/services/database/models/flow/model.py: Reformatted the FlowBase and Flow classes to improve readability by breaking long lines into multiple lines. [1] [2]

Functionality improvements:

  • src/backend/base/langflow/api/v1/flows.py: Updated the read_flows function to use FlowHeader.model_validate for validating flow headers, simplifying the code.
  • src/backend/base/langflow/services/database/models/flow/model.py: Added model_validator to the FlowHeader class to ensure data is set to None if is_component is False.

Import enhancements:

  • src/backend/base/langflow/services/database/models/flow/model.py: Added model_validator import from pydantic to support the new validation in FlowHeader.

lucaseduoli avatar Dec 19 '24 19:12 lucaseduoli