Skip to content

fix: change lambda filter to smart function#8558

Merged
edwinjosechittilappilly merged 15 commits into
mainfrom
fix-smart-function
Jun 20, 2025
Merged

fix: change lambda filter to smart function#8558
edwinjosechittilappilly merged 15 commits into
mainfrom
fix-smart-function

Conversation

@Yukiyukiyeah
Copy link
Copy Markdown
Contributor

@Yukiyukiyeah Yukiyukiyeah commented Jun 16, 2025

This pull request refactors the Lambda filter component into a new Smart function component, updates related documentation, and removes unused methods and outputs from the backend implementation. The changes aim to improve clarity and streamline functionality.

Documentation Updates:

  • Renamed the Lambda filter component to Smart function throughout the documentation. Updated examples and instructions to reflect this change, including how to connect components and use the Instructions field. [1] [2]

Backend Code Simplification:

  • Removed the as_dataframe method and its corresponding output from the LambdaFilterComponent class, as it is no longer needed. [1] [2]
  • Removed an unused import of DataFrame from lambda_filter.py.

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 16, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 16, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes rename the LambdaFilterComponent to SmartFunctionComponent across the codebase and documentation. Imports, exports, class names, and references are updated accordingly. The DataFrame output and related method are removed from the component. Associated documentation and tests are also updated to reflect the new component name.

Changes

File(s) Change Summary
docs/docs/Components/components-processing.md Updated all references from Lambda filter to Smart function, including examples, instructions, and descriptions.
src/backend/base/langflow/components/processing/init.py Replaced LambdaFilterComponent with SmartFunctionComponent in imports and all exports.
src/backend/base/langflow/components/processing/smart_function.py Renamed LambdaFilterComponent to SmartFunctionComponent; removed DataFrame output and as_dataframe method.
src/backend/tests/unit/components/processing/test_lambda_filter.py Updated imports and fixtures to use SmartFunctionComponent instead of LambdaFilterComponent.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SmartFunctionComponent
    User->>SmartFunctionComponent: Provide structured data and filter/transform function
    SmartFunctionComponent->>SmartFunctionComponent: Generate and validate lambda function
    SmartFunctionComponent->>SmartFunctionComponent: Apply function to data
    SmartFunctionComponent-->>User: Return filtered/transformed data
Loading

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • Yukiyukiyeah
  • rodrigosnader
  • edwinjosechittilappilly
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch fix-smart-function

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 16, 2025
@Yukiyukiyeah Yukiyukiyeah requested a review from Copilot June 16, 2025 14:15
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 16, 2025

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 16, 2025

Build successful! ✅
Deploying docs draft.
Deploy successful! View draft

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 16, 2025

Build successful! ✅
Deploying docs draft.
Deploy successful! View draft

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 16, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (3)
src/backend/base/langflow/components/processing/__init__.py (1)

14-20: Missing import for ParseDataFrameComponent

ParseDataFrameComponent is still exposed in __all__ (lines 37-38) but the corresponding import statement is absent. Any runtime code that performs from langflow.components.processing import ParseDataFrameComponent will raise ImportError.

 from .parse_json_data import ParseJSONDataComponent
+from .parse_dataframe import ParseDataFrameComponent
 from .parser import ParserComponent
docs/docs/Components/components-processing.md (1)

291-297: Docs expose a DataFrame output that no longer exists

SmartFunctionComponent.outputs now only contains "filtered_data", but the table still lists a dataframe output. Update the docs or re-add the output implementation to stay consistent.

src/backend/base/langflow/components/processing/smart_function.py (1)

140-142: eval on LLM-generated code is a high-risk security hole

Blindly evaluating arbitrary code from an external model can lead to RCE. At minimum, run eval with an empty __builtins__, or better, execute in a sandbox such as ast.literal_eval/numexpr, or disallow anything except list/dict comprehensions.

safe_globals: dict[str, Any] = {"__builtins__": {}}
fn = eval(lambda_text, safe_globals, {})
🧹 Nitpick comments (5)
src/backend/tests/unit/components/processing/test_lambda_filter.py (1)

10-14: Rename the test class for clarity

The class is still called TestLambdaFilterComponent, which no longer matches the component under test and will confuse future readers.

-class TestLambdaFilterComponent(ComponentTestBaseWithoutClient):
+class TestSmartFunctionComponent(ComponentTestBaseWithoutClient):
docs/docs/Components/components-processing.md (2)

24-33: Doc/image still references Lambda asset

Line 276 embeds /img/component-lambda-filter.png, but the component was renamed.
Rename the asset (or update the path) to avoid broken images and inconsistent wording.


34-34: Specify fenced-code language

