langchain_community.llms.watsonxllm.WatsonxLLM¶
class langchain_community.llms.watsonxllm.WatsonxLLM[source]¶
Bases: BaseLLM
IBM watsonx.ai large language models.
To use, you should have ibm_watson_machine_learning python package installed,
and the environment variable WATSONX_APIKEY set with your API key, or pass
it as a named parameter to the constructor.
Example
from ibm_watson_machine_learning.metanames import GenTextParamsMetaNames
parameters = {
    GenTextParamsMetaNames.DECODING_METHOD: "sample",
    GenTextParamsMetaNames.MAX_NEW_TOKENS: 100,
    GenTextParamsMetaNames.MIN_NEW_TOKENS: 1,
    GenTextParamsMetaNames.TEMPERATURE: 0.5,
    GenTextParamsMetaNames.TOP_K: 50,
    GenTextParamsMetaNames.TOP_P: 1,
}
from langchain_community.llms import WatsonxLLM
llm = WatsonxLLM(
    model_id="google/flan-ul2",
    url="https://us-south.ml.cloud.ibm.com",
    apikey="*****",
    project_id="*****",
    params=parameters,
)
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param apikey: Optional[pydantic.types.SecretStr] = None¶
Apikey to Watson Machine Learning instance
Constraints
type = string
writeOnly = True
format = password
param cache: Optional[bool] = None¶
param callback_manager: Optional[BaseCallbackManager] = None¶
param callbacks: Callbacks = None¶