  The production of J/$\psi$ is measured at midrapidity ($|y|<0.9$) in
proton-proton collisions at $\sqrt{s}$ = 5.02 and 13 TeV, through the
dielectron decay channel, using the ALICE detector at the Large Hadron
Collider. The data sets used for the analyses correspond to integrated
luminosities of $\mathcal{L}_{\rm int}$ = 19.4 $\pm$ 0.4 nb$^{-1}$ and
$\mathcal{L}_{\rm int}$ = 32.2 $\pm$ 0.5 nb$^{-1}$ at $\sqrt{s}$ = 5.02 and 13
TeV, respectively. The fraction of non-prompt J/$\psi$ mesons, i.e. those
originating from the decay of beauty hadrons, is measured down to a transverse
momentum $p_{\rm T}$ = 2 GeV/$c$ (1 GeV/$c$) at $\sqrt{s}$ = 5.02 TeV (13 TeV).
The $p_{\rm T}$ and rapidity ($y$) differential cross sections, as well as the
corresponding values integrated over $p_{\rm T}$ and $y$, are carried out
separately for prompt and non-prompt J/$\psi$ mesons. The results are compared
with measurements from other experiments and theoretical calculations based on
quantum chromodynamics (QCD). The shapes of the $p_{\rm T}$ and $y$
distributions of beauty quarks predicted by state-of-the-art perturbative QCD
models are used to extrapolate an estimate of the $\rm b\overline{b}$ pair
cross section at midrapidity and in the total phase space. The total $\rm
b\overline{b}$ cross sections are found to be $\sigma_{\rm b \overline{\rm b}}
= 541 \pm 45 (\rm stat.) \pm 69 (\rm syst.)_{-12}^{+10} (\rm extr.)~{\rm \mu
b}$ and $\sigma_{\rm b \overline{\rm b}}~=~218 \pm 37 (\rm stat.) \pm 31 (\rm
syst.)_{-9.1}^{+8.2} (\rm extr.)~{\rm \mu b}$ at $\sqrt{s}$ = 13 and 5.02 TeV,
respectively. The value obtained from the combination of ALICE and LHCb
measurements in pp collisions at $\sqrt{s}$ = 13 TeV is also provided.
