aixplain.modules.model.response
ModelResponse Objects
class ModelResponse()
ModelResponse class to store the response of the model run.
This class provides a structured way to store and manage the response from model runs. It includes fields for status, data, details, completion status, error messages, usage information, and additional metadata.
__init__
def __init__(status: ResponseStatus,
data: Text = "",
details: Optional[Union[Dict, List]] = {},
completed: bool = False,
error_message: Text = "",
used_credits: float = 0.0,
run_time: float = 0.0,
usage: Optional[Dict] = None,
url: Optional[Text] = None,
error_code: Optional[ErrorCode] = None,
**kwargs)
Initialize a new ModelResponse instance.
Arguments:
statusResponseStatus - The status of the response.dataText - The data returned by the model.detailsOptional[Union[Dict, List]] - Additional details about the response.completedbool - Whether the response is complete.error_messageText - The error message if the response is not successful.used_creditsfloat - The amount of credits used for the response.run_timefloat - The time taken to generate the response.usageOptional[Dict] - Usage information about the response.urlOptional[Text] - The URL of the response.error_codeOptional[ErrorCode] - The error code if the response is not successful.data0 - Additional keyword arguments.
__getitem__
def __getitem__(key: Text) -> Any
Get an item from the ModelResponse.
Arguments:
keyText - The key to get the value for.
Returns:
Any- The value associated with the key.
Raises:
KeyError- If the key is not found in the ModelResponse.
get
def get(key: Text, default: Optional[Any] = None) -> Any
Get an item from the ModelResponse with a default value.
Arguments:
keyText - The key to get the value for.defaultOptional[Any] - The default value to return if the key is not found.
Returns:
Any- The value associated with the key or the default value if the key is not found.
__setitem__
def __setitem__(key: Text, value: Any) -> None
Set an item in the ModelResponse.
Arguments:
keyText - The key to set the value for.valueAny - The value to set.
Raises:
KeyError- If the key is not found in the ModelResponse.
__repr__
def __repr__() -> str
Return a string representation of the ModelResponse.
Returns:
str- A string representation of the ModelResponse.
__contains__
def __contains__(key: Text) -> bool
Check if a key is in the ModelResponse.
Arguments:
keyText - The key to check for.
Returns:
bool- True if the key is in the ModelResponse, False otherwise.
to_dict
def to_dict() -> Dict[Text, Any]
Convert the ModelResponse to a dictionary.
Returns:
Dict[Text, Any]: A dictionary representation of the ModelResponse.