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 reconcile_index(&self) -> Result<HealthReport>
pub fn reconcile_index(&self) -> Result<HealthReport>
显式对账:把索引里实际存在的记录 id 与主库现存的记录 id 求差集对齐—— 索引里多出来的按 key 摘掉,缺的就地补上。只由下游主动调用:停电标记恢复 覆盖不了的残余(例如绕过 API 直改主库)由这里一次收敛。稳态下差集为空, 连一次提交都不发生。
Sourcepub fn update_index(&self) -> Result<HealthReport>
pub fn update_index(&self) -> Result<HealthReport>
提交写入攒下的增删(索引提交是写入路径的职责),并把已提交的「正在写入」标记清干净。
只清写入标记:删除标记(status=2)代表「删除没做完」,得留给下次开机或人工处理,
在这里抹掉就等于把恢复线索删了。没有对账、没有自愈——派生与权威的对齐由写路径当场保证,
差集对齐只留给显式调用。
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 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