File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -47,9 +47,7 @@ async fn main() {
4747
4848async fn listen_for_tokens ( mut chat_stream : Receiver < ChatCompletionDelta > ) -> ChatCompletion {
4949 let mut merged: Option < ChatCompletionDelta > = None ;
50-
51- let mut d = true ;
52- while d {
50+ loop {
5351 match chat_stream. try_recv ( ) {
5452 Ok ( delta) => {
5553 let choice = & delta. choices [ 0 ] ;
@@ -60,8 +58,7 @@ async fn listen_for_tokens(mut chat_stream: Receiver<ChatCompletionDelta>) -> Ch
6058 print ! ( "{}" , content) ;
6159 }
6260 stdout ( ) . flush ( ) . unwrap ( ) ;
63-
64- // Merge completion into accrued.
61+ // Merge token into full completion.
6562 match merged. as_mut ( ) {
6663 Some ( c) => {
6764 c. merge ( delta) . unwrap ( ) ;
@@ -70,11 +67,11 @@ async fn listen_for_tokens(mut chat_stream: Receiver<ChatCompletionDelta>) -> Ch
7067 } ;
7168 }
7269 Err ( TryRecvError :: Empty ) => {
73- let d = std:: time:: Duration :: from_millis ( 100 ) ;
74- std :: thread :: sleep ( d ) ;
70+ let duration = std:: time:: Duration :: from_millis ( 50 ) ;
71+ tokio :: time :: sleep ( duration ) . await ;
7572 }
7673 Err ( TryRecvError :: Disconnected ) => {
77- d = false ;
74+ break ;
7875 }
7976 } ;
8077 }
You can’t perform that action at this time.
0 commit comments