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,  # theoretically supported, but not implemented
        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 = []
        for tool in tools:
            tool_dicts.append(
                {
                    "name": tool.metadata.name,
                    "description": tool.metadata.description,
                    "parameters": tool.metadata.get_parameters_dict(),
                }
            )

        tool_config = (
            {"tool_config": self._to_function_calling_config(tool_required)}
            if self._is_gemini
            else {}
        )

        print("tool_config", tool_config)
        return {
            "messages": chat_history,
            "tools": tool_dicts or None,
            **tool_config,
            **kwargs,
        }
Prepare the arguments needed to let the LLM chat with tools.
llama-index-integrations/llms/llama-index-llms-vertex/llama_index/llms/vertex/base.py