View module source on GitHub

current_retrieval

def current_retrieval() -> Optional[Retrieval]

Get the current retrieval from the context variable.

Returns:

NameDescription
Optional[[Retrieval](/sdk/python/references/logger/components/retrieval)]The current retrieval instance if one exists,

otherwise None.

retrieval

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 objects for tracking retrieval operations, including inputs, outputs, and metadata. The decorated function must be called within a @trace or @span decorated context.

Arguments:

NameTypeDescription
loggerOptional[Logger]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.