Skip to main content
Version: 1.0

aixplain.modules.agent.agent_response

AgentResponse Objects

class AgentResponse(ModelResponse)

[view_source]

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:

  • status ResponseStatus - The status of the agent execution.
  • data Optional[AgentResponseData] - Structured data from the agent execution.
  • details Optional[Union[Dict, List]] - Additional execution details.
  • completed bool - Whether the execution has completed.
  • error_message Text - Error message if execution failed.
  • used_credits float - Number of credits used for execution.
  • run_time float - Total execution time in seconds.
  • usage Optional[Dict] - Resource usage information.
  • url Optional[Text] - URL for asynchronous result polling.

__init__

def __init__(status: ResponseStatus = ResponseStatus.FAILED,
data: Optional[AgentResponseData] = 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)

[view_source]

Initialize a new AgentResponse instance.

Arguments:

  • status ResponseStatus, optional - The status of the agent execution. Defaults to ResponseStatus.FAILED.
  • data Optional[AgentResponseData], optional - Structured data from the agent execution. Defaults to None.
  • details Optional[Union[Dict, List]], optional - Additional execution details. Defaults to {}.
  • completed bool, optional - Whether the execution has completed. Defaults to False.
  • error_message Text, optional - Error message if execution failed. Defaults to "".
  • used_credits float, optional - Number of credits used for execution. Defaults to 0.0.
  • run_time float, optional - Total execution time in seconds. Defaults to 0.0.
  • usage Optional[Dict], optional - Resource usage information. Defaults to None.
  • url Optional[Text], optional - URL for asynchronous result polling. Defaults to None.
  • **kwargs - Additional keyword arguments passed to ModelResponse.

__getitem__

def __getitem__(key: Text) -> Any

[view_source]

Get a response attribute using dictionary-style access.

Overrides the parent class's getitem to handle AgentResponseData serialization when accessing the 'data' key.

Arguments:

  • key Text - 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

[view_source]

Set a response attribute using dictionary-style access.

Overrides the parent class's setitem to handle AgentResponseData deserialization when setting the 'data' key.

Arguments:

  • key Text - The name of the attribute to set.
  • value Any - The value to assign. For 'data' key, can be either a dictionary or AgentResponseData instance.

to_dict

def to_dict() -> Dict[Text, Any]

[view_source]

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

[view_source]

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.