self._refresh_access_token_with_lock()
                    resp = self._embedding({"input": [text for text in chunk]})
                else:
                    raise ValueError(f"Error from Ernie: {resp}")
            lst.extend([i["embedding"] for i in resp["data"]])
        return lst
[docs]    def embed_query(self, text: str) -> List[float]:
        """Embed query text.
        Args:
            text: The text to embed.
        Returns:
            List[float]: Embeddings for the text.
        """
        if not self.access_token:
            self._refresh_access_token_with_lock()
        resp = self._embedding({"input": [text]})
        if resp.get("error_code"):
            if resp.get("error_code") == 111:
                self._refresh_access_token_with_lock()
                resp = self._embedding({"input": [text]})
            else:
                raise ValueError(f"Error from Ernie: {resp}")
        return resp["data"][0]["embedding"]
[docs]    async def aembed_query(self, text: str) -> List[float]:
        """Asynchronous Embed query text.
        Args:
            text: The text to embed.
        Returns:
            List[float]: Embeddings for the text.
        """
        return await asyncio.get_running_loop().run_in_executor(
            None, partial(self.embed_query, text)
        )
[docs]    async def aembed_documents(self, texts: List[str]) -> List[List[float]]:
        """Asynchronous Embed search docs.
        Args:
            texts: The list of texts to embed
        Returns:
            List[List[float]]: List of embeddings, one for each text.
        """