karthink / gptel

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

How do you tweak the model parameters? #6

Closed agzam closed 1 year ago

agzam commented 1 year ago

It looks like (at least at the moment) it's sending requests with:

"You are a large language model living in Emacs and a helpful assistant. Respond concisely.",

But what if I don't want it to respond concisely? How can I configure it so the responses in Emacs virtually would be the same as in the browser?

I can see that you added gptel--system-message-alist, but it doesn't seem to be used. Also, it seems model parameter vars defined as locals, making it difficult to override them. Are you planning to make things more configurable?

karthink commented 1 year ago

Hi Ag,

I've written a magit-style menu for setting all parameters when sending requests, just haven't pushed it yet. (That's why gptel-transient is referred to in the code but not loaded.)

I'll push it in a few hours.

Also you can select a region of text in any buffer and call gptel-send, it should do the right thing, including identifying who said what in the region.

On Thu, Mar 9, 2023, 3:09 PM Ag Ibragimov @.***> wrote:

It looks like (at least at the moment) it's sending requests with:

"You are a large language model living in Emacs and a helpful assistant. Respond concisely.",

But what if I don't want it to respond concisely? How can I configure it so the responses in Emacs virtually would be the same as in the browser?

I can see that you added gptel--system-message-alist, but it doesn't seem to be used.

— Reply to this email directly, view it on GitHub https://github.com/karthink/gptel/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBVOLA55KGOPJUHF4ZFULTW3JPI7ANCNFSM6AAAAAAVVXHHW4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

agzam commented 1 year ago

Awesome. I apologize if I'm getting ahead of myself. I know you just wrote this thing and it is still very much actively being developed. But I can't contain my excitement, I giggled like a little girl when it worked. I'll be using this thing way too much, that's for sure.

karthink commented 1 year ago

@agzam, I just pushed a transient branch. You can switch to it and test out the transient menu(s) to set parameters. To bring up the menu, call gptel-send with a prefix argument, i.e. C-u C-c RET or C-u M-x gptel-send. What the options do and how to set them should be explained by the menu. Any option you set here is set for that buffer, you don't need to set it again for each request.

If you try it out, please let me know if (i) it works for you, and (ii) if you have any suggestions.

You can also use this in any buffer by selecting a region of text first.

Also, the reason this isn't on the main branch is because I'm using features of transient.el to generate menus dynamically that are not in the latest tagged release (which is from July '22), so it's not clear yet how to declare the dependency. If you're using a recent version of any transient-based application (like magit) you should be good.

agzam commented 1 year ago

I tried transient branch and it worked. The only issue I had is that it wasn't autoloaded and (featurep 'gptel-transient) would still return nil, initially. After manually requiring it, it worked. I have tested different transient suffixes and they appear to be working.

Funny, when testing the custom directive I set it to "Reply as if you're in love with me", and the responses made me very happy :)

Also, I still prefer for the vars to be global, so I can set the initial values in my config. I'm not sure why you made them with defvar-local. I'm not complaining, genuinely curious, maybe some aspect of elisp that I don't know.

karthink commented 1 year ago

The only issue I had is that it wasn't autoloaded and (featurep 'gptel-transient) would still return nil, initially.

The branch has been merged into master (see #10), and the way it's required is slightly different. Could you switch back to the master branch and try? I'm trying to avoid loading transient from the start since it freezes my Emacs for over a second on first load.

Funny, when testing the custom directive I set it to "Reply as if you're in love with me", and the responses made me very happy :)

That's one way to test the directives menu :)

Also, I still prefer for the vars to be global, so I can set the initial values in my config. I'm not sure why you made them with defvar-local.

They're buffer-local because you might want different directives in a code buffer, a shell, an org buffer where you're writing prose and one where you're writing documentation.

If you want to set their initial values in your config, you can do something like this:

(setq-default
 gptel--system-message-alist
 '((default . "You are a large language model living in Emacs and a helpful assistant. Respond concisely.")
   (programming . "Provide code and only code as output without any additional text, prompt or note.")
   (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.")))

A couple of notes:

  1. Because of issues with older versions of Transient (#14), I had to hard-code the keys default, programming, writing and chat, and you can only set their values. Once the new release of Transient is out (soon), you can edit the alist in a free-form way, including adding your own keys.
  2. Since this is going to be a user option, I'm going to eventually change the name from gptel--system-message-alist to something that makes more sense, like gptel-directives. When that happens your config might break, just a heads-up.
karthink commented 1 year ago

Also, I still prefer for the vars to be global, so I can set the initial values in my config.

I've changed the parameters to be customizable user options with saner names. You can now set them officially (and globally) in addition to interactively using the transient menu. Please run M-x customize-group gptel and update your config.

karthink commented 1 year ago

I'm closing this issue now that setting API parameters is fully implemented.