gen_ai_hub.proxy.native.sap.client module

class gen_ai_hub.proxy.native.sap.client.RPTClient(proxy_client: GenAIHubProxyClient | None = None, timeout: int | float | Timeout | None = None)

Bases: object

Handles interaction with RPT models for making predictions.

This class acts as a client for executing prediction requests using RPT models deployed via the Gen AI Hub. It retrieves deployment information, handles timeouts, and processes request and response data.

Parameters:
  • proxy_client (Optional[GenAIHubProxyClient]) – Proxy client for interacting with the Gen AI Hub API. If not provided, a default implementation is used.

  • timeout (Union[int, float, httpx.Timeout, None]) – Default timeout value for the HTTP client used for requests.

__init__(proxy_client: GenAIHubProxyClient | None = None, timeout: int | float | Timeout | None = None)
predict(body: dict | RPTRequest, deployment_url: str | None = None, model_name: str | None = None, model_version: str | None = None, timeout: int | float | Timeout | None = None, **kwargs) RPTResponse

Executes a prediction request by sending the provided data and deployment parameters.

The body parameter can be supplied either as a dictionary or as an instance of RPTRequest.

Parameters:
  • body (Union[dict, RPTRequest]) – The input data for the prediction request, represented either as a dictionary or an RPTRequest object.

  • deployment_url (Optional[str]) – The URL of the deployment to use for prediction. If not provided, model_name or other deployment parameters must be specified.

  • model_name (Optional[str]) – The name of the model to use for prediction. If not provided, api_url or other deployment parameters must be specified.

  • model_version (Optional[str]) – The version of the model to use for prediction. Could be provided only if model_name is provided.

  • timeout (Union[int, float, httpx.Timeout, None]) – The time duration to wait for the prediction request to complete. Can be an integer, float, or an instance of httpx.Timeout.

Returns:

The response received from the prediction endpoint, represented as an RPTResponse object.

Return type:

RPTResponse

Raises:

ValueError – If no deployment is found for the given parameters.

async apredict(body: dict | RPTRequest, deployment_url: str | None = None, model_name: str | None = None, model_version: str | None = None, timeout: int | float | Timeout | None = None, **kwargs) RPTResponse

Asynchronously executes a prediction request by sending the provided data and deployment parameters.

The body parameter can be supplied either as a dictionary or as an instance of RPTRequest.

Parameters:
  • body (Union[dict, RPTRequest]) – The input data for the prediction request, represented either as a dictionary or an RPTRequest object.

  • deployment_url (Optional[str]) – The URL of the deployment to use for prediction. If not provided, model_name or other deployment parameters must be specified.

  • model_name (Optional[str]) – The name of the model to use for prediction. If not provided, api_url or other deployment parameters must be specified.

  • model_version (Optional[str]) – The version of the model to use for prediction. Could be provided only if model_name is provided.

  • timeout (Union[int, float, httpx.Timeout, None]) – The time duration to wait for the prediction request to complete. Can be an integer, float, or an instance of httpx.Timeout.

Returns:

The response received from the prediction endpoint, represented as an RPTResponse object.

Return type:

RPTResponse

Raises:

ValueError – If no deployment is found for the given parameters.