@@ -529,6 +529,21 @@ See `chatgpt-shell-allow-model-versions' and
529
529
:type 'function
530
530
:group 'chatgpt-shell )
531
531
532
+ (defcustom chatgpt-shell-swap-model-selector nil
533
+ " Custom function to select a model during swap.
534
+
535
+ This would allow a user to sort, group, filter, present a different selection
536
+ user experience, attach affixations, and so on. An example:
537
+
538
+ (setq chatgpt-shell-swap-model-selector
539
+ (lambda (candidates)
540
+ (completing-read \" New model: \"
541
+ (my-custom-model-completion-table candidates) nil t)))
542
+
543
+ See also `chatgpt-shell-swap-model' ."
544
+ :type 'function
545
+ :group 'chatgpt-shell )
546
+
532
547
(defun chatgpt-shell-allow-model-versions (versions )
533
548
" Return a filter function to keep known model VERSIONS only.
534
549
@@ -548,7 +563,10 @@ Use with `chatgpt-shell-model-filter'."
548
563
models)))
549
564
550
565
(defun chatgpt-shell-swap-model ()
551
- " Swap model version from `chatgpt-shell-models' ."
566
+ " Swap model version from `chatgpt-shell-models' .
567
+
568
+ To select a model, it uses `chatgpt-shell-swap-model-selector' if
569
+ non-nil; otherwise `completing-read' ."
552
570
(interactive )
553
571
(if-let* ((last-label (chatgpt-shell--model-label))
554
572
(width (let ((width))
@@ -568,8 +586,10 @@ Use with `chatgpt-shell-model-filter'."
568
586
(if chatgpt-shell-model-filter
569
587
(funcall chatgpt-shell-model-filter chatgpt-shell-models)
570
588
chatgpt-shell-models)))
571
- (selection (nth 1 (split-string (completing-read " Model version: "
572
- models nil t )))))
589
+ (selection (nth 1 (split-string (if chatgpt-shell-swap-model-selector
590
+ (funcall chatgpt-shell-swap-model-selector models)
591
+ (completing-read " Model version: "
592
+ models nil t ))))))
573
593
(progn
574
594
(when (derived-mode-p 'chatgpt-shell-mode )
575
595
(setq-local chatgpt-shell-model-version selection)
0 commit comments