Record Events using the AgentOps SDK
To get the most out of AgentOps, it is best to carefully consider what events to record - not simply record whatever your agent is logging. AgentOps offers two ways to record events outside of logs.
record_action
DecoratorTo make AgentOps easier to integrate, we also provide a function decorator to automatically creates and records an event for your function.
The decorator will record the function’s parameters, returns, and the time duration. We suggest using this on functions that take a long time and contain nested functions. For example, if you decorate a function that makes several OpenAI calls, then each openai call will show in the replay graph as a child of the decorated function.
record_action:
Arguments
record()
MethodFrom this point, simply call the .record() method in the AgentOps client:
In AgentOps, each session is associated with a number of “Events”. Events have must have an “event_type” which is any arbitrary string of your choice. It might be something like “OpenAI Call”. Events can also have other information such as the parameters of the operation, the returned data, alongside tags, etc.
Events: Represents a discrete event to be recorded.
Args: event_type (str): Type of the event, e.g., “API Call”. Required. params (Optional[Dict[str, Any]], optional): The parameters passed to the operation. Defaults to None. returns (str, optional): The output of the operation. Defaults to None. result (str, optional): Result of the operation, e.g., “Success”, “Fail”, “Indeterminate”. Defaults to “Indeterminate”. action_type (str, optional): Type of action of the event e.g. ‘action’, ‘llm’, ‘api’, ‘screenshot’. Defaults to ‘action’. model (Models, optional): The model used during the event if an LLM is used (i.e. GPT-4). For models, see the types available in the Models enum. If a model is set but an action_type is not, the action_type will be coerced to ‘llm’. Arguments
Attributes
Record Events using the AgentOps SDK
To get the most out of AgentOps, it is best to carefully consider what events to record - not simply record whatever your agent is logging. AgentOps offers two ways to record events outside of logs.
record_action
DecoratorTo make AgentOps easier to integrate, we also provide a function decorator to automatically creates and records an event for your function.
The decorator will record the function’s parameters, returns, and the time duration. We suggest using this on functions that take a long time and contain nested functions. For example, if you decorate a function that makes several OpenAI calls, then each openai call will show in the replay graph as a child of the decorated function.
record_action:
Arguments
record()
MethodFrom this point, simply call the .record() method in the AgentOps client:
In AgentOps, each session is associated with a number of “Events”. Events have must have an “event_type” which is any arbitrary string of your choice. It might be something like “OpenAI Call”. Events can also have other information such as the parameters of the operation, the returned data, alongside tags, etc.
Events: Represents a discrete event to be recorded.
Args: event_type (str): Type of the event, e.g., “API Call”. Required. params (Optional[Dict[str, Any]], optional): The parameters passed to the operation. Defaults to None. returns (str, optional): The output of the operation. Defaults to None. result (str, optional): Result of the operation, e.g., “Success”, “Fail”, “Indeterminate”. Defaults to “Indeterminate”. action_type (str, optional): Type of action of the event e.g. ‘action’, ‘llm’, ‘api’, ‘screenshot’. Defaults to ‘action’. model (Models, optional): The model used during the event if an LLM is used (i.e. GPT-4). For models, see the types available in the Models enum. If a model is set but an action_type is not, the action_type will be coerced to ‘llm’. Arguments
Attributes