One way to build melodic solos is to have a sense of flow that connects one idea to the next. Similar phrasing, note choice, or using the same notes and/or rhythm of a phrase and then shifting it across the bar will allow for a stronger, more musical solo to develop.
Sometimes we can just play random ideas that don’t connect in anyway to what we just played, or what we might play next.
The accompanying video is a very short idea that was improvised over a backing track. Whilst it was completely spontaneous, it sounds very musical.