(
            self, client: AsyncClient, data: bytes, url: str
    )
return self._parse_response(response)
This function sends a single request to the server.

        Parameters
        ----------
        client
            HTTPX client that communicates with the server
        data
            Data packed in the sequence of bytes.
        url
            Rest of the url string.

        Returns
        -------
        embedding
            Embedding. For items that are not successfully embedded returns
            None.
This function sends a single request to the server.
This function sends a single request to the server .
async def _send_request(
            self, client: AsyncClient, data: bytes, url: str
    ) -> Optional[List[float]]:
        """
        This function sends a single request to the server.

        Parameters
        ----------
        client
            HTTPX client that communicates with the server
        data
            Data packed in the sequence of bytes.
        url
            Rest of the url string.

        Returns
        -------
        embedding
            Embedding. For items that are not successfully embedded returns
            None.
        """
        headers = {
            "Content-Type": self.content_type,
            "Content-Length": str(len(data)),
        }
        try:
            response = await client.post(url, headers=headers, data=data)
        except ReadTimeout as ex:
            log.debug("Read timeout", exc_info=True)
            # it happens when server do not respond in 60 seconds, in
            # this case we return None and items will be resend later

            # if it happens more than in ten consecutive cases it means
            # sth is wrong with embedder we stop embedding
            self.count_read_errors += 1

            if self.count_read_errors >= self.max_errors:
                self.num_parallel_requests = 0  # for safety reasons
                raise EmbeddingConnectionError from ex
            return None
        except (OSError, NetworkError) as ex:
            log.debug("Network error", exc_info=True)
            # it happens when no connection and items cannot be sent to the
            # server
            # we count number of consecutive errors
            # if more than 10 consecutive errors it means there is no
            # connection so we stop embedding with EmbeddingConnectionError
            self.count_connection_errors += 1
            if self.count_connection_errors >= self.max_errors:
                self.num_parallel_requests = 0  # for safety reasons
                raise EmbeddingConnectionError from ex
            return None
        except Exception:
            log.debug("Embedding error", exc_info=True)
            raise
        # we reset the counter at successful embedding
        self.count_connection_errors = 0
        self.count_read_errors = 0
        return self._parse_response(response)
async def _send_request ( self , client : AsyncClient , data : bytes , url : str ) -> Optional [ List [ float ] ] : headers = { "Content-Type" : self . content_type , "Content-Length" : str ( len ( data ) ) , } try : response = await client . post ( url , headers = headers , data = data ) except ReadTimeout as ex : log . debug ( "Read timeout" , exc_info = True ) # it happens when server do not respond in 60 seconds, in # this case we return None and items will be resend later # if it happens more than in ten consecutive cases it means # sth is wrong with embedder we stop embedding self . count_read_errors += 1 if self . count_read_errors >= self . max_errors : self . num_parallel_requests = 0 # for safety reasons raise EmbeddingConnectionError from ex return None except ( OSError , NetworkError ) as ex : log . debug ( "Network error" , exc_info = True ) # it happens when no connection and items cannot be sent to the # server # we count number of consecutive errors # if more than 10 consecutive errors it means there is no # connection so we stop embedding with EmbeddingConnectionError self . count_connection_errors += 1 if self . count_connection_errors >= self . max_errors : self . num_parallel_requests = 0 # for safety reasons raise EmbeddingConnectionError from ex return None except Exception : log . debug ( "Embedding error" , exc_info = True ) raise # we reset the counter at successful embedding self . count_connection_errors = 0 self . count_read_errors = 0 return self . _parse_response ( response )