File tree Expand file tree Collapse file tree 2 files changed +4
-0
lines changed Expand file tree Collapse file tree 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) {
29932993 }, [&](json error_data) {
29942994 server_sent_event (sink, " error" , error_data);
29952995 });
2996+ static const std::string ev_done = " data: [DONE]\n\n " ;
2997+ sink.write (ev_done.data (), ev_done.size ());
29962998 sink.done ();
29972999 return true ;
29983000 };
Original file line number Diff line number Diff line change @@ -1020,6 +1020,8 @@ async def oai_chat_completions(user_prompt,
10201020 event_data = line .split (': ' , 1 )
10211021 assert event_data [0 ] == 'data' , f'Bad event code received: ```{ event_data } ```'
10221022 chunk_raw = event_data [1 ]
1023+ if chunk_raw == '[DONE]' :
1024+ break
10231025
10241026 chunk = json .loads (chunk_raw )
10251027 assert len (chunk ['choices' ]) == 1 , f"no choices provided, line ```{ line } ```"
You can’t perform that action at this time.
0 commit comments