Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
6e5b557a
Commit
6e5b557a
authored
Aug 14, 2024
by
Timothy J. Baek
Browse files
refac
parent
6aefc798
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
40 deletions
+3
-40
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+3
-40
No files found.
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
6e5b557a
...
...
@@ -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) /
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment