[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ellama 6abe8d46aa 3/7: Add functionality to send last u
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ellama 6abe8d46aa 3/7: Add functionality to send last user message |
Date: |
Fri, 29 Nov 2024 18:58:09 -0500 (EST) |
branch: externals/ellama
commit 6abe8d46aa251fc0ff8073d6875a25e6f83c91f4
Author: Sergey Kostyaev <sskostyaev@gmail.com>
Commit: Sergey Kostyaev <sskostyaev@gmail.com>
Add functionality to send last user message
Added a new function `ellama-get-last-user-message` to extract the
last unsent user message from the current session buffer. Also, added
a new command `ellama-chat-send-last-message` to interactively send
this last message.
---
ellama.el | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/ellama.el b/ellama.el
index 3c942d0163..61d6f96d5b 100644
--- a/ellama.el
+++ b/ellama.el
@@ -1571,6 +1571,16 @@ Extract profession from this message. Be short and
concise."
(string-trim (buffer-substring-no-properties (point-min) (point-max)))
(kill-buffer)))))
+(defun ellama-get-last-user-message ()
+ "Return last not sent user message in current session buffer."
+ (when ellama--current-session
+ (save-excursion
+ (save-match-data
+ (goto-char (point-max))
+ (and (search-backward (concat (ellama-get-nick-prefix-for-mode) " "
ellama-user-nick ":\n") nil t)
+ (search-forward (concat (ellama-get-nick-prefix-for-mode) " "
ellama-user-nick ":\n") nil t)
+ (buffer-substring-no-properties (point) (point-max)))))))
+
(defun ellama-chat-done (text &optional on-done)
"Chat done.
Will call `ellama-chat-done-callback' and ON-DONE on TEXT."
@@ -1722,6 +1732,27 @@ the full response text when the request completes (with
BUFFER current)."
:filter (when (derived-mode-p 'org-mode)
#'ellama--translate-markdown-to-org-filter)))))))
+;;;###autoload
+(defun ellama-chat-send-last-message ()
+ "Send last user message extracted from current ellama chat buffer."
+ (interactive)
+ (when-let* ((session ellama--current-session)
+ (message (ellama-get-last-user-message))
+ ((length> message 0))
+ (text (if (derived-mode-p 'org-mode)
+ (ellama-convert-org-to-md message)
+ message)))
+ (goto-char (point-max))
+ (insert "\n\n")
+ (when (ellama-session-context session)
+ (insert (ellama--format-context session)))
+ (insert (ellama-get-nick-prefix-for-mode) " " ellama-assistant-nick ":\n")
+ (ellama-stream text
+ :session session
+ :on-done #'ellama-chat-done
+ :filter (when (derived-mode-p 'org-mode)
+ #'ellama--translate-markdown-to-org-filter))))
+
;;;###autoload
(defun ellama-ask-about ()
"Ask ellama about selected region or current buffer."
- [elpa] externals/ellama updated (7a714c9114 -> d4927093e2), ELPA Syncer, 2024/11/29
- [elpa] externals/ellama 6ecde6aa8b 5/7: Add display action functions for chat and instant modes, ELPA Syncer, 2024/11/29
- [elpa] externals/ellama 6abe8d46aa 3/7: Add functionality to send last user message,
ELPA Syncer <=
- [elpa] externals/ellama a9c48d4416 2/7: Ensure user nick is present at the end of session buffer, ELPA Syncer, 2024/11/29
- [elpa] externals/ellama 1a3dd96d62 4/7: Add ellama-chat-send-last-message to documentation., ELPA Syncer, 2024/11/29
- [elpa] externals/ellama d4927093e2 7/7: Bump version, ELPA Syncer, 2024/11/29
- [elpa] externals/ellama d8e5659680 6/7: Merge pull request #184 from s-kostyaev/send-message-from-session-buffer, ELPA Syncer, 2024/11/29
- [elpa] externals/ellama b1467d15e0 1/7: Add function to convert org syntax to markdown, ELPA Syncer, 2024/11/29