def _prepare_chat_with_tools(
        self,
        tools: List["BaseTool"],
        user_msg: Optional[Union[str, ChatMessage]] = None,
        chat_history: Optional[List[ChatMessage]] = None,
        verbose: bool = False,
        allow_parallel_tool_calls: bool = False,
        tool_required: bool = False,
        **kwargs: Any,
    ) -> Dict[str, Any]:
        """Prepare the arguments needed to let the LLM chat with tools."""
        chat_history = chat_history or []

        if isinstance(user_msg, str):
            user_msg = ChatMessage(role=MessageRole.USER, content=user_msg)
            chat_history.append(user_msg)

        tool_dicts = [to_inference_tool(tool.metadata) for tool in tools]

        return {
            "messages": chat_history,
            "tools": tool_dicts or None,
            "tool_choice": self._to_azure_tool_choice(tool_required),
            **kwargs,
        }
Prepare the arguments needed to let the LLM chat with tools.
llama-index-integrations/llms/llama-index-llms-azure-inference/llama_index/llms/azure_inference/base.py