mirror of
https://github.com/open-webui/open-webui
synced 2024-11-24 21:13:59 +00:00
refac
This commit is contained in:
parent
6aefc79807
commit
6e5b557a1f
@ -2,8 +2,6 @@
|
||||
import { toast } from 'svelte-sonner';
|
||||
import dayjs from 'dayjs';
|
||||
import { marked } from 'marked';
|
||||
import tippy from 'tippy.js';
|
||||
import auto_render from 'katex/dist/contrib/auto-render.mjs';
|
||||
import mermaid from 'mermaid';
|
||||
|
||||
import { fade } from 'svelte/transition';
|
||||
@ -81,6 +79,7 @@
|
||||
import 'katex/dist/katex.min.css';
|
||||
|
||||
import markedKatex from '$lib/utils/katex-extension';
|
||||
|
||||
const options = {
|
||||
throwOnError: false
|
||||
};
|
||||
@ -95,37 +94,6 @@
|
||||
}
|
||||
})();
|
||||
|
||||
$: if (message?.done ?? false) {
|
||||
renderLatex();
|
||||
}
|
||||
|
||||
const renderLatex = () => {
|
||||
let chatMessageElements = document
|
||||
.getElementById(`message-${message.id}`)
|
||||
?.getElementsByClassName('chat-assistant');
|
||||
|
||||
if (chatMessageElements) {
|
||||
for (const element of chatMessageElements) {
|
||||
auto_render(element, {
|
||||
// customised options
|
||||
// • auto-render specific keys, e.g.:
|
||||
delimiters: [
|
||||
{ left: '$$', right: '$$', display: false },
|
||||
{ left: '$ ', right: ' $', display: false },
|
||||
{ left: '\\pu{', right: '}', display: false },
|
||||
{ left: '\\ce{', right: '}', display: false },
|
||||
{ left: '\\(', right: '\\)', display: false },
|
||||
{ left: '( ', right: ' )', display: false },
|
||||
{ left: '\\[', right: '\\]', display: false },
|
||||
{ left: '[ ', right: ' ]', display: false }
|
||||
],
|
||||
// • rendering keys, e.g.:
|
||||
throwOnError: false
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const playAudio = (idx) => {
|
||||
return new Promise((res) => {
|
||||
speakingIdx = idx;
|
||||
@ -191,7 +159,7 @@
|
||||
const res = await synthesizeOpenAISpeech(
|
||||
localStorage.token,
|
||||
$settings?.audio?.tts?.defaultVoice === $config.audio.tts.voice
|
||||
? ($settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice)
|
||||
? $settings?.audio?.tts?.voice ?? $config?.audio?.tts?.voice
|
||||
: $config?.audio?.tts?.voice,
|
||||
sentence
|
||||
).catch((error) => {
|
||||
@ -279,14 +247,12 @@
|
||||
editedContent = '';
|
||||
|
||||
await tick();
|
||||
renderLatex();
|
||||
};
|
||||
|
||||
const cancelEditMessage = async () => {
|
||||
edit = false;
|
||||
editedContent = '';
|
||||
await tick();
|
||||
renderLatex();
|
||||
};
|
||||
|
||||
const generateImage = async (message) => {
|
||||
@ -311,7 +277,6 @@
|
||||
$: if (!edit) {
|
||||
(async () => {
|
||||
await tick();
|
||||
renderLatex();
|
||||
|
||||
await mermaid.run({
|
||||
querySelector: '.mermaid'
|
||||
@ -321,8 +286,6 @@
|
||||
|
||||
onMount(async () => {
|
||||
await tick();
|
||||
renderLatex();
|
||||
|
||||
await mermaid.run({
|
||||
querySelector: '.mermaid'
|
||||
});
|
||||
@ -803,7 +766,7 @@
|
||||
100
|
||||
) / 100
|
||||
} tokens` ?? 'N/A'
|
||||
}<br/>
|
||||
}<br/>
|
||||
prompt_token/s: ${
|
||||
Math.round(
|
||||
((message.info.prompt_eval_count ?? 0) /
|
||||
|
Loading…
Reference in New Issue
Block a user