From 6e5b557a1f9818498dfb6f0cdc1163b70fca63d3 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 14 Aug 2024 16:08:23 +0200 Subject: [PATCH] refac --- .../chat/Messages/ResponseMessage.svelte | 43 ++----------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index 150f26931..5fdf03db8 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -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' - }
+ }
prompt_token/s: ${ Math.round( ((message.info.prompt_eval_count ?? 0) /