def get_text_embedding_batch(
        self,
        texts: List[str],
        show_progress: bool = False,
        **kwargs: Any,
    ) -> List[Embedding]:
        """Get a list of text embeddings, with batching."""
        cur_batch: List[str] = []
        result_embeddings: List[Embedding] = []

        queue_with_progress = enumerate(
            get_tqdm_iterable(texts, show_progress, "Generating embeddings")
        )

        model_dict = self.to_dict()
        model_dict.pop("api_key", None)
        for idx, text in queue_with_progress:
            cur_batch.append(text)
            if idx == len(texts) - 1 or len(cur_batch) == self.embed_batch_size:
                # flush
                dispatcher.event(
                    EmbeddingStartEvent(
                        model_dict=model_dict,
                    )
                )
                with self.callback_manager.event(
                    CBEventType.EMBEDDING,
                    payload={EventPayload.SERIALIZED: self.to_dict()},
                ) as event:
                    if not self.embeddings_cache:
                        embeddings = self._get_text_embeddings(cur_batch)
                    elif self.embeddings_cache is not None:
                        embeddings = []
                        for txt in cur_batch:
                            cached_emb = self.embeddings_cache.get(
                                key=txt, collection="embeddings"
                            )
                            if cached_emb is not None:
                                cached_key = next(iter(cached_emb.keys()))
                                embeddings.append(cached_emb[cached_key])
                            else:
                                text_embedding = self._get_text_embedding(txt)
                                embeddings.append(text_embedding)
                                self.embeddings_cache.put(
                                    key=txt,
                                    val={str(uuid.uuid4()): text_embedding},
                                    collection="embeddings",
                                )
                    result_embeddings.extend(embeddings)
                    event.on_end(
                        payload={
                            EventPayload.CHUNKS: cur_batch,
                            EventPayload.EMBEDDINGS: embeddings,
                        },
                    )
                dispatcher.event(
                    EmbeddingEndEvent(
                        chunks=cur_batch,
                        embeddings=embeddings,
                    )
                )
                cur_batch = []

        return result_embeddings
Get a list of text embeddings, with batching.
llama-index-core/llama_index/core/base/embeddings/base.py