[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elisa c59d491e18 35/98: Add prompt rewriting with ellam
From: |
ELPA Syncer |
Subject: |
[elpa] externals/elisa c59d491e18 35/98: Add prompt rewriting with ellama-chain |
Date: |
Wed, 17 Jul 2024 18:58:02 -0400 (EDT) |
branch: externals/elisa
commit c59d491e18898f0c56da7602cb5bbdeb031757ff
Author: Sergey Kostyaev <kostyaev.sergey2@wb.ru>
Commit: Sergey Kostyaev <kostyaev.sergey2@wb.ru>
Add prompt rewriting with ellama-chain
---
elisa.el | 38 +++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/elisa.el b/elisa.el
index 20c4a251ed..a222b61745 100644
--- a/elisa.el
+++ b/elisa.el
@@ -5,7 +5,7 @@
;; Author: Sergey Kostyaev <sskostyaev@gmail.com>
;; URL: http://github.com/s-kostyaev/elisa
;; Keywords: help local tools
-;; Package-Requires: ((emacs "29.2") (ellama "0.8.6") (llm "0.9.1") (async
"1.9.8"))
+;; Package-Requires: ((emacs "29.2") (ellama "0.9.3") (llm "0.9.1") (async
"1.9.8"))
;; Version: 0.1.4
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Created: 18th Feb 2024
@@ -92,11 +92,25 @@
:group 'tools
:type 'string)
-(defcustom elisa-semantic-split-threshold 0.6
+(defcustom elisa-semantic-split-threshold 0.6 ;; 0.6 for paragraphs, 0.22 for
sentences
"Cosine similarity threshold for semantic splitting."
:group 'tools
:type 'float)
+(defcustom elisa-prompt-rewriting-enabled t
+ "Enable prompt rewriting for better retrieving."
+ :group 'tools
+ :type 'boolean)
+
+(defcustom elisa-rewrite-prompt-template
+ "With given context rewrite next user prompt to be understandable
+without context. Don't answer to prompt itself. Be short and
+concise. Act like user. Prompt:
+%s"
+ "Prompt template for prompt rewriting."
+ :group 'tools
+ :type 'string)
+
(defun elisa-sqlite-vss-download-url ()
"Generate sqlite vss download url based on current system."
(cond ((string-equal system-type "darwin")
@@ -428,9 +442,23 @@ closer it is to 1, the more similar it is."
(defun elisa-chat (prompt)
"Send PROMPT to elisa."
(interactive "sAsk elisa: ")
- (let ((infos (elisa-find-similar prompt)))
- (mapc #'ellama-context-add-info-node infos)
- (ellama-chat prompt nil :provider elisa-chat-provider)))
+ (if (and elisa-prompt-rewriting-enabled ellama--current-session-id)
+ (ellama-chain
+ prompt
+ `((:provider elisa-chat-provider
+ :session ,(with-current-buffer (ellama-get-session-buffer
ellama--current-session-id)
+ ellama--current-session)
+ :transform (lambda (s)
+ (format elisa-rewrite-prompt-template s)))
+ (:provider elisa-chat-provider
+ :transform (lambda (s)
+ (let ((infos (elisa-find-similar s)))
+ (mapc #'ellama-context-add-info-node infos)
+ ,prompt))
+ :chat t)))
+ (let ((infos (elisa-find-similar prompt)))
+ (mapc #'ellama-context-add-info-node infos)
+ (ellama-chat prompt nil :provider elisa-chat-provider))))
(provide 'elisa)
;;; elisa.el ends here.
- [elpa] externals/elisa 35f6e3dbd1 75/98: Disable reranker by default, (continued)
- [elpa] externals/elisa 35f6e3dbd1 75/98: Disable reranker by default, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 7d8da4cd04 79/98: Fix checkdoc warning, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 539b2ab04c 03/98: Add readme skeleton, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa fc5f9cae2a 45/98: Fix semantic split, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 2d8c6ef402 56/98: Use WAL for sqlite for handle concurrency, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 27fc248901 71/98: Remove files metadata on collection remove, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 5bf5d63fc1 07/98: Improve defaults, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 61dd36890a 21/98: Enable load file check in CI, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 1f5393d37e 22/98: Warn user instead of network call during package loading, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 80401a0b52 30/98: Search for gzipped builtin manuals, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa c59d491e18 35/98: Add prompt rewriting with ellama-chain,
ELPA Syncer <=
- [elpa] externals/elisa 3874a7007c 36/98: Improve semantic split api, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa f2bf34b201 39/98: Improve sqlite escape function, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 45b854ba2d 46/98: Fix linter warning, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa d58e172912 48/98: Make web search async, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa f312d189f2 51/98: Fix one word lines in webpage quotes parsed asyncronously, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 0fc73b4b9a 69/98: Add instruction to elisa-chat, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 4710f87851 72/98: Refactor parsing info manuals, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 86f4ea0afb 74/98: Fix parsing info manuals with infinite loop, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 9c7004e15c 77/98: Add functionality to parse web pages and add them to collections, ELPA Syncer, 2024/07/17
- [elpa] externals/elisa 4063c45908 78/98: Add custom variables documentation, ELPA Syncer, 2024/07/17