From cbbf8cfe5d02ee6e9545cc7190b09acac9d89f72 Mon Sep 17 00:00:00 2001 From: Marcelo Date: Wed, 4 Sep 2024 14:30:57 -0300 Subject: [PATCH 1/2] docs: Small improvement ChatWatsonx setup description --- libs/ibm/langchain_ibm/chat_models.py | 37 +++++++++++++++++---------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/libs/ibm/langchain_ibm/chat_models.py b/libs/ibm/langchain_ibm/chat_models.py index f30d0dc..fb7574c 100644 --- a/libs/ibm/langchain_ibm/chat_models.py +++ b/libs/ibm/langchain_ibm/chat_models.py @@ -286,12 +286,19 @@ class _FunctionCall(TypedDict): class ChatWatsonx(BaseChatModel): - """ - IBM watsonx.ai large language chat models. + """IBM watsonx.ai large language chat models. + + .. dropdown:: Setup + :open: + + To use, you should have ``langchain_ibm`` python package installed, + and the environment variable ``WATSONX_APIKEY`` set with your API key, or pass + it as a named parameter to the constructor. + + .. code-block:: bash - To use, you should have ``langchain_ibm`` python package installed, - and the environment variable ``WATSONX_APIKEY`` set with your API key, or pass - it as a named parameter to the constructor. + pip install -U langchain-ibm + export WATSONX_APIKEY="your-api-key" Example: @@ -464,15 +471,17 @@ def validate_environment(cls, values: Dict) -> Dict: url=values["url"].get_secret_value() if values["url"] else None, api_key=values["apikey"].get_secret_value() if values["apikey"] else None, token=values["token"].get_secret_value() if values["token"] else None, - password=values["password"].get_secret_value() - if values["password"] - else None, - username=values["username"].get_secret_value() - if values["username"] - else None, - instance_id=values["instance_id"].get_secret_value() - if values["instance_id"] - else None, + password=( + values["password"].get_secret_value() if values["password"] else None + ), + username=( + values["username"].get_secret_value() if values["username"] else None + ), + instance_id=( + values["instance_id"].get_secret_value() + if values["instance_id"] + else None + ), version=values["version"].get_secret_value() if values["version"] else None, verify=values["verify"], ) From 6d8878e9c1e9d284ad5f2877e644017a72089c2d Mon Sep 17 00:00:00 2001 From: Marcelo Date: Wed, 4 Sep 2024 14:48:36 -0300 Subject: [PATCH 2/2] docs: Small improvement chat models description --- libs/ibm/langchain_ibm/chat_models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/ibm/langchain_ibm/chat_models.py b/libs/ibm/langchain_ibm/chat_models.py index fb7574c..7d45455 100644 --- a/libs/ibm/langchain_ibm/chat_models.py +++ b/libs/ibm/langchain_ibm/chat_models.py @@ -1,3 +1,5 @@ +"""IBM watsonx.ai large language chat models wrapper.""" + import json import logging import os