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: Add toolset component utilities and refactor tool mode handling #4946

Merged
merged 3 commits into from
Nov 30, 2024

Conversation

Cristhianzl
Copy link
Member

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 the tool_mode attribute to schemas, updating logic to handle tool_mode in backend and frontend components, and ensuring that the state and UI reflect the new attribute correctly.

Backend Changes:

  • Added tool_mode attribute to UpdateCustomComponentRequest schema in src/backend/base/langflow/api/v1/schemas.py to allow the attribute to be passed in API requests.
  • Updated the custom_component_update function in src/backend/base/langflow/api/v1/endpoints.py to include the tool_mode attribute in the component node.

Frontend Changes:

  • Added tool_mode attribute handling in various frontend components, such as NodeInputField, GenericNode, and RefreshParameterComponent. [1] [2] [3]
  • Implemented checkHasToolMode utility function in src/frontend/src/utils/reactflowUtils.ts to check if any template fields have tool_mode set to true. [1] [2]
  • Updated usePostTemplateValue function in src/frontend/src/controllers/API/queries/nodes/use-post-template-value.ts to include tool_mode in the payload. [1] [2]

UI and State Management:

  • Modified mutateTemplate function to accept a callback, ensuring the state is updated correctly after mutating the template. [1] [2]
  • Updated NodeToolbarComponent to handle tool_mode activation and ensure the flow state is patched and updated accordingly. [1] [2] [3]

@Cristhianzl Cristhianzl self-assigned this Nov 29, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Nov 29, 2024
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 29, 2024
Copy link

codspeed-hq bot commented Nov 29, 2024

CodSpeed Performance Report

Merging #4946 will degrade performances by 95.14%

Comparing cz/fix-toolmode (36db9e8) with main (9cee720)

Summary

❌ 4 regressions
✅ 11 untouched benchmarks

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

Benchmarks breakdown

Benchmark main cz/fix-toolmode Change
test_successful_run_with_input_type_any 179.5 ms 235.3 ms -23.72%
test_successful_run_with_input_type_text 232.4 ms 4,776.5 ms -95.14%
test_successful_run_with_output_type_any 260.4 ms 313 ms -16.81%
test_successful_run_with_output_type_debug 172.2 ms 232.5 ms -25.93%

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 30, 2024
Cristhianzl and others added 3 commits November 30, 2024 15:03
… update

🔧 (schemas.py): Add tool_mode field to UpdateCustomComponentRequest schema
♻️ (component.py): Refactor run_and_validate_update_outputs method to handle tool_mode field
🔧 (index.tsx): Add tool_mode property to NodeInputField component
🔧 (index.tsx): Refactor hasToolMode logic to use checkHasToolMode utility function
🔧 (mutate-template.ts): Add callback parameter to mutateTemplate function
🔧 (use-handle-new-value.tsx): Add tool_mode property to useHandleOnNewValue hook
🔧 (popover/index.tsx): Add console.log for placeholder, value, and id
🔧 (inputGlobalComponent/index.tsx): Add tool_mode property to InputGlobalComponent
🔧 (refreshParameterComponent/index.tsx): Add tool_mode property to RefreshParameterComponent
🔧 (use-post-template-value.ts): Add tool_mode parameter to usePostTemplateValue function
🔧 (nodeToolbarComponent/index.tsx): Add support for tool_mode functionality in NodeToolbarComponent
🔧 (reactflowUtils.ts): Add checkHasToolMode utility function to check for tool_mode field in template
@ogabrielluiz ogabrielluiz enabled auto-merge (squash) November 30, 2024 18:05
@ogabrielluiz ogabrielluiz merged commit ce12ac0 into main Nov 30, 2024
31 checks passed
@ogabrielluiz ogabrielluiz deleted the cz/fix-toolmode branch November 30, 2024 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants