4. In the inscribed $\triangle A B C$ of $\odot O$, $A B=10, A C$ $=2$, point $P$ is the midpoint of the major arc opposite chord $B C$, $P Q \perp A B$ at $Q$. Then the length of $A Q$ is $\qquad$
4.4 or 6.

If point $A$ is on the major arc corresponding to chord $BC$, as shown in Figure 6, extend $BA$ to point $D$ such that $AD = AC$. Connect $PA$, $PB$, $PC$, and $PD$. Then
$$
AD = 2.
$$

Since $\overparen{PB} = \overparen{PC}$, we have
$$
PB = PC, \angle PBC = \angle PCB.
$$

Also, quadrilateral $APBC$ is a cyclic quadrilateral of $\odot O$, so $\angle PAC + \angle PBC = 180^\circ$, $\angle PAC + \angle PCB = 180^\circ$. From $\angle PAD + \angle PAB = 180^\circ$, $\angle PAB = \angle PCB$, we get $\angle PAC = \angle PAD$.
Since $AC = AD$, $PA = PA$, we have
$\triangle PAC \cong \triangle PAD$.
Thus, $PC = PD$.
Therefore, $PB = PD$.
Since $PQ \perp AB$, we have $BQ = QD$.
Thus, $BQ = \frac{1}{2} BD = \frac{1}{2}(AB + AD) = 6$.
Then $AQ = AB - BQ = 10 - 6 = 4$.
If point $A$ is on the minor arc corresponding to chord $BC$. As shown in Figure 7, cut $AD = AC$ on $AB$, and connect $PA$, $PB$, $PC$, and $PD$. Then $AD = 2$.
Similarly, $PB = PC = PD$.
Since $PQ \perp AB$, we have
$$
BQ = QD.
$$

Thus, $BQ = \frac{1}{2} BD = \frac{1}{2}(AB - AD) = 4$.
Then $AQ = AB - BQ = 10 - 4 = 6$.