enhance: index embedding for updated blocks every 30s

This commit is contained in:
Tienson Qin
2025-07-19 14:36:11 +08:00
parent 133b5e497a
commit de80615c5f
4 changed files with 25 additions and 7 deletions

View File

@@ -3,9 +3,9 @@
(:require [frontend.common.missionary :as c.m]
[frontend.config :as config]
[frontend.flows :as flows]
[frontend.handler.db-based.vector-search-flows :as vector-search-flows]
[frontend.state :as state]
[missionary.core :as m]
[promesa.core :as p]))
[missionary.core :as m]))
(defn- run-background-task-when-not-publishing
[key' task]
@@ -15,7 +15,14 @@
(run-background-task-when-not-publishing
::init-load-model-when-switch-graph
(m/reduce
(fn [_ repo]
(when repo
(state/<invoke-db-worker :thread-api/vec-search-init-embedding-model repo)))
flows/current-repo-flow))
(constantly nil)
(m/ap
(m/?> vector-search-flows/infer-worker-ready-flow)
(when-let [repo (m/?< flows/current-repo-flow)]
(c.m/<? (state/<invoke-db-worker :thread-api/vec-search-init-embedding-model repo))
(m/?
(m/reduce
(fn []
(state/<invoke-db-worker :thread-api/vec-search-embedding-graph repo))
;; index new updates every 30s
(c.m/clock (* 30 1000))))))))