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
a140d319
Commit
a140d319
authored
Aug 06, 2024
by
Timothy J. Baek
Browse files
refac
parent
9581bf5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
10 deletions
+19
-10
src/lib/components/chat/Messages/Markdown.svelte
src/lib/components/chat/Messages/Markdown.svelte
+16
-2
src/lib/components/chat/Messages/ResponseMessage.svelte
src/lib/components/chat/Messages/ResponseMessage.svelte
+3
-8
No files found.
src/lib/components/chat/Messages/Markdown
Tokens
.svelte
→
src/lib/components/chat/Messages/Markdown.svelte
View file @
a140d319
<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;
};
};
...
...
src/lib/components/chat/Messages/ResponseMessage.svelte
View file @
a140d319
<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';
...
@@ -38,7 +37,7 @@
...
@@ -38,7 +37,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
Tokens
from './Markdown
Tokens
.svelte';
import Markdown from './Markdown.svelte';
export let message;
export let message;
export let siblings;
export let siblings;
...
@@ -77,10 +76,6 @@
...
@@ -77,10 +76,6 @@
let selectedCitation = null;
let selectedCitation = null;
$: tokens = marked.lexer(
replaceTokens(sanitizeResponseContent(message?.content), model?.name, $user?.name)
);
$: if (message) {
$: if (message) {
renderStyling();
renderStyling();
}
}
...
@@ -500,8 +495,8 @@
...
@@ -500,8 +495,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
tokens
}
{#key
message.id
}
<Markdown
Tokens
id={message.id} {
tok
en
s
} />
<Markdown id={message.id} {
model} content={message.cont
en
t
} />
{/key}
{/key}
{/if}
{/if}
...
...
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