Helpers¶
- class ibm_watsonx_ai.foundation_models_manager.FoundationModelsManager(client)[source]¶
- get_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False, filters='function_text_generation,!lifecycle_withdrawn:and', **kwargs)[source]¶
Retrieves a list of specifications for a deployed foundation model.
- Parameters:
model_id (str or ModelTypes, optional) – id of the model, defaults to None (all models specifications are returned)
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, will work as a generator
get_all (bool, optional) – if True, will get all entries in ‘limited’ chunks
filters (str, list[str], optional) –
a set of filters to specify the list of models, default to
function_text_generation
Filters are described by the following pattern:pattern: tfilter[,tfilter][:(or|and)]
tfilter: filter | !filter
filter
– requires existence of the filter.!filter
– requires absence of the filter.
Available filters:
Filter
Description
Example
modelid_*
Filters by model id. Selects a model with a specific model id.
modelid_ibm/granite-3-3-8b-instruct
provider_*
Filters by provider. Selects all models with a specific provider.
provider_IBM
source_*
Filters by source. Selects all models with a specific source.
source_IBM
input_tier_*
Filters by input tier. Selects all models with a specific input tier.
input_tier_class_1
output_tier_*
Filters by output tier. Selects all models with a specific output tier.
output_tier_class_c1
tier_*
Filters by tier. Selects all models with a specific input or output tier.
tier_class_12
task_*
Filters by task id. Selects all models supporting a specific task id.
task_generation
lifecycle_*
Filters by lifecycle state. Selects all models in the specified lifecycle state.
lifecycle_available
function_*
Filters by function. Selects all models supporting a specific function.
function_text_chat
- Returns:
list of specifications for the deployed foundation model
- 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 ONE FILTER client.foundation_models.get_model_specs(filters="function_text_generation") # GET MODEL SPECS WITH MULTIPLE FILTERS client.foundation_models.get_model_specs(filters="function_text_generation,function_text_chat,!lifecycle_withdrawn:and")
- get_chat_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Operations to retrieve the list of chat foundation models specifications.
- 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
- Return type:
dict or generator
Example
# GET CHAT MODEL SPECS client.foundation_models.get_chat_model_specs() # GET CHAT MODEL SPECS BY MODEL_ID client.foundation_models.get_chat_model_specs(model_id="ibm/granite-13b-chat-v2")
- get_chat_function_calling_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Operations to retrieve the list of chat foundation models specifications with function calling 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
- Return type:
dict or generator
Example
# GET CHAT FUNCTION CALLING MODEL SPECS client.foundation_models.get_chat_function_calling_model_specs() # GET CHAT FUNCTION CALLING MODEL SPECS BY MODEL_ID client.foundation_models.get_chat_function_calling_model_specs(model_id="meta-llama/llama-3-1-70b-instruct")
- get_audio_chat_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Operations to retrieve the list of audio chat foundation models specifications.
- 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
- Return type:
dict or generator
Example
# GET AUDIO CHAT MODEL SPECS client.foundation_models.get_audio_chat_model_specs() # GET AUDIO CHAT MODEL SPECS BY MODEL_ID client.foundation_models.get_audio_chat_model_specs(model_id="ibm/granite-speech-3-3-8b")
- get_text_generation_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Operations to retrieve the list of text generation foundation models specifications.
- Parameters:
model_id (str or ModelTypes, optional) – id of the model, defaults to None (all models specifications are returned)
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, will work as a generator
get_all (bool, optional) – if True, will get all entries in ‘limited’ chunks
- Returns:
list of specifications for the deployed foundation model
- Return type:
dict or generator
Example:
# GET TEXT GENERATION MODEL SPECS client.foundation_models.get_text_generation_model_specs() # GET TEXT GENERATION MODEL SPECS BY MODEL_ID client.foundation_models.get_text_generation_model_specs(model_id="google/flan-ul2")
- get_custom_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Get details on available custom model(s) as a dictionary or as a 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 specifications are returned)
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, will work as a generator
get_all (bool, optional) – if True, will get all entries in ‘limited’ chunks
- Returns:
details of supported custom models, None if no supported custom models are found for the given model_id
- 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]¶
Retrieves the specifications of an embeddings model.
- Parameters:
model_id (str, optional) – id of the model, defaults to None (all models specifications are returned)
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, will work as a generator
get_all (bool, optional) – if True, will get all entries in ‘limited’ chunks
- Returns:
specifications of the embeddings model
- 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_time_series_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Retrieves the specifications of an time series model.
- Parameters:
model_id (str, optional) – id of the model, defaults to None (all models specifications are returned)
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, will work as a generator
get_all (bool, optional) – if True, will get all entries in ‘limited’ chunks
- Returns:
specifications of the time series model
- Return type:
dict or generator
Example:
client.foundation_models.get_time_series_model_specs() client.foundation_models.get_time_series_model_specs('ibm/granite-ttm-1536-96-r2')
- get_rerank_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Retrieves the specifications of a rerank model.
- Parameters:
model_id (str, optional) – id of the model, defaults to None (all models specifications are returned)
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, will work as a generator
get_all (bool, optional) – if True, will get all entries in ‘limited’ chunks
- Returns:
specifications of the rerank model
- Return type:
dict or generator
Example:
client.foundation_models.get_rerank_model_specs() client.foundation_models.get_rerank_model_specs('ibm/slate-125m-english-rtrvr-v2')
- get_audio_transcriptions_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Retrieves the specifications of an audio transcriptions model.
- Parameters:
model_id (str, optional) – id of the model, defaults to None (all models specifications are returned)
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, will work as a generator
get_all (bool, optional) – if True, will get all entries in ‘limited’ chunks
- Returns:
specifications of the audio transcriptions model
- Return type:
dict or generator
Example:
client.foundation_models.get_audio_transcriptions_model_specs() client.foundation_models.get_audio_transcriptions_model_specs('openai/whisper-tiny')
- get_base_foundation_model_deployable_specs(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Retrieve the specifications of a base deployable foundation models
- Parameters:
model_id (str, optional) – id of the model, defaults to None (all models specifications are returned)
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, will work as a generator
get_all (bool, optional) – if True, will get all entries in ‘limited’ chunks
- Returns:
specifications of the base foundation model deployable
- Return type:
dict or generator
Example:
client.foundation_models.get_base_foundation_model_deployable_specs() client.foundation_models.get_base_foundation_model_deployable_specs('meta-llama/llama-3-1-8b')
- get_model_specs_with_prompt_tuning_support(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Queries the details of deployed foundation models with prompt tuning support.
- Parameters:
model_id (str, optional) – id of the model, defaults to None (all models specifications are returned)
limit (int, optional) – limit number of fetched records
asynchronous (bool, optional) – if True, will work as a generator
get_all (bool, optional) – if True, will get all entries in ‘limited’ chunks
- Returns:
list of specifications of a deployed foundation model 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')
- get_model_specs_with_fine_tuning_support(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Operations to query the details of the deployed foundation models with fine-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 fine-tuning support
- Return type:
dict or generator
Example
client.foundation_models.get_model_specs_with_fine_tuning_support() client.foundation_models.get_model_specs_with_fine_tuning_support('bigscience/bloom')
- get_model_specs_with_lora_fine_tuning_support(model_id=None, limit=None, asynchronous=False, get_all=False)[source]¶
Operations to query the details of the deployed foundation models with lora fine-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 lora fine-tuning support
- Return type:
dict or generator
Example
client.foundation_models.get_model_specs_with_lora_fine_tuning_support() client.foundation_models.get_model_specs_with_lora_fine_tuning_support('bigscience/bloom')
- get_model_lifecycle(model_id, **kwargs)[source]¶
Retrieves a list of lifecycle data of a foundation model.
- Parameters:
model_id (str) – id of the model
- Returns:
list of lifecycle data of a foundation model
- Return type:
list
Example:
client.foundation_models.get_model_lifecycle( model_id="ibm/granite-13b-instruct-v2" )
- ibm_watsonx_ai.foundation_models.get_model_specs(url, model_id=None)[source]¶
Retrieve the list of deployed foundation models specifications.
Deprecated since version v1.0: The
get_model_specs()
function is deprecated, use theclient.foundation_models.get_model_specs()
function instead.- Parameters:
url (str) – URL of the environment
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]¶
Retrieve the list of model lifecycle data.
Deprecated since version v1.0: The
get_model_lifecycle()
function is deprecated, use theclient.foundation_models.get_model_lifecycle()
function instead.- Parameters:
url (str) – URL of environment
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]¶
Query the details of the deployed foundation models with prompt tuning support.
Deprecated since version v1.0: The
get_model_specs_with_prompt_tuning_support()
function is deprecated, use theclient.foundation_models.get_model_specs_with_prompt_tuning_support()
function instead.- Parameters:
url (str) – URL of environment
- 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]¶
Retrieves a list of tasks that are supported by the foundation models.
- Parameters:
url (str) – URL of the environment
- 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" )