Add IBM Watsonx CPD Chat and Embeddings Components
- add new WatsonxAIComponent for text generation, supporting both SaaS and Cloud Pak for Data deployments
- add new WatsonxEmbeddingsComponent for embedding generation with equivalent SaaS/CPD support
Summary by CodeRabbit
Release Notes
- New Features
- Added support for IBM watsonx.ai integration supporting both Cloud Pak for Data (CPD) on-premises and SaaS deployments
- Introduced configurable language model component with dynamic credential handling and model selection
- Introduced embedding generation component with multi-deployment support and customizable parameters
[!IMPORTANT]
Review skipped
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
Two new IBM watsonx.ai components are introduced: WatsonxAIComponentCPD for chat and WatsonxEmbeddingsComponentCPD for embeddings. Both support dual deployment modes (SaaS and On-Premise CPD), featuring dynamic model loading from APIs, deployment-specific credential handling, and UI field visibility adjustments based on selected deployment type.
Changes
| Cohort / File(s) | Summary |
|---|---|
IBM Watsonx.ai CPD Components src/lfx/src/lfx/components/ibm/watsonx_cpd.py, src/lfx/src/lfx/components/ibm/watsonx_embedding_cpd.py |
Added WatsonxAIComponentCPD and WatsonxEmbeddingsComponentCPD classes with model fetching from SaaS API, dynamic config updates based on deployment type (SaaS vs On-Prem CPD), credential handling for both modes, and model building with comprehensive parameter support. Both components support fallback to default model lists on API errors. |
Estimated code review effort
π― 3 (Moderate) | β±οΈ ~20 minutes
- Dynamic UI configuration logic: Verify correctness of field visibility and requirement updates based on
deployment_typechanges in both components - Credential handling branches: Ensure SaaS (API key) and CPD (username/password) authentication paths are properly differentiated and error-handled
- API error handling and fallbacks: Check that model fetching gracefully falls back to defaults and logging is appropriate
- Parameter parsing: Review JSON parsing for
logit_biasand validation of optional generation hyperparameters - Consistency between components: Verify similar patterns are implemented consistently in both chat and embedding components
Possibly related PRs
- langflow-ai/langflow#10356: Adds IBM WatsonX embedding support and model constants that align with the embedding component implementation.
- langflow-ai/langflow#10524: Modifies IBM watsonx integration for endpoint selection and UI configuration, likely related to credential and deployment mode handling.
Suggested labels
enhancement
Suggested reviewers
- lucaseduoli
- edwinjosechittilappilly
Pre-merge checks and finishing touches
[!IMPORTANT]
Pre-merge checks failed
Please resolve all errors before merging. Addressing warnings is optional.
β Failed checks (2 warnings, 2 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Test Quality And Coverage | β οΈ Warning | No test files added for WatsonxAIComponentCPD and WatsonxEmbeddingsComponentCPD components with complex API integration and credential handling logic. | Add comprehensive pytest test files covering fetch_models(), update_build_config(), build_model()/build_embeddings() methods with mocking for API calls and credential scenarios. |
| Test File Naming And Structure | β οΈ Warning | Pull request adds two new components (WatsonxAIComponentCPD and WatsonxEmbeddingsComponentCPD) but includes no corresponding test files following the test_*.py naming convention in tests/components/ibm/ directory. | Add test_watsonx_cpd.py and test_watsonx_embedding_cpd.py in tests/components/ibm/ with comprehensive pytest coverage for initialization, model fetching, configuration updates, and credential handling. |
| Test Coverage For New Implementations | β Inconclusive | Component files (watsonx_cpd.py, watsonx_embedding_cpd.py) could not be located in repository despite extensive searching, preventing assessment of test coverage. | Verify PR branch is checked out and component files are accessible; then confirm test files exist in standard test directory following naming convention test_watsonx_cpd.py and test_watsonx_embedding_cpd.py. |
| Excessive Mock Usage Warning | β Inconclusive | No test files found for the new WatsonxAIComponentCPD and WatsonxEmbeddingsComponentCPD components to assess mock usage patterns. | Locate or provide test files for these components to evaluate mock usage; if no tests exist, add appropriate unit tests using minimal mocking for external dependencies only. |
β Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title accurately describes the main additions: two new IBM Watsonx components for CPD with chat and embeddings functionality. |
| Docstring Coverage | β Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
[!TIP]
π Customizable high-level summaries are now available in beta!
You can now customize how CodeRabbit generates the high-level summary in your pull requests β including its content, structure, tone, and formatting.
- Provide your own instructions using the
high_level_summary_instructionssetting.- Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
- Use
high_level_summary_in_walkthroughto move the summary from the description to the walkthrough section.Example instruction:
"Divide the high-level summary into five sections:
- π Description β Summarize the main change in 50β60 words, explaining what was done.
- π References β List relevant issues, discussions, documentation, or related PRs.
- π¦ Dependencies & Requirements β Mention any new/updated dependencies, environment variable changes, or configuration updates.
- π Contributor Summary β Include a Markdown table showing contributions:
| Contributor | Lines Added | Lines Removed | Files Changed |- βοΈ Additional Notes β Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
@Empreiteiro could you take a look at the ruff errors listed? if you go to the Files changed tab it should show them.
Also, maybe a quick test for the two components? Looks good to me otherwise!
@erichare, I corrected ruff's errors.
Can you help me with the tests? I've never created tests for components before. Help me with these so I can do them in the future!