def post(
        self,
        url: str,
        json: serial_utils.JSON,
        headers: Optional[Dict] = None,
        timeout: Optional[float] = None,
    ) -> requests.Response:
        """Pretend to make an http post request to some model execution API."""

        assert isinstance(json, dict), "Payload should be a dict."

        if headers is None:
            headers = {}

        if timeout is None:
            timeout = threading_utils.DEFAULT_NETWORK_TIMEOUT

        request = self._fake_post_request(url, json=json, headers=headers)

        # allocate some data to pretend we are doing hard work
        temporary = np.empty(self.alloc, dtype=np.int8)  # noqa: F841

        if self.delay > 0.0:
            sleep(
                max(0.0, self.ndt.np_random.normal(self.delay, self.delay / 2))
            )

        r = self.ndt.discrete_choice(
            seq=list(_DummyOutcome),
            probs=[
                1
                - self.freeze_prob
                - self.error_prob
                - self.loading_prob
                - self.overloaded_prob,
                self.freeze_prob,
                self.error_prob,
                self.loading_prob,
                self.overloaded_prob,
            ],
        )

        if r == _DummyOutcome.FREEZE:
            # Simulated freeze outcome.

            while True:
                sleep(timeout)

        elif r == _DummyOutcome.ERROR:
            # Simulated error outcome.

            raise RuntimeError("Simulated error happened.")

        elif r == _DummyOutcome.LOADING:
            # Simulated loading model outcome.

            wait_time = self.ndt.np_random.uniform(
                *self.loading_time_uniform_params
            )
            logger.warning(
                "Waiting for model to load (%s) second(s).",
                wait_time,
            )
            sleep(wait_time + 2)
            return self.post(url, json=json, timeout=timeout, headers=headers)

        elif r == _DummyOutcome.OVERLOADED:
            # Simulated overloaded outcome.

            logger.warning("Waiting for overloaded API before trying again.")
            sleep(10)
            return self.post(url, json=json, timeout=timeout, headers=headers)

        elif r == _DummyOutcome.NORMAL:
            if "api-inference.huggingface.co" in url:
                # pretend to produce huggingface api classification results
                ret = self._fake_classification()
            else:
                ret = self._fake_completion(
                    model=json["model"],
                    prompt=json["prompt"],
                    temperature=json["temperature"],
                )

            return self._fake_post_response(
                status_code=200, json=ret, request=request
            )

        else:
            raise RuntimeError("Unknown random result type.")
Pretend to make an http post request to some model execution API.
src/feedback/trulens/feedback/dummy/endpoint.py