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

Add o1-preview support (or how to hack it in) #393

Open
johannesCmayer opened this issue Sep 25, 2024 · 3 comments
Open

Add o1-preview support (or how to hack it in) #393

johannesCmayer opened this issue Sep 25, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@johannesCmayer
Copy link

Currently, I can't do

(gptel-make-openai "custom1" :models '("o1-preview") :key gptel-api-key)

The problem I am running into so far is that o1-preview does not support system messages yet. And it seems gptel always tries to send system messages. Could there be an option not to send a system message (or what is the option if it exists)?

Alternatively, how can I hack it so that it works? Some pointers would be helpful.

@karthink
Copy link
Owner

There is an open PR to allow disabling the system message, see #339.

@ileixe
Copy link

ileixe commented Oct 23, 2024

gptel$ git diff HEAD^1
diff --git a/gptel-openai.el b/gptel-openai.el
index beb252b..a18a61e 100644
--- a/gptel-openai.el
+++ b/gptel-openai.el
@@ -151,7 +151,7 @@ with differing settings.")
                            (regexp-quote (gptel-response-prefix-string)))))
             prompts)
       (and max-entries (cl-decf max-entries)))
-    (cons (list :role "system"
+    (cons (list :role "user"
                 :content gptel--system-message)
           prompts)))

diff --git a/gptel.el b/gptel.el
index 88892eb..694597a 100644
--- a/gptel.el
+++ b/gptel.el
@@ -419,12 +419,16 @@ The current options for ChatGPT are
 - \"gpt-4-turbo-preview\"
 - \"gpt-4-32k\"
 - \"gpt-4-1106-preview\"
+- \"o1-preview\"
+- \"o1-mini\"

 To set the model for a chat session interactively call
 `gptel-send' with a prefix argument."
   :safe #'always
   :type '(choice
           (string :tag "Specify model name")
+          (const :tag "o1 (preview)" "o1-preview")
+          (const :tag "o1 mini" "o1-mini")
           (const :tag "GPT 4 omni mini" "gpt-4o-mini")
           (const :tag "GPT 3.5 turbo" "gpt-3.5-turbo")
           (const :tag "GPT 3.5 turbo 16k" "gpt-3.5-turbo-16k")
@@ -455,7 +459,8 @@ To set the temperature for a chat session interactively call
    :stream t
    :models '("gpt-3.5-turbo" "gpt-3.5-turbo-16k" "gpt-4o-mini"
              "gpt-4" "gpt-4o" "gpt-4-turbo" "gpt-4-turbo-preview"
-             "gpt-4-32k" "gpt-4-1106-preview" "gpt-4-0125-preview")))
+             "gpt-4-32k" "gpt-4-1106-preview" "gpt-4-0125-preview"
+             "o1-preview" "o1-mini")))

 (defcustom gptel-backend gptel--openai
   "LLM backend to use.

For those who are willing to try hack, I see it's working with this changes.

@karthink karthink added the enhancement New feature or request label Oct 24, 2024
@Inkbottle007
Copy link

I did exactly what @ileixe suggested above, with adjustments for the breaking changes:

# git diff HEAD^1
diff --git a/gptel-openai.el b/gptel-openai.el
index 61339b3..a4ac6ef 100644
--- a/gptel-openai.el
+++ b/gptel-openai.el
@@ -181,7 +181,8 @@ with differing settings.")
                   :content
                   (gptel--trim-prefixes (buffer-substring-no-properties (point-min) (point-max))))
             prompts))
-    (cons (list :role "system"
+    ;; (cons (list :role "system"
+    (cons (list :role "user"
                 :content gptel--system-message)
           prompts)))

Additionally, my init.el includes the following configuration:

(setq
 gptel-model 'o1-mini
 gptel-backend (gptel-make-openai
                   "ChatGPT"
                 :key 'gptel-api-key
                 :stream nil ;; server doesn't accept stream = true with o1-mini
                 :models '((gpt-3.5-turbo) (gpt-3.5-turbo-16k) (gpt-4o-mini)
                           (gpt-4) (gpt-4o) (gpt-4-turbo) (gpt-4-turbo-preview)
                           (gpt-4-32k) (gpt-4-1106-preview) (gpt-4-0125-preview)
                           (o1-preview) (o1-mini))))

And that's it.

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

No branches or pull requests

4 participants