One extension makes this approach for text-webui (oogabooga). I think there's also a similar feature for SillyTavernAI.