Helpers¶
- class ibm_watsonx_ai.foundation_models_manager.FoundationModelsManager(client)[source]¶
- get_custom_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Get details on available custom model(s) as dict or as generator (
asynchronous
). Ifasynchronous
orget_all
is set, thenmodel_id
is ignored.- Parameters:
model_id (str, optional) – Id of the model, defaults to None (all models specs are returned).
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, it will work as a generator
get_all (bool, optional) – if True, it will get all entries in ‘limited’ chunks
- Returns:
details of supported custom models, None if for given model_id non is found
- Return type:
dict or generator
Example
client.foundation_models.get_custom_models_spec() client.foundation_models.get_custom_models_spec() client.foundation_models.get_custom_models_spec(model_id='mistralai/Mistral-7B-Instruct-v0.2') client.foundation_models.get_custom_models_spec(limit=20) client.foundation_models.get_custom_models_spec(limit=20, get_all=True) for spec in client.foundation_models.get_custom_model_specs(limit=20, asynchronous=True, get_all=True): print(spec, end="")
- get_embeddings_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Operation to retrieve the embeddings model specs.
- Parameters:
model_id (str, optional) – Id of the model, defaults to None (all models specs are returned).
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, it will work as a generator
get_all (bool, optional) – if True, it will get all entries in ‘limited’ chunks
- Returns:
embeddings model specs
- Return type:
dict or generator
Example
client.foundation_models.get_embeddings_model_specs() client.foundation_models.get_embeddings_model_specs('ibm/slate-125m-english-rtrvr')
- get_model_lifecycle(model_id, **kwargs)[source]¶
Operation to retrieve the list of model lifecycle data.
- Parameters:
model_id (str) – the type of model to use
- Returns:
list of deployed foundation model lifecycle data
- Return type:
list
Example
client.foundation_models.get_model_lifecycle( model_id="ibm/granite-13b-instruct-v2" )
- get_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False, **kwargs)[source]¶
Operations to retrieve the list of deployed foundation models specifications.
- Parameters:
model_id (str or ModelTypes, optional) – Id of the model, defaults to None (all models specs are returned).
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, it will work as a generator
get_all (bool, optional) – if True, it will get all entries in ‘limited’ chunks
- Returns:
list of deployed foundation model specs
- Return type:
dict or generator
Example
# GET ALL MODEL SPECS client.foundation_models.get_model_specs() # GET MODEL SPECS BY MODEL_ID client.foundation_models.get_model_specs(model_id="google/flan-ul2")
- get_model_specs_with_prompt_tuning_support(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Operations to query the details of the deployed foundation models with prompt tuning support.
- Parameters:
model_id (str, optional) – Id of the model, defaults to None (all models specs are returned).
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, it will work as a generator
get_all (bool, optional) – if True, it will get all entries in ‘limited’ chunks
- Returns:
list of deployed foundation model specs with prompt tuning support
- Return type:
dict or generator
Example
client.foundation_models.get_model_specs_with_prompt_tuning_support() client.foundation_models.get_model_specs_with_prompt_tuning_support('google/flan-t5-xl')
- ibm_watsonx_ai.foundation_models.get_model_specs(url, model_id=None)[source]¶
Operations to retrieve the list of deployed foundation models specifications.
Decrecated: get_model_specs() function is deprecated from 1.0, please use client.foundation_models.get_model_specs() function instead.
- Parameters:
url (str) – environment url
model_id (Optional[str, ModelTypes], optional) – Id of the model, defaults to None (all models specs are returned).
- Returns:
list of deployed foundation model specs
- Return type:
dict
Example
from ibm_watsonx_ai.foundation_models import get_model_specs # GET ALL MODEL SPECS get_model_specs( url="https://us-south.ml.cloud.ibm.com" ) # GET MODEL SPECS BY MODEL_ID get_model_specs( url="https://us-south.ml.cloud.ibm.com", model_id="google/flan-ul2" )
- ibm_watsonx_ai.foundation_models.get_model_lifecycle(url, model_id)[source]¶
Operation to retrieve the list of model lifecycle data.
Decrecated: get_model_lifecycle() function is deprecated from 1.0, please use client.foundation_models.get_model_lifecycle() function instead.
- Parameters:
url (str) – environment url
model_id (str) – the type of model to use
- Returns:
list of deployed foundation model lifecycle data
- Return type:
list
Example
from ibm_watsonx_ai.foundation_models import get_model_lifecycle get_model_lifecycle( url="https://us-south.ml.cloud.ibm.com", model_id="ibm/granite-13b-instruct-v2" )
- ibm_watsonx_ai.foundation_models.get_model_specs_with_prompt_tuning_support(url)[source]¶
Operations to query the details of the deployed foundation models with prompt tuning support.
Decrecated: get_model_specs_with_prompt_tuning_support() function is deprecated from 1.0, please use client.foundation_models.get_model_specs_with_prompt_tuning_support() function instead.
- Parameters:
url (str) – environment url
- Returns:
list of deployed foundation model specs with prompt tuning support
- Return type:
dict
Example
from ibm_watsonx_ai.foundation_models import get_model_specs_with_prompt_tuning_support get_model_specs_with_prompt_tuning_support( url="https://us-south.ml.cloud.ibm.com" )
- ibm_watsonx_ai.foundation_models.get_supported_tasks(url)[source]¶
Operation to retrieve the list of tasks that are supported by the foundation models.
- Parameters:
url (str) – environment url
- Returns:
list of tasks that are supported by the foundation models
- Return type:
dict
Example
from ibm_watsonx_ai.foundation_models import get_supported_tasks get_supported_tasks( url="https://us-south.ml.cloud.ibm.com" )