1
0
Fork 0

Show welcome message when starting the FastGPT shell

This commit is contained in:
Bram Schoenmakers 2024-07-20 21:32:58 +02:00
parent eb767d1e0d
commit ad6cd1cf6c
Signed by: bram
GPG key ID: 0CCD19DFDC63258F
3 changed files with 31 additions and 2 deletions

View file

@ -120,6 +120,7 @@ In order to use the Kagi API, follow these steps:
|----------------------------------------+---------------------------------------------------------| |----------------------------------------+---------------------------------------------------------|
| kagi-api-token | The Kagi API token. | | kagi-api-token | The Kagi API token. |
| kagi-fastgpt-api-url | The Kagi FastGPT API entry point. | | kagi-fastgpt-api-url | The Kagi FastGPT API entry point. |
| kagi-fastgpt-welcome-function | A function returning a welcome string. |
| kagi-summarizer-api-url | The Kagi Summarizer API entry point. | | kagi-summarizer-api-url | The Kagi Summarizer API entry point. |
| kagi-summarizer-cache | Determines whether the Summarizer should cache results. | | kagi-summarizer-cache | Determines whether the Summarizer should cache results. |
| kagi-summarizer-default-language | Default target language of the summary. | | kagi-summarizer-default-language | Default target language of the summary. |
@ -261,6 +262,12 @@ Needless to say, the tests won't make actual API calls. Otherwise it wouldn't be
The full changelog can be found in README.org. The full changelog can be found in README.org.
** 0.6pre
*** New
- Show a welcome message when starting the FastGPT shell (=kagi-fastgpt-shell=). This can be customized with =kagi-fastgpt-welcome-function=, a variable with a function that returns a welcome string.
** 0.5 ** 0.5
*** Breaking changes *** Breaking changes
@ -289,7 +296,7 @@ The full changelog can be found in README.org.
- Fixed language code for Czech summaries. - Fixed language code for Czech summaries.
- Handle error responses when calling the FastGPT API. - Handle error responses when calling the FastGPT API.
** 0.4 ** 0.4 :noexport:
*** Breaking changes *** Breaking changes

24
kagi.el
View file

@ -400,6 +400,26 @@ retrieving a result from Lisp code."
(text-mode) (text-mode)
(display-buffer buffer-name)))) (display-buffer buffer-name))))
(defun kagi--fastgpt-welcome-message (_config)
"Return a string to be shown at the start of a new FastGPT shell.
This can be overridden by setting a different function in
`kagi-fastgpt-welcome-function'."
(format "Welcome to Kagi FastGPT.
- Enter `help' for more info.
- Press `C-c RET' to open a URL.
"))
(defcustom kagi-fastgpt-welcome-function #'kagi--fastgpt-welcome-message
"A function returning a welcome string.
The function takes one argument: a shell-maker configuration
object (created with `make-shell-maker-config')."
:type 'function
:group 'kagi)
(defvar kagi-fastgpt--config (defvar kagi-fastgpt--config
(make-shell-maker-config (make-shell-maker-config
:name "FastGPT" :name "FastGPT"
@ -419,7 +439,9 @@ retrieving a result from Lisp code."
(defun kagi-fastgpt-shell () (defun kagi-fastgpt-shell ()
"Start an FastGPT shell." "Start an FastGPT shell."
(interactive) (interactive)
(shell-maker-start kagi-fastgpt--config)) (shell-maker-start kagi-fastgpt--config
nil
kagi-fastgpt-welcome-function))
(defun kagi--get-text-for-prompt () (defun kagi--get-text-for-prompt ()
"Return the text to insert in a prompt. "Return the text to insert in a prompt.

BIN
kagi.info

Binary file not shown.