branch: externals/ellama commit b5390444106f2a310922528b5b3f1b073765e181 Author: Sergey Kostyaev <sskosty...@gmail.com> Commit: Sergey Kostyaev <sskosty...@gmail.com>
Add option to remove reasoning from session Added new custom variable `ellama-session-remove-reasoning` to control whether internal reasoning should be removed from the session after ellama provides an answer. This can help improve long-term communication with reasoning models by reducing the conversation context. --- ellama.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ellama.el b/ellama.el index 724ced21a3..336eac6c38 100644 --- a/ellama.el +++ b/ellama.el @@ -78,6 +78,12 @@ :group 'ellama :type '(sexp :validate llm-standard-provider-p)) +(defcustom ellama-session-remove-reasoning t + "Remove internal reasoning from the session after ellama provide an answer. +This can improve long-term communication with reasoning models." + :group 'ellama + :type 'boolean) + (defcustom ellama-chat-translation-enabled nil "Enable chat translations." :group 'ellama @@ -1681,6 +1687,17 @@ failure (with BUFFER current). (mapc (lambda (fn) (funcall fn text)) donecb) (funcall donecb text)) + (when (and ellama--current-session + ellama-session-remove-reasoning) + (mapc (lambda (interaction) + (setf (llm-chat-prompt-interaction-content + interaction) + (ellama-remove-reasoning + (llm-chat-prompt-interaction-content + interaction)))) + (llm-chat-prompt-interactions + (ellama-session-prompt + ellama--current-session)))) (setq ellama--current-request nil) (ellama-request-mode -1))) (lambda (_ msg)