karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.04k stars 113 forks source link

Use predefined directives when refactor #136

Open HIRANO-Satoshi opened 7 months ago

HIRANO-Satoshi commented 7 months ago

This is a bug or a feature request.

I want to have a directive like this to improve English text in HTML.

(english . "You are a proofreader. Put the following into standard English keeping HTML tags.")

However, even I select the directive with 'h' command, 'r' command replaces it with the standard one such as "You are a html programmer...". That results proofreading does not occur.

An expected behavior is to keep the selected directive in the 'r' command.

karthink commented 7 months ago

This is a good point, but I'm not sure how to fix it. It does not make sense to reuse the general system message/directive that you set with h in the refactor menu, since rewriting is a special case. Most of the time -- and for most users -- it will not be a rewrite message.

I could provide a user-customizable "rewrite message" menu (and alist gptel-rewrite-directives, like gptel-directives) that you can pre-populate with your rewrite messages. Then the rewrite menu can let you select between these, or provide a custom directive. I don't like this solution because it complicates the configuration and adds a feature that very few users will need.

Alternatively, you don't have to use the rewrite menu at all -- set your 'english directive like you do and just use gptel-send the usual way. The rewriting menu is only a convenience, the only addition is the ability to ediff. The results don't differ from regular gptel usage in any other way.

HIRANO-Satoshi commented 7 months ago

The h command could be more simple to select a directive according to the current buffer mode.

Suppose we have the following gptel-directives and we are in python-ts-mode. The h command could show comment, test, and debug directives in addition to default, writing, and chat directives. After selecting one of them, we could use the r command.

((default . "You are a large language model living in Emacs and a helpful assistant. Respond concisely.") (writing . "You are a large language model and a writing assistant. Respond concisely.") (chat . "You are a large language model and a conversation partner. Respond concisely.") ((web-mode . spanish) . "Translate into Spanish keeping HTML tags.") ((web-mode . japanese) . "Translate into Japanese keeping HTML tags.") ((web-mode . english) . "Correct English keeping HTML tags.") ((python-ts-mode . comment) . "Make a doc comment against the given code without any additional text, prompt or note.") ((python-ts-mode . test) . "Make a set of doctest against the given code without any additional text, prompt or note..") ((python-ts-mode . debug) . "Debug the given code without any additional text, prompt or note.") )

The above directive system would be very useful for web developers who are making multi language web sites.