IBM watsonx.ai
WatsonxEmbeddings is a wrapper for IBM watsonx.ai foundation models.
This example shows how to communicate with watsonx.ai
models using LangChain
.
Overview
Integration details
Provider | Package |
---|---|
IBM | langchain-ibm |
Setup
To access IBM watsonx.ai models you'll need to create an IBM watsonx.ai account, get an API key, and install the langchain-ibm
integration package.
Credentials
This cell defines the WML credentials required to work with watsonx Embeddings.
Action: Provide the IBM Cloud user API key. For details, see documentation.
import os
from getpass import getpass
watsonx_api_key = getpass()
os.environ["WATSONX_APIKEY"] = watsonx_api_key
Additionaly you are able to pass additional secrets as an environment variable.
import os
os.environ["WATSONX_URL"] = "your service instance url"
os.environ["WATSONX_TOKEN"] = "your token for accessing the CPD cluster"
os.environ["WATSONX_PASSWORD"] = "your password for accessing the CPD cluster"
os.environ["WATSONX_USERNAME"] = "your username for accessing the CPD cluster"
os.environ["WATSONX_INSTANCE_ID"] = "your instance_id for accessing the CPD cluster"
Installation
The LangChain IBM integration lives in the langchain-ibm
package:
!pip install -qU langchain-ibm