File tree 2 files changed +4
-0
lines changed
2 files changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -2986,6 +2986,8 @@ int main(int argc, char ** argv) {
2986
2986
}, [&](json error_data) {
2987
2987
server_sent_event (sink, " error" , error_data);
2988
2988
});
2989
+ static const std::string ev_done = " data: [DONE]\n\n " ;
2990
+ sink.write (ev_done.data (), ev_done.size ());
2989
2991
sink.done ();
2990
2992
return true ;
2991
2993
};
Original file line number Diff line number Diff line change @@ -1020,6 +1020,8 @@ async def oai_chat_completions(user_prompt,
1020
1020
event_data = line .split (': ' , 1 )
1021
1021
assert event_data [0 ] == 'data' , f'Bad event code received: ```{ event_data } ```'
1022
1022
chunk_raw = event_data [1 ]
1023
+ if chunk_raw == '[DONE]' :
1024
+ break
1023
1025
1024
1026
chunk = json .loads (chunk_raw )
1025
1027
assert len (chunk ['choices' ]) == 1 , f"no choices provided, line ```{ line } ```"
You can’t perform that action at this time.
0 commit comments