Skip to content

Combine all Cleanlab bundle components into one and update documentation#10067

Open
cmauck10 wants to merge 9 commits into
langflow-ai:mainfrom
cmauck10:cmauck10/cleanlab
Open

Combine all Cleanlab bundle components into one and update documentation#10067
cmauck10 wants to merge 9 commits into
langflow-ai:mainfrom
cmauck10:cmauck10/cleanlab

Conversation

@cmauck10
Copy link
Copy Markdown
Contributor

@cmauck10 cmauck10 commented Oct 1, 2025

Summary

Consolidates Cleanlab into a single component and refreshes docs/assets to match the new workflow.

What’s in this PR

  • Cleanlab component refactor
    • Added src/lfx/src/lfx/components/cleanlab/cleanlab.py (unified component)
    • Removed cleanlab_evaluator.py, cleanlab_rag_evaluator.py, cleanlab_remediator.py
    • Updated pyproject.toml and uv.lock
  • Docs and assets
    • Rewrote docs/docs/Components/bundles-cleanlab.mdx for the new flow
    • Replaced docs/static/files/eval_and_remediate_cleanlab.json with docs/static/files/cleanlab_quickstart_rag_flow.json
    • Added images under docs/static/img/* (validation, guardrails, remediation, flow)

Breaking changes

  • Legacy Cleanlab evaluator/remediator components removed.

Migration

  • Replace old Cleanlab nodes with the new Cleanlab component.
  • Use docs/static/files/cleanlab_quickstart_rag_flow.json as a wiring reference.

Summary by CodeRabbit

  • New Features
    • Introduced a unified Cleanlab component that validates model outputs and remediates issues with expert answers or fallback responses.
  • Documentation
    • Revamped Cleanlab integration docs with a streamlined intro, Quickstart, example flows, visuals, and guardrails/evaluations guidance. Removed exhaustive parameter tables and updated screenshots and user journey.
  • Refactor
    • Consolidated multiple Cleanlab evaluator/remediator components into a single component and removed the legacy workflow asset.
  • Chores
    • Added new runtime dependencies to support the updated Cleanlab integration and related functionality.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 1, 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

Consolidates Cleanlab integration by removing separate evaluator/remediator components and introducing a single Cleanlab component, updates docs to a unified guardrails/remediation narrative with Quickstart, deletes a legacy example JSON flow, and adds dependencies cleanlab-codex and langchain-voyageai.

Changes

Cohort / File(s) Summary of Changes
Docs overhaul (Cleanlab)
docs/docs/Components/bundles-cleanlab.mdx
Rewrote docs to a unified Cleanlab component narrative, added Quickstart, examples, visuals, and guardrails/remediation guidance; removed detailed evaluator/remediator params and outputs.
Example flow removal
docs/static/files/eval_and_remediate_cleanlab.json
Deleted serialized example workflow defining evaluator/remediator nodes and edges.
Dependencies
pyproject.toml
Added runtime dependencies: cleanlab-codex>=1.0.29, langchain-voyageai>=0.1.7.
Cleanlab component consolidation
src/lfx/src/lfx/components/cleanlab/__init__.py, src/lfx/src/lfx/components/cleanlab/cleanlab.py, src/lfx/src/lfx/components/cleanlab/cleanlab_evaluator.py, src/lfx/src/lfx/components/cleanlab/cleanlab_rag_evaluator.py, src/lfx/src/lfx/components/cleanlab/cleanlab_remediator.py
Exposed single Cleanlab component via lazy import; added new Cleanlab class handling validation/remediation; removed CleanlabEvaluator, CleanlabRAGEvaluator, CleanlabRemediator classes and files; updated __all__ to ["Cleanlab"].

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Langflow as Langflow Flow
  participant CleanlabCmp as Cleanlab Component
  participant CLAPI as Cleanlab API (Project)

  User->>Langflow: Provide query/input
  Langflow->>CleanlabCmp: response, query, context, system_message, api_key
  CleanlabCmp->>CLAPI: Project.from_access_key(api_key)
  CleanlabCmp->>CLAPI: validate(messages, response, query, context)
  CLAPI-->>CleanlabCmp: result {is_bad_response, expert_answer?}
  alt Acceptable response
    CleanlabCmp-->>Langflow: final_response = original response (status: accepted)
  else Bad response + expert answer
    CleanlabCmp-->>Langflow: final_response = expert answer (status: remediated_expert)
  else Bad response, no expert answer
    CleanlabCmp-->>Langflow: final_response = fallback_text (status: remediated_fallback)
  end
  Langflow-->>User: Final response
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

enhancement, refactor, size:XXL

Suggested reviewers

  • mfortman11
  • mendonk
  • erichare

Pre-merge checks and finishing touches

❌ Failed checks (1 error, 4 warnings)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error I searched the PR’s repository for added or updated tests and for any tests referencing the new Cleanlab component. The results show no Python or TypeScript test files that import or exercise lfx.components.cleanlab.Cleanlab, no tests calling get_final_response, and no newly added tests related to this component; there are also no replacements for tests that previously targeted the removed CleanlabEvaluator/CleanlabRAGEvaluator/CleanlabRemediator classes. Given a new component with user-facing behavior was introduced and older components were removed, the PR lacks corresponding unit/integration tests or migration of prior tests to cover the unified component. Add unit tests for the new Cleanlab component that cover: happy path (acceptable response returned), remediation via expert answer, and fallback path when flagged without expert answer; include tests for optional system_message and missing/empty context handling. Provide an integration-style test wiring the component with minimal stubs/mocks of the Cleanlab API (Project.validate) to verify message construction and status outputs. If tests existed for the removed components, migrate or replace them to target the new Cleanlab behavior, and ensure files follow test_*.py naming.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Test Quality And Coverage ⚠️ Warning I searched the repository for pytest tests and any references to the new Cleanlab component and found no test files targeting src/lfx/src/lfx/components/cleanlab/cleanlab.py, nor tests that validate its behavior, success/error paths, or fallback/expert answer logic. There are also no async functions in this component to warrant async testing checks, and I did not find API endpoints or corresponding tests affected by this PR. Given the removal of prior evaluator/remediator components and addition of a new unified Cleanlab component, the absence of tests means the main functionality is not covered and behavior is not verified beyond smoke-level presence. Therefore, the PR does not meet the stated testing quality and coverage requirements for new implementations. Add pytest tests for the Cleanlab component covering: (1) acceptable response path returns original response; (2) flagged response with expert_answer returns that answer; (3) flagged response without expert_answer returns fallback_text; (4) error handling when Project.from_access_key or project.validate raises (use monkeypatch to stub Cleanlab SDK). Use Message factory/fixtures to construct inputs and assert status strings and final_response content, and include at least one test with optional system_message/context provided and omitted. If any API surface is async in future, adopt pytest-asyncio patterns accordingly.
Test File Naming And Structure ⚠️ Warning I scanned the repository for test files and structures using ripgrep and fd to locate Python pytest files (def test_*), TypeScript/TSX *.test.ts(x) files, Playwright usage, integration/e2e markers, and setup/teardown patterns. The search did not reveal any backend pytest files, frontend *.test.ts/tsx files, Playwright-based tests, or clearly marked integration/e2e directories or markers, nor supporting configs/scripts for Playwright in package.json. Given the absence of discoverable tests, I cannot verify naming conventions, descriptive test names, setup/teardown practices, or coverage of positive/negative scenarios and edge cases as required by the check. Therefore, the repository does not meet the specified test naming and structure requirements for this PR as it currently stands. Add backend pytest files named test_*.py for the new Cleanlab component (cover success, expert remediation, and fallback paths, plus error handling), and place any integration tests in a clearly named directory (e.g., tests/integration) with @pytest.mark.integration. For the frontend, include Playwright-based *.test.ts/tsx files where applicable and ensure package.json scripts and a playwright.config.ts are present. Use descriptive test function names, fixtures for setup/teardown, and include both positive and negative scenarios with edge cases to satisfy the check.
Excessive Mock Usage Warning ⚠️ Warning
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the primary change of unifying all Cleanlab bundle components into one and also notes the accompanying updates to documentation, directly reflecting the key objectives and file modifications in the pull request. It is clear, specific, and concise enough for teammates to understand the core purpose without extraneous details or ambiguous phrasing.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/docs/Components/bundles-cleanlab.mdx (1)

1-4: Add required description field to front matter.

Per coding guidelines, all Markdown/MDX pages must include at least title and description in front matter. Consider also adding sidebar_position if this page should appear in a specific order within the docs navigation.

Apply this diff:

 ---
 title: Cleanlab
 slug: /bundles-cleanlab
+description: Integrate Cleanlab with Langflow to add trustworthy evaluation and remediation to your AI pipelines.
+sidebar_position: X
 ---

Replace X with the appropriate position number for this page in the Components section.

🧹 Nitpick comments (1)
src/lfx/src/lfx/components/cleanlab/cleanlab.py (1)

114-122: Consider validating required input content is non-empty.

The method uses self.input, self.response, and self.query directly without checking if they contain meaningful content. While these inputs are marked as required=True, a Message object can have empty or None text.

Consider adding validation at the start of the method to provide clearer error messages:

def get_final_response(self) -> Message:
    # Validate required inputs
    if not self.input or not str(self.input).strip():
        raise ValueError("Input message cannot be empty")
    if not self.response or not str(self.response).strip():
        raise ValueError("Model response cannot be empty")
    if not self.query or not str(self.query).strip():
        raise ValueError("User query cannot be empty")
    
    project = Project.from_access_key(self.api_key)
    # ... rest of method

This provides better user feedback if the component is wired incorrectly.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7382ac8 and b4310b4.

⛔ Files ignored due to path filters (16)
  • docs/static/img/cleanlab-add-remediation.png is excluded by !**/*.png
  • docs/static/img/cleanlab-ai-platform.png is excluded by !**/*.png
  • docs/static/img/cleanlab-expert-answer.png is excluded by !**/*.png
  • docs/static/img/cleanlab-fallback.png is excluded by !**/*.png
  • docs/static/img/cleanlab-flow-example.png is excluded by !**/*.png
  • docs/static/img/cleanlab-politics-guardrail.png is excluded by !**/*.png
  • docs/static/img/cleanlab-politics-guardrailed-chat.png is excluded by !**/*.png
  • docs/static/img/cleanlab-politics-guardrailed.png is excluded by !**/*.png
  • docs/static/img/cleanlab-response-passed-validation.png is excluded by !**/*.png
  • docs/static/img/cleanlab-wrong-response.png is excluded by !**/*.png
  • docs/static/img/cleanlab_remediator_example.png is excluded by !**/*.png
  • docs/static/img/cleanlab_remediator_example_fallback.png is excluded by !**/*.png
  • docs/static/img/eval_rag.png is excluded by !**/*.png
  • docs/static/img/eval_response.png is excluded by !**/*.png
  • docs/static/img/eval_summary_rag.png is excluded by !**/*.png
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • docs/docs/Components/bundles-cleanlab.mdx (1 hunks)
  • docs/static/files/eval_and_remediate_cleanlab.json (0 hunks)
  • pyproject.toml (1 hunks)
  • src/lfx/src/lfx/components/cleanlab/__init__.py (1 hunks)
  • src/lfx/src/lfx/components/cleanlab/cleanlab.py (1 hunks)
  • src/lfx/src/lfx/components/cleanlab/cleanlab_evaluator.py (0 hunks)
  • src/lfx/src/lfx/components/cleanlab/cleanlab_rag_evaluator.py (0 hunks)
  • src/lfx/src/lfx/components/cleanlab/cleanlab_remediator.py (0 hunks)
