Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export const adapterSettings: {
etaCutoff: ['aphrodite'],

prefill: ['claude'],
continueMessagePrompt: AI_ADAPTERS.slice(),

topP: [
'horde',
Expand Down
1 change: 1 addition & 0 deletions common/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const presetValidator = {
prefixNameAppend: 'boolean?',
prefill: 'string?',
antiBond: 'boolean?',
continueMessagePrompt: 'string?',

replicateModelType: 'string?',
replicateModelVersion: 'string?',
Expand Down
1 change: 1 addition & 0 deletions common/presets/claude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ Enter roleplay mode. You will write {{char}}'s next reply in a dialogue between
</facts>`,
ultimeJailbreak: `Do not decide what {{user}} says or does.`,
prefill: '',
continueMessagePrompt: `\n\nHuman: <system_note>Continue {{char}}'s reply.</system_note>`,
},
} satisfies Record<string, Partial<AppSchema.GenSettings>>
2 changes: 2 additions & 0 deletions common/presets/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Facts: {{memory}}

Relevant Information: {{user_embed}}
`,
continueMessagePrompt: `\n\nContinue {{char}}'s response.`,
},
openaiTurbo: {
name: 'DaVinci',
Expand All @@ -74,5 +75,6 @@ Description of {{char}}: {{personality}}
Circumstances and context of the dialogue: {{scenario}}

Facts: {{memory}}`,
continueMessagePrompt: `\n\nContinue {{char}}'s response.`,
},
} satisfies Record<string, Partial<AppSchema.GenSettings>>
10 changes: 9 additions & 1 deletion common/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,18 @@ function createPostPrompt(
| 'book'
| 'replyAs'
| 'impersonate'
| 'sender'
>
) {
const post = []
post.push(`${opts.replyAs.name}:`)
if (opts.kind === 'continue') {
const continuePrompt = (opts.settings?.continueMessagePrompt ?? '\n{{char}}:')
.replace(BOT_REPLACE, opts.replyAs.name)
.replace(SELF_REPLACE, opts.sender.handle)
if (continuePrompt) post.push(continuePrompt)
} else {
post.push(`${opts.replyAs.name}:`)
}
return post
}

Expand Down
1 change: 1 addition & 0 deletions common/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ export namespace AppSchema {
prefill?: string
ignoreCharacterUjb?: boolean
antiBond?: boolean
continueMessagePrompt?: string

frequencyPenalty?: number
presencePenalty?: number
Expand Down
8 changes: 7 additions & 1 deletion srv/adapter/chat-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,13 @@ async function getPostInstruction(
}

case 'continue':
return { role: 'system', content: `${prefix}\n\nContinue ${opts.replyAs.name}'s response` }
const prompt = (opts.gen.continueMessagePrompt ?? '\n{{char}}:')
.replace(BOT_REPLACE, opts.replyAs.name)
.replace(SELF_REPLACE, opts.sender.handle)
return {
role: 'system',
content: `${prefix}${prompt}`,
}

case 'summary': {
let content = opts.user.images?.summaryPrompt || IMAGE_SUMMARY_PROMPT.openai
Expand Down
24 changes: 11 additions & 13 deletions srv/adapter/claude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { defaultPresets } from '../../common/presets'
import {
SAMPLE_CHAT_PREAMBLE,
BOT_REPLACE,
SELF_REPLACE,
injectPlaceholders,
ensureValidTemplate,
START_REPLACE,
Expand Down Expand Up @@ -283,7 +284,7 @@ async function createClaudePrompt(opts: AdapterProps) {
})
).parsed

const prefill = opts.gen.prefill ? opts.gen.prefill + '\n' : ''
const prefill = opts.gen.prefill ? opts.gen.prefill : ''
const prefillCost = await encoder()(prefill)

const maxBudget =
Expand Down Expand Up @@ -347,21 +348,18 @@ async function createClaudePrompt(opts: AdapterProps) {
messages.push(ujb)
}

const continueAddon =
opts.kind === 'continue'
? `\n\nHuman: <system_note>Continue ${replyAs.name}'s reply.</system_note>`
: ''
const continuePost = (opts.gen.continueMessagePrompt ?? '\n{{char}}:')
.replace(BOT_REPLACE, opts.replyAs.name)
.replace(SELF_REPLACE, opts.sender.handle)

// When rebasing before merging, ensure the changes from #750 are reflected here
const appendName = opts.gen.prefixNameAppend ?? true
const nonContinuePost = appendName ? `\n${replyAs.name}:` : ''

const post = opts.kind === 'continue' ? continuePost : nonContinuePost

// <https://console.anthropic.com/docs/prompt-design#what-is-a-prompt>
return (
messages.join('\n\n') +
continueAddon +
'\n\n' +
'Assistant: ' +
prefill +
(appendName ? replyAs.name + ':' : '')
)
return messages.join('\n\n') + '\n\n' + 'Assistant: ' + prefill + post
}

type LineType = 'system' | 'char' | 'user' | 'example'
Expand Down
13 changes: 13 additions & 0 deletions web/shared/GenerationSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,19 @@ const PromptSettings: Component<
/>
</div>
</Card>
<Card class="flex flex-col gap-4">
<h3 class="text-lg">Miscellaneous prompts</h3>
<TextInput
fieldName="continueMessagePrompt"
label="'Generate More' prompt"
helperText={<>Prompt appended to input when using 'Generate More'</>}
placeholder="&#10;{{char}}:"
isMultiline
value={props.inherit?.continueMessagePrompt ?? '\n{{char}}:'}
disabled={props.disabled}
class="form-field focusable-field text-900 min-h-[8rem] w-full rounded-xl px-4 py-2 text-sm"
/>
</Card>
</div>

<div classList={{ hidden: props.tab !== 'Memory' }}>
Expand Down