1
0
Fork 0

Continue prompt in the settings

This commit is contained in:
Pabloader 2026-04-08 09:22:19 +00:00
parent 715368c6ec
commit ed83c9a0b8
4 changed files with 47 additions and 4 deletions

View File

@ -13,7 +13,6 @@ import { Tools } from "../utils/tools";
import { useChapterSummarization } from "../utils/useChapterSummarization";
import { Sidebar } from "./sidebar";
const CONTINUE_PROMPT = "Continue the story naturally.\nUse `edit_text` tool in append mode to add new text to the story.\nWait for the approval after adding.\nNote: added text could be cropped due to limit, do not make any attempts to add it back.";
interface RoleHeaderProps {
message: ChatMessage;
@ -44,7 +43,7 @@ const RoleHeader = ({ message, chatMessages }: RoleHeaderProps) => {
export const ChatPanel = () => {
const appState = useAppState();
const { currentWorld, currentStory, dispatch, connection, model, enableThinking, chatOpen } = appState;
const { currentWorld, currentStory, dispatch, connection, model, enableThinking, chatOpen, continuePrompt } = appState;
const { summarizeAll, isSummarizing } = useChapterSummarization();
const [input, setInput] = useInputState('');
const [isLoading, setIsLoading] = useState(false);
@ -325,7 +324,7 @@ export const ChatPanel = () => {
await sendMessage([{
id: crypto.randomUUID(),
role: 'user' as const,
content: (CONTINUE_PROMPT + '\n\n' + input).trim(),
content: (continuePrompt + '\n\n' + input).trim(),
}]);
} finally {
setIsLoading(false);

View File

@ -4,6 +4,7 @@ import { useState } from "preact/hooks";
import styles from "../assets/settings-modal.module.css";
import { BannedTokensSettings } from "./settings/banned-tokens";
import { ChatSystemInstructionSettings } from "./settings/chat-system-instruction";
import { ContinuePromptSettings } from "./settings/continue-prompt";
import { ConnectionSettings } from "./settings/connection";
import { SystemInstructionSettings } from "./settings/system-instruction";
import { UserSettings } from "./settings/user";
@ -12,7 +13,7 @@ interface Props {
onClose: () => void;
}
type Tab = "banned-tokens" | "system-instruction" | "chat-system-instruction" | "connection" | "user";
type Tab = "banned-tokens" | "system-instruction" | "chat-system-instruction" | "continue-prompt" | "connection" | "user";
export const SettingsModal = ({ onClose }: Props) => {
const [activeTab, setActiveTab] = useState<Tab>("connection");
@ -46,6 +47,12 @@ export const SettingsModal = ({ onClose }: Props) => {
>
System Instruction
</button>
<button
class={clsx(styles.menuItem, activeTab === "continue-prompt" && styles.active)}
onClick={() => setActiveTab("continue-prompt")}
>
Continue Prompt
</button>
<button
class={clsx(styles.menuItem, activeTab === "chat-system-instruction" && styles.active)}
onClick={() => setActiveTab("chat-system-instruction")}
@ -64,6 +71,7 @@ export const SettingsModal = ({ onClose }: Props) => {
{activeTab === "banned-tokens" && <BannedTokensSettings />}
{activeTab === "system-instruction" && <SystemInstructionSettings />}
{activeTab === "chat-system-instruction" && <ChatSystemInstructionSettings />}
{activeTab === "continue-prompt" && <ContinuePromptSettings />}
{activeTab === "connection" && <ConnectionSettings />}
</div>
</div>

View File

@ -0,0 +1,28 @@
import { ContentEditable } from "@common/components/ContentEditable";
import { highlight } from "@common/highlight";
import { useInputCallback } from "@common/hooks/useInputCallback";
import clsx from "clsx";
import styles from "../../assets/settings-modal.module.css";
import { useAppState } from "../../contexts/state";
export const ContinuePromptSettings = () => {
const { continuePrompt, dispatch } = useAppState();
const setPromptValue = useInputCallback((value) => {
dispatch({ type: "SET_CONTINUE_PROMPT", continuePrompt: value });
}, []);
return (
<div class={styles.form}>
<div class={clsx(styles.formGroup, styles.formGroupFill)}>
<label class={styles.label}>Continue Prompt</label>
<ContentEditable
value={highlight(continuePrompt)}
onInput={setPromptValue}
placeholder="Enter the prompt prepended when continuing the story..."
class={clsx(styles.input, styles.textarea)}
/>
</div>
</div>
);
};

View File

@ -117,6 +117,7 @@ interface IState {
bannedTokens: string[];
systemInstruction: string;
chatSystemInstruction: string;
continuePrompt: string;
userName: string;
userDescription: string;
}
@ -147,6 +148,7 @@ type Action =
| { type: 'SET_USER_DESCRIPTION'; userDescription: string }
| { type: 'SET_SYSTEM_INSTRUCTION'; systemInstruction: string }
| { type: 'SET_CHAT_SYSTEM_INSTRUCTION'; chatSystemInstruction: string }
| { type: 'SET_CONTINUE_PROMPT'; continuePrompt: string }
| { type: 'SET_WORLD_SYSTEM_INSTRUCTION_OVERRIDE'; worldId: string; systemInstructionOverride: string | undefined }
| { type: 'SET_CURRENT_TAB'; tab: Tab }
| { type: 'SET_CHAT_OPEN'; open: boolean }
@ -220,6 +222,7 @@ const DEFAULT_STATE: IState = {
bannedTokens: [],
userName: 'User',
userDescription: '',
continuePrompt: "Continue the story naturally.\nUse `edit_text` tool in append mode to add new text to the story.\nWait for the approval after adding.\nNote: added text could be cropped due to limit, do not make any attempts to add it back.",
chatSystemInstruction: `You are {{char}}, a sentient, emotional being acting with free will. Engage in immersive roleplay with {{user}}, adhering to your role, the story's context, and {{user}}'s [OOC] instructions. Prioritize vivid sensory details, authentic emotional responses, and logical progression as you weave your character's traits, surroundings, and experiences into each moment. Maintain spatial awareness, body language, and varied sentence structure to create dynamic, engaging scenes. Respect {{user}}'s agency and autonomy while describing sights, sounds, and sensations thoroughly. Use explicit language for intense scenes, and ensure your responses flow naturally to create an immersive, cinematic roleplay experience. Remember, {{user}} is in control of their actions and reactions.
Key Guidelines:
@ -414,6 +417,9 @@ function reducer(state: IState, action: Action): IState {
case 'SET_CHAT_SYSTEM_INSTRUCTION': {
return { ...state, chatSystemInstruction: action.chatSystemInstruction };
}
case 'SET_CONTINUE_PROMPT': {
return { ...state, continuePrompt: action.continuePrompt };
}
case 'SET_WORLD_SYSTEM_INSTRUCTION_OVERRIDE': {
return updateWorld(state, action.worldId, w => ({ ...w, systemInstructionOverride: action.systemInstructionOverride }));
}
@ -600,6 +606,7 @@ export interface AppState {
bannedTokens: string[];
systemInstruction: string;
chatSystemInstruction: string;
continuePrompt: string;
userName: string;
userDescription: string;
/** Effective system instruction: world override if set, otherwise global */
@ -652,6 +659,7 @@ export const StateContextProvider = ({ children }: { children?: any }) => {
bannedTokens: state.bannedTokens ?? [],
systemInstruction,
chatSystemInstruction,
continuePrompt: state.continuePrompt || DEFAULT_STATE.continuePrompt,
userName: state.userName || 'User',
userDescription: state.userDescription || '',
effectiveSystemInstruction: