def _prepare_messages(
        self, messages: Sequence[ChatMessage], image_documents: Sequence[ImageDocument]
    ) -> Dict[str, Any]:
        """
        Prepares the input messages and images.
        """
        conversation = []
        images = []
        conversation.append(
            {"type": "text", "text": messages[0].content}
        )  # Add user text message
        for img_doc in image_documents:
            images.append(Image.open(img_doc.image_path))
            conversation.append({"type": "image"})
        messages = [
            {"role": "user", "content": conversation}
        ]  # Wrap conversation in a user role

        # Apply a chat template to format the message with the processor
        text_prompt = self._processor.apply_chat_template(
            messages, add_generation_prompt=True
        )

        # Prepare the model inputs (text + images) and convert to tensor
        return self._processor(text=text_prompt, images=images, return_tensors="pt")

        Prepares the input messages and images.
        
llama-index-integrations/multi_modal_llms/llama-index-multi-modal-llms-openvino/llama_index/multi_modal_llms/openvino/base.py