def test_prepare_chat_with_tools_tool_required_gemini(self, mock_create_client):
        """Test that tool_required is correctly passed to tool_config for Gemini models."""
        mock_client = Mock()
        mock_create_client.return_value = mock_client

        llm = Vertex(model="gemini-pro", project="test-project")

        # Test with tool_required=True
        result = llm._prepare_chat_with_tools(tools=[search_tool], tool_required=True)

        # Verify tool_config mode using string representation
        tool_config_str = str(result["tool_config"])
        assert "tool_config" in result
        assert isinstance(result["tool_config"], ToolConfig)
        assert "mode: ANY" in tool_config_str
        assert len(result["tools"]) == 1
        assert result["tools"][0]["name"] == "search_tool"
Test that tool_required is correctly passed to tool_config for Gemini models.
llama-index-integrations/llms/llama-index-llms-vertex/tests/test_tool_required.py