Skip to content

Commit 65a8a88

Browse files
committed
style(xtask): 整理 think 的处理逻辑
Signed-off-by: YdrMaster <ydrml@hotmail.com>
1 parent b11aa15 commit 65a8a88

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

xtask/src/service/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,20 @@ async fn start_infer_service(
127127
tokens = &tokens[1..]
128128
}
129129
let think = if session_info.think {
130-
&tokens[..tokens.iter().take_while(|t| **t != _think).count()]
130+
if let Some(_think) = tokens.iter().position(|t| *t == _think) {
131+
session_info.think = false;
132+
let think = &tokens[.._think];
133+
tokens = &tokens[_think + 1..];
134+
think
135+
} else {
136+
let think = tokens;
137+
tokens = &[];
138+
think
139+
}
131140
} else {
132141
&[]
133142
};
134143

135-
if session_info.think {
136-
if think.len() < tokens.len() {
137-
session_info.think = false;
138-
tokens = &tokens[think.len() + 1..]
139-
} else {
140-
tokens = &[]
141-
}
142-
}
143144
let think = service_manager_for_recv
144145
.terminal
145146
.decode(think, &mut session_info.buf);

0 commit comments

Comments
 (0)