-
Notifications
You must be signed in to change notification settings - Fork 8.1k
feat: add watsonx governance component #10728
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
base: main
Are you sure you want to change the base?
Conversation
…ple, but it doesnt work
… needed for api calls
WalkthroughAdded two new IBM Cloud dependencies to the project, registered a new Changes
Sequence DiagramsequenceDiagram
participant Client as Client Code
participant Component as WatsonxGovernanceComponent
participant IAM as IBM Cloud Identity
participant Governance as watsonx.governance API
Client->>Component: execute_call()
activate Component
Component->>Component: get_token()
activate Component
Component->>IAM: POST /identity/token (api_key)
IAM-->>Component: access_token
deactivate Component
Component->>Component: format_prompt_vars()
Component-->>Component: formatted_vars (dict)
Component->>Component: build request payload
Component->>Governance: POST /deployments/{deployment_id}/governance (auth header, payload)
activate Governance
Governance-->>Component: response
deactivate Governance
Component-->>Client: Data(text, payload)
deactivate Component
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Example instruction:
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 |
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
pyproject.toml (1)
134-135: Confirm IBM dependencies are needed and ensurerequestsis a declared runtime dependency where usedThe new IBM deps look consistent with the feature, but the current watsonx governance component uses
requestsdirectly and doesn’t appear to import eitheribm-cloud-sdk-coreoribm-watson-openscale.Two follow‑ups worth doing:
- If the component is not (yet) using these IBM SDKs, consider dropping them for now to avoid unnecessary weight and security surface, or wire the component up to use them instead of raw HTTP.
- Make sure the package that owns
src/lfx/src/lfx/components/ibm/watsonx_governance.pydeclaresrequestsas a runtime dependency (not just in thedevgroup), so this component can’t fail at import/runtime in environments whererequestsis not pulled in transitively.src/lfx/src/lfx/components/ibm/watsonx_governance.py (2)
73-145: Tighten error handling and logging behavior around the governance callThe overall structure of
execute_callis solid (timeouts, HTTP error handling, logging response body), but there are a couple of smaller refinement opportunities:
- The
except json.JSONDecodeErrorblock after the maintryis currently unreachable, since JSON parsing is already wrapped in an innertry/except ValueErroraroundresponse.json(). You can safely drop that outerexcept json.JSONDecodeErroror repurpose it if you later add ajson.loadson the response.- You’re logging full payloads and responses at
INFOlevel. For a governance component that may see sensitive prompts and generations, you might want this atDEBUGor behind a flag to avoid duplicating potentially sensitive content in application logs on top of sending it to governance.These are non‑blocking, but worth considering for maintainability and privacy posture.
147-155: Alignformat_prompt_varsdocstring with the actual signatureThe docstring still documents a
user_inputargument, but the method doesn’t take any parameters and usesself.prompt_variablesinstead. This is a small mismatch that can confuse users and tooling.Consider updating the docstring to reflect that the input comes from
self.prompt_variablesand drop theArgssection or reword it accordingly.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
src/frontend/package-lock.jsonis excluded by!**/package-lock.jsonuv.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
pyproject.toml(1 hunks)src/lfx/src/lfx/components/ibm/__init__.py(1 hunks)src/lfx/src/lfx/components/ibm/watsonx_governance.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{pyproject.toml,uv.lock}
📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)
Use
uv(>=0.4) for Python dependency management in backend development
Files:
pyproject.toml
🧠 Learnings (1)
📚 Learning: 2025-11-24T19:46:09.074Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-11-24T19:46:09.074Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update `__init__.py` with alphabetically sorted imports when adding new components
Applied to files:
src/lfx/src/lfx/components/ibm/__init__.py
🧬 Code graph analysis (1)
src/lfx/src/lfx/components/ibm/__init__.py (1)
src/lfx/src/lfx/components/ibm/watsonx_governance.py (1)
WatsonxGovernanceComponent(14-184)
🔇 Additional comments (2)
src/lfx/src/lfx/components/ibm/__init__.py (1)
7-19: Lazy‑loader wiring forWatsonxGovernanceComponentlooks correctTYPE_CHECKING import,
_dynamic_importsentry, and__all__update are consistent and should integrate the new component cleanly into the IBM namespace.src/lfx/src/lfx/components/ibm/watsonx_governance.py (1)
60-96: Based on my verification, I've searched the repository thoroughly and found that:
- The file
src/lfx/src/lfx/components/ibm/watsonx_governance.pydoes not exist in the repository- None of the methods referenced exist:
get_token(),execute_call(),format_prompt_vars()are not in the codebase- The attribute
deployment_idis not referenced anywhere in the IBM componentsThe IBM components directory (
src/lfx/src/lfx/components/ibm/) contains only:
watsonx.py(WatsonxAIComponent)watsonx_embeddings.py(WatsonxEmbeddingsComponent)__init__.pyThe review comment references code that does not exist in the current PR branch.
Likely an incorrect or invalid review comment.
|
This is interesting, looking forward to this component. |
Created a custom component under the ibm folder for integrating with IBM watsonx governance to detect and catalog harmful AI inputs/outputs accordingly.
Summary by CodeRabbit
New Features
Dependencies
✏️ Tip: You can customize this high-level summary in your review settings.