emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/elisa f312d189f2 51/98: Fix one word lines in webpage q


From: ELPA Syncer
Subject: [elpa] externals/elisa f312d189f2 51/98: Fix one word lines in webpage quotes parsed asyncronously
Date: Wed, 17 Jul 2024 18:58:03 -0400 (EDT)

branch: externals/elisa
commit f312d189f290eb1fa22f4717da046e13ffd5b855
Author: Sergey Kostyaev <kostyaev.sergey2@wb.ru>
Commit: Sergey Kostyaev <kostyaev.sergey2@wb.ru>

    Fix one word lines in webpage quotes parsed asyncronously
---
 elisa.el | 66 ++++++++++++++++++++++++++++++++++------------------------------
 1 file changed, 35 insertions(+), 31 deletions(-)

diff --git a/elisa.el b/elisa.el
index 40f2de7fd0..e14b62be60 100644
--- a/elisa.el
+++ b/elisa.el
@@ -458,36 +458,36 @@ ARGS contains keys for fine control.
 :threshold-amount K -- K is a breakpoint threshold amount.
 
 than T, it will be packed into single semantic chunk."
-  (let* ((func (or (plist-get args :function) elisa-semantic-split-function))
-        (k (or (plist-get args :threshold-amount) 
elisa-breakpoint-threshold-amount))
-        (chunks (funcall func))
-        (embeddings (cl-remove-if
-                     #'not
-                     (mapcar (lambda (s)
-                               (when (length> (string-trim s) 0)
-                                 (llm-embedding elisa-embeddings-provider s)))
-                             chunks)))
-        (distances (elisa--distances embeddings))
-        (threshold (elisa-calculate-threshold k distances))
-        (result nil)
-        (current (car chunks))
-        (tail (cdr chunks)))
-    (mapc
-     (lambda (el)
-       (if (<= el threshold)
-          (setq current (concat current (car tail)))
-        (push current result)
-        (setq current (car tail)))
-       (setq tail (cdr tail)))
-     distances)
-    (push current result)
-    (cl-remove-if
-     #'string-empty-p
-     (mapcar (lambda (s)
-              (if s
-                  (string-trim s)
-                ""))
-            (nreverse result)))))
+  (when-let* ((func (or (plist-get args :function) 
elisa-semantic-split-function))
+             (k (or (plist-get args :threshold-amount) 
elisa-breakpoint-threshold-amount))
+             (chunks (funcall func))
+             (embeddings (cl-remove-if
+                          #'not
+                          (mapcar (lambda (s)
+                                    (when (length> (string-trim s) 0)
+                                      (llm-embedding elisa-embeddings-provider 
s)))
+                                  chunks)))
+             (distances (elisa--distances embeddings))
+             (threshold (elisa-calculate-threshold k distances))
+             (current (car chunks))
+             (tail (cdr chunks)))
+    (let* ((result nil))
+      (mapc
+       (lambda (el)
+        (if (<= el threshold)
+            (setq current (concat current (car tail)))
+          (push current result)
+          (setq current (car tail)))
+        (setq tail (cdr tail)))
+       distances)
+      (push current result)
+      (cl-remove-if
+       #'string-empty-p
+       (mapcar (lambda (s)
+                (if s
+                    (string-trim s)
+                  ""))
+              (nreverse result))))))
 
 (defun elisa-search-duckduckgo (prompt)
   "Search duckduckgo for PROMPT and return list of urls."
@@ -531,7 +531,10 @@ You can customize `elisa-searxng-url' to use non local 
instance."
                       (plz 'get url :as 'buffer
                         :headers `(("Accept" . ,eww-accept-content-types)
                                    ("Accept-Encoding" . "gzip")
-                                   ("User-Agent" . 
,(url-http--user-agent-default-string)))))))
+                                   ("User-Agent" . 
,(url-http--user-agent-default-string))))))
+       ;; fix one word lines for async execution
+       (shr-use-fonts nil)
+       (shr-width (- ellama-long-lines-length 5)))
     (when buffer-name
       (with-current-buffer buffer-name
        (goto-char (point-min))
@@ -814,6 +817,7 @@ WHERE d.rowid in %s;"
                  ,(async-inject-variables "elisa-web-pages-limit")
                  ,(async-inject-variables "elisa-breakpoint-threshold-amount")
                  ,(async-inject-variables "elisa-pandoc-executable")
+                 ,(async-inject-variables "ellama-long-lines-length")
                  ,(async-inject-variables "load-path")
                  (require 'elisa)
                  (,func))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]