First, you should convince yourself that the question whether a given morphism $\operatorname{Spec} \mathcal{O}_{X,x} \to Y$ extends to an open neighborhood of $x$ comes down to the following question in commutative algebra:
Let $A$ and $B$ be two rings and let $\mathfrak{p}$ be a prime ideal of $A$. Does a given ring homomorphism $B \to A_\mathfrak{p}$ factor as $B \to A_f \to A_\mathfrak{p}$ for some $f \in A \setminus \mathfrak{p}$?
Note that there is no reason to hope that such a factorization always exists. Indeed, the answer to the above question might be "no".
But what if $B$ is a finitely generated $R$-algebra with $R$ a Noetherian ring, $A$ is an $R$-algebra and the given morphism is a morphism of $R$-algebras? This is the case you have to deal with in solving your exercise (I'll assume you are able to work out why - if you have trouble, just drop a comment). Then the above question is guaranteed to have a positive answer. Let's prove this. Write $B = R[T_1,\dotsc,T_n] / (g_1,\dotsc,g_m)$, denote the composite of the canonical projection $R[T_1,\dotsc,T_n] \twoheadrightarrow B$ with the given morphism $B \to A_\mathfrak{p}$ by $\varphi$ and write
$$\varphi(T_i) = \frac{a_i}{f_i}, \quad i=1,\dotsc,n \, ,$$
$$\varphi(g_j) = \frac{a_j'}{h_j}, \quad j=1,\dotsc,m \, .$$
Now, for each $j \in \lbrace 1,\dotsc,m \rbrace$, choose some $f_j' \in A \setminus \mathfrak{p}$ such that $f_j' a_j' = 0$ in $A$ (which exists since $\varphi(g_j) = 0 \in A_\mathfrak{p}$). I now claim that $f = \prod_{i=1}^n f_i \prod_{j=1}^m f_j'$ has the desired property, i.e. that the given homomorphism factors through $A_f \to A_\mathfrak{p}$. To see why, we first make use of the fact that, by construction, $f$ is a common denominator of all the $\varphi(T_i)$ and note that
$$ T_i \mapsto \frac{a_i \prod_{k \neq i} f_k \prod_{j=1}^m f_j'}{f}, \quad i=1,\dotsc,n$$
defines a morphism of $R$-algebras $R[T_1,\dotsc,T_n] \to A_f$ whose composite with $A_f \to A_\mathfrak{p}$ agrees with $\varphi$. In addition, we have, by construction, $a_j' f = 0$ for all $j \in \lbrace 1,\dotsc,m \rbrace$; thus, the morphism just defined maps each $g_j$ to $0$ and, as a consequence, factors over $B$.
Best Answer
In Liu's errata to the book from his website, he has decided to change the definition to agree with the one in EGA and stack exchange. One reason he provides is that this definition is stable under composition. See his website: https://www.math.u-bordeaux.fr/~qliu/Book/ This answers the question for me.