Skip to main content

module aixplain.modules.model

Global Variables

  • utils
  • response
  • llm_model
  • utility_model

class Model

This is ready-to-use AI model. This model can be run in both synchronous and asynchronous manner.

Attributes:

  • id (Text): ID of the Model
  • name (Text): Name of the Model
  • description (Text, optional): description of the model. Defaults to "".
  • api_key (Text, optional): API key of the Model. Defaults to None.
  • url (Text, optional): endpoint of the model. Defaults to config.MODELS_RUN_URL.
  • supplier (Union[Dict, Text, Supplier, int], optional): supplier of the asset. Defaults to "aiXplain".
  • version (Text, optional): version of the model. Defaults to "1.0".
  • function (Function, optional): model AI function. Defaults to None.
  • url (str): URL to run the model.
  • backend_url (str): URL of the backend.
  • pricing (Dict, optional): model price. Defaults to None.
  • **additional_info: Any additional Model info to be saved
  • input_params (Dict, optional): input parameters for the function.
  • output_params (Dict, optional): output parameters for the function.

method __init__

__init__(
id: str,
name: str,
description: str = '',
api_key: str = 'd0d1ea8a13cfe80dbb34378c3941e5df13d724e1059fa065d1a802dacd4ade15',
supplier: Union[Dict, str, Supplier, int] = 'aiXplain',
version: Optional[str] = None,
function: Optional[Function] = None,
is_subscribed: bool = False,
cost: Optional[Dict] = None,
created_at: Optional[datetime] = None,
input_params: Optional[Dict] = None,
output_params: Optional[Dict] = None,
**additional_info
)None

Model Init

Args:

  • id (Text): ID of the Model
  • name (Text): Name of the Model
  • description (Text, optional): description of the model. Defaults to "".
  • api_key (Text, optional): API key of the Model. Defaults to None.
  • supplier (Union[Dict, Text, Supplier, int], optional): supplier of the asset. Defaults to "aiXplain".
  • version (Text, optional): version of the model. Defaults to "1.0".
  • function (Text, optional): model AI function. Defaults to None.
  • is_subscribed (bool, optional): Is the user subscribed. Defaults to False.
  • cost (Dict, optional): model price. Defaults to None.
  • **additional_info: Any additional Model info to be saved

method check_finetune_status

check_finetune_status(after_epoch: Optional[int] = None)

Check the status of the FineTune model.

Args:

  • after_epoch (Optional[int], optional): status after a given epoch. Defaults to None.

Raises:

  • Exception: If the 'TEAM_API_KEY' is not provided.

Returns:

  • FinetuneStatus: The status of the FineTune model.

method delete

delete()None

Delete Model service


method poll

poll(poll_url: str, name: str = 'model_process') → ModelResponse

Poll the platform to check whether an asynchronous call is done.

Args:

  • poll_url (Text): polling
  • name (Text, optional): ID given to a call. Defaults to "model_process".

Returns:

  • Dict: response obtained by polling call

method run

run(
data: Union[str, Dict],
name: str = 'model_process',
timeout: float = 300,
parameters: Optional[Dict] = None,
wait_time: float = 0.5
) → ModelResponse

Runs a model call.

Args:

  • data (Union[Text, Dict]): link to the input data
  • name (Text, optional): ID given to a call. Defaults to "model_process".
  • timeout (float, optional): total polling time. Defaults to 300.
  • parameters (Dict, optional): optional parameters to the model. Defaults to None.
  • wait_time (float, optional): wait time in seconds between polling calls. Defaults to 0.5.

Returns:

  • Dict: parsed output from model

method run_async

run_async(
data: Union[str, Dict],
name: str = 'model_process',
parameters: Optional[Dict] = None
) → ModelResponse

Runs asynchronously a model call.

Args:

  • data (Union[Text, Dict]): link to the input data
  • name (Text, optional): ID given to a call. Defaults to "model_process".
  • parameters (Dict, optional): optional parameters to the model. Defaults to None.

Returns:

  • dict: polling URL in response

method sync_poll

sync_poll(
poll_url: str,
name: str = 'model_process',
wait_time: float = 0.5,
timeout: float = 300
) → ModelResponse

Keeps polling the platform to check whether an asynchronous call is done.

Args:

  • poll_url (Text): polling URL
  • name (Text, optional): ID given to a call. Defaults to "model_process".
  • wait_time (float, optional): wait time in seconds between polling calls. Defaults to 0.5.
  • timeout (float, optional): total polling time. Defaults to 300.

Returns:

  • Dict: response obtained by polling call

method to_dict

to_dict() → Dict

Get the model info as a Dictionary

Returns:

  • Dict: Model Information