Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling system message #339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

janEbert
Copy link

@janEbert janEbert commented Jul 3, 2024

Means that it can be set to nil and won't be supplied in requests.

(Requested here: #249 (comment))

Means that it can be set to `nil` and won't be supplied in requests.
@tshu-w
Copy link
Contributor

tshu-w commented Aug 30, 2024

@karthink I just wanted to kindly remind you about this PR, in case it may have slipped your attention.

Copy link
Owner

@karthink karthink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three sources that combine to form the system message in gptel:

  1. gptel--system-message,
  2. the "additional directive" option for quick instructions from the transient menu, and
  3. the context chunks added via gptel-add, assuming gptel-use-system is set to system.

Sources 2 and 3 have to be explicitly specified, and source 1 is automatic. This PR should not disable 2 and 3 when disabling 1.

@@ -110,7 +110,10 @@
(list :text (string-trim
(buffer-substring-no-properties (point-min) (point-max)))))
prompts))
(cl-callf (lambda (msg) (concat gptel--system-message "\n\n" msg))
(cl-callf (lambda (msg)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, you can avoid the whole cl-callf statement if no system message is available.

(truncate-string-to-width prompt (- width 30) nil nil t))
")")
'face 'shadow))
(if prompt
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be possible to disable the system message from the transient menu. It should probably be a standalone option in the menu, bound to <delete> or something.

@@ -806,7 +821,8 @@ Or in an extended conversation:
:position position
:in-place (and in-place (not output-to-other-buffer-p))
:stream stream
:system (concat gptel--system-message system-extra)
:system (when gptel--system-message
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's no system message, it should still be possible to add an additional directive from the transient menu (the d option captured in system-extra here). This will now function as the whole system message.

@@ -374,7 +374,8 @@ transient menu interface provided by `gptel-menu'."
'((default . "You are a large language model living in Emacs and a helpful assistant. Respond concisely.")
(programming . "You are a large language model and a careful programmer. 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."))
(chat . "You are a large language model and a conversation partner. Respond concisely.")
(none))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is none an option here? There appears to be no way to actually choose this to select nil as the value of gptel--system-message.

@@ -968,7 +970,8 @@ Model parameters can be let-bound around calls to this function."
(declare (indent 1))
(let* ((gptel--system-message
;Add context chunks to system message if required
(if (and gptel-context--alist
(if (and system
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's no system message but there are context chunks (and gptel-use-context is set to system), they should still be supplied as the context.

@janEbert
Copy link
Author

Hey, just a quick heads-up, I haven't forgotten about this, but vacation off the computer and other priorities kept me from implementing your improvements. Thank you already for the review!

@guibor
Copy link

guibor commented Oct 7, 2024

Is there anything one can do to help to test this?

@karthink
Copy link
Owner

karthink commented Oct 7, 2024

Is there anything one can do to help to test this?

It would be best to rebase this PR onto the feature-capabilities branch, which affects a fair bit of gptel's system message handling. This branch (which adds image support and the requirements for supporting other features) will be merged into master soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants