1
0
Fork 0

Compare commits

...

2 commits

Author SHA1 Message Date
Bram Schoenmakers 2252dc0451
Revise docstrings 2024-04-10 18:00:52 +02:00
Bram Schoenmakers 989f3816e9
Remove the kagi-fastgpt-prompt-synonym command
It's rather specific, it's up to the user to add it.

There is one example, kagi-fastgpt-prompt-definition, which should be sufficient.
2024-04-10 17:59:39 +02:00
2 changed files with 11 additions and 14 deletions

View file

@ -31,7 +31,6 @@ kagi.el has some functions that use FastGPT to perform certain operations on tex
- =kagi-translate= :: Translates strings or complete buffers to another language (including programming languages).
- =kagi-proofread= :: Proofread a string or buffer.
- =kagi-fastgpt-prompt-definition= :: Returns the definition of a word.
- =kagi-fastgpt-prompt-synonym= :: Returns a synonym for a word.
** Universal Summarizer
@ -217,9 +216,8 @@ Needless to say, the tests won't make actual API calls. Otherwise it wouldn't be
- The =define-kagi-fastgpt-prompt= macro allows you to define your own prompts, that may contain a placeholder to fill in relevant text.
- The macro is used to define two new commands:
- The macro is used to (re)define commands:
- =kagi-fastgpt-prompt-definition=: Define the a word.
- =kagi-fastgpt-prompt-synonym=: Find a synonym of a word.
- =kagi-proofread= is now defined with the macro.
- =kagi-summarize= has a =no-cache= parameter to opt out from caching at Kagi's side.

21
kagi.el
View file

@ -82,8 +82,8 @@ https://kagi.com/settings?p=api"
PROMPT can be a string or a function returning a string.
When PROMPT contains %s, it will be replaced with the region (if
active), the buffer content of the selected buffer or a manually
entered prompt.
active), the (narrowed) buffer content of the selected buffer or
a manually entered prompt.
The NAME is also shown as an option when `kagi-fastgpt-prompt' is
called interactively, to select the corresponding prompt. When no
@ -437,9 +437,10 @@ the text manually."
(t (error "No buffer or text entered"))))))
(defun kagi--fastgpt-expand-prompt-placeholders (prompt text-function)
"Expand all occurences of %s in PROMPT with the result of TEXT-FUNCTION.
"Expand all occurrences of %s in PROMPT with the result of TEXT-FUNCTION.
It gets replaced with the region text, buffer text or user input."
It gets replaced with the region text, (narrowed) buffer text or
user input."
(let ((user-text))
(replace-regexp-in-string (rx (seq "%" anychar))
(lambda (match)
@ -465,10 +466,11 @@ or text input)."
"Feed the given PROMPT to FastGPT.
When PROMPT contains %s, it will be replaced with the region (if
active), the buffer content of the selected buffer or a manually
entered prompt. %s remains unprocessed when `kagi-fastgpt-prompt'
is called non-interactively (when INTERACTIVE-P is nil). %%
becomes % and any other placeholder is left as-is.
active), the (narrowed) buffer content of the selected buffer or
a manually entered prompt. %s remains unprocessed when
`kagi-fastgpt-prompt' is called non-interactively (when
INTERACTIVE-P is nil). %% becomes % and any other placeholder is
left as-is.
If INSERT is non-nil, the response is inserted at point (if the
buffer is writable).
@ -496,9 +498,6 @@ string (suitable for invocations from Emacs Lisp)."
(define-kagi-fastgpt-prompt kagi-fastgpt-prompt-definition
"Define the following word: %s"
"Definition")
(define-kagi-fastgpt-prompt kagi-fastgpt-prompt-synonym
"Find synonyms for the following word: %s"
"Synonym")
(defun kagi--read-language (prompt)
"Read a language from the minibuffer interactively.