@@ -55,12 +55,12 @@ import { log } from '@/utils';
55
55
import { ROUTE_CHATDOC_CONVERSATION } from ' @/router' ;
56
56
import axios from ' axios' ;
57
57
import { isJSONString } from ' @/utils/is' ;
58
- import { Status } from ' @/models' ;
58
+ import { IService , Status } from ' @/models' ;
59
59
import ApplicationStatus from ' @/components/application/Status.vue' ;
60
- import { IChatdocChatResponse , IChatdocConversation , IChatdocMessageState , IChatdocRepository } from ' @/models' ;
60
+ import { IChatdocConversationResponse , IChatdocConversation , IChatdocMessageState , IChatdocRepository } from ' @/models' ;
61
61
62
62
export default defineComponent ({
63
- name: ' ChatdocChat ' ,
63
+ name: ' ChatdocConversation ' ,
64
64
components: {
65
65
Layout ,
66
66
Conversations ,
@@ -92,7 +92,7 @@ export default defineComponent({
92
92
repository(): IChatdocRepository | undefined {
93
93
return this .$store .state ?.chatdoc ?.repositories ?.find ((repository ) => repository .id === this .repositoryId );
94
94
},
95
- conversations() {
95
+ conversations(): IChatdocConversation [] | undefined {
96
96
return this .repository ?.conversations ;
97
97
},
98
98
conversationId(): string | undefined {
@@ -107,29 +107,23 @@ export default defineComponent({
107
107
initializing() {
108
108
return this .$store .state .chatdoc .status .getApplication === Status .Request ;
109
109
},
110
- service() {
110
+ service(): IService | undefined {
111
111
return this .$store .state .chatdoc .service ;
112
112
}
113
113
},
114
114
async mounted() {
115
115
console .log (' start get conversations' );
116
116
this .loading = true ;
117
- this .$store
118
- .dispatch (' chatdoc/getConversations' , { repositoryId: this .repositoryId })
119
- .then (() => {
120
- this .loading = false ;
121
- })
122
- .catch (() => {
123
- this .loading = false ;
124
- });
117
+ this .$store .dispatch (' chatdoc/getConversations' , { repositoryId: this .repositoryId }).finally (() => {
118
+ this .loading = false ;
119
+ });
125
120
},
126
121
methods: {
127
122
async onSubmit() {
128
123
this .messages .push ({
129
124
content: this .question ,
130
125
role: ROLE_USER
131
126
});
132
- console .debug (' onSubmit' , this .question );
133
127
await this .onFetchAnswer ();
134
128
},
135
129
async onScrollDown() {
@@ -169,21 +163,21 @@ export default defineComponent({
169
163
// request server to get answer
170
164
this .answering = true ;
171
165
chatdocOperator
172
- .chat (
166
+ .chatConversation (
173
167
{
174
168
repositoryId: this .repositoryId ,
175
169
question ,
176
- conversationId : this .conversationId
170
+ id : this .conversationId
177
171
},
178
172
{
179
173
token ,
180
- stream : (response : IChatdocChatResponse ) => {
174
+ stream : (response : IChatdocConversationResponse ) => {
181
175
this .messages [this .messages .length - 1 ] = {
182
176
role: ROLE_ASSISTANT ,
183
177
content: response .answer ,
184
178
state: IChatdocMessageState .ANSWERING
185
179
};
186
- conversationId = response .conversation_id ;
180
+ conversationId = response .id ;
187
181
this .onScrollDown ();
188
182
}
189
183
}
0 commit comments