ai-error-assistant-pro 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/demo/api/index.js +27 -4
- package/components/demo/src/chat-tools.vue +5 -1
- package/components/demo/src/chat.vue +131 -33
- package/components/demo/src/error-chat.vue +18 -4
- package/components/demo/src/main.vue +57 -24
- package/components/demo/utils/config.js +15 -11
- package/components/demo/utils/request.js +9 -7
- package/dist/ai-error-assistant-pro.common.js +2829 -235
- package/dist/ai-error-assistant-pro.common.js.map +1 -1
- package/dist/ai-error-assistant-pro.css +1 -1
- package/dist/ai-error-assistant-pro.umd.js +2829 -235
- package/dist/ai-error-assistant-pro.umd.js.map +1 -1
- package/dist/ai-error-assistant-pro.umd.min.js +4 -4
- package/dist/ai-error-assistant-pro.umd.min.js.map +1 -1
- package/package.json +6 -5
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import request from '../utils/request'
|
|
2
2
|
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
|
3
3
|
import constants from '../utils/constants';
|
|
4
|
-
const baseURL = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_BASE_URL') || constants.publicPath;
|
|
5
|
-
const prefix = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_PRE_FIX') || constants.publicPrefix;
|
|
6
4
|
import cache from '../plugins/cache';
|
|
5
|
+
const baseURL = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_BASE_URL') || constants.publicPath;
|
|
6
|
+
let prefix = sessionStorage.getItem('AI-INTELLIGENT-TOOLS_PRE_FIX') || constants.publicPrefix;
|
|
7
|
+
|
|
8
|
+
// 0.0.7 版本接口升级
|
|
9
|
+
prefix += '/plugin/v2';
|
|
7
10
|
export const ssoAuth = (token) => {
|
|
8
11
|
return request({
|
|
9
12
|
url: prefix + '/sso/assistant',
|
|
@@ -70,14 +73,34 @@ export const chartClear = (chatId) => {
|
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
export const checkCourseIdIsExist = (resId) => {
|
|
77
|
+
return request({
|
|
78
|
+
url: prefix + `/ia/hasPermission?courseId=${resId}`,
|
|
79
|
+
method: 'get',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 自动追问
|
|
85
|
+
* @param iaId 请求参数id
|
|
86
|
+
* @param message 对话对
|
|
87
|
+
* @returns 返回节点详情数据
|
|
88
|
+
*/
|
|
89
|
+
export async function getAutoQuestioning(iaId, message) {
|
|
90
|
+
return request.post(`${prefix}/ia/autoFollowUp`, {
|
|
91
|
+
iaId,
|
|
92
|
+
messages: message,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
73
96
|
export async function sendMessageEventSource(params, signal, onmessage) {
|
|
74
|
-
return fetchEventSource(`${baseURL}${prefix}/assistant/conversation`, {
|
|
97
|
+
return fetchEventSource(`${baseURL}${prefix}/assistant/conversation?token=${cache.session.getJSON('SRKJ_TOKEN_CACHE')}`, {
|
|
75
98
|
method: 'POST',
|
|
76
99
|
signal: signal,
|
|
77
100
|
openWhenHidden: true,
|
|
78
101
|
headers: {
|
|
79
102
|
'Content-Type': 'application/json',
|
|
80
|
-
'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE'),
|
|
103
|
+
// 'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE'),
|
|
81
104
|
},
|
|
82
105
|
body: JSON.stringify(params),
|
|
83
106
|
onmessage,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="robot-tools" v-if="listData">
|
|
3
3
|
<div class="robot-reanswer"
|
|
4
4
|
style="margin-bottom: 8px"
|
|
5
|
-
v-if="listData.stop || listData.finish || type === 'error' && !sending"
|
|
5
|
+
v-if="(listData.stop || listData.finish || type === 'error' && !sending) && isLast"
|
|
6
6
|
@click="reAnswer(listData)">
|
|
7
7
|
<i class="el-icon-refresh-right"></i>
|
|
8
8
|
重新回答
|
|
@@ -83,6 +83,10 @@ export default {
|
|
|
83
83
|
sending: {
|
|
84
84
|
type: Boolean,
|
|
85
85
|
default: false
|
|
86
|
+
},
|
|
87
|
+
isLast: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: false
|
|
86
90
|
}
|
|
87
91
|
},
|
|
88
92
|
data() {
|
|
@@ -12,22 +12,48 @@
|
|
|
12
12
|
<div :class="{'user-info': list.type === 'user'}" class="robot-message">
|
|
13
13
|
<div v-html="list.message"></div>
|
|
14
14
|
<div v-if="list.type === 'robot' && list.links.length > 0" class="link">
|
|
15
|
+
<div v-if="!list.allIdWithStart">
|
|
16
|
+
<div class="link-title">参考文件</div>
|
|
17
|
+
<div class="link-content">
|
|
18
|
+
<template v-for="item in list.links">
|
|
19
|
+
<div class="links" v-if="!item.title.startsWith(chatMajorId)">
|
|
20
|
+
<a :href="'https://ai-yuliao.hep.com.cn'+item.documentUrl" target="_blank">
|
|
21
|
+
<span>{{ item.title }}</span>
|
|
22
|
+
</a>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
<div v-if="list.type === 'robot' && list.connectUrl.length > 0" class="link">
|
|
15
29
|
<div class="link-title">相关链接</div>
|
|
16
30
|
<div class="link-content">
|
|
17
|
-
<template v-for="item in list.
|
|
18
|
-
<div class="links"
|
|
19
|
-
<a :href="
|
|
20
|
-
<span>{{ item.
|
|
31
|
+
<template v-for="item in list.connectUrl">
|
|
32
|
+
<div class="links">
|
|
33
|
+
<a :href="item.iaUrl" target="_blank">
|
|
34
|
+
<span>{{ item.iaUrlName }}</span>
|
|
21
35
|
</a>
|
|
22
36
|
</div>
|
|
23
37
|
</template>
|
|
24
|
-
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<div v-if="list.type === 'robot' && finish && list.followUps && list.followUps.length > 0">
|
|
41
|
+
<div class="link-title">智能追问</div>
|
|
42
|
+
<div class="link-content">
|
|
43
|
+
<div class="hot-list"
|
|
44
|
+
v-for="(list, index) in list.followUps"
|
|
45
|
+
:key="index"
|
|
46
|
+
@click="selectModule(list)">
|
|
47
|
+
{{ list }}
|
|
48
|
+
<i class="el-icon-arrow-right go-icon"></i>
|
|
49
|
+
</div>
|
|
25
50
|
</div>
|
|
26
51
|
</div>
|
|
27
52
|
<chat-tools v-if="list.type === 'robot'"
|
|
28
53
|
:chatId="chatId"
|
|
29
54
|
:detail-data="list"
|
|
30
55
|
:sending="list.sending"
|
|
56
|
+
:is-last="index === messageData.length - 1"
|
|
31
57
|
@on-reanswer="(list) => reanswer(list, index)"
|
|
32
58
|
@on-stop-chat="onStopChat"/>
|
|
33
59
|
</div>
|
|
@@ -38,7 +64,8 @@
|
|
|
38
64
|
import { errorList } from '../utils/config';
|
|
39
65
|
import ChatTools from './chat-tools.vue';
|
|
40
66
|
import ErrorChat from './error-chat.vue';
|
|
41
|
-
import {
|
|
67
|
+
import { marked } from 'marked';
|
|
68
|
+
import { chartClear, sendMessageEventSource, getAutoQuestioning } from "../api";
|
|
42
69
|
const controller = new AbortController();
|
|
43
70
|
const signal = controller.signal;
|
|
44
71
|
|
|
@@ -73,6 +100,7 @@ export default {
|
|
|
73
100
|
messageData: [],
|
|
74
101
|
chatId: '', // 对话id
|
|
75
102
|
chatMajorId: '',
|
|
103
|
+
finish: false,
|
|
76
104
|
}
|
|
77
105
|
},
|
|
78
106
|
computed: {
|
|
@@ -103,6 +131,7 @@ export default {
|
|
|
103
131
|
},
|
|
104
132
|
async postMessage(list, commonKey, parentMsgId) {
|
|
105
133
|
let reanswerParams = {};
|
|
134
|
+
this.finish = false;
|
|
106
135
|
if (list) {
|
|
107
136
|
list.sending = true;
|
|
108
137
|
reanswerParams = {
|
|
@@ -112,6 +141,8 @@ export default {
|
|
|
112
141
|
content: this.messageData[list.index - 1].message,
|
|
113
142
|
}
|
|
114
143
|
this.messageData[list.index].message = '';
|
|
144
|
+
this.messageData[list.index].cacheMessage = '';
|
|
145
|
+
this.makeAutoMessage();
|
|
115
146
|
}
|
|
116
147
|
const params = {
|
|
117
148
|
messageList: [
|
|
@@ -121,35 +152,54 @@ export default {
|
|
|
121
152
|
chatId: this.chatId || undefined,
|
|
122
153
|
commonKey: commonKey || false,
|
|
123
154
|
parentMsgId: parentMsgId || undefined,
|
|
155
|
+
xtId: this.analyExercise.busId,
|
|
124
156
|
...reanswerParams,
|
|
125
157
|
}
|
|
126
158
|
]
|
|
127
159
|
};
|
|
128
160
|
// list 存在说明是重新生成
|
|
129
161
|
if (!list && !commonKey) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
162
|
+
const userWord = this.keyWord || this.cacheKeyWord;
|
|
163
|
+
this.messageData.push({ type: 'user', message: userWord.replace(/\n/g, '<br>') });
|
|
164
|
+
setTimeout(() => {
|
|
165
|
+
this.messageData.push(
|
|
166
|
+
{
|
|
167
|
+
type: 'robot',
|
|
168
|
+
message: '',
|
|
169
|
+
cacheMessage: '',
|
|
170
|
+
zan: false,
|
|
171
|
+
cai: false,
|
|
172
|
+
stop: false,
|
|
173
|
+
finish: false,
|
|
174
|
+
sending: true,
|
|
175
|
+
links: [],
|
|
176
|
+
connectUrl: [],
|
|
177
|
+
reAnswerCount: 0
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
this.makeAutoMessage();
|
|
181
|
+
});
|
|
144
182
|
}
|
|
145
183
|
await sendMessageEventSource(params, signal, res => {
|
|
146
184
|
this.makeMessageLine(res, list);
|
|
147
185
|
});
|
|
148
186
|
},
|
|
187
|
+
makeAutoMessage() {
|
|
188
|
+
const cacheMessage = [];
|
|
189
|
+
for (let i = 0; i < this.messageData.length; i++) {
|
|
190
|
+
const current = this.messageData[i];
|
|
191
|
+
cacheMessage.push({
|
|
192
|
+
role: current.type === 'robot' ? 'assistant' : 'user',
|
|
193
|
+
content: current.message || '正在思考中。',
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
this.makeAutoQuestioning(cacheMessage);
|
|
197
|
+
},
|
|
149
198
|
makeMessageLine(res, list) {
|
|
150
|
-
const { content, status, chatId, msgId, parentMsgId, reference, commonKey } = JSON.parse(res.data);
|
|
199
|
+
const { content, status, chatId, msgId, parentMsgId, reference, commonKey, connectUrl } = JSON.parse(res.data);
|
|
151
200
|
let index = list ? list.index : this.messageData.length - 1;
|
|
152
201
|
const currentList = this.messageData[index];
|
|
202
|
+
let allIdWithStart = true;
|
|
153
203
|
// 结束标识
|
|
154
204
|
if (status === 2 || status === 1) {
|
|
155
205
|
if (commonKey) {
|
|
@@ -160,12 +210,23 @@ export default {
|
|
|
160
210
|
currentList.finish = true;
|
|
161
211
|
if (reference) {
|
|
162
212
|
currentList.links = JSON.parse(reference);
|
|
213
|
+
currentList.links.map((item) => {
|
|
214
|
+
if (!item.title.startsWith(this.chatMajorId)) {
|
|
215
|
+
allIdWithStart = false;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
163
218
|
}
|
|
219
|
+
if (connectUrl) {
|
|
220
|
+
currentList.connectUrl = JSON.parse(connectUrl);
|
|
221
|
+
}
|
|
222
|
+
currentList.allIdWithStart = allIdWithStart;
|
|
164
223
|
this.cacheKeyWord = '';
|
|
224
|
+
this.finish = true;
|
|
165
225
|
this.$emit('on-message-finish', chatId);
|
|
166
226
|
return;
|
|
167
227
|
}
|
|
168
|
-
currentList.
|
|
228
|
+
currentList.cacheMessage += content;
|
|
229
|
+
currentList.message = marked.parse(currentList.cacheMessage);
|
|
169
230
|
currentList.msgId = msgId;
|
|
170
231
|
currentList.parentMsgId = parentMsgId;
|
|
171
232
|
currentList.chatId = chatId;
|
|
@@ -176,9 +237,25 @@ export default {
|
|
|
176
237
|
// 防止出现调用基础模型前导致停止回答id错误
|
|
177
238
|
setTimeout(() => currentList.sending = false,500);
|
|
178
239
|
},
|
|
240
|
+
async makeAutoQuestioning (messages) {
|
|
241
|
+
// 首次不触发
|
|
242
|
+
if (messages.length <= 2) return;
|
|
243
|
+
const autoRes = await getAutoQuestioning(this.chatMajorId, messages);
|
|
244
|
+
const {
|
|
245
|
+
message: {
|
|
246
|
+
content: { followUps },
|
|
247
|
+
},
|
|
248
|
+
} = autoRes;
|
|
249
|
+
this.messageData[this.messageData.length - 1].followUps =
|
|
250
|
+
followUps.length > 3 ? followUps.splice(0, 3) : followUps;
|
|
251
|
+
},
|
|
179
252
|
onStopChat(list){
|
|
180
253
|
this.$emit('on-message-finish', list.chatId)
|
|
181
254
|
},
|
|
255
|
+
selectModule(message) {
|
|
256
|
+
this.cacheKeyWord = message;
|
|
257
|
+
this.postMessage();
|
|
258
|
+
},
|
|
182
259
|
async clearChat() {
|
|
183
260
|
if (this.messageData.length < 1) {
|
|
184
261
|
this.$message.warning('当前对话为最新对话');
|
|
@@ -193,26 +270,37 @@ export default {
|
|
|
193
270
|
list.stop = false;
|
|
194
271
|
list.finish = false;
|
|
195
272
|
list.links = [];
|
|
273
|
+
list.connectUrl = [];
|
|
196
274
|
this.postMessage(list);
|
|
197
275
|
this.$emit('on-reanser');
|
|
198
276
|
},
|
|
199
277
|
errorChatInit(list, chatId) {
|
|
200
|
-
const { chatMajorId } = list[0];
|
|
201
|
-
this.chatMajorId = chatMajorId.toString();
|
|
202
278
|
if (list && list[0].contents) {
|
|
279
|
+
const { chatMajorId } = list[0];
|
|
280
|
+
this.chatMajorId = chatMajorId && chatMajorId.toString();
|
|
203
281
|
const cacheArray = [];
|
|
204
282
|
list[0].contents.reverse().map((list) => {
|
|
283
|
+
let allIdWithStart = true;
|
|
284
|
+
if (this.chatMajorId && list.references) {
|
|
285
|
+
list.references.map((item) => {
|
|
286
|
+
if (!item.title.startsWith(this.chatMajorId)) {
|
|
287
|
+
allIdWithStart = false;
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
205
291
|
const obj = {
|
|
206
292
|
type: list.role === 'assistant' ? 'robot' : 'user',
|
|
207
|
-
message: list.content.replace(/\n/g, '<br>'),
|
|
293
|
+
message: list.role === 'assistant' ? marked.parse(list.content) : list.content.replace(/\n/g, '<br>'),
|
|
208
294
|
zan: list.type === 1,
|
|
209
295
|
cai: list.type === 2,
|
|
210
296
|
stop: list.status === 1,
|
|
211
297
|
finish: true,
|
|
212
298
|
links: list.references || [],
|
|
299
|
+
connectUrl: list.connectUrls || [],
|
|
213
300
|
reAnswerCount: 0,
|
|
214
301
|
msgId: list.contentId,
|
|
215
|
-
parentMsgId: list.parentMsgId
|
|
302
|
+
parentMsgId: list.parentMsgId,
|
|
303
|
+
allIdWithStart
|
|
216
304
|
};
|
|
217
305
|
cacheArray.push(obj);
|
|
218
306
|
})
|
|
@@ -311,13 +399,6 @@ export default {
|
|
|
311
399
|
width: 100%;
|
|
312
400
|
margin-bottom: 16px;
|
|
313
401
|
|
|
314
|
-
.link-title {
|
|
315
|
-
color: #878aab;
|
|
316
|
-
font-size: 14px;
|
|
317
|
-
margin: 8px 0;
|
|
318
|
-
text-align: left;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
402
|
.link-content {
|
|
322
403
|
background: #fafafd;
|
|
323
404
|
border-radius: 8px;
|
|
@@ -347,10 +428,27 @@ export default {
|
|
|
347
428
|
}
|
|
348
429
|
}
|
|
349
430
|
}
|
|
431
|
+
.link-title {
|
|
432
|
+
color: #878aab;
|
|
433
|
+
font-size: 14px;
|
|
434
|
+
margin: 8px 0;
|
|
435
|
+
text-align: left;
|
|
436
|
+
}
|
|
350
437
|
.robot-image-div {
|
|
351
438
|
width: 48px;
|
|
352
439
|
height: 48px;
|
|
353
440
|
background: url("../static/robot.png");
|
|
354
441
|
background-size: 100%;
|
|
355
442
|
}
|
|
443
|
+
.hot-list {
|
|
444
|
+
background-color: rgba(241, 243, 245, 1);
|
|
445
|
+
border-radius: 8px;
|
|
446
|
+
font-size: 16px;
|
|
447
|
+
padding: 10px 24px 10px 16px;
|
|
448
|
+
margin-top: 8px;
|
|
449
|
+
cursor: pointer;
|
|
450
|
+
&:hover {
|
|
451
|
+
background-color: rgba(96, 96, 224, 0.24);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
356
454
|
</style>
|
|
@@ -67,10 +67,15 @@
|
|
|
67
67
|
<div class="answer-content" v-html="analysisData.analysis"></div>
|
|
68
68
|
<div class="title-label">错因分析</div>
|
|
69
69
|
<div class="answer-content" v-html="analysisData.reason"></div>
|
|
70
|
-
<div class="title-label" v-if="analysisData.recommend && analysisData.recommend.length > 0"
|
|
70
|
+
<div class="title-label" v-if="analysisData.recommend && analysisData.recommend.length > 0 && !allIdWithStart">
|
|
71
|
+
推荐资料
|
|
72
|
+
</div>
|
|
71
73
|
<div class="answer-content">
|
|
72
74
|
<div v-for="(list,index) in analysisData.recommend" :key="index" style="margin-bottom: 8px">
|
|
73
|
-
<a :href="'https://ai-yuliao.hep.com.cn' + list.url"
|
|
75
|
+
<a :href="'https://ai-yuliao.hep.com.cn' + list.url"
|
|
76
|
+
target="_blank"
|
|
77
|
+
v-if="!list.title.startsWith(chatMajorId)">{{ list.title }}
|
|
78
|
+
</a>
|
|
74
79
|
</div>
|
|
75
80
|
</div>
|
|
76
81
|
<chat-tools type="error"
|
|
@@ -95,7 +100,9 @@ export default {
|
|
|
95
100
|
return {
|
|
96
101
|
detailData: {}, // 记录页面点赞 踩情况
|
|
97
102
|
analysisData: {}, // 记录页面点赞 踩情况
|
|
98
|
-
chatId: '' // 对话id
|
|
103
|
+
chatId: '', // 对话id
|
|
104
|
+
chatMajorId: '', // 智能体id
|
|
105
|
+
allIdWithStart: true // 智能体id
|
|
99
106
|
}
|
|
100
107
|
},
|
|
101
108
|
watch: {
|
|
@@ -123,6 +130,7 @@ export default {
|
|
|
123
130
|
eaAnalysisDtoList: [{ content, errId, chatId, contentId, type }],
|
|
124
131
|
xhModelDetailVoList
|
|
125
132
|
} = analysisRes;
|
|
133
|
+
if (xhModelDetailVoList) this.chatMajorId = xhModelDetailVoList[0].chatMajorId;
|
|
126
134
|
// 传入工具中的值
|
|
127
135
|
this.chatId = chatId;
|
|
128
136
|
this.detailData = {
|
|
@@ -134,13 +142,19 @@ export default {
|
|
|
134
142
|
try {
|
|
135
143
|
this.analysisData = JSON.parse(content);
|
|
136
144
|
this.detailData.errId = errId;
|
|
145
|
+
|
|
146
|
+
for (let item of this.analysisData.recommend) {
|
|
147
|
+
if (!item.title.startsWith(this.chatMajorId)) {
|
|
148
|
+
this.allIdWithStart = false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
137
151
|
} catch (e) {
|
|
138
152
|
this.$message.warning('解析失败' + e);
|
|
139
153
|
this.analysisData = { key: true };
|
|
140
154
|
console.log(e);
|
|
141
155
|
}
|
|
142
156
|
} catch (e) {
|
|
143
|
-
|
|
157
|
+
throw new Error(e);
|
|
144
158
|
}
|
|
145
159
|
},
|
|
146
160
|
async reanswer(list) {
|
|
@@ -10,37 +10,42 @@
|
|
|
10
10
|
<i class="el-icon-close"></i>
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
|
-
<div class="
|
|
14
|
-
<
|
|
15
|
-
:resId="resId"
|
|
16
|
-
:xtId="xtId"
|
|
17
|
-
:key-word="aiMessageKeyWord"
|
|
18
|
-
:analy-exercise="analyExercise"
|
|
19
|
-
@on-reanser="reanserMethod"
|
|
20
|
-
@on-message-finish="messageFinish" />
|
|
13
|
+
<div v-if="!courseFlag" class="message-wrap">
|
|
14
|
+
<div class="message-line">{{message}}</div>
|
|
21
15
|
</div>
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<img src="../static/send-icon.png" alt="" style="width: 24px; height: 24px">
|
|
16
|
+
<template v-else>
|
|
17
|
+
<div class="ai-main-content">
|
|
18
|
+
<chat ref="chatRef"
|
|
19
|
+
:resId="resId"
|
|
20
|
+
:xtId="xtId"
|
|
21
|
+
:key-word="aiMessageKeyWord"
|
|
22
|
+
:analy-exercise="analyExercise"
|
|
23
|
+
@on-reanser="reanserMethod"
|
|
24
|
+
@on-message-finish="messageFinish" />
|
|
32
25
|
</div>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
<div class="tools-wrap">
|
|
27
|
+
<span @click="clearChat">清空对话</span>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="ai-message-send" @keyup.enter="goChat">
|
|
30
|
+
<el-input v-model="aiMessage"
|
|
31
|
+
placeholder="可以提出问题..."
|
|
32
|
+
type="textarea"
|
|
33
|
+
:rows="2"></el-input>
|
|
34
|
+
<div class="ai-send-icon" @click="goChat">
|
|
35
|
+
<img src="../static/send-icon.png" alt="" style="width: 24px; height: 24px">
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
<p class="disclaimer">
|
|
39
|
+
此功能公测期间对正式版用户开放
|
|
40
|
+
</p>
|
|
41
|
+
</template>
|
|
37
42
|
</div>
|
|
38
43
|
</template>
|
|
39
44
|
<script>
|
|
40
45
|
import Chat from './chat.vue';
|
|
41
46
|
import Cookies from "js-cookie";
|
|
42
47
|
import { getUserInfo } from '../utils/config';
|
|
43
|
-
import {
|
|
48
|
+
import { checkCourseIdIsExist } from '../api/index';
|
|
44
49
|
export default {
|
|
45
50
|
name: 'AiErrorAssistant',
|
|
46
51
|
components: {
|
|
@@ -58,11 +63,27 @@ export default {
|
|
|
58
63
|
return this.analyExercise.busId;
|
|
59
64
|
}
|
|
60
65
|
},
|
|
66
|
+
watch: {
|
|
67
|
+
visible() {
|
|
68
|
+
if (this.visible){
|
|
69
|
+
checkCourseIdIsExist(this.resId).then(res=>{
|
|
70
|
+
if (res.flag === true){
|
|
71
|
+
this.courseFlag = true;
|
|
72
|
+
}else{
|
|
73
|
+
this.courseFlag = false;
|
|
74
|
+
this.message = res.message;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
},
|
|
61
80
|
data() {
|
|
62
81
|
return {
|
|
63
82
|
aiMessage: '', // 页面显示值
|
|
64
83
|
aiMessageKeyWord: '', // 传入组件值
|
|
65
|
-
stop: false
|
|
84
|
+
stop: false,
|
|
85
|
+
courseFlag: false,
|
|
86
|
+
message:'',
|
|
66
87
|
}
|
|
67
88
|
},
|
|
68
89
|
mounted() {
|
|
@@ -219,6 +240,18 @@ export default {
|
|
|
219
240
|
text-align: center;
|
|
220
241
|
margin-top: 6px;
|
|
221
242
|
}
|
|
243
|
+
.message-wrap {
|
|
244
|
+
height: calc(100% - 53px );
|
|
245
|
+
align-items: center;
|
|
246
|
+
justify-content: center;
|
|
247
|
+
display: flex;
|
|
248
|
+
flex-direction: column;
|
|
249
|
+
}
|
|
250
|
+
.message-line {
|
|
251
|
+
color: red;
|
|
252
|
+
font-size: 25px;
|
|
253
|
+
margin: 8px 0; /* 上下各 8px 的间距 */
|
|
254
|
+
}
|
|
222
255
|
:deep {
|
|
223
256
|
.ai-message-send {
|
|
224
257
|
.el-textarea__inner {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ssoAuth, authUser } from '../api/index';
|
|
2
|
-
import constants from '../utils/constants';
|
|
2
|
+
// import constants from '../utils/constants';
|
|
3
3
|
import cache from '../plugins/cache';
|
|
4
4
|
|
|
5
5
|
export const errorList = [
|
|
@@ -74,15 +74,19 @@ export const cacheMessageList = [
|
|
|
74
74
|
// studentAnswer: '错误的简答题简答题错误错误的简答题简答题错误错误的简答题简答题错误错误的简答题简答题错误',
|
|
75
75
|
// }
|
|
76
76
|
|
|
77
|
+
// export const getUserInfo = async (token) => {
|
|
78
|
+
// const ssoRes = await ssoAuth(token);
|
|
79
|
+
// const userRes = await authUser({
|
|
80
|
+
// 'X-Auth-User': encodeURIComponent(ssoRes.name),
|
|
81
|
+
// 'X-Auth-Token': ssoRes.password,
|
|
82
|
+
// 'X-Enterprise-Id': `${constants['X-Enterprise-Id']}`,
|
|
83
|
+
// 'X-App-Id': `${constants['X-App-Id']}`,
|
|
84
|
+
// 'X-App-Secret': `${constants['X-App-Secret']}`,
|
|
85
|
+
// 'X-Auth-User-Type': '1',
|
|
86
|
+
// });
|
|
87
|
+
// cache.session.setJSON('SRKJ_TOKEN_CACHE', userRes);
|
|
88
|
+
// }
|
|
77
89
|
export const getUserInfo = async (token) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
'X-Auth-User': encodeURIComponent(ssoRes.name),
|
|
81
|
-
'X-Auth-Token': ssoRes.password,
|
|
82
|
-
'X-Enterprise-Id': `${constants['X-Enterprise-Id']}`,
|
|
83
|
-
'X-App-Id': `${constants['X-App-Id']}`,
|
|
84
|
-
'X-App-Secret': `${constants['X-App-Secret']}`,
|
|
85
|
-
'X-Auth-User-Type': '1',
|
|
86
|
-
});
|
|
87
|
-
cache.session.setJSON('SRKJ_TOKEN_CACHE', userRes);
|
|
90
|
+
await ssoAuth(token);
|
|
91
|
+
cache.session.setJSON('SRKJ_TOKEN_CACHE', token);
|
|
88
92
|
}
|
|
@@ -16,7 +16,9 @@ const service = axios.create({
|
|
|
16
16
|
|
|
17
17
|
service.interceptors.request.use(config => {
|
|
18
18
|
if (cache.session.getJSON('SRKJ_TOKEN_CACHE')) {
|
|
19
|
-
config.headers["X-Id-Token"] = cache.session.getJSON('SRKJ_TOKEN_CACHE');
|
|
19
|
+
// config.headers["X-Id-Token"] = cache.session.getJSON('SRKJ_TOKEN_CACHE');
|
|
20
|
+
if (!config.params) config.params = {};
|
|
21
|
+
config.params.token = cache.session.getJSON('SRKJ_TOKEN_CACHE');
|
|
20
22
|
}
|
|
21
23
|
// 是否需要防止数据重复提交
|
|
22
24
|
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
|
|
@@ -51,12 +53,12 @@ service.interceptors.response.use(res => {
|
|
|
51
53
|
return res.data
|
|
52
54
|
}
|
|
53
55
|
let srkjData = res.data;
|
|
54
|
-
if (srkjData) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
56
|
+
// if (srkjData) {
|
|
57
|
+
// const respData = decrypt(srkjData);
|
|
58
|
+
// try {
|
|
59
|
+
// srkjData = JSON.parse(respData);
|
|
60
|
+
// } catch (e) {}
|
|
61
|
+
// }
|
|
60
62
|
if (res.status === 401) {
|
|
61
63
|
Message.warning(srkjData.message.description);
|
|
62
64
|
return;
|