async def generate_entities(self) -> AsyncGenerator[ChunkEntity, None]:
        """Generate all Gmail entities: Threads, Messages, and Attachments."""
        logger.info("===== STARTING GMAIL ENTITY GENERATION =====")
        entity_count = 0
        # Track processed message IDs to avoid duplicates across threads
        processed_message_ids = set()

        try:
            async with httpx.AsyncClient() as client:
                logger.info("HTTP client created, starting entity generation")
                # Generate thread entities (which also generates messages and attachments)
                async for entity in self._generate_thread_entities(client, processed_message_ids):
                    entity_count += 1
                    entity_type = type(entity).__name__
                    logger.info(
                        f"Yielding entity #{entity_count}: {entity_type} with ID {entity.entity_id}"
                    )
                    yield entity
        except Exception as e:
            logger.error(f"Error in entity generation: {str(e)}", exc_info=True)
            raise
        finally:
            logger.info(f"===== GMAIL ENTITY GENERATION COMPLETE: {entity_count} entities =====")
Generate all Gmail entities: Threads, Messages, and Attachments.
backend/airweave/platform/sources/gmail.py