pub struct FocusManager {
pub current_focus_id: Option<String>,
pub foci: HashMap<String, FocusPoint>,
pub focus_history: Vec<String>,
pub config: FocusConfig,
pub focus_stack: Vec<String>,
pub active_foci: HashSet<String>,
pub focus_graph: HashMap<String, Vec<(String, f32)>>,
pub focus_tree: HashMap<String, Vec<String>>,
pub relevance_cache: HashMap<String, HashMap<String, f32>>,
pub cache_capacity: usize,
pub hardcode_config: HardcodeConfig,
}Expand description
聚焦点管理器
Fields§
§current_focus_id: Option<String>当前活跃的聚焦点 ID
foci: HashMap<String, FocusPoint>所有聚焦点(ID -> FocusPoint)
focus_history: Vec<String>聚焦点历史(按时间排序)
config: FocusConfig配置
focus_stack: Vec<String>焦点栈(支持多焦点并行跟踪) 第一个元素是主焦点,后续是次要焦点
active_foci: HashSet<String>活跃焦点集合(当前正在处理的多个焦点)
focus_graph: HashMap<String, Vec<(String, f32)>>焦点关联图(知识图谱) key: focus_id, value: [(related_focus_id, strength)]
focus_tree: HashMap<String, Vec<String>>焦点树(层次化结构) key: parent_focus_id, value: children_focus_ids
relevance_cache: HashMap<String, HashMap<String, f32>>相关性缓存(LRU) key: user_input_hash, value: {focus_id: relevance}
cache_capacity: usize缓存最大容量
hardcode_config: HardcodeConfig硬编码配置
Implementations§
Source§impl FocusManager
impl FocusManager
pub fn new() -> Self
Sourcepub fn current_focus(&self) -> Option<&FocusPoint>
pub fn current_focus(&self) -> Option<&FocusPoint>
获取当前聚焦点
Sourcepub fn current_focus_mut(&mut self) -> Option<&mut FocusPoint>
pub fn current_focus_mut(&mut self) -> Option<&mut FocusPoint>
获取当前聚焦点的可变引用
Sourcepub fn add_focus(&mut self, focus: FocusPoint)
pub fn add_focus(&mut self, focus: FocusPoint)
添加新聚焦点
Sourcepub fn switch_focus(&mut self, focus_id: &str) -> Option<()>
pub fn switch_focus(&mut self, focus_id: &str) -> Option<()>
切换聚焦点
Sourcepub fn should_create_new_focus(&self, user_input: &str) -> bool
pub fn should_create_new_focus(&self, user_input: &str) -> bool
判断是否需要创建新聚焦点
Sourcepub fn get_most_relevant_focus(&self, user_input: &str) -> Option<String>
pub fn get_most_relevant_focus(&self, user_input: &str) -> Option<String>
获取最相关的聚���点
Sourcepub fn update_focus_range(&mut self, focus_id: &str, message_index: usize)
pub fn update_focus_range(&mut self, focus_id: &str, message_index: usize)
更新聚焦点范围
Sourcepub fn complete_focus(&mut self, focus_id: &str)
pub fn complete_focus(&mut self, focus_id: &str)
标记聚焦点为已完成
Sourcepub fn create_focus_message(&self) -> Option<String>
pub fn create_focus_message(&self) -> Option<String>
生成聚焦点提示消息
Sourcepub fn primary_focus(&self) -> Option<&FocusPoint>
pub fn primary_focus(&self) -> Option<&FocusPoint>
获取焦点栈顶部的焦点(主焦点)
Sourcepub fn get_active_foci(&self) -> Vec<&FocusPoint>
pub fn get_active_foci(&self) -> Vec<&FocusPoint>
获取所有活跃焦点
Sourcepub fn switch_to_previous_focus(&mut self) -> Option<()>
pub fn switch_to_previous_focus(&mut self) -> Option<()>
切换回上一个焦点
Sourcepub fn activate_multiple_foci(&mut self, focus_ids: &[String])
pub fn activate_multiple_foci(&mut self, focus_ids: &[String])
并行激活多个焦点
Sourcepub fn add_focus_transition(
&mut self,
from_id: &str,
to_id: &str,
strength: f32,
)
pub fn add_focus_transition( &mut self, from_id: &str, to_id: &str, strength: f32, )
添加焦点切换关联
唤醒相关焦点
获取最相关的焦点(根据关联图)
Sourcepub fn split_focus(&mut self, parent_id: &str, child: FocusPoint)
pub fn split_focus(&mut self, parent_id: &str, child: FocusPoint)
分裂焦点(创建子焦点)
Sourcepub fn merge_focus_to_parent(&mut self, parent_id: &str, child_id: &str)
pub fn merge_focus_to_parent(&mut self, parent_id: &str, child_id: &str)
合并子焦点到父焦点
Sourcepub fn get_focus_tree_depth(&self, focus_id: &str) -> usize
pub fn get_focus_tree_depth(&self, focus_id: &str) -> usize
获取焦点树深度
Sourcepub fn record_negative_feedback(&mut self, focus_id: &str, message_index: usize)
pub fn record_negative_feedback(&mut self, focus_id: &str, message_index: usize)
记录负面反馈
Sourcepub fn record_positive_feedback(&mut self, focus_id: &str, message_index: usize)
pub fn record_positive_feedback(&mut self, focus_id: &str, message_index: usize)
记录正面反馈
Sourcepub fn predict_next_focus(&self) -> Option<String>
pub fn predict_next_focus(&self) -> Option<String>
预测下一个焦点
Sourcepub fn predict_by_keywords(&self, keywords: &[String]) -> Option<String>
pub fn predict_by_keywords(&self, keywords: &[String]) -> Option<String>
基于关键词相似度预测焦点
Sourcepub fn get_cached_relevance(
&mut self,
user_input: &str,
) -> Option<HashMap<String, f32>>
pub fn get_cached_relevance( &mut self, user_input: &str, ) -> Option<HashMap<String, f32>>
从缓存获取相关性
Sourcepub fn cache_relevance(
&mut self,
user_input: &str,
relevance: HashMap<String, f32>,
)
pub fn cache_relevance( &mut self, user_input: &str, relevance: HashMap<String, f32>, )
缓存相关性计算结果
Trait Implementations§
Source§impl Clone for FocusManager
impl Clone for FocusManager
Source§fn clone(&self) -> FocusManager
fn clone(&self) -> FocusManager
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FocusManager
impl Debug for FocusManager
Source§impl<'de> Deserialize<'de> for FocusManager
impl<'de> Deserialize<'de> for FocusManager
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for FocusManager
impl RefUnwindSafe for FocusManager
impl Send for FocusManager
impl Sync for FocusManager
impl Unpin for FocusManager
impl UnsafeUnpin for FocusManager
impl UnwindSafe for FocusManager
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