From 4c541b38fd8b30d13deeea7795a543732a6dc0ad Mon Sep 17 00:00:00 2001 From: ccurme Date: Mon, 16 Sep 2024 18:52:24 -0400 Subject: [PATCH] ibm[patch]: fix validation errors for WatsonxLLM when initializing from Model object (#22) * fix * fix space_id --- libs/ibm/langchain_ibm/llms.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libs/ibm/langchain_ibm/llms.py b/libs/ibm/langchain_ibm/llms.py index 51779f2..355a65a 100644 --- a/libs/ibm/langchain_ibm/llms.py +++ b/libs/ibm/langchain_ibm/llms.py @@ -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")