Skip to main content
The @weave.op decorator is used to track function calls in Weave. It automatically logs inputs, outputs, and metadata for decorated functions.

Basic Usage

Decorator Options

name

Set a custom name for the operation.

call_display_name

Set a display name for all calls of this operation.
You can also use a function to dynamically generate display names:

postprocess_inputs

Transform inputs before they are logged.

postprocess_output

Transform outputs before they are logged.

Op Methods

call

Get both the result and the Call object.

name

Get or set the operation name.

Working with Async Functions

Weave supports async operations:

Working with Generators

Weave can track generator functions:

Class Methods

Decorate methods on classes:

Static and Class Methods

The @weave.op decorator should be the innermost decorator when stacking decorators.