ai-error-assistant-pro 0.0.26 → 0.0.28
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/src/chat.vue +72 -5
- package/components/demo/src/error-chat.vue +62 -7
- package/dist/ai-error-assistant-pro.common.js +18632 -29
- 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 +18632 -29
- 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/dist/fonts/KaTeX_AMS-Regular.1608a09b.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.4aafdb68.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.a79f1c31.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.cce5b8ec.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.07ef19e7.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.9f256b85.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.b18f59e1.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.d42a5579.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.7c187121.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.d3c882a6.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ed38e79f.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.b74a1a8b.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.c3fb5ac2.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.d181c465.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.6f2bb1df.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.70d8b0a5.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.e3f82f9d.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.47373d1e.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.8916142b.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.9024d815.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.0462f03b.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.7f51fe03.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.b7f8fe9b.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.572d331f.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.a879cf83.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.f1035d8d.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.5295ba48.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.939bc644.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.f28c23ac.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.8c5b5494.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.94e1e8dc.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.bf59d231.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.3b1e59b3.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.7c9bc82b.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.b4c20c84.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.74048478.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ba21ed5f.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.d4d7ba48.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.03e9641d.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.07505710.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.fe9cbbe1.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.fabc004a.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.d6b476ec.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.fbccdabe.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.6258592b.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.a8709e36.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.d97aaf4a.ttf +0 -0
- package/package.json +2 -1
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</div>
|
|
14
14
|
<div v-if ="list.type === 'user' && avatarUrl===''" class="robot user">user</div>
|
|
15
15
|
<div :class="{'user-info': list.type === 'user'}" class="robot-message">
|
|
16
|
-
<div v-html="list.message"></div>
|
|
16
|
+
<div v-html="renderFormulas(list.message)"></div>
|
|
17
17
|
<div v-if="list.type === 'robot' && list.links.length > 0 && showFile" class="link">
|
|
18
18
|
<div v-if="!list.allIdWithStart">
|
|
19
19
|
<div class="link-title">参考文件</div>
|
|
@@ -90,6 +90,9 @@ import ChatTools from './chat-tools.vue';
|
|
|
90
90
|
import ErrorChat from './error-chat.vue';
|
|
91
91
|
import { marked } from 'marked';
|
|
92
92
|
import { chartClear, sendMessageEventSource, getAutoQuestioning, pdfUrl, pdfUrlBase } from "../api";
|
|
93
|
+
import katex from 'katex';
|
|
94
|
+
import renderMathInElement from 'katex/contrib/auto-render/auto-render.js'
|
|
95
|
+
import 'katex/dist/katex.min.css';
|
|
93
96
|
const controller = new AbortController();
|
|
94
97
|
const signal = controller.signal;
|
|
95
98
|
|
|
@@ -158,7 +161,14 @@ export default {
|
|
|
158
161
|
}
|
|
159
162
|
},
|
|
160
163
|
immediate: true
|
|
161
|
-
}
|
|
164
|
+
},
|
|
165
|
+
messageData: {
|
|
166
|
+
handler() {
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
this.renderKaTeX();
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
}
|
|
162
172
|
},
|
|
163
173
|
methods: {
|
|
164
174
|
handleScroll() {
|
|
@@ -401,6 +411,66 @@ export default {
|
|
|
401
411
|
const baseUrl = `${pdfUrlBase}/#/pdf-view?documentUrl=${encodeURIComponent(url)}&pageIndex=${pageIndex}`;
|
|
402
412
|
window.open(baseUrl, '_blank');
|
|
403
413
|
},
|
|
414
|
+
renderFormulas(text) {
|
|
415
|
+
const {renderToString} = katex;
|
|
416
|
+
return text
|
|
417
|
+
.replace(/\$\$(.*?)\$\$/gs, (match) => {
|
|
418
|
+
try {
|
|
419
|
+
// 渲染块级公式
|
|
420
|
+
return renderToString(match.slice(2, -2), {displayMode: false});
|
|
421
|
+
} catch (error) {
|
|
422
|
+
console.error('Error rendering block formula:', error);
|
|
423
|
+
return match;
|
|
424
|
+
}
|
|
425
|
+
})
|
|
426
|
+
.replace(/\$.*?\$/g, (match) => {
|
|
427
|
+
match = match.replace(/<br>/g, '');
|
|
428
|
+
try {
|
|
429
|
+
// 渲染行内公式
|
|
430
|
+
return renderToString(match.slice(1, -1), {displayMode: false});
|
|
431
|
+
} catch (error) {
|
|
432
|
+
console.error('Error rendering inline formula:', error);
|
|
433
|
+
return match;
|
|
434
|
+
}
|
|
435
|
+
})
|
|
436
|
+
.replace(/\\\(.*?\\\)/g, (match) => {
|
|
437
|
+
try {
|
|
438
|
+
// 渲染行内公式
|
|
439
|
+
return renderToString(match.slice(2, -2), {displayMode: false});
|
|
440
|
+
} catch (error) {
|
|
441
|
+
console.error('Error rendering inline formula:', error);
|
|
442
|
+
return match;
|
|
443
|
+
}
|
|
444
|
+
})
|
|
445
|
+
.replace(/\\\[[\s\S]*?\\\]/g, (match) => {
|
|
446
|
+
match = match.replace(/<br>/g, '');
|
|
447
|
+
try {
|
|
448
|
+
// 渲染块级公式
|
|
449
|
+
return renderToString(match.slice(2, -2), {displayMode: false});
|
|
450
|
+
} catch (error) {
|
|
451
|
+
console.error('Error rendering block formula:', error);
|
|
452
|
+
return match;
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
},
|
|
456
|
+
renderKaTeX() {
|
|
457
|
+
setTimeout(() => {
|
|
458
|
+
// 自动渲染页面中的所有 KaTeX 公式
|
|
459
|
+
if (this.$refs.chatContainer) {
|
|
460
|
+
renderMathInElement(this.$refs.chatContainer, {
|
|
461
|
+
delimiters: [
|
|
462
|
+
{left: '$$', right: '$$', display: false},
|
|
463
|
+
{left: '\(', right: '\)', display: false},
|
|
464
|
+
{left: '\[', right: '\]', display: false}
|
|
465
|
+
],
|
|
466
|
+
errorCallback() {
|
|
467
|
+
console.log('忽略错误')
|
|
468
|
+
},
|
|
469
|
+
ignoredClasses: ['link-content']
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
}, 50)
|
|
473
|
+
},
|
|
404
474
|
},
|
|
405
475
|
}
|
|
406
476
|
</script>
|
|
@@ -484,9 +554,6 @@ export default {
|
|
|
484
554
|
.robot-message {
|
|
485
555
|
p {
|
|
486
556
|
margin: 0;
|
|
487
|
-
span {
|
|
488
|
-
color: #fff !important;
|
|
489
|
-
}
|
|
490
557
|
}
|
|
491
558
|
pre {
|
|
492
559
|
code {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="error-chat-contain" @scroll="handleScroll">
|
|
3
3
|
<div class="exercises-answer">
|
|
4
4
|
<div class="exercises-answer-bg"></div>
|
|
5
|
-
<p class="question-stem" v-html="questionStem.title"></p>
|
|
5
|
+
<p class="question-stem" v-html="renderFormulas(questionStem.title)"></p>
|
|
6
6
|
<div class="answer-part" v-if="questionStem.type === 'single' || questionStem.type === 'multiple'">
|
|
7
7
|
<div class="answer-list" v-for="(item, index) in questionStem.options" :key="index">
|
|
8
8
|
<div class="check-content" style="width: 24px">
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
alt=""
|
|
12
12
|
style="width: 24px; height: 24px" />
|
|
13
13
|
</div>
|
|
14
|
-
<div class="answer-list" v-html="item"></div>
|
|
14
|
+
<div class="answer-list" v-html="renderFormulas(item)"></div>
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
17
|
<div class="answer-part"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
style="padding-bottom: 24px"
|
|
34
34
|
v-if="questionStem.type === 'shortanswer' || questionStem.type === 'gapfilling'">
|
|
35
35
|
<span style="vertical-align: inherit; display: inline-block">正确答案:</span>
|
|
36
|
-
<span style="margin-left: 8px; display: inline-block; width: calc(100% - 82px); vertical-align: top;" v-html="questionStem.answer.join(',')"></span>
|
|
36
|
+
<span style="margin-left: 8px; display: inline-block; width: calc(100% - 82px); vertical-align: top;" v-html="renderFormulas(questionStem.answer.join(','))"></span>
|
|
37
37
|
</div>
|
|
38
38
|
<div class="student-answer-part">
|
|
39
39
|
<div class="check-content" style="width: 24px; margin-right: 16px">
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
<div v-for="(item, index) in questionStem.studentAnswer"
|
|
44
44
|
style="margin-right: 16px"
|
|
45
45
|
:key="index"
|
|
46
|
-
v-html="item">
|
|
46
|
+
v-html="renderFormulas(item)">
|
|
47
47
|
</div>
|
|
48
48
|
</div>
|
|
49
49
|
<div v-if="questionStem.type === 'judge'">
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
<!-- {{ item }}<span v-if="index !== questionStem.studentAnswer.length - 1">,</span>-->
|
|
57
57
|
<!-- </span>-->
|
|
58
58
|
<div v-if="questionStem.type === 'shortanswer' || questionStem.type === 'gapfilling'">
|
|
59
|
-
<span style="margin-left: 8px" v-html="questionStem.studentAnswer.join(',')"></span>
|
|
59
|
+
<span style="margin-left: 8px" v-html="renderFormulas(questionStem.studentAnswer.join(','))"></span>
|
|
60
60
|
</div>
|
|
61
61
|
</div>
|
|
62
62
|
</div>
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
element-loading-text="分析中,请稍后"
|
|
65
65
|
v-loading="!Object.keys(analysisData).length > 0">
|
|
66
66
|
<div class="title-label">题目解析</div>
|
|
67
|
-
<div class="answer-content" v-html="analysisData.analysis"></div>
|
|
67
|
+
<div class="answer-content" v-html="renderFormulas(analysisData.analysis)"></div>
|
|
68
68
|
<div class="title-label">错因分析</div>
|
|
69
|
-
<div class="answer-content" v-html="analysisData.reason"></div>
|
|
69
|
+
<div class="answer-content" v-html="renderFormulas(analysisData.reason)"></div>
|
|
70
70
|
<div class="title-label" v-if="businessSource !== '2' && analysisData.recommend && analysisData.recommend.length > 0 && !allIdWithStart">
|
|
71
71
|
推荐资料
|
|
72
72
|
</div>
|
|
@@ -89,6 +89,8 @@
|
|
|
89
89
|
<script>
|
|
90
90
|
import ChatTools from './chat-tools.vue';
|
|
91
91
|
import {erranalysis, pdfUrlBase, retryAnalysis} from '../api/index'
|
|
92
|
+
import katex from 'katex';
|
|
93
|
+
import 'katex/dist/katex.min.css';
|
|
92
94
|
export default {
|
|
93
95
|
name: 'ErrorChart',
|
|
94
96
|
components: {
|
|
@@ -197,7 +199,60 @@ export default {
|
|
|
197
199
|
this.analysisData = { key: true };
|
|
198
200
|
console.log(e);
|
|
199
201
|
}
|
|
202
|
+
},
|
|
203
|
+
renderFormulas(text) {
|
|
204
|
+
if (!text) return '';
|
|
205
|
+
// 如果整个文本包含 LaTeX 命令且没有定界符,整体包裹
|
|
206
|
+
const hasDelimiter = /\$|\\\(|\\\[/.test(text);
|
|
207
|
+
if (!hasDelimiter) {
|
|
208
|
+
text = text.replace(
|
|
209
|
+
/(\\(?:frac|sqrt|sum|int|cdot|times|geq|leq|neq|pm|div|alpha|beta|gamma|theta|pi|sigma|omega|infty|log|sin|cos|tan|left|right|overline|hat|vec|bar|lim|in|notin|supset|subseteq|ln|Gamma|to)(?:\{[^{}]*(?:\{[^{}]*(?:\{[^{}]*\}[^{}]*)*\}[^{}]*)*\}|[^\s{},。?!、;:\u4e00-\u9fa5])*)/g,
|
|
210
|
+
(match) => `\\(${match}\\)`
|
|
211
|
+
);
|
|
200
212
|
}
|
|
213
|
+
const { renderToString } = katex;
|
|
214
|
+
return text
|
|
215
|
+
// 块级公式 $$...$$
|
|
216
|
+
.replace(/\$\$(.*?)\$\$/gs, (match, p1) => {
|
|
217
|
+
try {
|
|
218
|
+
return renderToString(p1, { displayMode: true, throwOnError:
|
|
219
|
+
false });
|
|
220
|
+
} catch (e) {
|
|
221
|
+
console.error('Block formula error:', e);
|
|
222
|
+
return match;
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
// 行内公式 $...$
|
|
226
|
+
.replace(/\$(.*?)\$/g, (match, p1) => {
|
|
227
|
+
try {
|
|
228
|
+
return renderToString(p1, { displayMode: false, throwOnError:
|
|
229
|
+
false });
|
|
230
|
+
} catch (e) {
|
|
231
|
+
console.error('Inline formula error:', e);
|
|
232
|
+
return match;
|
|
233
|
+
}
|
|
234
|
+
})
|
|
235
|
+
// 行内公式 \( ... \)
|
|
236
|
+
.replace(/\\\((.*?)\\\)/g, (match, p1) => {
|
|
237
|
+
try {
|
|
238
|
+
return renderToString(p1, { displayMode: false, throwOnError:
|
|
239
|
+
false });
|
|
240
|
+
} catch (e) {
|
|
241
|
+
console.error('Inline formula error:', e);
|
|
242
|
+
return match;
|
|
243
|
+
}
|
|
244
|
+
})
|
|
245
|
+
// 块级公式 \[ ... \]
|
|
246
|
+
.replace(/\\\[(.*?)\\\]/gs, (match, p1) => {
|
|
247
|
+
try {
|
|
248
|
+
return renderToString(p1, { displayMode: true, throwOnError:
|
|
249
|
+
false });
|
|
250
|
+
} catch (e) {
|
|
251
|
+
console.error('Block formula error:', e);
|
|
252
|
+
return match;
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
},
|
|
201
256
|
}
|
|
202
257
|
}
|
|
203
258
|
</script>
|