def _get_response(self, texts: Union[str, List[str]]) -> CreateEmbeddingResponse:
        """Get embedding response from OpenAI API."""
        while True:
            try:
                response = self._client.embeddings.create(input=texts, model=self._model)
                break
            except openai.RateLimitError as e:
                expected_wait = parse_wait_time_from_error(e)
                if expected_wait is not None:
                    print(f"Embedding failed due to RateLimitError, wait for {expected_wait} seconds")
                    time.sleep(expected_wait)
                else:
                    print("Embedding failed due to RateLimitError, wait for 30 seconds")
                    time.sleep(30)
            except Exception as e:
                print(f"Embedding failed due to exception {e}")
                return None

        return response
Get embedding response from OpenAI API.
pikerag/llm_client/standard_openai_api.py