ai-error-assistant-pro 0.0.5 → 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 +139 -31
- package/components/demo/src/error-chat.vue +18 -4
- package/components/demo/src/main.vue +65 -26
- package/components/demo/utils/config.js +15 -11
- package/components/demo/utils/request.js +9 -7
- package/dist/ai-error-assistant-pro.common.js +2811 -202
- 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 +2811 -202
- 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,12 +12,40 @@
|
|
|
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
|
-
<
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
|
|
31
|
+
<template v-for="item in list.connectUrl">
|
|
32
|
+
<div class="links">
|
|
33
|
+
<a :href="item.iaUrl" target="_blank">
|
|
34
|
+
<span>{{ item.iaUrlName }}</span>
|
|
35
|
+
</a>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
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>
|
|
21
49
|
</div>
|
|
22
50
|
</div>
|
|
23
51
|
</div>
|
|
@@ -25,6 +53,7 @@
|
|
|
25
53
|
:chatId="chatId"
|
|
26
54
|
:detail-data="list"
|
|
27
55
|
:sending="list.sending"
|
|
56
|
+
:is-last="index === messageData.length - 1"
|
|
28
57
|
@on-reanswer="(list) => reanswer(list, index)"
|
|
29
58
|
@on-stop-chat="onStopChat"/>
|
|
30
59
|
</div>
|
|
@@ -35,7 +64,8 @@
|
|
|
35
64
|
import { errorList } from '../utils/config';
|
|
36
65
|
import ChatTools from './chat-tools.vue';
|
|
37
66
|
import ErrorChat from './error-chat.vue';
|
|
38
|
-
import {
|
|
67
|
+
import { marked } from 'marked';
|
|
68
|
+
import { chartClear, sendMessageEventSource, getAutoQuestioning } from "../api";
|
|
39
69
|
const controller = new AbortController();
|
|
40
70
|
const signal = controller.signal;
|
|
41
71
|
|
|
@@ -69,6 +99,8 @@ export default {
|
|
|
69
99
|
cacheKeyWord: '', // 由于外部需要快速清掉 keyword 但是存在重新发送请求的情况,因此需要一个混存记录
|
|
70
100
|
messageData: [],
|
|
71
101
|
chatId: '', // 对话id
|
|
102
|
+
chatMajorId: '',
|
|
103
|
+
finish: false,
|
|
72
104
|
}
|
|
73
105
|
},
|
|
74
106
|
computed: {
|
|
@@ -99,6 +131,7 @@ export default {
|
|
|
99
131
|
},
|
|
100
132
|
async postMessage(list, commonKey, parentMsgId) {
|
|
101
133
|
let reanswerParams = {};
|
|
134
|
+
this.finish = false;
|
|
102
135
|
if (list) {
|
|
103
136
|
list.sending = true;
|
|
104
137
|
reanswerParams = {
|
|
@@ -108,6 +141,8 @@ export default {
|
|
|
108
141
|
content: this.messageData[list.index - 1].message,
|
|
109
142
|
}
|
|
110
143
|
this.messageData[list.index].message = '';
|
|
144
|
+
this.messageData[list.index].cacheMessage = '';
|
|
145
|
+
this.makeAutoMessage();
|
|
111
146
|
}
|
|
112
147
|
const params = {
|
|
113
148
|
messageList: [
|
|
@@ -117,60 +152,110 @@ export default {
|
|
|
117
152
|
chatId: this.chatId || undefined,
|
|
118
153
|
commonKey: commonKey || false,
|
|
119
154
|
parentMsgId: parentMsgId || undefined,
|
|
155
|
+
xtId: this.analyExercise.busId,
|
|
120
156
|
...reanswerParams,
|
|
121
157
|
}
|
|
122
158
|
]
|
|
123
159
|
};
|
|
124
160
|
// list 存在说明是重新生成
|
|
125
161
|
if (!list && !commonKey) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
+
});
|
|
139
182
|
}
|
|
140
183
|
await sendMessageEventSource(params, signal, res => {
|
|
141
184
|
this.makeMessageLine(res, list);
|
|
142
185
|
});
|
|
143
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
|
+
},
|
|
144
198
|
makeMessageLine(res, list) {
|
|
145
|
-
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);
|
|
146
200
|
let index = list ? list.index : this.messageData.length - 1;
|
|
147
201
|
const currentList = this.messageData[index];
|
|
202
|
+
let allIdWithStart = true;
|
|
148
203
|
// 结束标识
|
|
149
204
|
if (status === 2 || status === 1) {
|
|
150
205
|
if (commonKey) {
|
|
206
|
+
currentList.sending = true;
|
|
151
207
|
this.postMessage(list, commonKey, parentMsgId);
|
|
152
208
|
return;
|
|
153
209
|
}
|
|
154
210
|
currentList.finish = true;
|
|
155
211
|
if (reference) {
|
|
156
212
|
currentList.links = JSON.parse(reference);
|
|
213
|
+
currentList.links.map((item) => {
|
|
214
|
+
if (!item.title.startsWith(this.chatMajorId)) {
|
|
215
|
+
allIdWithStart = false;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
157
218
|
}
|
|
219
|
+
if (connectUrl) {
|
|
220
|
+
currentList.connectUrl = JSON.parse(connectUrl);
|
|
221
|
+
}
|
|
222
|
+
currentList.allIdWithStart = allIdWithStart;
|
|
158
223
|
this.cacheKeyWord = '';
|
|
224
|
+
this.finish = true;
|
|
159
225
|
this.$emit('on-message-finish', chatId);
|
|
160
226
|
return;
|
|
161
227
|
}
|
|
162
|
-
currentList.
|
|
228
|
+
currentList.cacheMessage += content;
|
|
229
|
+
currentList.message = marked.parse(currentList.cacheMessage);
|
|
163
230
|
currentList.msgId = msgId;
|
|
164
231
|
currentList.parentMsgId = parentMsgId;
|
|
165
232
|
currentList.chatId = chatId;
|
|
166
|
-
|
|
233
|
+
|
|
167
234
|
setTimeout(() => {
|
|
168
235
|
if (!list) this.scrollToBottom();
|
|
169
|
-
}, 100)
|
|
236
|
+
}, 100);
|
|
237
|
+
// 防止出现调用基础模型前导致停止回答id错误
|
|
238
|
+
setTimeout(() => currentList.sending = false,500);
|
|
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;
|
|
170
251
|
},
|
|
171
252
|
onStopChat(list){
|
|
172
253
|
this.$emit('on-message-finish', list.chatId)
|
|
173
254
|
},
|
|
255
|
+
selectModule(message) {
|
|
256
|
+
this.cacheKeyWord = message;
|
|
257
|
+
this.postMessage();
|
|
258
|
+
},
|
|
174
259
|
async clearChat() {
|
|
175
260
|
if (this.messageData.length < 1) {
|
|
176
261
|
this.$message.warning('当前对话为最新对话');
|
|
@@ -185,24 +270,37 @@ export default {
|
|
|
185
270
|
list.stop = false;
|
|
186
271
|
list.finish = false;
|
|
187
272
|
list.links = [];
|
|
273
|
+
list.connectUrl = [];
|
|
188
274
|
this.postMessage(list);
|
|
189
275
|
this.$emit('on-reanser');
|
|
190
276
|
},
|
|
191
277
|
errorChatInit(list, chatId) {
|
|
192
278
|
if (list && list[0].contents) {
|
|
279
|
+
const { chatMajorId } = list[0];
|
|
280
|
+
this.chatMajorId = chatMajorId && chatMajorId.toString();
|
|
193
281
|
const cacheArray = [];
|
|
194
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
|
+
}
|
|
195
291
|
const obj = {
|
|
196
292
|
type: list.role === 'assistant' ? 'robot' : 'user',
|
|
197
|
-
message: list.content.replace(/\n/g, '<br>'),
|
|
293
|
+
message: list.role === 'assistant' ? marked.parse(list.content) : list.content.replace(/\n/g, '<br>'),
|
|
198
294
|
zan: list.type === 1,
|
|
199
295
|
cai: list.type === 2,
|
|
200
296
|
stop: list.status === 1,
|
|
201
297
|
finish: true,
|
|
202
298
|
links: list.references || [],
|
|
299
|
+
connectUrl: list.connectUrls || [],
|
|
203
300
|
reAnswerCount: 0,
|
|
204
301
|
msgId: list.contentId,
|
|
205
|
-
parentMsgId: list.parentMsgId
|
|
302
|
+
parentMsgId: list.parentMsgId,
|
|
303
|
+
allIdWithStart
|
|
206
304
|
};
|
|
207
305
|
cacheArray.push(obj);
|
|
208
306
|
})
|
|
@@ -301,13 +399,6 @@ export default {
|
|
|
301
399
|
width: 100%;
|
|
302
400
|
margin-bottom: 16px;
|
|
303
401
|
|
|
304
|
-
.link-title {
|
|
305
|
-
color: #878aab;
|
|
306
|
-
font-size: 14px;
|
|
307
|
-
margin: 8px 0;
|
|
308
|
-
text-align: left;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
402
|
.link-content {
|
|
312
403
|
background: #fafafd;
|
|
313
404
|
border-radius: 8px;
|
|
@@ -337,10 +428,27 @@ export default {
|
|
|
337
428
|
}
|
|
338
429
|
}
|
|
339
430
|
}
|
|
431
|
+
.link-title {
|
|
432
|
+
color: #878aab;
|
|
433
|
+
font-size: 14px;
|
|
434
|
+
margin: 8px 0;
|
|
435
|
+
text-align: left;
|
|
436
|
+
}
|
|
340
437
|
.robot-image-div {
|
|
341
438
|
width: 48px;
|
|
342
439
|
height: 48px;
|
|
343
440
|
background: url("../static/robot.png");
|
|
344
441
|
background-size: 100%;
|
|
345
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
|
+
}
|
|
346
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() {
|
|
@@ -73,6 +94,9 @@ export default {
|
|
|
73
94
|
},
|
|
74
95
|
methods: {
|
|
75
96
|
closeMessage() {
|
|
97
|
+
if (!this.stopMessage()) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
76
100
|
this.$emit('close');
|
|
77
101
|
},
|
|
78
102
|
messageFinish() {
|
|
@@ -91,11 +115,14 @@ export default {
|
|
|
91
115
|
if (!this.stopMessage()) {
|
|
92
116
|
return;
|
|
93
117
|
}
|
|
94
|
-
console.log(this.aiMessage.length);
|
|
95
118
|
if (this.aiMessage.length > 6000) {
|
|
96
119
|
this.$message.warning('文字长度不能超过3000字');
|
|
97
120
|
return;
|
|
98
121
|
}
|
|
122
|
+
if (!this.aiMessage.trim()) {
|
|
123
|
+
this.$message.error('输入内容为空');
|
|
124
|
+
return
|
|
125
|
+
}
|
|
99
126
|
this.aiMessageKeyWord = this.aiMessage;
|
|
100
127
|
this.stop = true;
|
|
101
128
|
setTimeout(() => {
|
|
@@ -213,6 +240,18 @@ export default {
|
|
|
213
240
|
text-align: center;
|
|
214
241
|
margin-top: 6px;
|
|
215
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
|
+
}
|
|
216
255
|
:deep {
|
|
217
256
|
.ai-message-send {
|
|
218
257
|
.el-textarea__inner {
|
|
@@ -223,7 +262,7 @@ export default {
|
|
|
223
262
|
border: 0;
|
|
224
263
|
border-radius: 40px;
|
|
225
264
|
background: linear-gradient(to bottom, #fff, #d8f0fb);
|
|
226
|
-
padding: 8px
|
|
265
|
+
padding: 8px 56px 0 24px;
|
|
227
266
|
&::placeholder {
|
|
228
267
|
color: rgba(51,51,51,.75);
|
|
229
268
|
}
|
|
@@ -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;
|