switch search protocol order

This commit is contained in:
Junyi Du
2023-08-15 19:37:12 +08:00
parent 316a75f760
commit 23643fcf49
4 changed files with 17 additions and 13 deletions

View File

@@ -318,5 +318,3 @@ test('Select codeblock language while surrounded by text', async ({ page }) => {
'ABC \n```clojure\n```\nXYZ'
)
})
traceAll()

View File

@@ -30,9 +30,9 @@
(query [_this q opts]
(println "D:Search > Query blocks:" repo q opts)
(let [[e1 e2 e3] (get-registered-engines repo)]
(doseq [e e2]
(doseq [e e2] ;; Plugin Engines
(protocol/query e q opts))
(when e3
(when e3 ;; Semantic Engine
(protocol/query e3 q opts))
;; Return the promise of the integrated search
(protocol/query e1 q opts)))
@@ -40,9 +40,9 @@
(query-page [_this q opts]
(println "D:Search > Query-page contents:" repo q opts)
(let [[e1 e2 e3] (get-registered-engines repo)]
(doseq [e e2]
(doseq [e e2] ;; Plugin Engines
(protocol/query-page e q opts))
(when e3
(when e3 ;; Semantic Engine
(protocol/query-page e3 q opts))
;; Return the promise of the integrated search
(protocol/query-page e1 q opts)))
@@ -50,9 +50,9 @@
(rebuild-blocks-indice! [_this]
(println "D:Search > Initial blocks indice!:" repo)
(let [[e1 e2 e3] (get-registered-engines repo)]
(doseq [e e2]
(doseq [e e2] ;; Plugin Engines
(protocol/rebuild-blocks-indice! e))
(when e3
(when e3 ;; Semantic Engine
(protocol/rebuild-blocks-indice! e3))
;; Return the promise of the integrated search
(protocol/rebuild-blocks-indice! e1)))

View File

@@ -32,14 +32,15 @@
10)]
(p/let [embeds (text-encoder/text-encode q encoder-name)
embed (nth embeds 0)
rets (vector-store/search store-conn embed ret-k)]
(let [clj-ret (bean/->clj rets)
rets (vector-store/search store-conn embed ret-k)
clj-ret (bean/->clj rets)
transform-fn (fn [{:keys [data]}]
(let [{:keys [uuid page snippet]} data]
{:block/uuid uuid
:block/content snippet
:block/page page}))]
(mapv transform-fn clj-ret)))))
:block/page page}))
blocks (mapv transform-fn clj-ret)]
blocks)))
(query-page [_this _q _opt]
(prn "query full page search"))
(rebuild-blocks-indice! [_this]
@@ -80,6 +81,9 @@
:id (:id block)
:uuid (:uuid block)}
embeds (text-encoder/text-encode (:content block) encoder-name)
_ (prn "debug block embeds -> vs")
_ (prn (:content block))
_ (prn embeds) ;; TODO Junyi
_ (vector-store/rm store-conn (str (:id block)))
emb-add->vs (fn [embed]
(vector-store/add store-conn embed (str (:id block)) (bean/->js metadata)))]

View File

@@ -1573,6 +1573,8 @@ Similar to re-frame subscriptions"
(:search/engines @state))
(defn update-plugin-search-engine
"Put search engine results into the :result of state under :search/engines.
Then subscribed by the search modal to display results."
[pid name f]
(when-let [pid (keyword pid)]
(set-state! :search/engines
@@ -1954,7 +1956,7 @@ Similar to re-frame subscriptions"
(defn semsearch-enabled?
"Conditions to enable semantic search"
[]
(-> (:ai/text-encoders state)
(-> (:ai/text-encoders @state)
(not-empty)
(boolean)))