-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
refactor: Calculator Component updating tool implementation and fix deprecation warnings #5442
refactor: Calculator Component updating tool implementation and fix deprecation warnings #5442
Conversation
Replace legacy tool mode implementation using CalculatorToolSchema with simplified tool_mode=True approach.
Fix ast.Num deprecation warnings by supporting ast.Constant while maintaining backwards compatibility.
…d of tuple syntax
Component name required; if not it would get None in Toolset
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure to have Name variable in component such that it would be used in the Edit tools table later.
CodSpeed Performance ReportMerging #5442 will degrade performances by 32.87%Comparing Summary
Benchmarks breakdown
|
@Vigtu can you check and fix why the unit test are failing? |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
refactor(calculator): update tool implementation and fix deprecation warnings
This pull request includes the addition of a new
CalculatorComponent
and the deprecation of the existingCalculatorToolComponent
. The changes involve updating the initialization file to include the new component, modifying the old component to mark it as deprecated, and adding comprehensive unit tests for the new component.Addition of new
CalculatorComponent
:src/backend/base/langflow/components/tools/__init__.py
: AddedCalculatorComponent
to the import list and component registry. [1] [2]src/backend/base/langflow/components/tools/calculator_core.py
: Implemented the newCalculatorComponent
with a complete evaluation function using AST parsing for arithmetic operations.Deprecation of existing
CalculatorToolComponent
:src/backend/base/langflow/components/tools/calculator.py
: Marked theCalculatorToolComponent
as deprecated by changing itsdisplay_name
and adding alegacy
attribute.Unit tests for
CalculatorComponent
:src/backend/tests/unit/components/tools/test_calculator.py
: Added unit tests to validate the functionality of the newCalculatorComponent
, including tests for basic and complex calculations, division by zero, invalid expressions, unsupported operations, and frontend node generation.