auto-label chunks via an LLM?

I've found that I can simply provide an Rmarkdown or Quarto doc to an LLM (e.g., GPT-4o or Claude), and the LLM can auto-generate high quality labels for all of the code chunks. However, I don't want the LLM to re-write the entire Rmarkdown/Quarto code, in order to just add the chunk labels.

This LLM-based labeling of chunks would be a great feature to see in future versions of the Rstudio IDE.

Has anyone perhaps created a tool that does the following:

  • the input is an Rmarkdown/Quarto doc
  • an LLM writes labels for each chunk in JSON format
  • the tool then parses the JSON and edits the input doc by updating all of the code chunck options to include the LLM-generated labels
  • the tool outputs the updated doc