mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-10-27 08:21:30 +00:00
feat: render user content as markdown option (#16358)
* feat: render user content as markdown option - Add a persisted 'renderUserContentAsMarkdown' preference to the settings defaults and info metadata so the choice survives reloads like other options - Surface the new 'Render user content as Markdown' checkbox in the General section of the chat settings dialog, beneath the PDF toggle - Render user chat messages with 'MarkdownContent' when the new setting is enabled, matching assistant formatting while preserving the existing card styling otherwise - chore: update webui build output * chore: update webui build output
This commit is contained in:
Binary file not shown.
@@ -2,8 +2,9 @@
|
|||||||
import { Check, X } from '@lucide/svelte';
|
import { Check, X } from '@lucide/svelte';
|
||||||
import { Card } from '$lib/components/ui/card';
|
import { Card } from '$lib/components/ui/card';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import { ChatAttachmentsList } from '$lib/components/app';
|
import { ChatAttachmentsList, MarkdownContent } from '$lib/components/app';
|
||||||
import { INPUT_CLASSES } from '$lib/constants/input-classes';
|
import { INPUT_CLASSES } from '$lib/constants/input-classes';
|
||||||
|
import { config } from '$lib/stores/settings.svelte';
|
||||||
import ChatMessageActions from './ChatMessageActions.svelte';
|
import ChatMessageActions from './ChatMessageActions.svelte';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -55,6 +56,7 @@
|
|||||||
|
|
||||||
let isMultiline = $state(false);
|
let isMultiline = $state(false);
|
||||||
let messageElement: HTMLElement | undefined = $state();
|
let messageElement: HTMLElement | undefined = $state();
|
||||||
|
const currentConfig = config();
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (!messageElement || !message.content.trim()) return;
|
if (!messageElement || !message.content.trim()) return;
|
||||||
@@ -123,9 +125,18 @@
|
|||||||
class="max-w-[80%] rounded-[1.125rem] bg-primary px-3.75 py-1.5 text-primary-foreground data-[multiline]:py-2.5"
|
class="max-w-[80%] rounded-[1.125rem] bg-primary px-3.75 py-1.5 text-primary-foreground data-[multiline]:py-2.5"
|
||||||
data-multiline={isMultiline ? '' : undefined}
|
data-multiline={isMultiline ? '' : undefined}
|
||||||
>
|
>
|
||||||
<span bind:this={messageElement} class="text-md whitespace-pre-wrap">
|
{#if currentConfig.renderUserContentAsMarkdown}
|
||||||
{message.content}
|
<div bind:this={messageElement} class="text-md">
|
||||||
</span>
|
<MarkdownContent
|
||||||
|
class="markdown-user-content text-primary-foreground"
|
||||||
|
content={message.content}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<span bind:this={messageElement} class="text-md whitespace-pre-wrap">
|
||||||
|
{message.content}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
</Card>
|
</Card>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,11 @@
|
|||||||
key: 'showModelInfo',
|
key: 'showModelInfo',
|
||||||
label: 'Show model information',
|
label: 'Show model information',
|
||||||
type: 'checkbox'
|
type: 'checkbox'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'renderUserContentAsMarkdown',
|
||||||
|
label: 'Render user content as Markdown',
|
||||||
|
type: 'checkbox'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export const SETTING_CONFIG_DEFAULT: Record<string, string | number | boolean> =
|
|||||||
pasteLongTextToFileLen: 2500,
|
pasteLongTextToFileLen: 2500,
|
||||||
pdfAsImage: false,
|
pdfAsImage: false,
|
||||||
showModelInfo: false,
|
showModelInfo: false,
|
||||||
|
renderUserContentAsMarkdown: false,
|
||||||
// make sure these default values are in sync with `common.h`
|
// make sure these default values are in sync with `common.h`
|
||||||
samplers: 'top_k;typ_p;top_p;min_p;temperature',
|
samplers: 'top_k;typ_p;top_p;min_p;temperature',
|
||||||
temperature: 0.8,
|
temperature: 0.8,
|
||||||
@@ -84,6 +85,7 @@ export const SETTING_CONFIG_INFO: Record<string, string> = {
|
|||||||
'Ask for confirmation before automatically changing conversation title when editing the first message.',
|
'Ask for confirmation before automatically changing conversation title when editing the first message.',
|
||||||
pdfAsImage: 'Parse PDF as image instead of text (requires vision-capable model).',
|
pdfAsImage: 'Parse PDF as image instead of text (requires vision-capable model).',
|
||||||
showModelInfo: 'Display the model name used to generate each message below the message content.',
|
showModelInfo: 'Display the model name used to generate each message below the message content.',
|
||||||
|
renderUserContentAsMarkdown: 'Render user messages using markdown formatting in the chat.',
|
||||||
pyInterpreterEnabled:
|
pyInterpreterEnabled:
|
||||||
'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.'
|
'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.'
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user