add hideSystemPrompt
This commit is contained in:
parent
0d4f12d900
commit
cd0cd9ebef
|
@ -32,12 +32,22 @@
|
||||||
mangle: false // Do not mangle email addresses
|
mangle: false // Do not mangle email addresses
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getDisplayMessage = ():string => {
|
||||||
|
const content = message.content
|
||||||
|
if (isSystem && chatSettings.hideSystemPrompt) {
|
||||||
|
const result = content.match(/::NOTE::[\s\S]+?::NOTE::/g)
|
||||||
|
return result ? result.map(r => r.replace(/::NOTE::([\s\S]+?)::NOTE::/, '$1')).join('') : '(hidden)'
|
||||||
|
}
|
||||||
|
return content
|
||||||
|
}
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let editing = false
|
let editing = false
|
||||||
let original:string
|
let original:string
|
||||||
let defaultModel:Model
|
let defaultModel:Model
|
||||||
let imageUrl:string
|
let imageUrl:string
|
||||||
let refreshCounter = 0
|
let refreshCounter = 0
|
||||||
|
let displayMessage = message.content
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
defaultModel = chatSettings.model
|
defaultModel = chatSettings.model
|
||||||
|
@ -46,10 +56,12 @@
|
||||||
imageUrl = 'data:image/png;base64, ' + i.b64image
|
imageUrl = 'data:image/png;base64, ' + i.b64image
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
displayMessage = getDisplayMessage()
|
||||||
})
|
})
|
||||||
|
|
||||||
afterUpdate(() => {
|
afterUpdate(() => {
|
||||||
if (message.streaming && message.content.slice(-5).includes('```')) refreshCounter++
|
if (message.streaming && message.content.slice(-5).includes('```')) refreshCounter++
|
||||||
|
displayMessage = getDisplayMessage()
|
||||||
})
|
})
|
||||||
|
|
||||||
const edit = () => {
|
const edit = () => {
|
||||||
|
@ -240,7 +252,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
{#key refreshCounter}
|
{#key refreshCounter}
|
||||||
<SvelteMarkdown
|
<SvelteMarkdown
|
||||||
source={message.content}
|
source={displayMessage}
|
||||||
options={markdownOptions}
|
options={markdownOptions}
|
||||||
renderers={{ code: Code, html: Code }}
|
renderers={{ code: Code, html: Code }}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -98,6 +98,7 @@ const defaults:ChatSettings = {
|
||||||
summaryPrompt: '',
|
summaryPrompt: '',
|
||||||
useSystemPrompt: false,
|
useSystemPrompt: false,
|
||||||
systemPrompt: '',
|
systemPrompt: '',
|
||||||
|
hideSystemPrompt: false,
|
||||||
sendSystemPromptLast: false,
|
sendSystemPromptLast: false,
|
||||||
autoStartSession: false,
|
autoStartSession: false,
|
||||||
trainingPrompts: [],
|
trainingPrompts: [],
|
||||||
|
@ -257,6 +258,13 @@ const systemPromptSettings: ChatSetting[] = [
|
||||||
type: 'other',
|
type: 'other',
|
||||||
hide: (chatId) => true
|
hide: (chatId) => true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'hideSystemPrompt',
|
||||||
|
name: 'Hide System Prompt',
|
||||||
|
title: 'Don\'t show system prompt when displaying message stream.',
|
||||||
|
type: 'boolean',
|
||||||
|
hide: (chatId) => !getChatSettings(chatId).useSystemPrompt
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'autoStartSession',
|
key: 'autoStartSession',
|
||||||
name: 'Auto-Start Session',
|
name: 'Auto-Start Session',
|
||||||
|
|
|
@ -74,6 +74,7 @@ export type ChatSettings = {
|
||||||
summaryPrompt: string;
|
summaryPrompt: string;
|
||||||
useSystemPrompt: boolean;
|
useSystemPrompt: boolean;
|
||||||
systemPrompt: string;
|
systemPrompt: string;
|
||||||
|
hideSystemPrompt: boolean;
|
||||||
sendSystemPromptLast: boolean;
|
sendSystemPromptLast: boolean;
|
||||||
autoStartSession: boolean;
|
autoStartSession: boolean;
|
||||||
hiddenPromptPrefix: string;
|
hiddenPromptPrefix: string;
|
||||||
|
|
Loading…
Reference in New Issue