File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -642,10 +642,9 @@ class FormatConverter {
642642 id : streamId ,
643643 model : modelName ,
644644 object : "chat.completion.chunk" ,
645- usage : null ,
646645 } ;
647646
648- // Attach cached usage data to the very last message
647+ // Attach cached usage data to the very last message (if available)
649648 if ( streamState . usage ) {
650649 finalResponse . usage = streamState . usage ;
651650 }
Original file line number Diff line number Diff line change @@ -418,7 +418,12 @@ class RequestHandler {
418418 }
419419 if ( message . data ) fullBody += message . data ;
420420 }
421- const translatedChunk = this . formatConverter . translateGoogleToOpenAIStream ( fullBody , model ) ;
421+ const streamState = { } ;
422+ const translatedChunk = this . formatConverter . translateGoogleToOpenAIStream (
423+ fullBody ,
424+ model ,
425+ streamState
426+ ) ;
422427 if ( translatedChunk ) res . write ( translatedChunk ) ;
423428 res . write ( "data: [DONE]\n\n" ) ;
424429 this . logger . info ( "[Adapter] Fake mode: Complete content sent at once." ) ;
@@ -838,7 +843,7 @@ class RequestHandler {
838843 }
839844
840845 async _streamOpenAIResponse ( messageQueue , res , model ) {
841- const streamState = { inThought : false } ;
846+ const streamState = { } ;
842847 let streaming = true ;
843848
844849 while ( streaming ) {
You can’t perform that action at this time.
0 commit comments