-
Notifications
You must be signed in to change notification settings - Fork 190
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 separation of backend infrastructure from model definitions #619
Comments
They don't. I think you're misunderstanding how struct inheritance works in elisp.
You can define your own OpenAI backend like this: (gptel-define-openai "my-openai"
:key 'gptel-api-key
:stream t
:models '((my-model-1
:description "..."
:capabilities (...))
(my-model-2
...))) And use it like normal.
If you want to be rid of the default backend, you can remove it from the registry: (setf (gptel-get-backend "ChatGPT") nil)
While this is planned for v1.0, it is purely cosmetic and will not change any behaviors. (Its biggest effect will be to annoy users who have to update their configuraitons.)
Backends and models are not tied together in any way. They are currently completely separate.
Because backends and models are completely separate, model definitions are not inherited. Each model is an independent object. If you are not happy with its existing metadata you can modify it or add your own, as described above.
Unfortunately none of the proposed changes will help with the
Having looked into this, this is not going to fix the problem. |
Thanks for all that. I have managed to configured gptel the way I like it now (no ChatGPT default backend and models). This does work: (setf (gptel-get-backend "ChatGPT") nil) when followed by the backend model definitions I want, but strangely only if I locate them outside the (use-package gptel) sexp. If locate them inside this sexp, in the :config clause, it does not work. It seems to be a config/state setup issue in gptel. Locating them as I have (outside and after the use-package sexp) it works but I am interested to know why it won't work inside the :config clause. This is what I have (use-package gptel
;; b0f78673-2d21-4a1b-b161-e75d3debdff4
:straight t
:bind (:map ctrl-z-map ("g" . gptel-send))
:custom
(gptel-default-mode 'org-mode)
(gptel-prompt-prefix-alist nil)
(gptel-org-branching-context t)
:config
(setq gptel-expert-commands t)
(setf (gptel-get-backend "ChatGPT") nil)) which is followed by: (gptel-make-gemini "Gemini"
:protocol "https"
:host "generativelanguage.googleapis.com"
:key (lambda () (auth-source-pick-first-password
:host "generativelanguage.googleapis.com"
:user "gemini-api-key"))
:stream t
:models '((gemini-2.0-flash
:description "Next gen, high speed, multimodal for a diverse variety of tasks"
:capabilities (tool-use json media)
:mime-types ("image/png" "image/jpeg" "image/webp" "image/heic" "image/heif"
"application/pdf" "text/plain" "text/csv" "text/html")
:context-window 1000
:input-cost 0.10
:output-cost 0.40
:cutoff-date "2024-08")))
(gptel-make-anthropic "Claude"...)
(gptel-make-openai "Perplexity"...)
(gptel-make-openai "DeepSeek"...) after the use-package sexp. If instead I do this: (use-package gptel
;; b0f78673-2d21-4a1b-b161-e75d3debdff4
:straight t
:bind (:map ctrl-z-map ("g" . gptel-send))
:custom
(gptel-default-mode 'org-mode)
(gptel-prompt-prefix-alist nil)
(gptel-org-branching-context t)
:config
(setq gptel-expert-commands t)
(setf (gptel-get-backend "ChatGPT") nil)
(gptel-make-gemini "Gemini"
:protocol "https"
:host "generativelanguage.googleapis.com"
:key (lambda () (auth-source-pick-first-password
:host "generativelanguage.googleapis.com"
:user "gemini-api-key"))
:stream t
:models '((gemini-2.0-flash
:description "Next gen, high speed, multimodal for a diverse variety of tasks"
:capabilities (tool-use json media)
:mime-types ("image/png" "image/jpeg" "image/webp" "image/heic" "image/heif"
"application/pdf" "text/plain" "text/csv" "text/html")
:context-window 1000
:input-cost 0.10
:output-cost 0.40
:cutoff-date "2024-08")))
(gptel-make-anthropic "Claude"...)
(gptel-make-openai "Perplexity"...)
(gptel-make-openai "DeepSeek"...)) It does not work? |
Just checking: Are you on the latest gptel commit? |
I tested this at this commit aa649b0. |
I made some changes to |
As of
This hack works (use-package gptel
:straight t
:bind (:map ctrl-z-map ("g" . gptel-send))
:custom
(gptel-default-mode 'org-mode)
(gptel-prompt-prefix-alist nil)
(gptel-org-branching-context t)
:config
(setq gptel-expert-commands t)
(setf (gptel-get-backend "ChatGPT") nil))
(setq gptel--openai...)
(gptel-make-gemini "Gemini"...)
(gptel-make-anthropic "Claude"...)
(gptel-make-openai "Perplexity"...)
(gptel-make-openai "DeepSeek"...) but this (preferred) configuration does not: (use-package gptel
:straight t
:bind (:map ctrl-z-map ("g" . gptel-send))
:custom
(gptel-default-mode 'org-mode)
(gptel-prompt-prefix-alist nil)
(gptel-org-branching-context t)
:config
(setq gptel-expert-commands t)
(setf (gptel-get-backend "ChatGPT") nil)
(setq gptel--openai...)
(gptel-make-gemini "Gemini"...)
(gptel-make-anthropic "Claude"...)
(gptel-make-openai "Perplexity"...)
(gptel-make-openai "DeepSeek"...)) That is, if the models are configured in :config inside (use-package gptel...) it does not work but if they are moved outside it and after it, it does. |
Sorry, I don't understand why this is happening. I couldn't reproduce it. |
Currently gptel combines backend infrastructure (OpenAI API compatibility) with model definitions in a way that makes it difficult for me to fully customize my list model definitions without inheriting the default ones. This is particularly evident when trying to override the default OpenAI models while still using the OpenAI-compatible API infrastructure.
Background:
Feature Request:
Separate the OpenAI API infrastructure from the model definitions by:
gptel-backend
causes recursive require error, prevents gptel from loading #556)Provide a clean way to define models without inheriting defaults:
(Optional) Consider renaming the
gptel-make-*
functions togptel-define-*
as suggested in Customization ofgptel-backend
causes recursive require error, prevents gptel from loading #556, since they both create backends and register them in gptel's namespace.I think this aligns with the ongoing work to reorganize the codebase (moving backend infrastructure to a separate file) while providing a cleaner way for users to fully customize their model definitions.
Benefits:
gptel-backend
causes recursive require error, prevents gptel from loading #556 and(void-variable gptel--known-backends)
when usinggptel-make-openai
#227The text was updated successfully, but these errors were encountered: