def with_logging(
    model_fn: Optional[callable] = None,
    *,
    endpoint: str,
    tags: Optional[List[str]] = None,
    timestamp: Optional[datetime.datetime] = None,
    log_query_body: bool = True,
    log_response_body: bool = True,
    api_key: Optional[str] = None,
):

source code

Wrap a local model callable with logging of the queries.

Arguments:

  • model_fn - The model callable to wrap logging around.
  • endpoint - The endpoint name to give to this local callable.
  • tags - Tags for later filtering.
  • timestamp - A timestamp (if not set, will be the time of sending).
  • log_query_body - Whether or not to log the query body.
  • log_response_body - Whether or not to log the response body.
  • api_key - If specified, unify API key to be used. Defaults to the value in the UNIFY_KEY environment variable.

Returns:

A new callable, but with logging added every time the function is called.

Raises:

  • requests.HTTPError: If the API request fails.