mirror of
https://github.com/morgan9e/chatgpt-web
synced 2026-04-13 16:04:05 +09:00
add hideSystemPrompt
This commit is contained in:
@@ -32,12 +32,22 @@
|
||||
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()
|
||||
let editing = false
|
||||
let original:string
|
||||
let defaultModel:Model
|
||||
let imageUrl:string
|
||||
let refreshCounter = 0
|
||||
let displayMessage = message.content
|
||||
|
||||
onMount(() => {
|
||||
defaultModel = chatSettings.model
|
||||
@@ -46,10 +56,12 @@
|
||||
imageUrl = 'data:image/png;base64, ' + i.b64image
|
||||
})
|
||||
}
|
||||
displayMessage = getDisplayMessage()
|
||||
})
|
||||
|
||||
afterUpdate(() => {
|
||||
if (message.streaming && message.content.slice(-5).includes('```')) refreshCounter++
|
||||
displayMessage = getDisplayMessage()
|
||||
})
|
||||
|
||||
const edit = () => {
|
||||
@@ -240,7 +252,7 @@
|
||||
{/if}
|
||||
{#key refreshCounter}
|
||||
<SvelteMarkdown
|
||||
source={message.content}
|
||||
source={displayMessage}
|
||||
options={markdownOptions}
|
||||
renderers={{ code: Code, html: Code }}
|
||||
/>
|
||||
|
||||
@@ -98,6 +98,7 @@ const defaults:ChatSettings = {
|
||||
summaryPrompt: '',
|
||||
useSystemPrompt: false,
|
||||
systemPrompt: '',
|
||||
hideSystemPrompt: false,
|
||||
sendSystemPromptLast: false,
|
||||
autoStartSession: false,
|
||||
trainingPrompts: [],
|
||||
@@ -257,6 +258,13 @@ const systemPromptSettings: ChatSetting[] = [
|
||||
type: 'other',
|
||||
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',
|
||||
name: 'Auto-Start Session',
|
||||
|
||||
@@ -74,6 +74,7 @@ export type ChatSettings = {
|
||||
summaryPrompt: string;
|
||||
useSystemPrompt: boolean;
|
||||
systemPrompt: string;
|
||||
hideSystemPrompt: boolean;
|
||||
sendSystemPromptLast: boolean;
|
||||
autoStartSession: boolean;
|
||||
hiddenPromptPrefix: string;
|
||||
|
||||
Reference in New Issue
Block a user