4
4
5
5
; ; Author: Alvaro Ramirez https://xenodium.com
6
6
; ; URL: https://github.com/xenodium/chatgpt-shell
7
- ; ; Version: 2.12.2
7
+ ; ; Version: 2.16.1
8
8
; ; Package-Requires: ((emacs "28.1") (shell-maker "0.76.2"))
9
- (defconst chatgpt-shell--version " 2.12.2 " )
9
+ (defconst chatgpt-shell--version " 2.16.1 " )
10
10
11
11
; ; This package is free software; you can redistribute it and/or modify
12
12
; ; it under the terms of the GNU General Public License as published by
36
36
; ;
37
37
; ; You must set an API key for most cloud services. Check out:
38
38
; ;
39
- ; ; `chatgpt-shell-openai-key' .
40
39
; ; `chatgpt-shell-anthropic-key' .
40
+ ; ; `chatgpt-shell-deepseek-key'
41
41
; ; `chatgpt-shell-google-key' .
42
42
; ; `chatgpt-shell-kagi-key' .
43
+ ; ; `chatgpt-shell-openai-key' .
44
+ ; ; `chatgpt-shell-openrouter-key'
43
45
; ; `chatgpt-shell-perplexity-key' .
44
46
; ;
45
47
; ; Alternatively, local services like Ollama do not require an API key.
67
69
(require 'ob-core )
68
70
(require 'color )
69
71
70
- (require 'chatgpt-shell-prompt-compose )
71
72
(require 'chatgpt-shell-anthropic )
73
+ (require 'chatgpt-shell-deepseek )
72
74
(require 'chatgpt-shell-google )
73
75
(require 'chatgpt-shell-kagi )
74
76
(require 'chatgpt-shell-ollama )
75
77
(require 'chatgpt-shell-openai )
76
- (require 'chatgpt-shell-perplexity )
77
78
(require 'chatgpt-shell-openrouter )
79
+ (require 'chatgpt-shell-perplexity )
80
+ (require 'chatgpt-shell-prompt-compose )
78
81
79
82
(defcustom chatgpt-shell-request-timeout 600
80
83
" How long to wait for a request to time out in seconds."
@@ -233,13 +236,14 @@ Can be used compile or run source block at point."
233
236
234
237
This function aggregates models from OpenAI, Anthropic, Google, and Ollama.
235
238
It returns a list containing all available models from these providers."
236
- (append (chatgpt-shell-openai -models)
237
- (chatgpt-shell-anthropic -models)
239
+ (append (chatgpt-shell-anthropic -models)
240
+ (chatgpt-shell-deepseek -models)
238
241
(chatgpt-shell-google-models)
239
242
(chatgpt-shell-kagi-models)
240
243
(chatgpt-shell-ollama-models)
241
- (chatgpt-shell-perplexity-models)
242
- (chatgpt-shell-openrouter-models)))
244
+ (chatgpt-shell-openai-models)
245
+ (chatgpt-shell-openrouter-models)
246
+ (chatgpt-shell-perplexity-models)))
243
247
244
248
(defcustom chatgpt-shell-models
245
249
(chatgpt-shell--make-default-models)
@@ -435,7 +439,7 @@ Or nil if none."
435
439
436
440
(defun chatgpt-shell-validate-no-system-prompt (command model settings )
437
441
" Perform validation for COMMAND with MODEL and SETTINGS.
438
- Then enforce that there is no system prompt. This is useful for models like
442
+ Then enforce that there is no system prompt. This is useful for models like
439
443
OpenAI's o1 that do not allow one."
440
444
(or (chatgpt-shell-openai--validate-command command model settings)
441
445
(when (map-elt settings :system-prompt )
@@ -517,6 +521,32 @@ Downloaded from https://github.com/f/awesome-chatgpt-prompts."
517
521
(setq chatgpt-shell-models (chatgpt-shell--make-default-models))
518
522
(message " Reloaded %d models " (length chatgpt-shell-models)))
519
523
524
+ (defcustom chatgpt-shell-model-filter nil
525
+ " Filter models to swap from using this function as a filter.
526
+
527
+ See `chatgpt-shell-allow-model-versions' and
528
+ `chatgpt-shell-ignore-model-versions' as examples."
529
+ :type 'function
530
+ :group 'chatgpt-shell )
531
+
532
+ (defun chatgpt-shell-allow-model-versions (versions )
533
+ " Return a filter function to keep known model VERSIONS only.
534
+
535
+ Use with `chatgpt-shell-model-filter' ."
536
+ (lambda (models )
537
+ (seq-filter (lambda (model )
538
+ (member (map-elt model :version ) versions))
539
+ models)))
540
+
541
+ (defun chatgpt-shell-ignore-model-versions (versions )
542
+ " Return a filter function to drop model VERSIONS.
543
+
544
+ Use with `chatgpt-shell-model-filter' ."
545
+ (lambda (models )
546
+ (seq-filter (lambda (model )
547
+ (not (member (map-elt model :version ) versions)))
548
+ models)))
549
+
520
550
(defun chatgpt-shell-swap-model ()
521
551
" Swap model version from `chatgpt-shell-models' ."
522
552
(interactive )
@@ -535,7 +565,9 @@ Downloaded from https://github.com/f/awesome-chatgpt-prompts."
535
565
(format (format " %% -%d s %% s" width)
536
566
(map-elt model :provider )
537
567
(map-elt model :version )))
538
- chatgpt-shell-models))
568
+ (if chatgpt-shell-model-filter
569
+ (funcall chatgpt-shell-model-filter chatgpt-shell-models)
570
+ chatgpt-shell-models)))
539
571
(selection (nth 1 (split-string (completing-read " Model version: "
540
572
models nil t )))))
541
573
(progn
@@ -1571,16 +1603,17 @@ With prefix REVIEW prompt before sending to ChatGPT."
1571
1603
(prin1-to-string
1572
1604
`(progn
1573
1605
(interactive )
1574
- (load ,(find-library-name " shell-maker" ) nil t )
1575
- (load ,(find-library-name " chatgpt-shell-openai" ) nil t )
1576
- (load ,(find-library-name " chatgpt-shell-openrouter" ) nil t )
1577
- (load ,(find-library-name " chatgpt-shell-google" ) nil t )
1606
+ (load ,(find-library-name " chatgpt-shell" ) nil t )
1578
1607
(load ,(find-library-name " chatgpt-shell-anthropic" ) nil t )
1579
- (load ,(find-library-name " chatgpt-shell-ollama" ) nil t )
1608
+ (load ,(find-library-name " chatgpt-shell-deepseek" ) nil t )
1609
+ (load ,(find-library-name " chatgpt-shell-google" ) nil t )
1580
1610
(load ,(find-library-name " chatgpt-shell-kagi" ) nil t )
1611
+ (load ,(find-library-name " chatgpt-shell-ollama" ) nil t )
1612
+ (load ,(find-library-name " chatgpt-shell-openai" ) nil t )
1613
+ (load ,(find-library-name " chatgpt-shell-openrouter" ) nil t )
1581
1614
(load ,(find-library-name " chatgpt-shell-perplexity" ) nil t )
1582
1615
(load ,(find-library-name " chatgpt-shell-prompt-compose" ) nil t )
1583
- (load ,(find-library-name " chatgpt- shell" ) nil t )
1616
+ (load ,(find-library-name " shell-maker " ) nil t )
1584
1617
(setq chatgpt-shell-model-temperature 0 )
1585
1618
(setq chatgpt-shell-openai-key ,(chatgpt-shell-openai-key))
1586
1619
(chatgpt-shell-command-line-from-prompt-file , prompt-file )))
@@ -3179,11 +3212,12 @@ Of the form
3179
3212
(line-beginning-position )))
3180
3213
(end (region-end )))
3181
3214
; ; Barf trailing space from selection.
3182
- (when (string-match " [ \n\t ]+$"
3183
- (buffer-substring-no-properties
3184
- start
3185
- end))
3186
- (setq end (- end (length (match-string 0 )))))
3215
+ (let ((text (buffer-substring-no-properties
3216
+ start
3217
+ end)))
3218
+ (when (string-match " [ \n\t ]+$"
3219
+ text)
3220
+ (setq end (- end (length (match-string 0 text))))))
3187
3221
(list (cons :start start)
3188
3222
(cons :end end)
3189
3223
(cons :buffer (current-buffer ))
0 commit comments