feat: Add toolset component utilities and refactor tool mode handling #4946
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes several changes to implement and handle a new
tool_mode
attribute across various components and files in the codebase. The most important changes include adding thetool_mode
attribute to schemas, updating logic to handletool_mode
in backend and frontend components, and ensuring that the state and UI reflect the new attribute correctly.Backend Changes:
tool_mode
attribute toUpdateCustomComponentRequest
schema insrc/backend/base/langflow/api/v1/schemas.py
to allow the attribute to be passed in API requests.custom_component_update
function insrc/backend/base/langflow/api/v1/endpoints.py
to include thetool_mode
attribute in the component node.Frontend Changes:
tool_mode
attribute handling in various frontend components, such asNodeInputField
,GenericNode
, andRefreshParameterComponent
. [1] [2] [3]checkHasToolMode
utility function insrc/frontend/src/utils/reactflowUtils.ts
to check if any template fields havetool_mode
set to true. [1] [2]usePostTemplateValue
function insrc/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts
to includetool_mode
in the payload. [1] [2]UI and State Management:
mutateTemplate
function to accept a callback, ensuring the state is updated correctly after mutating the template. [1] [2]NodeToolbarComponent
to handletool_mode
activation and ensure the flow state is patched and updated accordingly. [1] [2] [3]