WatsonxEmbeddings#

class langchain_ibm.embeddings.WatsonxEmbeddings[source]#

Bases: BaseModel, Embeddings

IBM watsonx.ai embedding models.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

param apikey: SecretStr | None [Optional]#

API key to the Watson Machine Learning or CPD instance.

param instance_id: SecretStr | None [Optional]#

Instance_id of the CPD instance.

param model: str | None = None#

Name or alias of the foundation model to use. When using IBM’s watsonx.ai Model Gateway (public preview), you can specify any supported third-party model—OpenAI, Anthropic, NVIDIA, Cerebras, or IBM’s own Granite series—via a single, OpenAI-compatible interface. Models must be explicitly provisioned (opt-in) through the Gateway to ensure secure, vendor-agnostic access and easy switch-over without reconfiguration.

For more details on configuration and usage, see IBM watsonx Model Gateway docs: https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-model-gateway.html?context=wx&audience=wdp

param model_id: str | None = None#

Type of model to use.

param params: Dict | None = None#

Model parameters to use during request generation.

param password: SecretStr | None [Optional]#

Password to the CPD instance.

param project_id: str | None = None#

ID of the Watson Studio project.

param space_id: str | None = None#

ID of the Watson Studio space.

param token: SecretStr | None [Optional]#

Token to the CPD instance.

param url: SecretStr [Optional]#

URL to the Watson Machine Learning or CPD instance.

param username: SecretStr | None [Optional]#

Username to the CPD instance.

param verify: str | bool | None = None#

You can pass one of following as verify: * the path to a CA_BUNDLE file * the path of directory with certificates of trusted CAs * True - default path to truststore will be taken * False - no verification will be made

param version: SecretStr | None = None#

Version of the CPD instance.

async aembed_documents(
texts: List[str],
**kwargs: Any,
) List[List[float]][source]#

Asynchronous Embed search docs.

Parameters:
  • texts (List[str])

  • kwargs (Any)

Return type:

List[List[float]]

async aembed_query(
text: str,
**kwargs: Any,
) List[float][source]#

Asynchronous Embed query text.

Parameters:
  • text (str)

  • kwargs (Any)

Return type:

List[float]

embed_documents(
texts: List[str],
**kwargs: Any,
) List[List[float]][source]#

Embed search docs.

Parameters:
  • texts (List[str])

  • kwargs (Any)

Return type:

List[List[float]]

embed_query(
text: str,
**kwargs: Any,
) List[float][source]#

Embed query text.

Parameters:
  • text (str)

  • kwargs (Any)

Return type:

List[float]