Continue prompt in the settings
This commit is contained in:
parent
715368c6ec
commit
ed83c9a0b8
|
|
@ -13,7 +13,6 @@ import { Tools } from "../utils/tools";
|
||||||
import { useChapterSummarization } from "../utils/useChapterSummarization";
|
import { useChapterSummarization } from "../utils/useChapterSummarization";
|
||||||
import { Sidebar } from "./sidebar";
|
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 {
|
interface RoleHeaderProps {
|
||||||
message: ChatMessage;
|
message: ChatMessage;
|
||||||
|
|
@ -44,7 +43,7 @@ const RoleHeader = ({ message, chatMessages }: RoleHeaderProps) => {
|
||||||
|
|
||||||
export const ChatPanel = () => {
|
export const ChatPanel = () => {
|
||||||
const appState = useAppState();
|
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 { summarizeAll, isSummarizing } = useChapterSummarization();
|
||||||
const [input, setInput] = useInputState('');
|
const [input, setInput] = useInputState('');
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
@ -325,7 +324,7 @@ export const ChatPanel = () => {
|
||||||
await sendMessage([{
|
await sendMessage([{
|
||||||
id: crypto.randomUUID(),
|
id: crypto.randomUUID(),
|
||||||
role: 'user' as const,
|
role: 'user' as const,
|
||||||
content: (CONTINUE_PROMPT + '\n\n' + input).trim(),
|
content: (continuePrompt + '\n\n' + input).trim(),
|
||||||
}]);
|
}]);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { useState } from "preact/hooks";
|
||||||
import styles from "../assets/settings-modal.module.css";
|
import styles from "../assets/settings-modal.module.css";
|
||||||
import { BannedTokensSettings } from "./settings/banned-tokens";
|
import { BannedTokensSettings } from "./settings/banned-tokens";
|
||||||
import { ChatSystemInstructionSettings } from "./settings/chat-system-instruction";
|
import { ChatSystemInstructionSettings } from "./settings/chat-system-instruction";
|
||||||
|
import { ContinuePromptSettings } from "./settings/continue-prompt";
|
||||||
import { ConnectionSettings } from "./settings/connection";
|
import { ConnectionSettings } from "./settings/connection";
|
||||||
import { SystemInstructionSettings } from "./settings/system-instruction";
|
import { SystemInstructionSettings } from "./settings/system-instruction";
|
||||||
import { UserSettings } from "./settings/user";
|
import { UserSettings } from "./settings/user";
|
||||||
|
|
@ -12,7 +13,7 @@ interface Props {
|
||||||
onClose: () => void;
|
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) => {
|
export const SettingsModal = ({ onClose }: Props) => {
|
||||||
const [activeTab, setActiveTab] = useState<Tab>("connection");
|
const [activeTab, setActiveTab] = useState<Tab>("connection");
|
||||||
|
|
@ -46,6 +47,12 @@ export const SettingsModal = ({ onClose }: Props) => {
|
||||||
>
|
>
|
||||||
System Instruction
|
System Instruction
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
class={clsx(styles.menuItem, activeTab === "continue-prompt" && styles.active)}
|
||||||
|
onClick={() => setActiveTab("continue-prompt")}
|
||||||
|
>
|
||||||
|
Continue Prompt
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
class={clsx(styles.menuItem, activeTab === "chat-system-instruction" && styles.active)}
|
class={clsx(styles.menuItem, activeTab === "chat-system-instruction" && styles.active)}
|
||||||
onClick={() => setActiveTab("chat-system-instruction")}
|
onClick={() => setActiveTab("chat-system-instruction")}
|
||||||
|
|
@ -64,6 +71,7 @@ export const SettingsModal = ({ onClose }: Props) => {
|
||||||
{activeTab === "banned-tokens" && <BannedTokensSettings />}
|
{activeTab === "banned-tokens" && <BannedTokensSettings />}
|
||||||
{activeTab === "system-instruction" && <SystemInstructionSettings />}
|
{activeTab === "system-instruction" && <SystemInstructionSettings />}
|
||||||
{activeTab === "chat-system-instruction" && <ChatSystemInstructionSettings />}
|
{activeTab === "chat-system-instruction" && <ChatSystemInstructionSettings />}
|
||||||
|
{activeTab === "continue-prompt" && <ContinuePromptSettings />}
|
||||||
{activeTab === "connection" && <ConnectionSettings />}
|
{activeTab === "connection" && <ConnectionSettings />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
@ -117,6 +117,7 @@ interface IState {
|
||||||
bannedTokens: string[];
|
bannedTokens: string[];
|
||||||
systemInstruction: string;
|
systemInstruction: string;
|
||||||
chatSystemInstruction: string;
|
chatSystemInstruction: string;
|
||||||
|
continuePrompt: string;
|
||||||
userName: string;
|
userName: string;
|
||||||
userDescription: string;
|
userDescription: string;
|
||||||
}
|
}
|
||||||
|
|
@ -147,6 +148,7 @@ type Action =
|
||||||
| { type: 'SET_USER_DESCRIPTION'; userDescription: string }
|
| { type: 'SET_USER_DESCRIPTION'; userDescription: string }
|
||||||
| { type: 'SET_SYSTEM_INSTRUCTION'; systemInstruction: string }
|
| { type: 'SET_SYSTEM_INSTRUCTION'; systemInstruction: string }
|
||||||
| { type: 'SET_CHAT_SYSTEM_INSTRUCTION'; chatSystemInstruction: 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_WORLD_SYSTEM_INSTRUCTION_OVERRIDE'; worldId: string; systemInstructionOverride: string | undefined }
|
||||||
| { type: 'SET_CURRENT_TAB'; tab: Tab }
|
| { type: 'SET_CURRENT_TAB'; tab: Tab }
|
||||||
| { type: 'SET_CHAT_OPEN'; open: boolean }
|
| { type: 'SET_CHAT_OPEN'; open: boolean }
|
||||||
|
|
@ -220,6 +222,7 @@ const DEFAULT_STATE: IState = {
|
||||||
bannedTokens: [],
|
bannedTokens: [],
|
||||||
userName: 'User',
|
userName: 'User',
|
||||||
userDescription: '',
|
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.
|
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:
|
Key Guidelines:
|
||||||
|
|
@ -414,6 +417,9 @@ function reducer(state: IState, action: Action): IState {
|
||||||
case 'SET_CHAT_SYSTEM_INSTRUCTION': {
|
case 'SET_CHAT_SYSTEM_INSTRUCTION': {
|
||||||
return { ...state, chatSystemInstruction: action.chatSystemInstruction };
|
return { ...state, chatSystemInstruction: action.chatSystemInstruction };
|
||||||
}
|
}
|
||||||
|
case 'SET_CONTINUE_PROMPT': {
|
||||||
|
return { ...state, continuePrompt: action.continuePrompt };
|
||||||
|
}
|
||||||
case 'SET_WORLD_SYSTEM_INSTRUCTION_OVERRIDE': {
|
case 'SET_WORLD_SYSTEM_INSTRUCTION_OVERRIDE': {
|
||||||
return updateWorld(state, action.worldId, w => ({ ...w, systemInstructionOverride: action.systemInstructionOverride }));
|
return updateWorld(state, action.worldId, w => ({ ...w, systemInstructionOverride: action.systemInstructionOverride }));
|
||||||
}
|
}
|
||||||
|
|
@ -600,6 +606,7 @@ export interface AppState {
|
||||||
bannedTokens: string[];
|
bannedTokens: string[];
|
||||||
systemInstruction: string;
|
systemInstruction: string;
|
||||||
chatSystemInstruction: string;
|
chatSystemInstruction: string;
|
||||||
|
continuePrompt: string;
|
||||||
userName: string;
|
userName: string;
|
||||||
userDescription: string;
|
userDescription: string;
|
||||||
/** Effective system instruction: world override if set, otherwise global */
|
/** Effective system instruction: world override if set, otherwise global */
|
||||||
|
|
@ -652,6 +659,7 @@ export const StateContextProvider = ({ children }: { children?: any }) => {
|
||||||
bannedTokens: state.bannedTokens ?? [],
|
bannedTokens: state.bannedTokens ?? [],
|
||||||
systemInstruction,
|
systemInstruction,
|
||||||
chatSystemInstruction,
|
chatSystemInstruction,
|
||||||
|
continuePrompt: state.continuePrompt || DEFAULT_STATE.continuePrompt,
|
||||||
userName: state.userName || 'User',
|
userName: state.userName || 'User',
|
||||||
userDescription: state.userDescription || '',
|
userDescription: state.userDescription || '',
|
||||||
effectiveSystemInstruction:
|
effectiveSystemInstruction:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue