-
Notifications
You must be signed in to change notification settings - Fork 8.3k
fix: valdiate watsonX key #11264
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?
fix: valdiate watsonX key #11264
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -319,9 +319,18 @@ | |||
| llm = ChatGoogleGenerativeAI(google_api_key=api_key, model=first_model, max_tokens=1) | ||||
| llm.invoke("test") | ||||
| elif provider == "IBM WatsonX": | ||||
| # WatsonX validation would require additional parameters | ||||
| # Skip for now as it needs project_id, url, etc. | ||||
| return | ||||
| from langchain_ibm import ChatWatsonx | ||||
|
|
||||
| default_url = "https://us-south.ml.cloud.ibm.com" | ||||
| llm = ChatWatsonx( | ||||
| apikey=api_key, | ||||
| url=default_url, | ||||
| model_id=first_model, | ||||
| project_id="dummy_project_for_validation", # Dummy project_id for validation | ||||
| params={"max_new_tokens": 1}, | ||||
| ) | ||||
| llm.invoke("test") | ||||
|
|
||||
|
||||
🧰 Tools
🪛 GitHub Actions: Ruff Style Check
[error] 333-333: Ruff: W293 Blank line contains whitespace. Command: uv run --only-dev ruff check --output-format=github .
🪛 GitHub Check: Ruff Style Check (3.13)
[failure] 333-333: Ruff (W293)
src/lfx/src/lfx/base/models/unified_models.py:333:1: W293 Blank line contains whitespace
🤖 Prompt for AI Agents
In @src/lfx/src/lfx/base/models/unified_models.py at line 333, Remove the
trailing whitespace on the blank line causing Ruff W293 in
src/lfx/src/lfx/base/models/unified_models.py (around the reported location near
line 333); delete the spaces on that empty line so it's truly empty, then re-run
ruff/formatting (or pre-commit) to confirm the W293 warning is resolved.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 80
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 1303
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 106
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 3381
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 46
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 107
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 46
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 974
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 46
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 150
🌐 Web query:
ChatWatsonx langchain-ibm 0.3 0.2 API parameters apikey url project_id initialization💡 Result:
Short answer — how to initialize ChatWatsonx (langchain-ibm v0.2/0.3):
Required identification/auth:
Typical Python instantiation (example):
from langchain_ibm import ChatWatsonx
from ibm_watsonx_ai.foundation_models.schema import TextChatParameters
parameters = TextChatParameters(temperature=0.5, top_p=1, max_completion_tokens=None)
chat = ChatWatsonx(
model_id="ibm/granite-34b-code-instruct", # or deployment_id
url="https://us-south.ml.cloud.ibm.com",
project_id="YOUR_PROJECT_ID",
api_key="YOUR_API_KEY", # or rely on WATSONX_API_KEY env var
params=parameters,
) [1][2]
Notes:
Sources:
[1] LangChain docs — IBM watsonx.ai (Python) (ChatWatsonx examples & notes).
[2] LangChain reference — ChatWatsonx API (fields: api_key, url, project_id, params; deprecation note).
[3] LangChain (JS) / community Watsonx examples (serviceUrl, projectId/spaceId/deployment).
🏁 Script executed:
Repository: langflow-ai/langflow
Length of output: 549
Fix deprecated
apikeyparameter and unreliable WatsonX validation logic.The
ChatWatsonxconstructor uses deprecated parameterapikey=(line 326); langchain-ibm v0.2/0.3+ requiresapi_key=. Additionally, hardcodingurl="https://us-south.ml.cloud.ibm.com"and using dummyproject_id="dummy_project_for_validation"means the validation will fail even for valid keys (wrong region, invalid project), making this check unreliable. Yourexcept Exceptionhandler will treat those failures as "network issues" and allow saving anyway, defeating the purpose.Consider validating the IBM Cloud API key directly (IAM token exchange) without requiring a real project context, or accept actual project credentials from the user configuration.
Proposed fix
Also fix line 333: Ruff W293 (blank line contains whitespace).
📝 Committable suggestion
🧰 Tools
🪛 GitHub Actions: Ruff Style Check
[error] 333-333: Ruff: W293 Blank line contains whitespace. Command: uv run --only-dev ruff check --output-format=github .
🪛 GitHub Check: Ruff Style Check (3.13)
[failure] 333-333: Ruff (W293)
src/lfx/src/lfx/base/models/unified_models.py:333:1: W293 Blank line contains whitespace