def _prepare_messages(
        self, message: ChatMessage, image_documents: Sequence[ImageDocument]
    ) -> Dict[str, Any]:
        """
        Prepares the input messages and images for Phi3.5 models. Images are appended in a custom format.
        """
        images = [Image.open(img_doc.image_path) for img_doc in image_documents]
        placeholder = "".join(f"<|image_{i + 1}|>\n" for i in range(len(images)))

        chat_messages = [{"role": message.role, "content": message.content}]
        if images:
            chat_messages[-1]["content"] = placeholder + chat_messages[-1]["content"]

        prompt = self._processor.tokenizer.apply_chat_template(
            chat_messages, tokenize=False, add_generation_prompt=True
        )
        return self._processor(prompt, images, return_tensors="pt").to(self.device)

        Prepares the input messages and images for Phi3.5 models. Images are appended in a custom format.
        
llama-index-integrations/multi_modal_llms/llama-index-multi-modal-llms-huggingface/llama_index/multi_modal_llms/huggingface/base.py