> ## Documentation Index
> Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# decorators.Retrieval

> Retrieval utilities for decorators for automatic logging and instrumentation of functions and methods.

[View module source on GitHub](https://github.com/maximhq/maxim-py/blob/main/maxim/decorators/retrieval.py)

#### current\_retrieval

```python theme={null}
def current_retrieval() -> Optional[Retrieval]
```

Get the current retrieval from the context variable.

**Returns**:

| Name                                                                        | Description                                   |
| --------------------------------------------------------------------------- | --------------------------------------------- |
| `Optional[[Retrieval](/sdk/python/references/logger/components/retrieval)]` | The current retrieval instance if one exists, |

otherwise None.

#### retrieval

```python theme={null}
def retrieval(logger: Optional[Logger] = None,
              id: Optional[Union[str, Callable]] = None,
              input: Optional[Union[str, Callable]] = None,
              name: Optional[str] = None,
              tags: Optional[Dict[str, str]] = None,
              evaluators: Optional[List[str]] = None,
              evaluator_variables: Optional[Dict[str, str]] = None)
```

Decorator for tracking retrieval operations.

This decorator wraps functions to automatically create and manage [Retrieval](/sdk/python/references/logger/components/retrieval)
objects for tracking retrieval operations, including inputs, outputs, and metadata.
The decorated function must be called within a @trace or @span decorated context.

**Arguments**:

| Name     | Type                                                        | Description                                                                      |
| -------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------- |
| `logger` | *Optional\[[Logger](/sdk/python/references/logger/logger)]* | [Maxim](/sdk/python/references/maxim) logger instance. If None, uses the current |

logger from context.

* `id` *Optional\[str] or Optional\[Callable], optional* - The ID for the retrieval. If callable, it will be called to generate the ID. Defaults to None.
* `input` *Optional\[str] or Optional\[Callable], optional* - The input for the retrieval. If callable, it will be called to generate the input. Defaults to None.
