Skip to content

Commit

Permalink
fix: answer state
Browse files Browse the repository at this point in the history
  • Loading branch information
xujingli authored and BroKun committed Oct 31, 2024
1 parent 5aa62f0 commit 2afa417
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions web-apps/ui/src/modules/chat-message/ai-message-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@ export class AIChatMessageItem extends ChatMessageItem {
}

appendChunk(e: ChatEventChunk) {
this.state = AnswerState.RECEIVING;
this.content = `${this.content}${e.output}`;
}

handleError(e: ChatEventError) {
this.state = AnswerState.FAIL;

// {"error": {"error_msg": "The node type is not supported"}, "type": "error"}
this.error = e.error;
}
Expand All @@ -95,6 +98,7 @@ export class AIChatMessageItem extends ChatMessageItem {
}

handleResult(e: ChatEventResult) {
this.state = AnswerState.SUCCESS;
this.content = e.output;
}
}
2 changes: 1 addition & 1 deletion web-apps/ui/src/modules/chat-message/chat-message-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export class ChatMessageModel implements Disposable {
this.handleChatEvent(value, ai);
}
}
ai.state = AnswerState.SUCCESS;
// ai.state = AnswerState.SUCCESS;
return;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class AUAgentChatMessageItem extends AIChatMessageItemModel {
}

override appendChunk(e: ChatEventChunk) {
this.state = AnswerState.RECEIVING;
this.content = `${this.content}${e.output}`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ export class AIChatMessageItemModel extends DefaultChatMessageItemModel {
}

appendChunk(e: ChatEventChunk) {
this.state = AnswerState.RECEIVING;
this.content = `${this.content}${e.output}`;
}

handleResult(e: ChatEventResult) {
this.content = e.output;
this.state = AnswerState.SUCCESS;
this.content = e.output;
}

handleError(e: ChatEventError) {
this.state = AnswerState.FAIL;
// {"error": {"error_msg": "The node type is not supported"}, "type": "error"}
this.error = { message: e.message };
}
Expand Down

0 comments on commit 2afa417

Please sign in to comment.