xenodium / chatgpt-shell

A multi-llm Emacs shell (ChatGPT, Claude, Gemini, Ollama) + editing integrations
https://lmno.lol/alvaro
GNU General Public License v3.0
862 stars 77 forks source link

[Feature request] Suggesting/Edit-mode for ChatGPT response to help with proofreading texts #127

Open mfasold opened 1 year ago

mfasold commented 1 year ago

It might be a bit far-fetched, but per this reddit thread I still try to post my feature idea here.

The main concept is this: I would like to use ChatGPT to proofread texts using prompts like "Proofread this text: [TEXT]". Essentially, this would be a combination of spellcheck, grammar check, and style check. Some argue that it works better than Grammarly. The idea is that one could highlight a text in Emacs, send it to ChatGPT with the proofread prompt prefix, and receive a [PROOFREAD_TEXT]. It would then be useful to compare the [PROOFREAD_TEXT] with the original [TEXT], enabling the user to accept or decline each of the suggestions, similar to the suggest mode in text processors like Word, Google Docs, or Libre Office. The browser plugin EditGPT does this. It would be great to have a similar feature in Emacs. I believe that an edit-mode for ChatGPT-suggested changes could have many applications, including improving code, prose, and documentation.

xenodium commented 1 year ago

Thanks for filing the feature request. chatgpt-shell-proofread-region currently proofreads a region (presenting result in separate buffer), but lacks the interactive application of diff hunks. Do you happen to know another Emacs package that has this functionality (interactively apply patches)?

mfasold commented 1 year ago

I did some research, but - surprising enough - I did not find such a package. I was actually looking for the Grammar/Style checkers, but they mostly seem to rely on Flycheck to Flymake to mark the issues, without the possibility to apply patches.

Furthermore, I just did another search based on your freshly introduced keywords, and found that Emacs diff mode obviously supports interactive application of hunks.

My feeling is, however, that the line-based approach implicated by "diff hunks" would not work well as the proofread text might have a different line structure. Hence, one needs to identify the text changes using something like Levenshtein-Edits or the Needleman-Wunsch algorithm.

xenodium commented 1 month ago

You might find the new generic M-x chatgpt-shell-quick-modify-region useful. Beware: It's still very fresh.

proofread_x1 2

mfasold commented 1 month ago

Nice! It just tried and it works nicely. The highlighting of changes looks good, too. My first impression is that a point-by-point suggest/approve of changes could be beneficial for longer paragraphs. But I shall first test this new functionality for a couple of weeks to be able to judge if this is really so.

xenodium commented 1 month ago

I'm thinking along the same lines. Maybe extend the options of keep change? (y/n) to offer that interactivity. May take me a little while to get there. Working on internal cleanups to enable more things.