💤 Files with no reviewable changes (4)
  • docs/static/files/eval_and_remediate_cleanlab.json
  • src/lfx/src/lfx/components/cleanlab/cleanlab_rag_evaluator.py
  • src/lfx/src/lfx/components/cleanlab/cleanlab_evaluator.py
  • src/lfx/src/lfx/components/cleanlab/cleanlab_remediator.py
🧰 Additional context used
📓 Path-based instructions (2)
docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (.cursor/rules/docs_development.mdc)

docs/**/*.{md,mdx}: All Markdown/MDX pages must start with front matter including at least title and description; include sidebar_position for docs pages when applicable
Code blocks must specify a language and may include a title (```lang title="…")
Use sentence case for headings and keep paragraphs short and scannable
Write in second person, present tense, with a professional but approachable tone
Use inline code with backticks for code terms; use bold for UI elements and italics for emphasis; keep lists in parallel structure
Ensure internal links are functional and navigation works (update cross-references as needed)
Verify all code examples in docs and blog actually run as shown
Use correct terminology capitalization: Langflow, Component, Flow, API, JSON
Reference images with absolute paths under /img/... and provide descriptive alt text

Files:

  • docs/docs/Components/bundles-cleanlab.mdx
docs/docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (.cursor/rules/docs_development.mdc)

Use Docusaurus admonitions (:::+tip|warning|danger) instead of custom callouts in docs pages

Files:

  • docs/docs/Components/bundles-cleanlab.mdx
🧬 Code graph analysis (2)
src/lfx/src/lfx/components/cleanlab/cleanlab.py (1)
src/lfx/src/lfx/schema/message.py (1)
  • Message (34-293)
src/lfx/src/lfx/components/cleanlab/__init__.py (1)
src/lfx/src/lfx/components/cleanlab/cleanlab.py (1)
  • Cleanlab (13-133)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Test Docs Build / Test Docs Build
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
  • GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
  • GitHub Check: Test Starter Templates
🔇 Additional comments (3)
docs/docs/Components/bundles-cleanlab.mdx (1)

50-108: LGTM: Image references follow guidelines.

All image paths use absolute /img/... paths with descriptive alt text as required by the coding guidelines.

src/lfx/src/lfx/components/cleanlab/__init__.py (1)

8-16: LGTM: API surface correctly consolidated.

The public API has been properly updated to expose a single Cleanlab component instead of three separate components (CleanlabEvaluator, CleanlabRAGEvaluator, CleanlabRemediator). The lazy-loading pattern is maintained correctly.

src/lfx/src/lfx/components/cleanlab/cleanlab.py (1)

109-133: Consider adding error handling for external API calls.

The get_final_response method calls external Cleanlab API methods (Project.from_access_key and project.validate) without error handling. If these calls fail (e.g., invalid API key, network issues, service unavailable), the component will raise an unhandled exception.

Consider whether error handling should be added to provide more graceful degradation. For example:

def get_final_response(self) -> Message:
    try:
        project = Project.from_access_key(self.api_key)
        
        # Build messages for validate()
        messages = []
        if getattr(self, "system_message", None):
            messages.append({"role": "system", "content": self.system_message})
        messages.append({"role": "user", "content": self.input})
        
        result = project.validate(
            messages=messages,
            response=self.response,
            query=self.query,
            context=self.context if getattr(self, "context", None) else "",
        )
        
        if result.is_bad_response:
            if result.expert_answer:
                self.status = "Bad response replaced with expert answer."
                return Message(text=result.expert_answer)
            self.status = "Bad response with no expert answer. Using fallback."
            return Message(text=self.fallback_text)
        
        self.status = "Original response accepted."
        return Message(text=self.response)
    except Exception as e:
        self.status = f"Cleanlab validation failed: {e}. Returning original response."
        return Message(text=self.response)

Verify whether the Langflow framework already handles component exceptions appropriately, or if explicit error handling is expected.

Comment thread docs/docs/Components/bundles-cleanlab.mdx Outdated
Comment thread pyproject.toml Outdated
Comment thread src/lfx/src/lfx/components/cleanlab/cleanlab.py
- Add unified Cleanlab component replacing separate evaluator/remediator
- Update pyproject.toml and uv.lock dependencies
- Rewrite bundles-cleanlab.mdx with new flow examples and assets
- Fix linting issues (docstring D205, line length E501)
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Oct 1, 2025

@@ -8,133 +8,145 @@ import PartialParams from '@site/docs/_partial-hidden-params.mdx';

[Cleanlab](https://www.cleanlab.ai/) adds automation and trust to every data point going in and every prediction coming out of AI and RAG solutions.

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.

I can edit this page after the PR is merged, but we use the Google Developer Documentation Style Guide as our primary style guide. This page doesn't follow a few of the main style points with respect to second person, present tense, and sentence case for headings.

Additionally, please look at some of the other bundle pages to see how we structure the information on these pages. Since you have a multi-purpose component here, you might use the Composio page for inspiration.

Finally, I would suggest linking to your own Cleanlab documentation (such as this and this) as much as possible for the explanations of the functionality. This document doesn't need to teach users how Cleanlab works; it should focus on configuring the Langflow Cleanlab component only. This future-proofs the page because you won't need to remember to update it if the Cleanlab UI or functionality change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants