ai-error-assistant-pro 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 +84 -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 +289 -0
  6. package/components/demo/src/chat.vue +342 -0
  7. package/components/demo/src/error-chat.vue +247 -0
  8. package/components/demo/src/main.vue +221 -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/error.png +0 -0
  14. package/components/demo/static/logo.png +0 -0
  15. package/components/demo/static/robot.png +0 -0
  16. package/components/demo/static/send-icon.png +0 -0
  17. package/components/demo/static/zan-active.png +0 -0
  18. package/components/demo/static/zan.png +0 -0
  19. package/components/demo/utils/aes-utils.js +35 -0
  20. package/components/demo/utils/config.js +88 -0
  21. package/components/demo/utils/constants.js +13 -0
  22. package/components/demo/utils/request.js +69 -0
  23. package/components/index.js +15 -0
  24. package/dist/ai-error-assistant-pro.common.js +12065 -0
  25. package/dist/ai-error-assistant-pro.common.js.map +1 -0
  26. package/dist/ai-error-assistant-pro.css +1 -0
  27. package/dist/ai-error-assistant-pro.umd.js +12084 -0
  28. package/dist/ai-error-assistant-pro.umd.js.map +1 -0
  29. package/dist/ai-error-assistant-pro.umd.min.js +18 -0
  30. package/dist/ai-error-assistant-pro.umd.min.js.map +1 -0
  31. package/dist/demo.html +1 -0
  32. package/dist/img/bg-img.9391d6da.png +0 -0
  33. package/dist/img/robot.7ad12cd4.png +0 -0
  34. package/package.json +44 -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,84 @@
1
+ import request from '../utils/request'
2
+ import { fetchEventSource } from '@microsoft/fetch-event-source';
3
+ const baseURL = sessionStorage.getItem('AI_BASE_URL_FOR_TEST') || 'https://zjyw.icve.com.cn/ai-api';
4
+ const prefix = sessionStorage.getItem('AI_PRE_FIX_FOR_TEST') || '/heatp';
5
+ import cache from '../plugins/cache';
6
+ export const ssoAuth = (token) => {
7
+ return request({
8
+ url: prefix + '/sso/assistant',
9
+ method: 'get',
10
+ params: {
11
+ token: token,
12
+ },
13
+ });
14
+ }
15
+
16
+ export const authUser = (headers) => {
17
+ return request({
18
+ url: '/uc/authuser',
19
+ method: 'get',
20
+ headers: headers,
21
+ });
22
+ }
23
+
24
+ export const erranalysis = (data) => {
25
+ return request({
26
+ url: prefix + '/erranalysis/send',
27
+ method: 'post',
28
+ data,
29
+ });
30
+ }
31
+
32
+ export const retryAnalysis = (errId) => {
33
+ return request({
34
+ url: prefix + '/erranalysis/retry',
35
+ method: 'post',
36
+ params: {
37
+ errId
38
+ },
39
+ });
40
+ }
41
+
42
+ export const chatEvaluateAdd = (params) => {
43
+ return request({
44
+ url: prefix + `/assistant/chatEvaluateAdd`,
45
+ method: 'post',
46
+ data: params
47
+ });
48
+ }
49
+
50
+ export const stopChat = (chatId) => {
51
+ return request({
52
+ url: prefix + `/assistant/stop/${chatId}`,
53
+ method: 'post',
54
+ });
55
+ }
56
+
57
+ export const chatEvaluateCancel = (params) => {
58
+ return request({
59
+ url: prefix + `/assistant/chatEvaluateCancel`,
60
+ method: 'post',
61
+ data: params
62
+ });
63
+ }
64
+
65
+ export const chartClear = (chatId) => {
66
+ return request({
67
+ url: prefix + `/assistant/chartClear/${chatId}`,
68
+ method: 'post',
69
+ });
70
+ }
71
+
72
+ export async function sendMessageEventSource(params, signal, onmessage) {
73
+ return fetchEventSource(`${baseURL}${prefix}/assistant/conversation`, {
74
+ method: 'POST',
75
+ signal: signal,
76
+ openWhenHidden: true,
77
+ headers: {
78
+ 'Content-Type': 'application/json',
79
+ 'X-Id-Token': cache.session.getJSON('SRKJ_TOKEN_CACHE'),
80
+ },
81
+ body: JSON.stringify(params),
82
+ onmessage,
83
+ });
84
+ }
@@ -0,0 +1,7 @@
1
+ import AiErrorAssistant from './src/main.vue'
2
+
3
+ AiErrorAssistant.install = function (Vue) {
4
+ Vue.component(AiErrorAssistant.name,AiErrorAssistant)
5
+ }
6
+
7
+ export default AiErrorAssistant
@@ -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,289 @@
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'"
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'">已停止生成</div>
12
+ <div class="stopMsg"
13
+ @click="stopChat(listData)"
14
+ v-if="!listData.stop && !listData.finish && type !== 'error'">停止输出</div>
15
+ <div class="right-tools">
16
+ <el-tooltip content="赞" effect="light" placement="top">
17
+ <div class="tools-icon" @click="doZan(listData)">
18
+ <img src="../static/zan.png" alt="" v-if="!listData.zan" />
19
+ <img alt="" src="../static/zan-active.png" v-else />
20
+ </div>
21
+ </el-tooltip>
22
+ <el-popover v-model="popover" placement="top-start" trigger="manual">
23
+ <div slot="reference">
24
+ <el-tooltip content="踩" effect="light" placement="bottom">
25
+ <div class="tools-icon" @click="openPopover" v-if="!listData.cai">
26
+ <img alt="" src="../static/cai.png">
27
+ </div>
28
+ <div class="tools-icon" v-else @click="doCai(listData)">
29
+ <img alt="" src="../static/cai-active.png">
30
+ </div>
31
+ </el-tooltip>
32
+ </div>
33
+ <div class="popover-box">
34
+ <div class="pop-title">
35
+ 你的反馈将 <br/>
36
+ 帮助职教一问优化进步
37
+ </div>
38
+ <i class="el-icon-close" style="font-size: 2rem"
39
+ @click="cancelPopover()"></i>
40
+ <div class="error-list">
41
+ <el-checkbox-group v-model="errors">
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
+ <el-input v-model="input" :rows="4"
51
+ maxlength="30"
52
+ placeholder="其他"
53
+ resize="none"
54
+ type="textarea" />
55
+ <div class="sumit-button">
56
+ <el-button :disabled="canSubmit" @click="doCai(listData)">提交</el-button>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </el-popover>
61
+ </div>
62
+ </div>
63
+ </template>
64
+ <script>
65
+ import { errorList } from "../utils/config";
66
+ import { chatEvaluateAdd, stopChat, chatEvaluateCancel } from '../api/index';
67
+ export default {
68
+ name: 'ChatTools',
69
+ props: {
70
+ detailData: {
71
+ type: Object,
72
+ default: () => {}
73
+ },
74
+ chatId: {
75
+ type: String,
76
+ default: '',
77
+ },
78
+ type: {
79
+ type: String,
80
+ default: 'chart'
81
+ },
82
+ },
83
+ data() {
84
+ return {
85
+ input: "",
86
+ popover: false,
87
+ errors: [],
88
+ errorList: errorList,
89
+ }
90
+ },
91
+ computed: {
92
+ canSubmit() {
93
+ return this.errors.length === 0 && this.input === "";
94
+ },
95
+ listData() {
96
+ return this.detailData;
97
+ },
98
+ },
99
+ methods: {
100
+ cancelPopover() {
101
+ this.popover = false;
102
+ },
103
+ openPopover() {
104
+ this.popover = true;
105
+ },
106
+ async stopChat(list) {
107
+ const { msgId } = list;
108
+ await stopChat(msgId);
109
+ list.stop = true;
110
+ this.$emit('on-stop-chat', list)
111
+ },
112
+ async reAnswer(list) {
113
+ this.$emit('on-reanswer', list);
114
+ },
115
+ async doZan(list) {
116
+ const param = {
117
+ chatId: this.chatId,
118
+ msgId: list.msgId,
119
+ type: 1,
120
+ }
121
+ list.zan ? await chatEvaluateCancel(param) : await chatEvaluateAdd(param);
122
+ list.zan = !list.zan;
123
+ list.cai = false;
124
+ },
125
+ async doCai(list) {
126
+ let caiOption = {};
127
+ if (!list.cai) {
128
+ caiOption = {
129
+ desc: this.input,
130
+ tags: this.errors
131
+ }
132
+ }
133
+ const param = {
134
+ chatId: this.chatId,
135
+ msgId: list.msgId,
136
+ type: 2,
137
+ ...caiOption
138
+ }
139
+ list.cai ? await chatEvaluateCancel(param) : await chatEvaluateAdd(param);
140
+ list.cai = !list.cai;
141
+ list.zan = false;
142
+ if (list.cai) {
143
+ this.$message.success('感谢您的反馈');
144
+ }
145
+ this.popover = false;
146
+ this.input = '';
147
+ this.errors = [];
148
+ }
149
+ }
150
+ }
151
+ </script>
152
+ <style lang="scss" scoped>
153
+ .robot-tools {
154
+ position: relative;
155
+ margin-top: 8px;
156
+ .robot-reanswer {
157
+ width: 104px;
158
+ height: 32px;
159
+ background-color: rgba(32, 40, 64, 0.078);
160
+ border-radius: 16px;
161
+ font-size: 13px;
162
+ text-align: center;
163
+ line-height: 32px;
164
+ cursor: pointer;
165
+
166
+ &:hover {
167
+ background: #ced0f0;
168
+ }
169
+
170
+ i {
171
+ font-size: 18px;
172
+ vertical-align: middle;
173
+ }
174
+ }
175
+ .stopMsg {
176
+ cursor: pointer;
177
+ height: 20px;
178
+ width: 100px;
179
+ font-size: 14px;
180
+ color: #316cff;
181
+ }
182
+ .tools-icon {
183
+ width: 40px;
184
+ height: 32px;
185
+ background-color: rgba(32, 40, 64, 0.078);
186
+ border-radius: 16px;
187
+ text-align: center;
188
+ line-height: 34px;
189
+ cursor: pointer;
190
+ margin-right: 8px;
191
+
192
+ &:hover {
193
+ background: #ced0f0;
194
+ }
195
+ }
196
+ .right-tools {
197
+ position: absolute;
198
+ right: 0;
199
+ top: 0;
200
+ display: flex;
201
+ }
202
+ }
203
+ .popover-box {
204
+ width: 380px;
205
+ height: 450px;
206
+ border-radius: 20px;
207
+ padding: 20px;
208
+ box-sizing: border-box;
209
+ position: relative;
210
+
211
+ .pop-title {
212
+ width: 220px;
213
+ height: 60px;
214
+ font-family: PingFangSC, PingFang SC;
215
+ font-weight: 500;
216
+ font-size: 22px;
217
+ color: #333333;
218
+ line-height: 30px;
219
+ text-align: left;
220
+ font-style: normal;
221
+ }
222
+
223
+ .el-icon-close {
224
+ position: absolute;
225
+ right: 0;
226
+ top: 0;
227
+ color: #333333;
228
+ cursor: pointer;
229
+ transition: all 0.3s;
230
+
231
+ &:hover {
232
+ transform: rotate(-180deg);
233
+ }
234
+ }
235
+
236
+ .error-list {
237
+ display: flex;
238
+ flex-wrap: wrap;
239
+ margin-top: 20px;
240
+
241
+ .el-textarea__inner {
242
+ resize: none;
243
+ }
244
+
245
+ .sumit-button {
246
+ margin-top: 20px;
247
+ margin-left: 114px;
248
+
249
+ .el-button {
250
+ width: 112px;
251
+ height: 42px;
252
+ background: linear-gradient(180deg, #5fa5ff 0%, #316cff 100%);
253
+ border-radius: 21px;
254
+ color: #fff;
255
+ }
256
+ }
257
+
258
+ label {
259
+ text-align: center;
260
+ }
261
+
262
+ .check.is-bordered {
263
+ margin-right: 0;
264
+ width: 165px;
265
+ height: 42px;
266
+ background: #f3f7ff;
267
+ border-radius: 6px;
268
+ margin-left: 0;
269
+ margin-bottom: 10px;
270
+
271
+ &:nth-child(2n-1) {
272
+ margin-right: 10px;
273
+ }
274
+
275
+ ::v-deep .el-checkbox__inner {
276
+ display: none;
277
+ }
278
+ }
279
+ }
280
+
281
+ ::v-deep .el-checkbox.is-bordered.is-checked {
282
+ border-color: #316cff;
283
+ }
284
+
285
+ ::v-deep .el-checkbox__input.is-checked+.el-checkbox__label {
286
+ color: #316cff;
287
+ }
288
+ }
289
+ </style>