ai-error-assistant-pro 0.0.28 → 0.0.29
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 +58 -41
- package/components/demo/src/error-chat.vue +36 -29
- package/dist/ai-error-assistant-pro.common.js +2967 -71
- 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 +2967 -71
- 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 +1 -1
|
@@ -93,6 +93,7 @@ import { chartClear, sendMessageEventSource, getAutoQuestioning, pdfUrl, pdfUrlB
|
|
|
93
93
|
import katex from 'katex';
|
|
94
94
|
import renderMathInElement from 'katex/contrib/auto-render/auto-render.js'
|
|
95
95
|
import 'katex/dist/katex.min.css';
|
|
96
|
+
import 'katex/contrib/mhchem/mhchem.js';
|
|
96
97
|
const controller = new AbortController();
|
|
97
98
|
const signal = controller.signal;
|
|
98
99
|
|
|
@@ -412,47 +413,63 @@ export default {
|
|
|
412
413
|
window.open(baseUrl, '_blank');
|
|
413
414
|
},
|
|
414
415
|
renderFormulas(text) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
})
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
416
|
+
if (!text) return '';
|
|
417
|
+
text = text.replace(/>/g, '>')
|
|
418
|
+
.replace(/</g, '<')
|
|
419
|
+
.replace(/&/g, '&')
|
|
420
|
+
.replace(/"/g, '"')
|
|
421
|
+
.replace(/'/g, "'");
|
|
422
|
+
// 如果整个文本包含 LaTeX 命令且没有定界符,整体包裹
|
|
423
|
+
const hasDelimiter = /\$|\\\(|\\\[/.test(text);
|
|
424
|
+
if (!hasDelimiter) {
|
|
425
|
+
text = text.replace(
|
|
426
|
+
/(\\(?: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,
|
|
427
|
+
(match) => `\\(${match}\\)`
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
const { renderToString } = katex;
|
|
431
|
+
return text
|
|
432
|
+
// $$ ... $$ 块级公式
|
|
433
|
+
.replace(/\$\$([\s\S]*?)\$\$/gs, function (_, formula) {
|
|
434
|
+
try {
|
|
435
|
+
const trimmedFormula = formula.trim()
|
|
436
|
+
return renderToString(trimmedFormula, { displayMode: true });
|
|
437
|
+
} catch (error) {
|
|
438
|
+
console.error('Error rendering block formula:', error);
|
|
439
|
+
return _;
|
|
440
|
+
}
|
|
441
|
+
})
|
|
442
|
+
// \(...\) 行内公式
|
|
443
|
+
.replace(/\\\((.*?)\\\)/gs, function (_, formula) {
|
|
444
|
+
try {
|
|
445
|
+
const trimmedFormula = formula.trim()
|
|
446
|
+
return renderToString(trimmedFormula, { displayMode: false });
|
|
447
|
+
} catch (error) {
|
|
448
|
+
console.error('Error rendering inline formula:', error);
|
|
449
|
+
return _;
|
|
450
|
+
}
|
|
451
|
+
})
|
|
452
|
+
// \[...\] 块级公式
|
|
453
|
+
.replace(/\\\[(.*?)\\\]/gs, function (_, formula) {
|
|
454
|
+
try {
|
|
455
|
+
const trimmedFormula = formula.trim()
|
|
456
|
+
return renderToString(trimmedFormula, { displayMode: true });
|
|
457
|
+
} catch (error) {
|
|
458
|
+
console.error('Error rendering block formula:', error);
|
|
459
|
+
return _;
|
|
460
|
+
}
|
|
461
|
+
})
|
|
462
|
+
// $...$ 行内公式
|
|
463
|
+
.replace(/\$(.+?)\$/gs, function (_, formula) {
|
|
464
|
+
try {
|
|
465
|
+
const trimmedFormula = formula.trim()
|
|
466
|
+
return renderToString(trimmedFormula, { displayMode: false });
|
|
467
|
+
} catch (error) {
|
|
468
|
+
console.error('Error rendering inline formula with $...$:', error);
|
|
469
|
+
return _;
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
},
|
|
456
473
|
renderKaTeX() {
|
|
457
474
|
setTimeout(() => {
|
|
458
475
|
// 自动渲染页面中的所有 KaTeX 公式
|
|
@@ -91,6 +91,7 @@ import ChatTools from './chat-tools.vue';
|
|
|
91
91
|
import {erranalysis, pdfUrlBase, retryAnalysis} from '../api/index'
|
|
92
92
|
import katex from 'katex';
|
|
93
93
|
import 'katex/dist/katex.min.css';
|
|
94
|
+
import 'katex/contrib/mhchem/mhchem.js';
|
|
94
95
|
export default {
|
|
95
96
|
name: 'ErrorChart',
|
|
96
97
|
components: {
|
|
@@ -200,8 +201,14 @@ export default {
|
|
|
200
201
|
console.log(e);
|
|
201
202
|
}
|
|
202
203
|
},
|
|
203
|
-
|
|
204
|
+
renderFormulas(text) {
|
|
204
205
|
if (!text) return '';
|
|
206
|
+
|
|
207
|
+
text = text.replace(/>/g, '>')
|
|
208
|
+
.replace(/</g, '<')
|
|
209
|
+
.replace(/&/g, '&')
|
|
210
|
+
.replace(/"/g, '"')
|
|
211
|
+
.replace(/'/g, "'");
|
|
205
212
|
// 如果整个文本包含 LaTeX 命令且没有定界符,整体包裹
|
|
206
213
|
const hasDelimiter = /\$|\\\(|\\\[/.test(text);
|
|
207
214
|
if (!hasDelimiter) {
|
|
@@ -212,44 +219,44 @@ export default {
|
|
|
212
219
|
}
|
|
213
220
|
const { renderToString } = katex;
|
|
214
221
|
return text
|
|
215
|
-
// 块级公式
|
|
216
|
-
.replace(/\$\$(
|
|
222
|
+
// $$ ... $$ 块级公式
|
|
223
|
+
.replace(/\$\$([\s\S]*?)\$\$/gs, function (_, formula) {
|
|
217
224
|
try {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} catch (
|
|
221
|
-
console.error('
|
|
222
|
-
return
|
|
225
|
+
const trimmedFormula = formula.trim()
|
|
226
|
+
return renderToString(trimmedFormula, { displayMode: true });
|
|
227
|
+
} catch (error) {
|
|
228
|
+
console.error('Error rendering block formula:', error);
|
|
229
|
+
return _;
|
|
223
230
|
}
|
|
224
231
|
})
|
|
225
|
-
// 行内公式
|
|
226
|
-
.replace(
|
|
232
|
+
// \(...\) 行内公式
|
|
233
|
+
.replace(/\\\((.*?)\\\)/gs, function (_, formula) {
|
|
227
234
|
try {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
} catch (
|
|
231
|
-
console.error('
|
|
232
|
-
return
|
|
235
|
+
const trimmedFormula = formula.trim()
|
|
236
|
+
return renderToString(trimmedFormula, { displayMode: false });
|
|
237
|
+
} catch (error) {
|
|
238
|
+
console.error('Error rendering inline formula:', error);
|
|
239
|
+
return _;
|
|
233
240
|
}
|
|
234
241
|
})
|
|
235
|
-
//
|
|
236
|
-
.replace(/\\\(
|
|
242
|
+
// \[...\] 块级公式
|
|
243
|
+
.replace(/\\\[(.*?)\\\]/gs, function (_, formula) {
|
|
237
244
|
try {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
} catch (
|
|
241
|
-
console.error('
|
|
242
|
-
return
|
|
245
|
+
const trimmedFormula = formula.trim()
|
|
246
|
+
return renderToString(trimmedFormula, { displayMode: true });
|
|
247
|
+
} catch (error) {
|
|
248
|
+
console.error('Error rendering block formula:', error);
|
|
249
|
+
return _;
|
|
243
250
|
}
|
|
244
251
|
})
|
|
245
|
-
//
|
|
246
|
-
.replace(
|
|
252
|
+
// $...$ 行内公式
|
|
253
|
+
.replace(/\$(.+?)\$/gs, function (_, formula) {
|
|
247
254
|
try {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
} catch (
|
|
251
|
-
console.error('
|
|
252
|
-
return
|
|
255
|
+
const trimmedFormula = formula.trim()
|
|
256
|
+
return renderToString(trimmedFormula, { displayMode: false });
|
|
257
|
+
} catch (error) {
|
|
258
|
+
console.error('Error rendering inline formula with $...$:', error);
|
|
259
|
+
return _;
|
|
253
260
|
}
|
|
254
261
|
});
|
|
255
262
|
},
|