pub struct KnowledgeBase { /* private fields */ }Expand description
Clone shares one process-local engine. Close invalidates all its handles.
Implementations§
Source§impl KnowledgeBase
impl KnowledgeBase
pub fn open(directory: impl AsRef<Path>) -> Result<Self>
pub fn directory(&self) -> &Path
pub fn close(&self) -> Result<()>
pub fn memories(&self) -> MemoryStore
pub fn graph(&self) -> GraphStore
pub fn notes(&self) -> NoteStore
pub fn embeddings(&self) -> EmbeddingStore
Sourcepub fn update_index(&self) -> Result<HealthReport>
pub fn update_index(&self) -> Result<HealthReport>
追平待索引队列:把写入累积的待办一趟索引完、只提交一次。
写入不再就地索引,使用方(尤其批量导入)在合适时机调用本方法即可;
期间读取走 sync_index_if_behind 自愈兜底。
Sourcepub fn register_event_sink<F: Fn(&LogEvent) + Send + Sync + 'static>(
&self,
sink: F,
)
pub fn register_event_sink<F: Fn(&LogEvent) + Send + Sync + 'static>( &self, sink: F, )
注册事件接收回调。库在检索线程里同步调用它,所以回调必须非阻塞—— 在里面做同步 IO 或网络上报,会把检索拖住,和慢的重排回调一样。 回调抛错只丢这一条事件,不影响检索。不注册就完全不产出事件。
Sourcepub fn unregister_event_sink(&self) -> bool
pub fn unregister_event_sink(&self) -> bool
注销事件接收回调,返回此前是否有注册。
Sourcepub fn event_sink_registered(&self) -> bool
pub fn event_sink_registered(&self) -> bool
当前是否注册了事件接收回调。
pub fn rebuild_indexes(&self) -> Result<HealthReport>
Sourcepub fn rebuild_progress(&self) -> Result<RebuildProgressReport>
pub fn rebuild_progress(&self) -> Result<RebuildProgressReport>
读一次全文索引重建的进度快照。纯原子读、不碰写锁,可在重建进行时从另一线程轮询。
pub fn health(&self) -> Result<HealthReport>
Source§impl KnowledgeBase
impl KnowledgeBase
Sourcepub fn register_reranker<F: Reranker + 'static>(
&self,
reranker: F,
) -> Result<()>
pub fn register_reranker<F: Reranker + 'static>( &self, reranker: F, ) -> Result<()>
注册重排回调。调用前按声明的定长约束强制截断,宿主不自己重排。
pub fn register_reranker_with<F: Reranker + 'static>( &self, reranker: F, options: RerankerOptions, ) -> Result<()>
pub fn unregister_reranker(&self) -> bool
pub fn reranker_registered(&self) -> bool
pub fn search(&self, request: &SearchRequest) -> Result<SearchResult>
Sourcepub fn search_with_context(
&self,
request: &SearchRequest,
limit: usize,
) -> Result<Vec<ContextualHit>>
pub fn search_with_context( &self, request: &SearchRequest, limit: usize, ) -> Result<Vec<ContextualHit>>
先按 request 检索,再给每条命中挂上它在图上所在实体的邻域(实体 + 关系)。
「挂载」靠标签文本:命中的记录所带的 tag,与同一 namespace / scope 内某实体的名字或别名
文本相同,就认为该记录挂在这个实体上(两者都落在 strings 表,同一套归一化)。
limit 是每个实体邻域的规模上限。命中记录若没有命中任何实体,返回空邻域。
Source§impl KnowledgeBase
impl KnowledgeBase
Sourcepub fn search_preset(&self, request: &PresetRequest) -> Result<PresetResult>
pub fn search_preset(&self, request: &PresetRequest) -> Result<PresetResult>
按预设检索。三个字段各自独立排序,互不挤占。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for KnowledgeBase
impl !UnwindSafe for KnowledgeBase
impl Freeze for KnowledgeBase
impl Send for KnowledgeBase
impl Sync for KnowledgeBase
impl Unpin for KnowledgeBase
impl UnsafeUnpin for KnowledgeBase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more