Skip to content

Commit 5dcbf40

Browse files
committed
gptel: Make model parameters global
* gptel.el (gptel-backend, gptel-model, gptel-temperature, gptel-max-tokens, gptel--num-messages-to-send, gptel--system-message): Make all model/request paramters global variables, i.e. not buffer-local by default. This is following the discussion in #249. * gptel-transient.el (gptel-menu, gptel-system-prompt--setup, gptel-system-prompt, gptel--suffix-system-message, gptel--infix-provider, gptel--infix-temperature, gptel--switches, gptel--set-buffer-locally, gptel--set-with-scope): and associated transient methods: add a toggle `gptel--set-buffer-locally` to allow model parameters to be set buffer-locally. The function `gptel--set-with-scope` can be used to reset a variable or set it buffer-locally. Reorder gptel-transient so all the custom classes, methods and utility functions are at the top. * README.org (all backend sections): Replace `setq-default` with setq in the recommended configuration.
1 parent e3b3591 commit 5dcbf40

File tree

3 files changed

+220
-156
lines changed

3 files changed

+220
-156
lines changed

README.org

+31-32
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ You can pick this backend from the menu when using gptel. (see [[#usage][Usage]]
160160

161161
***** (Optional) Set as the default gptel backend
162162

163-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
163+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
164164
#+begin_src emacs-lisp
165165
;; OPTIONAL configuration
166-
(setq-default
166+
(setq
167167
gptel-model "gpt-3.5-turbo"
168168
gptel-backend (gptel-make-azure "Azure-1"
169169
:protocol "https"
@@ -192,10 +192,10 @@ You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
192192

193193
***** (Optional) Set as the default gptel backend
194194

195-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above. Additionally you may want to increase the response token size since GPT4All uses very short (often truncated) responses by default.
195+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above. Additionally you may want to increase the response token size since GPT4All uses very short (often truncated) responses by default.
196196
#+begin_src emacs-lisp
197197
;; OPTIONAL configuration
198-
(setq-default
198+
(setq
199199
gptel-max-tokens 500
200200
gptel-model "mistral-7b-openorca.Q4_0.gguf"
201201
gptel-backend (gptel-make-gpt4all "GPT4All"
@@ -223,10 +223,10 @@ You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
223223

224224
***** (Optional) Set as the default gptel backend
225225

226-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
226+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
227227
#+begin_src emacs-lisp
228228
;; OPTIONAL configuration
229-
(setq-default
229+
(setq
230230
gptel-model "mistral:latest"
231231
gptel-backend (gptel-make-ollama "Ollama"
232232
:host "localhost:11434"
@@ -251,10 +251,10 @@ You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
251251

252252
***** (Optional) Set as the default gptel backend
253253

254-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
254+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
255255
#+begin_src emacs-lisp
256256
;; OPTIONAL configuration
257-
(setq-default
257+
(setq
258258
gptel-model "gemini-pro"
259259
gptel-backend (gptel-make-gemini "Gemini"
260260
:key "YOUR_GEMINI_API_KEY"
@@ -285,10 +285,10 @@ You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
285285

286286
***** (Optional) Set as the default gptel backend
287287

288-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
288+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
289289
#+begin_src emacs-lisp
290290
;; OPTIONAL configuration
291-
(setq-default
291+
(setq
292292
gptel-model "test"
293293
gptel-backend (gptel-make-openai "llama-cpp"
294294
:stream t
@@ -319,10 +319,10 @@ You can pick this backend and the model (fastgpt/summarizer) from the transient
319319

320320
***** (Optional) Set as the default gptel backend
321321

322-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
322+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
323323
#+begin_src emacs-lisp
324324
;; OPTIONAL configuration
325-
(setq-default
325+
(setq
326326
gptel-model "fastgpt"
327327
gptel-backend (gptel-make-kagi "Kagi"
328328
:key "YOUR_KAGI_API_KEY"))
@@ -352,10 +352,10 @@ You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
352352

353353
***** (Optional) Set as the default gptel backend
354354

355-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
355+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
356356
#+begin_src emacs-lisp
357357
;; OPTIONAL configuration
358-
(setq-default
358+
(setq
359359
gptel-model "mistralai/Mixtral-8x7B-Instruct-v0.1"
360360
gptel-backend
361361
(gptel-make-openai "TogetherAI"
@@ -387,10 +387,10 @@ You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
387387

388388
***** (Optional) Set as the default gptel backend
389389

390-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
390+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
391391
#+begin_src emacs-lisp
392392
;; OPTIONAL configuration
393-
(setq-default
393+
(setq
394394
gptel-model "mistralai/Mixtral-8x7B-Instruct-v0.1"
395395
gptel-backend
396396
(gptel-make-openai "Anyscale"
@@ -424,10 +424,10 @@ You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
424424

425425
***** (Optional) Set as the default gptel backend
426426

427-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
427+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
428428
#+begin_src emacs-lisp
429429
;; OPTIONAL configuration
430-
(setq-default
430+
(setq
431431
gptel-model "pplx-7b-chat"
432432
gptel-backend
433433
(gptel-make-openai "Perplexity"
@@ -458,10 +458,10 @@ You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
458458

459459
***** (Optional) Set as the default gptel backend
460460

461-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
461+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
462462
#+begin_src emacs-lisp
463463
;; OPTIONAL configuration
464-
(setq-default
464+
(setq
465465
gptel-model "claude-3-sonnet-20240229" ; "claude-3-opus-20240229" also available
466466
gptel-backend (gptel-make-anthropic "Claude"
467467
:stream t :key "your-api-key"))
@@ -489,20 +489,19 @@ You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
489489

490490
***** (Optional) Set as the default gptel backend
491491

492-
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the default value of =gptel-backend=. Use this instead of the above.
492+
The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
493493
#+begin_src emacs-lisp
494494
;; OPTIONAL configuration
495-
(setq-default
496-
gptel-model "mixtral-8x7b-32768"
497-
gptel-backend
498-
(gptel-make-openai "Groq"
499-
:host "api.groq.com"
500-
:endpoint "/openai/v1/chat/completions"
501-
:stream t
502-
:key "your-api-key"
503-
:models '("mixtral-8x7b-32768"
504-
"gemma-7b-it"
505-
"llama2-70b-4096")))
495+
(setq gptel-model "mixtral-8x7b-32768"
496+
gptel-backend
497+
(gptel-make-openai "Groq"
498+
:host "api.groq.com"
499+
:endpoint "/openai/v1/chat/completions"
500+
:stream t
501+
:key "your-api-key"
502+
:models '("mixtral-8x7b-32768"
503+
"gemma-7b-it"
504+
"llama2-70b-4096")))
506505
#+end_src
507506

508507
#+html: </details>

0 commit comments

Comments
 (0)