Markdown-lint flags this line (```) because the language is missing.

-```
+```text
src/backend/base/langflow/components/processing/smart_function.py (2)

71-74: Method shadowing causes confusion

The method is named get_data_structure, identical to the imported helper.
Inside the body you purposefully call the global helper, but readers will expect a recursive call to self.get_data_structure.

-    def get_data_structure(self, data):
+    def _build_data_structure(self, data):
         """Extract the structure of a dictionary, replacing values with their types."""
-        return {k: get_data_structure(v) for k, v in data.items()}
+        return {k: get_data_structure(v) for k, v in data.items()}

Adjust call sites (self._build_data_structure) accordingly.


135-139: Comment contradicts code

The comment says “Validation is commented out”, yet _validate_lambda is still executed.
Either delete the call or fix the comment to reflect reality.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 706cb1e and ab8d7b1.

📒 Files selected for processing (4)
  • docs/docs/Components/components-processing.md (2 hunks)
  • src/backend/base/langflow/components/processing/__init__.py (2 hunks)
  • src/backend/base/langflow/components/processing/smart_function.py (1 hunks)
  • src/backend/tests/unit/components/processing/test_lambda_filter.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/backend/base/langflow/components/processing/__init__.py (1)
src/backend/base/langflow/components/processing/smart_function.py (1)
  • SmartFunctionComponent (16-153)
src/backend/tests/unit/components/processing/test_lambda_filter.py (1)
src/backend/base/langflow/components/processing/smart_function.py (1)
  • SmartFunctionComponent (16-153)
🪛 markdownlint-cli2 (0.17.2)
docs/docs/Components/components-processing.md

34-34: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🪛 Pylint (3.3.7)
src/backend/tests/unit/components/processing/test_lambda_filter.py

[error] 4-4: No name 'components' in module 'langflow'

(E0611)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-deploy
🔇 Additional comments (2)
src/backend/base/langflow/components/processing/__init__.py (1)

24-48: Keep __all__ in sync and alphabetically ordered

After adding SmartFunctionComponent, the list stays alphabetically correct, but remember to insert / remove entries together with their imports to avoid the drift caught above.

src/backend/tests/unit/components/processing/test_lambda_filter.py (1)

4-4: Import path triggers pylint E0611

Static analysis cannot resolve langflow.components.processing.smart_function.
If the package root is langflow, make sure it is added to PYTHONPATH in test settings; otherwise use a relative import (from ...processing.smart_function import SmartFunctionComponent) to stay package-local.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 16, 2025
@Yukiyukiyeah Yukiyukiyeah added this pull request to the merge queue Jun 16, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 16, 2025
from langflow.utils.data_structure import get_data_structure

if TYPE_CHECKING:
from collections.abc import Callable


class LambdaFilterComponent(Component):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a superbreaking change which we cannot do. Is it highly necessary to update the component name?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@edwinjosechittilappilly is renaming the class itself a breaking change if the code is refactored properly? i was under the impression that compatibility was derived from the name="filtered_data" parameter to the constructor?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If changing the name of the class, it will break the connection between a component in the canvas and their sidebar counterpart. What you can do is add the name attribute to avoid that, but the best solution is to not change the name of the class, just the display name.

cc: @edwinjosechittilappilly @Yukiyukiyeah

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The name of the component comes from the name of the class. In very old versions we got it from the name of the file, to avoid having files named OpenAIComponent we created the name attribute and set it instead to OpenAIComponent so we don't lose the connection. Now the name of the class is the standard, and the name is kept just so we serve the purpose above, so we should avoid using it to eventually remove it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you @ogabrielluiz that makes a lot of sense! I had it kind of backwards in my head.

Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly left a comment

Choose a reason for hiding this comment

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

Need confirmation since it breaks without informing, since the component class name is changes @ogabrielluiz need your consult on this

@dosubot dosubot Bot removed the lgtm This PR has been approved by a maintainer label Jun 17, 2025
@erichare erichare self-requested a review June 17, 2025 14:16
@github-actions
Copy link
Copy Markdown
Contributor

Build failure! ❌

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 18, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 18, 2025

Build successful! ✅
Deploying docs draft.
Deploy successful! View draft

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 19, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 19, 2025

Build successful! ✅
Deploying docs draft.
Deploy successful! View draft

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 20, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 20, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 20, 2025

Build successful! ✅
Deploying docs draft.
Deploy successful! View draft

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 20, 2025

Build successful! ✅
Deploying docs draft.
Deploy successful! View draft

@ogabrielluiz ogabrielluiz added the fast-track Skip tests and sends PR into the merge queue label Jun 20, 2025
@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels Jun 20, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 20, 2025

Build successful! ✅
Deploying docs draft.
Deploy successful! View draft

@edwinjosechittilappilly edwinjosechittilappilly added this pull request to the merge queue Jun 20, 2025
Merged via the queue into main with commit 9c25245 Jun 20, 2025
19 checks passed
@edwinjosechittilappilly edwinjosechittilappilly deleted the fix-smart-function branch June 20, 2025 19:03
ogabrielluiz added a commit to bkatya2001/langflow that referenced this pull request Jun 24, 2025
* change lambda filter nme

* reverse change for lambda filter

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Khurdhula-Harshavardhan pushed a commit to JigsawStack/langflow that referenced this pull request Jul 1, 2025
* change lambda filter nme

* reverse change for lambda filter

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fast-track Skip tests and sends PR into the merge queue lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants