Skip to content

滑动窗口初步#10

Open
seeelee wants to merge 12 commits intomainfrom
devel/sliding_window
Open

滑动窗口初步#10
seeelee wants to merge 12 commits intomainfrom
devel/sliding_window

Conversation

@seeelee
Copy link
Collaborator

@seeelee seeelee commented Jan 21, 2026

一坨草案

fn summarize(&self) {
let mut summary_text = self.summary.lock().unwrap().clone();
async fn summarize(&self) -> Result<Arc<RwLock<String>>, Box<dyn Error>> {
let mut summary_text = self.summary.write().unwrap().clone();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑使用更加健壮的错误处理

Err(e) => eprintln!("LLM Error: {}", e),
match call_llm(&summary_text).await {
Ok(response) => {
*summary_arc.write().unwrap() = response;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑使用更加健壮的错误处理

}
//获取摘要记忆
pub fn get_summary(&self) -> Arc<Mutex<String>> {
pub fn get_summary(&self) -> Arc<RwLock<String>> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

传出的类型应该不允许可变,summary是一个滑动窗口维护的状态。

Copy link
Owner

@dynamder dynamder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请采用更加健壮的错误处理方式,并更细致的控制方法返回的类型是否应该允许可变。

}

//将摘要记忆和当前滑动窗口信息合并提供LLM
async fn summarize(&self) -> Result<Arc<RwLock<String>>, Box<dyn Error>> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

返回类型Arc不必要,同时此处的返回类型将写权限暴露给外部

Comment on lines +101 to +107
let mut summary_text = match self.summary.write() {
Ok(mut value) => value.clone(),
Err(e) => {
eprintln!("Summary Error: {}", e);
String::new()
}
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处错误为锁中毒,应该提前返回

println!("Summary updated in background.");
*value = response
},
Err(e) => eprintln!("LLM Error: {}", e),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处错误为锁中毒

Copy link
Owner

@dynamder dynamder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants