ai-error-assistant-mobile 0.0.1

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.
Files changed (34) hide show
  1. package/README.md +33 -0
  2. package/components/demo/api/index.js +123 -0
  3. package/components/demo/index.js +7 -0
  4. package/components/demo/plugins/cache.js +77 -0
  5. package/components/demo/src/chat-tools.vue +477 -0
  6. package/components/demo/src/chat.vue +618 -0
  7. package/components/demo/src/error-chat.vue +384 -0
  8. package/components/demo/src/main.vue +408 -0
  9. package/components/demo/static/bg-img.png +0 -0
  10. package/components/demo/static/cai-active.png +0 -0
  11. package/components/demo/static/cai.png +0 -0
  12. package/components/demo/static/correct.png +0 -0
  13. package/components/demo/static/delete.png +0 -0
  14. package/components/demo/static/error.png +0 -0
  15. package/components/demo/static/logo.png +0 -0
  16. package/components/demo/static/robot.png +0 -0
  17. package/components/demo/static/send-icon.png +0 -0
  18. package/components/demo/static/zan-active.png +0 -0
  19. package/components/demo/static/zan.png +0 -0
  20. package/components/demo/utils/aes-utils.js +35 -0
  21. package/components/demo/utils/config.js +99 -0
  22. package/components/demo/utils/constants.js +15 -0
  23. package/components/demo/utils/request.js +72 -0
  24. package/components/index.js +16 -0
  25. package/dist/ai-error-assistant-mobile.common.js +14916 -0
  26. package/dist/ai-error-assistant-mobile.common.js.map +1 -0
  27. package/dist/ai-error-assistant-mobile.css +1 -0
  28. package/dist/ai-error-assistant-mobile.umd.js +14935 -0
  29. package/dist/ai-error-assistant-mobile.umd.js.map +1 -0
  30. package/dist/ai-error-assistant-mobile.umd.min.js +18 -0
  31. package/dist/ai-error-assistant-mobile.umd.min.js.map +1 -0
  32. package/dist/demo.html +1 -0
  33. package/dist/img/robot.7ad12cd4.png +0 -0
  34. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # ai-questtion
