branch: externals/llm
commit 54d99eb64662b9f409f269922b23ed634b465564
Author: Andrew Hyatt <[email protected]>
Commit: GitHub <[email protected]>

    Added gpt-oss model and enabled low/medium/high reasoning for it (#232)
    
    Fixes https://github.com/ahyatt/llm/issues/229
---
 NEWS.org      |  1 +
 llm-models.el |  7 ++++++-
 llm-ollama.el | 18 +++++++++++++-----
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/NEWS.org b/NEWS.org
index 21a6795a72..d5b5c10f61 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -2,6 +2,7 @@
 - Removed bad interactions made in Ollama tool calls
 - Fixed Ollama tool calling requests
 - Fixed Ollama reasoning, whose API has changed
+- Added gpt-oss, supported low/medium/high reasoning with Ollama
 - Run tools in the original buffer
 * Version 0.28.3
 - Fixed breakage in Ollama streaming tool calling
diff --git a/llm-models.el b/llm-models.el
index 5c999f9b2e..c1bcb2b9fd 100644
--- a/llm-models.el
+++ b/llm-models.el
@@ -377,7 +377,12 @@ REGEX is a regular expression that can be used to identify 
the model, uniquely (
     :name "BGE-M3" :symbol 'bge-m3
     :capabilities '(embedding free-software)  ;; MIT license
     :context-length 8192
-    :regex "bge-m3")))
+    :regex "bge-m3")
+   (make-llm-model
+    :name "gpt-oss" :symbol 'gpt-oss
+    :capabilities '(generation free-software reasoning tool-use) ; Apache 
license
+    :context-length 128000
+    :regex "gpt-oss")))
 
 (defun llm-models-by-symbol (symbol)
   "Return the model with SYMBOL."
diff --git a/llm-ollama.el b/llm-ollama.el
index 54768dafe8..3e90099221 100644
--- a/llm-ollama.el
+++ b/llm-ollama.el
@@ -188,11 +188,19 @@ PROVIDER is the llm-ollama provider."
                                      (llm-ollama--response-format
                                       (llm-chat-prompt-response-format 
prompt)))))
     (setq request-plist (plist-put request-plist :stream (if streaming t 
:false)))
-    (when (llm-chat-prompt-reasoning prompt)
-      (setq request-plist (plist-put request-plist :think
-                                     (if (eq 'none (llm-chat-prompt-reasoning 
prompt))
-                                         :false
-                                       't))))
+    (let ((model (llm-models-match (llm-ollama-chat-model provider))))
+      (when (and (llm-chat-prompt-reasoning prompt)
+                 (member 'reasoning (llm-model-capabilities model))
+                 (not (eq 'none (llm-chat-prompt-reasoning prompt))))
+        (setq request-plist (plist-put request-plist :think
+                                       (if (eq 'gpt-oss model)
+                                           (pcase (llm-chat-prompt-reasoning 
prompt)
+                                             ('light "low")
+                                             ('medium "medium")
+                                             ('maximum "high"))
+                                         (if (eq 'none 
(llm-chat-prompt-reasoning prompt))
+                                             :false
+                                           't))))))
     (when (llm-chat-prompt-temperature prompt)
       (setq options (plist-put options :temperature 
(llm-chat-prompt-temperature prompt))))
     (when (llm-chat-prompt-max-tokens prompt)

Reply via email to