Skip to content

Commit

Permalink
ibm[patch]: fix validation errors for WatsonxLLM when initializing fr…
Browse files Browse the repository at this point in the history
…om Model object (#22)

* fix

* fix space_id
  • Loading branch information
ccurme authored Sep 16, 2024
1 parent 73ebbe5 commit 4c541b3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions libs/ibm/langchain_ibm/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,19 @@ def validate_environment(cls, values: Dict) -> Any:
"""Validate that credentials and python package exists in environment."""
if isinstance(values.get("watsonx_model"), (ModelInference, Model)):
values["model_id"] = getattr(values["watsonx_model"], "model_id")
values["deployment_id"] = getattr(
values["watsonx_model"], "deployment_id", ""
values["deployment_id"] = (
getattr(values["watsonx_model"], "deployment_id", "") or ""
)
values["project_id"] = getattr(
getattr(values["watsonx_model"], "_client"),
"default_project_id",
values["project_id"] = (
getattr(
getattr(values["watsonx_model"], "_client"),
"default_project_id",
)
or ""
)
values["space_id"] = getattr(
getattr(values["watsonx_model"], "_client"), "default_space_id"
values["space_id"] = (
getattr(getattr(values["watsonx_model"], "_client"), "default_space_id")
or ""
)
values["params"] = getattr(values["watsonx_model"], "params")

Expand Down

0 comments on commit 4c541b3

Please sign in to comment.