Helpers

class ibm_watsonx_ai.foundation_models_manager.FoundationModelsManager(client)[source]
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 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 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_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 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 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_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). If asynchronous or get_all is set, then model_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_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"
    )
get_model_specs(model_id=None, limit=None, asynchronous=False, get_all=False, **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

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_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 prompt 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_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_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_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')
ibm_watsonx_ai.foundation_models.get_model_specs(url, model_id=None)[source]

Retrieve the list of deployed foundation models specifications.

Decrecated: From ibm_watsonx_ai 1.0, the get_model_specs() function is deprecated, use the client.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.

Decrecated: From ibm_watsonx_ai 1.0, the get_model_lifecycle() function is deprecated, use client.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.

Decrecated: From ibm_watsonx_ai 1.0, the get_model_specs_with_prompt_tuning_support() function is deprecated, use the client.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"
    )