gptel: Make gptel-backend customizable

* gptel.el (gptel-backend): Turn `gptel-backend` into a defcustom
so it can be used with setopt.  Fix #167.

* gptel-openai.el (gptel-make-openai): Improve docstring.
This commit is contained in:
Karthik Chikmagalur 2024-01-04 17:19:57 -08:00
parent 0fce1d86d1
commit febeada960
2 changed files with 25 additions and 2 deletions

View file

@ -118,7 +118,7 @@
(host "api.openai.com") (host "api.openai.com")
(protocol "https") (protocol "https")
(endpoint "/v1/chat/completions")) (endpoint "/v1/chat/completions"))
"Register a ChatGPT backend for gptel with NAME. "Register an OpenAI API-compatible backend for gptel with NAME.
Keyword arguments: Keyword arguments:

View file

@ -417,7 +417,30 @@ with differing settings.")
:stream t :stream t
:models '("gpt-3.5-turbo" "gpt-3.5-turbo-16k" "gpt-4" "gpt-4-1106-preview"))) :models '("gpt-3.5-turbo" "gpt-3.5-turbo-16k" "gpt-4" "gpt-4-1106-preview")))
(defvar-local gptel-backend gptel--openai) (defcustom gptel-backend gptel--openai
"LLM backend to use.
This is the default \"backend\", an object of type
`gptel-backend' containing connection, authentication and model
information.
A backend for ChatGPT is pre-defined by gptel. Backends for
other LLM providers (local or remote) may be constructed using
one of the available backend creation functions:
- `gptel-make-openai'
- `gptel-make-azure'
- `gptel-make-ollama'
- `gptel-make-gpt4all'
- `gptel-make-gemini'
See their documentation for more information and the package
README for examples."
:local t
:safe #'always
:group 'gptel
:type `(choice
(const :tag "ChatGPT" ,gptel--openai)
(restricted-sexp :match-alternatives (gptel-backend-p 'nil)
:tag "Other backend")))
(defvar-local gptel--bounds nil) (defvar-local gptel--bounds nil)
(put 'gptel--bounds 'safe-local-variable #'always) (put 'gptel--bounds 'safe-local-variable #'always)