File tree Expand file tree Collapse file tree 1 file changed +18
-19
lines changed Expand file tree Collapse file tree 1 file changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -507,22 +507,6 @@ export class OpenRouterChatLanguageModel implements LanguageModelV2 {
507
507
508
508
const delta = choice . delta ;
509
509
510
- if ( delta . content != null ) {
511
- if ( ! textStarted ) {
512
- textId = openrouterResponseId || generateId ( ) ;
513
- controller . enqueue ( {
514
- type : 'text-start' ,
515
- id : textId ,
516
- } ) ;
517
- textStarted = true ;
518
- }
519
- controller . enqueue ( {
520
- type : 'text-delta' ,
521
- delta : delta . content ,
522
- id : textId || generateId ( ) ,
523
- } ) ;
524
- }
525
-
526
510
const emitReasoningChunk = ( chunkText : string ) => {
527
511
if ( ! reasoningStarted ) {
528
512
reasoningId = openrouterResponseId || generateId ( ) ;
@@ -567,11 +551,26 @@ export class OpenRouterChatLanguageModel implements LanguageModelV2 {
567
551
}
568
552
}
569
553
}
570
- }
571
- else if ( delta . reasoning != null ) {
554
+ } else if ( delta . reasoning != null ) {
572
555
emitReasoningChunk ( delta . reasoning ) ;
573
556
}
574
-
557
+
558
+ if ( delta . content != null ) {
559
+ if ( ! textStarted ) {
560
+ textId = openrouterResponseId || generateId ( ) ;
561
+ controller . enqueue ( {
562
+ type : 'text-start' ,
563
+ id : textId ,
564
+ } ) ;
565
+ textStarted = true ;
566
+ }
567
+ controller . enqueue ( {
568
+ type : 'text-delta' ,
569
+ delta : delta . content ,
570
+ id : textId || generateId ( ) ,
571
+ } ) ;
572
+ }
573
+
575
574
if ( delta . tool_calls != null ) {
576
575
for ( const toolCallDelta of delta . tool_calls ) {
577
576
const index = toolCallDelta . index ?? toolCalls . length - 1 ;
You can’t perform that action at this time.
0 commit comments