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 @@ -2993,6 +2993,8 @@ int main(int argc, char ** argv) {
2993
2993
}, [&](json error_data) {
2994
2994
server_sent_event (sink, " error" , error_data);
2995
2995
});
2996
+ static const std::string ev_done = " data: [DONE]\n\n " ;
2997
+ sink.write (ev_done.data (), ev_done.size ());
2996
2998
sink.done ();
2997
2999
return true ;
2998
3000
};
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