mirror of
https://github.com/open-webui/open-webui
synced 2024-11-26 14:02:29 +00:00
parent
a140d319fe
commit
ff90b125ee
@ -1,28 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from 'svelte';
|
|
||||||
import { marked } from 'marked';
|
|
||||||
import type { Token } from 'marked';
|
import type { Token } from 'marked';
|
||||||
|
import { revertSanitizedResponseContent, unescapeHtml } from '$lib/utils';
|
||||||
import {
|
|
||||||
replaceTokens,
|
|
||||||
revertSanitizedResponseContent,
|
|
||||||
sanitizeResponseContent,
|
|
||||||
unescapeHtml
|
|
||||||
} from '$lib/utils';
|
|
||||||
import CodeBlock from '$lib/components/chat/Messages/CodeBlock.svelte';
|
import CodeBlock from '$lib/components/chat/Messages/CodeBlock.svelte';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
import MarkdownInlineTokens from '$lib/components/chat/Messages/MarkdownInlineTokens.svelte';
|
import MarkdownInlineTokens from '$lib/components/chat/Messages/MarkdownInlineTokens.svelte';
|
||||||
import { user } from '$lib/stores';
|
|
||||||
|
|
||||||
export let id: string;
|
export let id: string;
|
||||||
export let tokens: Token[];
|
export let tokens: Token[];
|
||||||
export let model = null;
|
|
||||||
export let content = '';
|
|
||||||
export let top = true;
|
export let top = true;
|
||||||
|
|
||||||
$: tokens = marked.lexer(
|
|
||||||
replaceTokens(sanitizeResponseContent(content), model?.name, $user?.name)
|
|
||||||
);
|
|
||||||
|
|
||||||
const headerComponent = (depth: number) => {
|
const headerComponent = (depth: number) => {
|
||||||
return 'h' + depth;
|
return 'h' + depth;
|
||||||
};
|
};
|
@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import { marked } from 'marked';
|
||||||
import tippy from 'tippy.js';
|
import tippy from 'tippy.js';
|
||||||
import auto_render from 'katex/dist/contrib/auto-render.mjs';
|
import auto_render from 'katex/dist/contrib/auto-render.mjs';
|
||||||
import 'katex/dist/katex.min.css';
|
import 'katex/dist/katex.min.css';
|
||||||
@ -37,7 +38,7 @@
|
|||||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||||
import WebSearchResults from './ResponseMessage/WebSearchResults.svelte';
|
import WebSearchResults from './ResponseMessage/WebSearchResults.svelte';
|
||||||
import Sparkles from '$lib/components/icons/Sparkles.svelte';
|
import Sparkles from '$lib/components/icons/Sparkles.svelte';
|
||||||
import Markdown from './Markdown.svelte';
|
import MarkdownTokens from './MarkdownTokens.svelte';
|
||||||
|
|
||||||
export let message;
|
export let message;
|
||||||
export let siblings;
|
export let siblings;
|
||||||
@ -76,6 +77,10 @@
|
|||||||
|
|
||||||
let selectedCitation = null;
|
let selectedCitation = null;
|
||||||
|
|
||||||
|
$: tokens = marked.lexer(
|
||||||
|
replaceTokens(sanitizeResponseContent(message?.content), model?.name, $user?.name)
|
||||||
|
);
|
||||||
|
|
||||||
$: if (message) {
|
$: if (message) {
|
||||||
renderStyling();
|
renderStyling();
|
||||||
}
|
}
|
||||||
@ -495,8 +500,8 @@
|
|||||||
<!-- always show message contents even if there's an error -->
|
<!-- always show message contents even if there's an error -->
|
||||||
<!-- unless message.error === true which is legacy error handling, where the error message is stored in message.content -->
|
<!-- unless message.error === true which is legacy error handling, where the error message is stored in message.content -->
|
||||||
|
|
||||||
{#key message.id}
|
{#key tokens}
|
||||||
<Markdown id={message.id} {model} content={message.content} />
|
<MarkdownTokens id={message.id} {tokens} />
|
||||||
{/key}
|
{/key}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user