async def add_message(
        self,
        db: AsyncSession,
        *,
        chat_id: UUID,
        obj_in: schemas.ChatMessageCreate,
        current_user: schemas.User,
        uow: Optional[UnitOfWork] = None,
    ) -> schemas.ChatMessage:
        """Add a message to a chat.

        Args:
            db (AsyncSession): The database session
            chat_id (UUID): The chat ID
            obj_in (schemas.ChatMessageCreate): The message to create
            current_user (schemas.User): The current user
            uow (Optional[UnitOfWork]): Optional unit of work for transaction management

        Returns:
            schemas.ChatMessage: The created message

        Raises:
            NotFoundException: If the chat is not found
        """
        # First verify chat exists and user has permission
        chat = await self.get(db, id=chat_id, current_user=current_user)
        if not chat:
            raise NotFoundException("Chat not found")

        # Convert to dict if it's not already
        if not isinstance(obj_in, dict):
            obj_in_data = obj_in.model_dump()
        else:
            obj_in_data = obj_in

        # Create the message object with all required fields
        db_obj = ChatMessage(
            **obj_in_data,
            chat_id=chat_id,
            organization_id=current_user.organization_id,
            created_by_email=current_user.email,
            modified_by_email=current_user.email,
        )

        db.add(db_obj)
        if not uow:
            await db.commit()
            await db.refresh(db_obj)

        return db_obj
Add a message to a chat.

        Args:
            db (AsyncSession): The database session
            chat_id (UUID): The chat ID
            obj_in (schemas.ChatMessageCreate): The message to create
            current_user (schemas.User): The current user
            uow (Optional[UnitOfWork]): Optional unit of work for transaction management

        Returns:
            schemas.ChatMessage: The created message

        Raises:
            NotFoundException: If the chat is not found
        
backend/airweave/crud/crud_chat.py