"""Compute doc embeddings using Cloudflare Workers AI.
        Args:
            texts: The list of texts to embed.
        Returns:
            List of embeddings, one for each text.
        """
        if self.strip_new_lines:
            texts = [text.replace("\n", " ") for text in texts]
        batches = [
            texts[i : i + self.batch_size]
            for i in range(0, len(texts), self.batch_size)
        ]
        embeddings = []
        for batch in batches:
            response = requests.post(
                f"{self.api_base_url}/{self.account_id}/ai/run/{self.model_name}",
                headers=self.headers,
                json={"text": batch},
            )
            embeddings.extend(response.json()["result"]["data"])
        return embeddings
[docs]    def embed_query(self, text: str) -> List[float]:
        """Compute query embeddings using Cloudflare Workers AI.
        Args:
            text: The text to embed.
        Returns:
            Embeddings for the text.
        """
        text = text.replace("\n", " ") if self.strip_new_lines else text
        response = requests.post(
            f"{self.api_base_url}/{self.account_id}/ai/run/{self.model_name}",
            headers=self.headers,
            json={"text": [text]},
        )
        return response.json()["result"]["data"][0]