[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ellama a0acd24abb 51/53: Add ellama complete command.
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ellama a0acd24abb 51/53: Add ellama complete command. |
Date: |
Sun, 17 Dec 2023 18:58:00 -0500 (EST) |
branch: externals/ellama
commit a0acd24abb2c80104bd51ae76bb4181393551bb8
Author: Sergey Kostyaev <kostyaev.sergey2@wb.ru>
Commit: Sergey Kostyaev <kostyaev.sergey2@wb.ru>
Add ellama complete command.
---
README.md | 13 +++++++----
ellama.el | 79 +++++++++++++++++++++++++++++++++++++--------------------------
2 files changed, 56 insertions(+), 36 deletions(-)
diff --git a/README.md b/README.md
index caea1e1782..c205fea184 100644
--- a/README.md
+++ b/README.md
@@ -12,15 +12,16 @@ output, making it effortless to use with your preferred
text editor.
## What's new
+- `10.12.2023` - Added command `ellama-complete`.
+- `17.11.2023` - Changes by ellama is now atomic. It can be useful if
+ you want to undo this changes. Two new commands added:
+ `ellama-ask-selection` and `ellama-ask-line`. Some cosmetic changes
+ done.
- `28.10.2023` - Switched from
[ollama](https://github.com/jmorganca/ollama)'s API to [llm
library](https://elpa.gnu.org/packages/llm.html). [Many
providers](https://github.com/ahyatt/llm#setting-up-providers)
supported.
-- `17.11.2023` - Changes by ellama is now atomic. It can be useful if
- you want to undo this changes. Two new commands added:
- `ellama-ask-selection` and `ellama-ask-line`. Some cosmetic changes
- done.
## Installation
@@ -70,6 +71,10 @@ Send selected region or current buffer to ellama chat.
Send current line to ellama chat.
+### ellama-complete
+
+Complete text in current buffer with ellama.
+
### ellama-translate
Ask Ellama to translate a selected region or word at the point.
diff --git a/ellama.el b/ellama.el
index 96c46cbebc..4f575f3c1a 100644
--- a/ellama.el
+++ b/ellama.el
@@ -113,36 +113,37 @@ in. Default value is (current-buffer).
(with-current-buffer buffer (point)))))
(with-current-buffer buffer
(unwind-protect
- (save-excursion
- (let* ((start (make-marker))
- (end (make-marker))
- (insert-text
- (lambda (text)
- ;; Erase and insert the new text between the marker cons.
- (with-current-buffer (marker-buffer start)
- (save-excursion
- (goto-char start)
- (delete-region start end)
- (insert text))))))
- (setq ellama--change-group (prepare-change-group))
- (activate-change-group ellama--change-group)
- (set-marker start point)
- (set-marker end point)
- (set-marker-insertion-type start nil)
- (set-marker-insertion-type end t)
- (spinner-start ellama-spinner-type)
- (llm-chat-streaming ellama-provider
- (llm-make-simple-chat-prompt prompt)
- insert-text
- (lambda (text)
- (funcall insert-text text)
- (with-current-buffer buffer
- (undo-amalgamate-change-group
ellama--change-group)
- (accept-change-group ellama--change-group)
- (spinner-stop)))
- (lambda (_ msg)
- (error "Error calling the LLM: %s" msg)
- (cancel-change-group
ellama--change-group)))))))))
+ (save-excursion
+ (let* ((start (make-marker))
+ (end (make-marker))
+ (insert-text
+ (lambda (text)
+ ;; Erase and insert the new text between the marker cons.
+ (with-current-buffer (marker-buffer start)
+ (save-excursion
+ (goto-char start)
+ (delete-region start end)
+ (insert text)
+ (fill-region start (point)))))))
+ (setq ellama--change-group (prepare-change-group))
+ (activate-change-group ellama--change-group)
+ (set-marker start point)
+ (set-marker end point)
+ (set-marker-insertion-type start nil)
+ (set-marker-insertion-type end t)
+ (spinner-start ellama-spinner-type)
+ (llm-chat-streaming ellama-provider
+ (llm-make-simple-chat-prompt prompt)
+ insert-text
+ (lambda (text)
+ (funcall insert-text text)
+ (with-current-buffer buffer
+ (undo-amalgamate-change-group
ellama--change-group)
+ (accept-change-group ellama--change-group)
+ (spinner-stop)))
+ (lambda (_ msg)
+ (error "Error calling the LLM: %s" msg)
+ (cancel-change-group
ellama--change-group)))))))))
(defun ellama-stream-filter (prompt prefix suffix buffer point)
"Query ellama for PROMPT with filtering.
@@ -210,7 +211,8 @@ In BUFFER at POINT will be inserted result between PREFIX
and SUFFIX."
(save-excursion
(goto-char start)
(delete-region start end)
- (insert text))))))
+ (insert text)
+ (fill-region start (point)))))))
(setq ellama--change-group (prepare-change-group))
(activate-change-group ellama--change-group)
(set-marker start point)
@@ -256,6 +258,19 @@ In BUFFER at POINT will be inserted result between PREFIX
and SUFFIX."
(buffer-substring-no-properties (point-min) (point-max)))))
(ellama-chat text)))
+;;;###autoload
+(defun ellama-complete ()
+ "Complete text in current buffer."
+ (interactive)
+ (let* ((beg (if (region-active-p)
+ (region-beginning)
+ (point-min)))
+ (end (if (region-active-p)
+ (region-end)
+ (point)))
+ (text (buffer-substring-no-properties beg end)))
+ (ellama-stream text)))
+
;;;###autoload
(defun ellama-ask-line ()
"Send current line to ellama chat."
@@ -385,7 +400,7 @@ In BUFFER at POINT will be inserted result between PREFIX
and SUFFIX."
;;;###autoload
(defun ellama-complete-code ()
- "Change selected code or code in current buffer according to provided
CHANGE."
+ "Complete selected code or code in current buffer."
(interactive)
(let* ((beg (if (region-active-p)
(region-beginning)
- [elpa] externals/ellama 660f08c126 23/53: add badges and installation section to readme, (continued)
- [elpa] externals/ellama 660f08c126 23/53: add badges and installation section to readme, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 3eac28a1ea 31/53: Merge pull request #4 from stardiviner/main, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 327c488e9b 33/53: Format and remove unnecessary code., ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 1c4aa12bf9 39/53: make spinner type customizable, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama f436d96206 47/53: Make changes by ellama atomic, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 88e8f3455f 16/53: remove ellama-instant from command list, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 7a84c5e737 18/53: add gif for enhance grammar and spelling, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama f22a21dd56 30/53: Add spinner support as mode-line progress indicator, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama f9e0de5af6 34/53: Merge pull request #3 from jiahut/main, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 2e5219afbe 43/53: Merge pull request #1 from s-kostyaev/switch-to-llm-library, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama a0acd24abb 51/53: Add ellama complete command.,
ELPA Syncer <=
- [elpa] externals/ellama 034140969d 12/53: reformat readme, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 68bbca9cb3 17/53: add more gifs to readme, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama ff604fc2b9 10/53: change default language to english, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 8717dcb145 11/53: add readme, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 162433ada3 15/53: mention streaming output in readme, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama caf4578e8d 21/53: add llm keyword to documentation, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama f35622b5f7 24/53: change default model to zephyr, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 92d4349bac 25/53: add information about local LLMs into package summary, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 75ed340a4d 26/53: add ollama into installation instructions, ELPA Syncer, 2023/12/17
- [elpa] externals/ellama 8caaf7a3b6 28/53: Merge pull request #2 from s-kostyaev/s-kostyaev-enable-gitlab-ci, ELPA Syncer, 2023/12/17