Any clue to implement textarea with autosuggestion and autocompletion?

Right now this textarea is pretty popular.

enter image description here

Users type something, LLM suggests something and users can type tab to adopt the suggestion.

Any clue how to implement the UI portion? Specifically, I am trying to implement a textarea component taking two parameters, content and suggestion.

  1. Content will be in black and suggestion will be in grey
  2. Suggestion will not be in the value of the textarea