branch: externals/ellama
commit c987326908fa9cd5aa9e6f45e7b2722cc7d06f3f
Author: Sergey Kostyaev <sskosty...@gmail.com>
Commit: Sergey Kostyaev <sskosty...@gmail.com>

    Add option to remove internal reasoning from ellama output
    
    Added a new customizable variable `ellama-output-remove-reasoning` to
    the `ellama.el` file. This variable allows users to enable or disable
    the removal of internal reasoning from the Ellama output, enhancing
    its versatility for various applications.
    
    Updated the README.org file to include documentation for the new
    variable, explaining its purpose and default behavior.
---
 README.org |  5 ++++-
 ellama.el  | 13 ++++++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/README.org b/README.org
index d5bd24537c..2eb2d86c1b 100644
--- a/README.org
+++ b/README.org
@@ -402,7 +402,10 @@ argument generated text string.
 - ~ellama-session-hide-org-quotes~: Hide org quotes in the Ellama
   session buffer. From now on, think tags will be replaced with
   quote blocks. If this flag is enabled, reasoning steps will be collapsed
-  after generation and upon session loading.
+  after generation and upon session loading. Enabled by default.
+- ~ellama-output-remove-reasoning~: Eliminate internal reasoning from
+  ellama output to enhance the versatility of reasoning models across
+  diverse applications.
 
 ** Acknowledgments
 
diff --git a/ellama.el b/ellama.el
index 0365c9060f..54d3e019a8 100644
--- a/ellama.el
+++ b/ellama.el
@@ -84,6 +84,12 @@ This can improve long-term communication with reasoning 
models."
   :group 'ellama
   :type 'boolean)
 
+(defcustom ellama-output-remove-reasoning t
+  "Remove internal reasoning from ellama output.
+Make reasoning models more useful for many cases."
+  :group 'ellama
+  :type 'boolean)
+
 (defcustom ellama-session-hide-org-quotes t
   "Hide org quotes in ellama session buffer."
   :group 'ellama
@@ -1703,7 +1709,12 @@ failure (with BUFFER current).
                                  llm-prompt
                                  insert-text
                                  (lambda (text)
-                                   (funcall insert-text (string-trim text))
+                                   (funcall insert-text
+                                            (string-trim
+                                             (if (and 
ellama-output-remove-reasoning
+                                                      (not session))
+                                                 (ellama-remove-reasoning text)
+                                               text)))
                                    (with-current-buffer buffer
                                      (accept-change-group ellama--change-group)
                                      (spinner-stop)

Reply via email to