File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -385,6 +385,7 @@ export class ChatService {
385
385
async chat ( msg : string | ChatBody ) : Promise < void > {
386
386
this . #ctrl = new AbortController ( ) ;
387
387
let hadMatchMessage = false ;
388
+ let hadUsefulMessage = false ;
388
389
this . #chatting = true ;
389
390
await fetchEventSource (
390
391
`${ getBasePath ( ) } api/gateway/easyops.api.aiops_chat.manage.LLMChatProxy@1.0.0/api/aiops_chat/v1/chat/completions` ,
@@ -423,9 +424,24 @@ export class ChatService {
423
424
const { data } = msg ;
424
425
hadMatchMessage = true ;
425
426
if ( data === "[DONE]" ) {
427
+ if ( ! hadUsefulMessage ) {
428
+ this . enqueue ( {
429
+ topic : "add" ,
430
+ message : {
431
+ created : moment ( ) . format ( "YYYY-MM-DD HH:mm:ss" ) ,
432
+ delta : {
433
+ role : "assistant" ,
434
+ content : "" ,
435
+ } ,
436
+ agentId : this . #agentId,
437
+ robotId : this . #robotId,
438
+ } ,
439
+ } ) ;
440
+ }
426
441
this . #ctrl! . abort ( ) ;
427
442
return ;
428
443
}
444
+ hadUsefulMessage = true ;
429
445
let result = { } as SSEMessageItem ;
430
446
try {
431
447
result = JSON . parse ( data ) ;
@@ -538,7 +554,7 @@ export class ChatService {
538
554
539
555
stop ( ) {
540
556
clearTimeout ( this . #emitTimer) ;
541
- this . #ctrl && this . #ctrl ?. abort ( ) ;
557
+ this . #ctrl?. abort ( ) ;
542
558
this . #chatting = false ;
543
559
this . #emitTimer = undefined ;
544
560
this . #isStartEmitEvent = false ;
You can’t perform that action at this time.
0 commit comments