aixplain.modules.agent.agent_response
AgentResponse Objects
class AgentResponse(ModelResponse)
A response object for agent execution results.
This class extends ModelResponse to handle agent-specific response data, including intermediate steps and execution statistics. It provides dictionary-like access to response data and serialization capabilities.
Attributes:
statusResponseStatus - The status of the agent execution.dataOptional[AgentResponseData] - Structured data from the agent execution.detailsOptional[Union[Dict, List]] - Additional execution details.completedbool - Whether the execution has completed.error_messageText - Error message if execution failed.used_creditsfloat - Number of credits used for execution.run_timefloat - Total execution time in seconds.usageOptional[Dict] - Resource usage information.urlOptional[Text] - URL for asynchronous result polling.
__init__
def __init__(status: ResponseStatus = ResponseStatus.FAILED,
data: Optional[Union[AgentResponseData,
"EvolverResponseData"]] = None,
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,
**kwargs)
Initialize a new AgentResponse instance.
Arguments:
statusResponseStatus, optional - The status of the agent execution. Defaults to ResponseStatus.FAILED.dataOptional[AgentResponseData], optional - Structured data from the agent execution. Defaults to None.detailsOptional[Union[Dict, List]], optional - Additional execution details. Defaults to {}.completedbool, optional - Whether the execution has completed. Defaults to False.error_messageText, optional - Error message if execution failed. Defaults to "".used_creditsfloat, optional - Number of credits used for execution. Defaults to 0.0.run_timefloat, optional - Total execution time in seconds. Defaults to 0.0.usageOptional[Dict], optional - Resource usage information. Defaults to None.urlOptional[Text], optional - URL for asynchronous result polling. Defaults to None.**kwargs- Additional keyword arguments passed to ModelResponse.
__getitem__
def __getitem__(key: Text) -> Any
Get a response attribute using dictionary-style access.
Overrides the parent class's getitem to handle AgentResponseData serialization when accessing the 'data' key.
Arguments:
keyText - The name of the attribute to get.
Returns:
Any- The value of the attribute. For 'data' key, returns the serialized dictionary form.
__setitem__
def __setitem__(key: Text, value: Any) -> None
Set a response attribute using dictionary-style access.
Overrides the parent class's setitem to handle AgentResponseData deserialization when setting the 'data' key.
Arguments:
keyText - The name of the attribute to set.valueAny - The value to assign. For 'data' key, can be either a dictionary or AgentResponseData instance.
to_dict
def to_dict() -> Dict[Text, Any]
Convert the response to a dictionary representation.
Overrides the parent class's to_dict to handle AgentResponseData serialization in the output dictionary.
Returns:
Dict[Text, Any]: A dictionary containing all response data, with the 'data' field containing the serialized AgentResponseData.
__repr__
def __repr__() -> str
Return a string representation of the response.
Returns:
str- A string showing all attributes and their values in a readable format, with the class name changed from ModelResponse to AgentResponse.