2
+
3
+ ## Project setup
4
+ ```
5
+ npm install
6
+ ```
7
+
8
+ ### Compiles and minifies for production
9
+ ```
10
+ npm run build
11
+ ```
12
+
13
+ ### Customize configuration
14
+ See [Configuration Reference](https://cli.vuejs.org/config/).
15
+
16
+
17
+ ### test-project是测试组件项目
18
+
19
+ ### 公司自用组件 npm i ai-question
20
+
21
+ ### 调用方法
22
+ ...
23
+
24
+ this.$refs.name.showAddQuestion()
25
+ ...
26
+
27
+ ### top控制侧边弹框到顶部的距离
28
+
29
+ ### knowledgeList根据elment传参格式传入树形数据
30
+
31
+ ### propFormat知识点传参格式修改 {value : 'xxx',label : 'xxx','children' : 'xxx'}
32
+
33
+ ### join加入题库
@@ -0,0 +1,123 @@
1
+ import request from '../utils/request'
2
+ import { fetchEventSource } from '@microsoft/fetch-event-source';
3
+ import constants from '../utils/constants';
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';
10
+
11
+ // export const pdfUrlBase = 'https://testagent.icve.com.cn';
12
+ export const pdfUrlBase = 'https://agent.icve.com.cn';
13
+ export const pdfUrl = pdfUrlBase + '/ossurl';
14
+ export const ssoAuth = (token, businessSource) => {
15
+ return request({
16
+ url: prefix + '/sso/assistant',
17
+ method: 'get',
18
+ params: {
19
+ token: token,
20
+ businessSource
21
+ },
22
+ });
23
+ }
24
+
25
+ export const authUser = (headers) => {
26
+ return request({
27
+ url: '/uc/authuser',
28
+ method: 'get',
29
+ headers: headers,
30
+ });
31
+ }
32
+
33
+ export const erranalysis = (data) => {
34
+ return request({
35
+ url: prefix + '/erranalysis/send',
36
+ method: 'post',
37
+ data,
38
+ });
39
+ }
40
+
41
+ export const retryAnalysis = (errId) => {
42
+ return request({
43
+ url: prefix + '/erranalysis/retry',
44
+ method: 'post',
45
+ params: {
46
+ errId
47
+ },
48
+ });
49
+ }
50
+
51
+ export const chatEvaluateAdd = (params) => {
52
+ return request({
53
+ url: prefix + `/assistant/chatEvaluateAdd`,
54
+ method: 'post',
55
+ data: params
56
+ });
57
+ }
58
+
59
+ export const stopChat = (chatId) => {
60
+ return request({
61
+ url: prefix + `/assistant/stop/${chatId}`,
62
+ method: 'post',
63
+ });
64
+ }
65
+
66
+ export const chatEvaluateCancel = (params) => {
67
+ return request({
68
+ url: prefix + `/assistant/chatEvaluateCancel`,
69
+ method: 'post',
70
+ data: params
71
+ });
72
+ }
73
+
74
+ export const chartClear = (chatId) => {
75
+ return request({
76
+ url: prefix + `/assistant/chartClear/${chatId}`,
77
+ method: 'post',
78
+ });
79
+ }
80
+
81
+ export const checkCourseIdIsExist = (resId) => {
82
+ return request({
83
+ url: prefix + `/ia/hasPermission?courseId=${resId}`,
84
+ method: 'get',
85
+ });
86
+ }
87
+
88
+ /**
89
+ * 自动追问
90
+ * @param iaId 请求参数id
91
+ * @param message 对话对
92
+ * @returns 返回节点详情数据
93
+ */
94
+ export async function getAutoQuestioning(iaId, message) {
95
+ return request.post(`${prefix}/ia/autoFollowUp`, {
96
+ iaId,
97
+ messages: message,
98
+ });
99
+ }
100
+
101
+ /**
102
+ * 开场白及提示词查询
103
+ * */
104
+ export const queryCallWord = (resId) => {
105
+ return request({
106
+ url: prefix + `/ia/byCourseId?courseId=${resId}`,
107
+ method: 'get',
108
+ });
109
+ }
110
+
111
+ export async function sendMessageEventSource(params, signal, onmessage) {
112
+ return fetchEventSource(`${baseURL}${prefix}/assistant/conversation?token=${cache.session.getJSON('SRKJ_TOKEN_CACHE')}`, {
113
+ method: 'POST',
114
+ signal: signal,
115
+ openWhenHidden: true,
116
+ headers: {
117
+ 'Content-Type': 'application/json',
118
+ // 'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE'),
119
+ },
120
+ body: JSON.stringify(params),
121
+ onmessage,
122
+ });
123
+ }
@@ -0,0 +1,7 @@
1
+ import AiErrorAssistantMobile from './src/main.vue'
2
+
3
+ AiErrorAssistantMobile.install = function (Vue) {
4
+ Vue.component(AiErrorAssistantMobile.name,AiErrorAssistantMobile)
5
+ }
6
+
7
+ export default AiErrorAssistantMobile
@@ -0,0 +1,77 @@
1
+ const sessionCache = {
2
+ set (key, value) {
3
+ if (!sessionStorage) {
4
+ return
5
+ }
6
+ if (key != null && value != null) {
7
+ sessionStorage.setItem(key, value)
8
+ }
9
+ },
10
+ get (key) {
11
+ if (!sessionStorage) {
12
+ return null
13
+ }
14
+ if (key == null) {
15
+ return null
16
+ }
17
+ return sessionStorage.getItem(key)
18
+ },
19
+ setJSON (key, jsonValue) {
20
+ if (jsonValue != null) {
21
+ this.set(key, JSON.stringify(jsonValue))
22
+ }
23
+ },
24
+ getJSON (key) {
25
+ const value = this.get(key)
26
+ if (value != null) {
27
+ return JSON.parse(value)
28
+ }
29
+ },
30
+ remove (key) {
31
+ sessionStorage.removeItem(key);
32
+ }
33
+ }
34
+ const localCache = {
35
+ set (key, value) {
36
+ if (!localStorage) {
37
+ return
38
+ }
39
+ if (key != null && value != null) {
40
+ localStorage.setItem(key, value)
41
+ }
42
+ },
43
+ get (key) {
44
+ if (!localStorage) {
45
+ return null
46
+ }
47
+ if (key == null) {
48
+ return null
49
+ }
50
+ return localStorage.getItem(key)
51
+ },
52
+ setJSON (key, jsonValue) {
53
+ if (jsonValue != null) {
54
+ this.set(key, JSON.stringify(jsonValue))
55
+ }
56
+ },
57
+ getJSON (key) {
58
+ const value = this.get(key)
59
+ if (value != null) {
60
+ return JSON.parse(value)
61
+ }
62
+ },
63
+ remove (key) {
64
+ localStorage.removeItem(key);
65
+ }
66
+ }
67
+
68
+ export default {
69
+ /**
70
+ * 会话级缓存
71
+ */
72
+ session: sessionCache,
73
+ /**
74
+ * 本地缓存
75
+ */
76
+ local: localCache
77
+ }
@@ -0,0 +1,477 @@
1
+ <template>
2
+ <div class="robot-tools" v-if="listData">
3
+ <div class="robot-reanswer"
4
+ style="margin-bottom: 8px"
5
+ v-if="(listData.stop || listData.finish || type === 'error' && !sending) && isLast"
6
+ @click="reAnswer(listData)">
7
+ <i class="el-icon-refresh-right"></i>
8
+ 重新回答
9
+ </div>
10
+ <div class="stopMsg" style="color: #cfcfcf; cursor: default"
11
+ v-if="listData.stop && type !== 'error'">已停止生成
12
+ </div>
13
+ <div class="stopMsg"
14
+ @click="stopChat(listData)"
15
+ v-if="!listData.stop && !listData.finish && type !== 'error' && !sending">停止输出
16
+ </div>
17
+ <div class="right-tools">
18
+ <el-tooltip :disabled="true" content="赞" effect="light" placement="top">
19
+ <div class="tools-icon" @click="doZan(listData)">
20
+ <img src="../static/zan.png" alt="" v-if="!listData.zan"/>
21
+ <img alt="" src="../static/zan-active.png" v-else/>
22
+ </div>
23
+ </el-tooltip>
24
+ <el-drawer
25
+ :visible.sync="drawer"
26
+ direction="btt"
27
+ size="80%"
28
+ :wrapperClosable="false"
29
+ :modal="false"
30
+ custom-class="feedback-drawer"
31
+ >
32
+ <div class="drawer-content">
33
+ <div class="drawer-header">
34
+ <div class="drawer-title">
35
+ 你的反馈将 <br/>
36
+ 帮助职教一问优化进步
37
+ </div>
38
+ </div>
39
+ <div class="error-list">
40
+ <div class="section-title">请选择问题类型</div>
41
+ <el-checkbox-group v-model="errors" class="checkbox-group">
42
+ <el-checkbox v-for="item in errorList"
43
+ :key="item.code"
44
+ :label="item.code"
45
+ border
46
+ class="check">
47
+ {{ item.name }}
48
+ </el-checkbox>
49
+ </el-checkbox-group>
50
+ <div class="section-title">其他问题描述</div>
51
+ <el-input v-model="input"
52
+ :rows="4"
53
+ maxlength="30"
54
+ show-word-limit
55
+ placeholder="请输入其他问题描述(选填)"
56
+ resize="none"
57
+ type="textarea"/>
58
+ <div class="sumit-button">
59
+ <el-button type="primary" :disabled="canSubmit" @click="doCai(listData)">提交反馈</el-button>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ </el-drawer>
64
+ <el-tooltip :disabled="true" content="踩" effect="light" placement="bottom">
65
+ <div class="tools-icon" @click="openDrawer" v-if="!listData.cai">
66
+ <img alt="" src="../static/cai.png">
67
+ </div>
68
+ <div class="tools-icon" v-else @click="doCai(listData)">
69
+ <img alt="" src="../static/cai-active.png">
70
+ </div>
71
+ </el-tooltip>
72
+ </div>
73
+ </div>
74
+ </template>
75
+ <script>
76
+ import {errorList} from "../utils/config";
77
+ import {chatEvaluateAdd, stopChat, chatEvaluateCancel} from '../api/index';
78
+
79
+ export default {
80
+ name: 'ChatTools',
81
+ props: {
82
+ detailData: {
83
+ type: Object,
84
+ default: () => {
85
+ }
86
+ },
87
+ chatId: {
88
+ type: String,
89
+ default: '',
90
+ },
91
+ type: {
92
+ type: String,
93
+ default: 'chart'
94
+ },
95
+ sending: {
96
+ type: Boolean,
97
+ default: false
98
+ },
99
+ isLast: {
100
+ type: Boolean,
101
+ default: false
102
+ }
103
+ },
104
+ data() {
105
+ return {
106
+ input: "",
107
+ drawer: false,
108
+ errors: [],
109
+ errorList: errorList,
110
+ }
111
+ },
112
+ computed: {
113
+ canSubmit() {
114
+ return this.errors.length === 0 && this.input === "";
115
+ },
116
+ listData() {
117
+ return this.detailData;
118
+ },
119
+ },
120
+ methods: {
121
+ cancelDrawer() {
122
+ this.drawer = false;
123
+ },
124
+ openDrawer() {
125
+ this.drawer = true;
126
+ },
127
+ async stopChat(list) {
128
+ const {msgId} = list;
129
+ await stopChat(msgId);
130
+ list.stop = true;
131
+ this.$emit('on-stop-chat', list)
132
+ },
133
+ async reAnswer(list) {
134
+ this.$emit('on-reanswer', list);
135
+ },
136
+ async doZan(list) {
137
+ const param = {
138
+ chatId: this.chatId,
139
+ msgId: list.msgId,
140
+ type: 1,
141
+ }
142
+ list.zan ? await chatEvaluateCancel(param) : await chatEvaluateAdd(param);
143
+ list.zan = !list.zan;
144
+ list.cai = false;
145
+ },
146
+ async doCai(list) {
147
+ let caiOption = {};
148
+ if (!list.cai) {
149
+ caiOption = {
150
+ desc: this.input,
151
+ tags: this.errors
152
+ }
153
+ }
154
+ const param = {
155
+ chatId: this.chatId,
156
+ msgId: list.msgId,
157
+ type: 2,
158
+ ...caiOption
159
+ }
160
+ list.cai ? await chatEvaluateCancel(param) : await chatEvaluateAdd(param);
161
+ list.cai = !list.cai;
162
+ list.zan = false;
163
+ if (list.cai) {
164
+ this.$message.success('感谢您的反馈');
165
+ }
166
+ this.drawer = false;
167
+ this.input = '';
168
+ this.errors = [];
169
+ }
170
+ }
171
+ }
172
+ </script>
173
+ <style lang="scss" scoped>
174
+ .robot-tools {
175
+ position: relative;
176
+ margin-top: 1.5rem;
177
+ min-height: 2rem;
178
+ display: flex;
179
+ align-items: center;
180
+ flex-wrap: wrap;
181
+
182
+ .robot-reanswer {
183
+ width: 6.5rem;
184
+ height: 2rem;
185
+ background-color: rgba(32, 40, 64, 0.078);
186
+ border-radius: 1rem;
187
+ font-size: 0.8125rem;
188
+ text-align: center;
189
+ line-height: 2rem;
190
+ cursor: pointer;
191
+ display: flex;
192
+ align-items: center;
193
+ justify-content: center;
194
+ margin-right: 0.5rem;
195
+
196
+ &:hover {
197
+ background: #ced0f0;
198
+ }
199
+
200
+ i {
201
+ font-size: 1.125rem;
202
+ margin-right: 0.25rem;
203
+ }
204
+ }
205
+
206
+ .stopMsg {
207
+ cursor: pointer;
208
+ height: 1.25rem;
209
+ font-size: 0.875rem;
210
+ color: #316cff;
211
+ padding: 0.25rem 0.5rem;
212
+ margin-right: 7rem;
213
+
214
+ &:hover {
215
+ text-decoration: underline;
216
+ }
217
+ }
218
+
219
+ .tools-icon {
220
+ width: 2.5rem;
221
+ height: 2rem;
222
+ background-color: rgba(32, 40, 64, 0.078);
223
+ border-radius: 1rem;
224
+ text-align: center;
225
+ line-height: 2rem;
226
+ cursor: pointer;
227
+ margin-right: 0.5rem;
228
+ display: flex;
229
+ align-items: center;
230
+ justify-content: center;
231
+
232
+ img {
233
+ width: 1.25rem;
234
+ height: 1.25rem;
235
+ }
236
+ }
237
+
238
+ .right-tools {
239
+ position: absolute;
240
+ right: 0;
241
+ top: 0;
242
+ display: flex;
243
+ align-items: center;
244
+ }
245
+ }
246
+
247
+ .feedback-drawer {
248
+ .drawer-content {
249
+ padding: 1.5rem;
250
+ height: 100%;
251
+ box-sizing: border-box;
252
+ display: flex;
253
+ flex-direction: column;
254
+ background: #fff;
255
+ border-radius: 1rem 1rem 0 0;
256
+ }
257
+
258
+ .drawer-header {
259
+ margin-bottom: 2rem;
260
+ text-align: center;
261
+
262
+ .drawer-title {
263
+ font-weight: 600;
264
+ font-size: 1.5rem;
265
+ color: #333;
266
+ line-height: 1.875rem;
267
+ }
268
+ }
269
+
270
+ .error-list {
271
+ flex: 1;
272
+ display: flex;
273
+ flex-direction: column;
274
+ gap: 1.5rem;
275
+
276
+ .section-title {
277
+ font-size: 1rem;
278
+ color: #666;
279
+ margin-bottom: 0.5rem;
280
+ }
281
+
282
+ .checkbox-group {
283
+ display: flex;
284
+ flex-wrap: wrap;
285
+ gap: 0.75rem;
286
+
287
+ .el-checkbox {
288
+ margin: 0;
289
+ padding: 0.75rem 1rem;
290
+ border-radius: 0.5rem;
291
+ transition: all 0.3s;
292
+
293
+ &:hover {
294
+ background: #f5f7fa;
295
+ }
296
+
297
+ &.is-checked {
298
+ background: #ecf5ff;
299
+ border-color: #409EFF;
300
+
301
+ .el-checkbox__label {
302
+ color: #409EFF;
303
+ }
304
+ }
305
+ }
306
+ }
307
+
308
+ .el-input {
309
+ width: 100%;
310
+
311
+ .el-textarea__inner {
312
+ border-radius: 0.75rem;
313
+ padding: 1rem;
314
+ font-size: 0.875rem;
315
+ line-height: 1.5;
316
+ resize: none;
317
+ border-color: #dcdfe6;
318
+ transition: all 0.3s;
319
+
320
+ &:focus {
321
+ border-color: #409EFF;
322
+ box-shadow: 0 0 0 2px rgba(64, 158, 255, .2);
323
+ }
324
+ }
325
+ }
326
+
327
+ .sumit-button {
328
+ margin-top: auto;
329
+ text-align: center;
330
+ padding-top: 1rem;
331
+
332
+ .el-button {
333
+ width: 100%;
334
+ padding: 0.875rem;
335
+ font-size: 1rem;
336
+ border-radius: 0.75rem;
337
+ font-weight: 500;
338
+ }
339
+ }
340
+ }
341
+ }
342
+
343
+ // 移动端适配
344
+ @media screen and (max-width: 768px) {
345
+ .robot-tools {
346
+ .robot-reanswer {
347
+ width: 5.5rem;
348
+ height: 1.75rem;
349
+ font-size: 0.75rem;
350
+
351
+ i {
352
+ font-size: 1rem;
353
+ }
354
+ }
355
+
356
+ .tools-icon {
357
+ width: 2.25rem;
358
+ height: 1.75rem;
359
+
360
+ img {
361
+ width: 1.125rem;
362
+ height: 1.125rem;
363
+ }
364
+ }
365
+ }
366
+
367
+ .feedback-drawer {
368
+ .drawer-content {
369
+ padding: 1.25rem;
370
+ }
371
+
372
+ .drawer-header {
373
+ margin-bottom: 1.5rem;
374
+
375
+ .drawer-title {
376
+ font-size: 1.25rem;
377
+ }
378
+ }
379
+
380
+ .error-list {
381
+ gap: 1.25rem;
382
+
383
+ .section-title {
384
+ font-size: 0.9375rem;
385
+ }
386
+
387
+ .checkbox-group {
388
+ gap: 0.5rem;
389
+
390
+ .el-checkbox {
391
+ padding: 0.625rem 0.875rem;
392
+ font-size: 0.875rem;
393
+ }
394
+ }
395
+
396
+ .el-input {
397
+ .el-textarea__inner {
398
+ font-size: 0.8125rem;
399
+ padding: 0.875rem;
400
+ }
401
+ }
402
+
403
+ .sumit-button {
404
+ .el-button {
405
+ padding: 0.75rem;
406
+ font-size: 0.9375rem;
407
+ }
408
+ }
409
+ }
410
+ }
411
+ }
412
+
413
+ @media screen and (max-width: 480px) {
414
+ .robot-tools {
415
+ .robot-reanswer {
416
+ width: 6rem;
417
+ height: 2rem;
418
+ font-size: 0.75rem;
419
+ }
420
+
421
+ .tools-icon {
422
+ width: 2rem;
423
+ height: 2rem;
424
+
425
+ img {
426
+ width: 1rem;
427
+ height: 1rem;
428
+ }
429
+ }
430
+ }
431
+
432
+ .feedback-drawer {
433
+ .drawer-content {
434
+ padding: 1rem;
435
+ }
436
+
437
+ .drawer-header {
438
+ margin-bottom: 1.25rem;
439
+
440
+ .drawer-title {
441
+ font-size: 1.125rem;
442
+ }
443
+ }
444
+
445
+ .error-list {
446
+ gap: 1rem;
447
+
448
+ .section-title {
449
+ font-size: 0.875rem;
450
+ }
451
+
452
+ .checkbox-group {
453
+ gap: 0.375rem;
454
+
455
+ .el-checkbox {
456
+ padding: 0.5rem 0.75rem;
457
+ font-size: 0.8125rem;
458
+ }
459
+ }
460
+
461
+ .el-input {
462
+ .el-textarea__inner {
463
+ font-size: 0.75rem;
464
+ padding: 0.75rem;
465
+ }
466
+ }
467
+
468
+ .sumit-button {
469
+ .el-button {
470
+ padding: 0.625rem;
471
+ font-size: 0.875rem;
472
+ }
473
+ }
474
+ }
475
+ }
476
+ }
477
+ </style>