[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ellama a040305a12 11/12: Merge pull request #76 from st
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ellama a040305a12 11/12: Merge pull request #76 from stephenwithav/ellama-chat-mode |
Date: |
Sat, 16 Mar 2024 12:58:02 -0400 (EDT) |
branch: externals/ellama
commit a040305a120b179c85e1d776d47c6e991026a2cf
Merge: 732f7dbee0 a5690a8fcb
Author: Sergey Kostyaev <s-kostyaev@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Merge pull request #76 from stephenwithav/ellama-chat-mode
Use appropriate ellama prefix based on mode.
---
ellama.el | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/ellama.el b/ellama.el
index 08adc02157..c3184f335f 100644
--- a/ellama.el
+++ b/ellama.el
@@ -55,10 +55,10 @@
:group 'ellama
:type 'string)
-(defcustom ellama-nick-prefix "**"
- "User and assistant nick prefix in logs."
+(defcustom ellama-nick-prefix-depth 2
+ "Prefix depth."
:group 'ellama
- :type 'string)
+ :type 'integer)
(defcustom ellama-language "English"
"Language for ellama translation."
@@ -414,11 +414,6 @@ This filter contains only subset of markdown syntax to be
good enough."
;; If ellama-enable-keymap is nil, remove the key bindings
(define-key global-map (kbd ellama-keymap-prefix) nil))))
-(defcustom ellama-session-file-extension "org"
- "File extension for saving ellama session."
- :type 'string
- :group 'ellama)
-
(defcustom ellama-sessions-directory (file-truename
(file-name-concat
user-emacs-directory
@@ -504,6 +499,20 @@ CONTEXT contains context for next request."
(defvar ellama--new-session-context nil)
+(defun ellama-get-nick-prefix-for-mode ()
+ "Return preferred header prefix char based om the current mode.
+Defaults to #, but supports `org-mode'. Depends on `ellama-major-mode'."
+ (let* ((prefix-char
+ (cond ((provided-mode-derived-p ellama-major-mode 'org-mode) ?*)
+ (t ?#))))
+ (make-string ellama-nick-prefix-depth prefix-char)))
+
+(defun ellama-get-session-file-extension ()
+ "Return file extension based om the current mode.
+Defaults to md, but supports org. Depends on \"ellama-major-mode.\""
+ (cond ((provided-mode-derived-p ellama-major-mode 'org-mode) "org")
+ (t "md")))
+
(defun ellama-new-session (provider prompt &optional ephemeral)
"Create new ellama session with unique id.
Provided PROVIDER and PROMPT will be used in new session.
@@ -521,7 +530,7 @@ If EPHEMERAL non nil new session will not be associated
with any file."
ellama-session-auto-save)
(file-name-concat
ellama-sessions-directory
- (concat id "." ellama-session-file-extension))))
+ (concat id "." (ellama-get-session-file-extension)))))
(session (make-ellama-session
:id id :provider provider :file file-name :context
ellama--new-session-context))
(buffer (if file-name
@@ -996,9 +1005,9 @@ Will call `ellama-chat-done-callback' on TEXT."
(with-current-buffer buffer
(save-excursion
(goto-char (point-max))
- (insert ellama-nick-prefix " " ellama-user-nick ":\n"
+ (insert (ellama-get-nick-prefix-for-mode) " " ellama-user-nick ":\n"
(ellama--format-context session) result "\n\n"
- ellama-nick-prefix " " ellama-assistant-nick ":\n")
+ (ellama-get-nick-prefix-for-mode) " " ellama-assistant-nick
":\n")
(ellama-stream result
:session session
:on-done (ellama--translate-generated-text-on-done
translation-buffer)
@@ -1011,9 +1020,9 @@ Will call `ellama-chat-done-callback' on TEXT."
(with-current-buffer translation-buffer
(save-excursion
(goto-char (point-max))
- (insert ellama-nick-prefix " " ellama-user-nick ":\n"
+ (insert (ellama-get-nick-prefix-for-mode) " " ellama-user-nick ":\n"
(ellama--format-context session) prompt "\n\n"
- ellama-nick-prefix " " ellama-assistant-nick ":\n")
+ (ellama-get-nick-prefix-for-mode) " " ellama-assistant-nick ":\n")
(ellama-stream
(format ellama-translation-template
"english"
@@ -1070,9 +1079,9 @@ ARGS contains keys for fine control.
(with-current-buffer buffer
(save-excursion
(goto-char (point-max))
- (insert ellama-nick-prefix " " ellama-user-nick ":\n"
+ (insert (ellama-get-nick-prefix-for-mode) " " ellama-user-nick ":\n"
(ellama--format-context session) prompt "\n\n"
- ellama-nick-prefix " " ellama-assistant-nick ":\n")
+ (ellama-get-nick-prefix-for-mode) " " ellama-assistant-nick
":\n")
(ellama-stream prompt
:session session
:on-done #'ellama-chat-done
- [elpa] externals/ellama 68f3c79600 04/12: Replace single-quotes with double-quotes., (continued)
- [elpa] externals/ellama 68f3c79600 04/12: Replace single-quotes with double-quotes., ELPA Syncer, 2024/03/16
- [elpa] externals/ellama ce2a62f465 06/12: Fix merge error., ELPA Syncer, 2024/03/16
- [elpa] externals/ellama 2d58238f22 07/12: don't repeatedly push to global list, build a local list instead, ELPA Syncer, 2024/03/16
- [elpa] externals/ellama 0da3ec950f 02/12: Add docstrings for extension-based mode funcs., ELPA Syncer, 2024/03/16
- [elpa] externals/ellama 3bd4be45b8 03/12: Refactor mode checks., ELPA Syncer, 2024/03/16
- [elpa] externals/ellama b94d5952d4 12/12: Bump version, ELPA Syncer, 2024/03/16
- [elpa] externals/ellama 54a01b9de0 05/12: Merge branch 'main' into ellama-chat-mode, ELPA Syncer, 2024/03/16
- [elpa] externals/ellama 732f7dbee0 09/12: Bump version, ELPA Syncer, 2024/03/16
- [elpa] externals/ellama 035e858380 08/12: Merge pull request #92 from malb/main, ELPA Syncer, 2024/03/16
- [elpa] externals/ellama a5690a8fcb 10/12: Apply suggestions from code review, ELPA Syncer, 2024/03/16
- [elpa] externals/ellama a040305a12 11/12: Merge pull request #76 from stephenwithav/ellama-chat-mode,
ELPA Syncer <=