From ba1d2f3bf18139988381e5fc225344a188b9a229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E5=BA=86=E6=89=8D=E4=B8=A8=E9=9D=99=E8=A7=85?= Date: Sun, 21 Apr 2024 01:26:50 +0800 Subject: [PATCH] Fix conversation issue (#29) --- ...datacloud-hub-8d08d261-4654-4cc5-825d-5aa0e5c9c8fb.json | 7 +++++++ src/pages/chat/Conversation.vue | 7 ++++--- src/store/chat/actions.ts | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 change/@acedatacloud-hub-8d08d261-4654-4cc5-825d-5aa0e5c9c8fb.json diff --git a/change/@acedatacloud-hub-8d08d261-4654-4cc5-825d-5aa0e5c9c8fb.json b/change/@acedatacloud-hub-8d08d261-4654-4cc5-825d-5aa0e5c9c8fb.json new file mode 100644 index 00000000..033dce04 --- /dev/null +++ b/change/@acedatacloud-hub-8d08d261-4654-4cc5-825d-5aa0e5c9c8fb.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix conversation display issue", + "packageName": "@acedatacloud/hub", + "email": "cqc@cuiqingcai.com", + "dependentChangeType": "patch" +} diff --git a/src/pages/chat/Conversation.vue b/src/pages/chat/Conversation.vue index 0a30ea67..d3d09f86 100644 --- a/src/pages/chat/Conversation.vue +++ b/src/pages/chat/Conversation.vue @@ -184,7 +184,7 @@ export default defineComponent({ const token = this.credential?.token; const question = this.question; const references = this.references; - log(this.onFetchAnswer, 'validated', question, references); + console.debug('validated', question, references); // reset question and references this.question = ''; this.references = []; @@ -205,7 +205,7 @@ export default defineComponent({ role: ROLE_ASSISTANT, state: IChatMessageState.PENDING }); - log(this.onFetchAnswer, 'start to get answer', this.messages); + console.debug('start to get answer', this.messages); this.onScrollDown(); // request server to get answer this.answering = true; @@ -221,6 +221,7 @@ export default defineComponent({ { token, stream: (response: IChatConversationResponse) => { + console.debug('stream response', response); this.messages[this.messages.length - 1] = { role: ROLE_ASSISTANT, content: response.answer, @@ -232,7 +233,7 @@ export default defineComponent({ } ) .then(async () => { - log(this.onFetchAnswer, 'finished fetch answer'); + console.debug('finished fetch answer', this.messages); this.messages[this.messages.length - 1].state = IChatMessageState.FINISHED; await this.$store.dispatch('chat/setConversation', { id: conversationId, diff --git a/src/store/chat/actions.ts b/src/store/chat/actions.ts index 11253707..0fbe6714 100644 --- a/src/store/chat/actions.ts +++ b/src/store/chat/actions.ts @@ -125,6 +125,8 @@ export const getConversations = async ({ resolve(conversations); }) .catch((error) => { + state.status.getConversations = Status.Error; + commit('setConversations', []); reject(error); }); });