class_docstr: A standard Starlette middleware that enables argilla logs for http prediction requests
class_docstr_tok: ["A","standard","Starlette","middleware","that","enables","argilla","logs","for","http","prediction","requests"]
code: def _prepare_argilla_data(
      self,
      inputs: List[Dict[str, Any]],
      outputs: List[Dict[str, Any]],
      **tags,
  ):
      # using the base monitor, we only need to provide the input data to the rg.log function
      # and the monitor will handle the sample rate, queue and argilla interaction
      try:
          records = self._records_mapper(inputs, outputs)
          assert records, ValueError(
              "The records_mapper returns and empty record list."
          )
          if not isinstance(records, list):
              records = [records]
      except Exception as ex:
          records = []
          _logger.error(
              "Cannot log to argilla. Error in records mapper.",
              exc_info=ex,
          )
  
      for record in records:
          if (
              self._monitor.agent is not None
              and not record.prediction_agent
          ):
              record.prediction_agent = self._monitor.agent
  
      return dict(
          records=records or [],
          name=self._dataset,
          tags=tags,
      )
  
imports: import datetime
  import json
  import logging
  import re
  from typing import Any, Callable, Dict, List, Optional, Tuple
  from argilla.client.models import Record, TextClassificationRecord, TokenClassificationRecord
  from argilla.monitoring.base import BaseMonitor
  from argilla.utils.dependency import require_dependencies
  from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
  from starlette.requests import Request
  from starlette.responses import JSONResponse, Response, StreamingResponse
  from starlette.types import Message, Receive
label_desc: Use image node_id 3 for calling the ArgillaLogHTTPMiddleware obj's underlying member method code with example usage: obj._prepare_argilla_data(inputs, outputs) and returns: dict