Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat: add prompt rewrite & translate feat (#13523)

Zhijie Hec87962943933
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index 1ef99957ed9..4c8c8a487e5 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -362,6 +362,11 @@
"productHunt.actionLabel": "Support us",
"productHunt.description": "Support us on Product Hunt. Your support means a lot to us!",
"productHunt.title": "We're on Product Hunt!",
+ "promptTransform.action": "Refine Idea",
+ "promptTransform.actions.rewrite": "Expand Details",
+ "promptTransform.actions.translate": "Translate",
+ "promptTransform.status.rewrite": "Expanding details...",
+ "promptTransform.status.translate": "Translating...",
"regenerate": "Regenerate",
"releaseNotes": "Version Details",
"rename": "Rename",
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index d2af11ef04d..a7827cbc116 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -782,6 +782,9 @@
"systemAgent.inputCompletion.label": "Model",
"systemAgent.inputCompletion.modelDesc": "Model used for input auto-completion suggestions (like GitHub Copilot ghost text)",
"systemAgent.inputCompletion.title": "Input Auto-Completion Agent",
+ "systemAgent.promptRewrite.label": "Model",
+ "systemAgent.promptRewrite.modelDesc": "Specify the model used to rewrite prompts",
+ "systemAgent.promptRewrite.title": "Prompt Rewrite Agent",
"systemAgent.queryRewrite.label": "Model",
"systemAgent.queryRewrite.modelDesc": "Specify the model used to optimize user inquiries",
"systemAgent.queryRewrite.title": "Library query rewrite Agent",
diff --git a/locales/zh-CN/common.json b/locales/zh-CN/common.json
index 2250395eaa2..f81db9d5315 100644
--- a/locales/zh-CN/common.json
+++ b/locales/zh-CN/common.json
@@ -362,6 +362,11 @@
"productHunt.actionLabel": "支持我们",
"productHunt.description": "在 Product Hunt 上支持我们,您的支持对我们意义重大!",
"productHunt.title": "我们登上 Product Hunt 了!",
+ "promptTransform.action": "优化创意",
+ "promptTransform.actions.rewrite": "丰富细节",
+ "promptTransform.actions.translate": "翻译",
+ "promptTransform.status.rewrite": "正在丰富细节...",
+ "promptTransform.status.translate": "正在翻译...",
"regenerate": "重新生成",
"releaseNotes": "版本详情",
"rename": "重命名",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index 06a1c32e560..97479f11191 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -782,6 +782,9 @@
"systemAgent.inputCompletion.label": "模型",
"systemAgent.inputCompletion.modelDesc": "指定用于输入自动补全建议的模型(类似 GitHub Copilot 幽灵文本)",
"systemAgent.inputCompletion.title": "输入自动补全助理",
+ "systemAgent.promptRewrite.label": "模型",
+ "systemAgent.promptRewrite.modelDesc": "指定用于重写提示词的模型",
+ "systemAgent.promptRewrite.title": "提示词重写助理",
"systemAgent.queryRewrite.label": "模型",
"systemAgent.queryRewrite.modelDesc": "指定用于优化用户提问的模型",
"systemAgent.queryRewrite.title": "资源库提问重写助理",
diff --git a/packages/const/src/settings/systemAgent.ts b/packages/const/src/settings/systemAgent.ts
index 05f402b288d..3e5cb3fa2df 100644
--- a/packages/const/src/settings/systemAgent.ts
+++ b/packages/const/src/settings/systemAgent.ts
@@ -1,5 +1,6 @@
import { DEFAULT_MINI_PROVIDER, DEFAULT_PROVIDER } from '@lobechat/business-const';
import type {
+ PromptRewriteSystemAgent,
QueryRewriteSystemAgent,
SystemAgentItem,
UserSystemAgentConfig,
@@ -23,6 +24,12 @@ export const DEFAULT_QUERY_REWRITE_SYSTEM_AGENT_ITEM: QueryRewriteSystemAgent =
provider: DEFAULT_MINI_SYSTEM_AGENT_ITEM.provider,
};
+export const DEFAULT_PROMPT_REWRITE_SYSTEM_AGENT_ITEM: PromptRewriteSystemAgent = {
+ enabled: true,
+ model: DEFAULT_MINI_SYSTEM_AGENT_ITEM.model,
+ provider: DEFAULT_MINI_SYSTEM_AGENT_ITEM.provider,
+};
+
export const DEFAULT_INPUT_COMPLETION_SYSTEM_AGENT_ITEM: SystemAgentItem = {
enabled: false,
model: DEFAULT_MINI_SYSTEM_AGENT_ITEM.model,
@@ -34,6 +41,7 @@ export const DEFAULT_SYSTEM_AGENT_CONFIG: UserSystemAgentConfig = {
generationTopic: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
historyCompress: DEFAULT_SYSTEM_AGENT_ITEM,
inputCompletion: DEFAULT_INPUT_COMPLETION_SYSTEM_AGENT_ITEM,
+ promptRewrite: DEFAULT_PROMPT_REWRITE_SYSTEM_AGENT_ITEM,
queryRewrite: DEFAULT_QUERY_REWRITE_SYSTEM_AGENT_ITEM,
thread: DEFAULT_SYSTEM_AGENT_ITEM,
topic: DEFAULT_MINI_SYSTEM_AGENT_ITEM,
diff --git a/packages/prompts/src/chains/__tests__/rewriteGenerationPrompt.test.ts b/packages/prompts/src/chains/__tests__/rewriteGenerationPrompt.test.ts
new file mode 100644
index 00000000000..2e2fc87c063
--- /dev/null
+++ b/packages/prompts/src/chains/__tests__/rewriteGenerationPrompt.test.ts
@@ -0,0 +1,37 @@
+import { describe, expect, it } from 'vitest';
+
+import { chainRewriteGenerationPrompt } from '../rewriteGenerationPrompt';
+
+describe('chainRewriteGenerationPrompt', () => {
+ it('should build image rewrite payload with system and user messages', () => {
+ const prompt = '一只在雨夜街头奔跑的狐狸';
+
+ const result = chainRewriteGenerationPrompt({ mode: 'image', prompt });
+
+ expect(result.messages).toHaveLength(2);
+ expect(result.messages![0].role).toBe('system');
+ expect(result.messages![1].role).toBe('user');
+ expect(result.messages![0].content).toContain('expert image prompt engineer');
+ expect(result.messages![1].content).toBe(prompt);
+ });
+
+ it('should build video rewrite payload with video-specific system prompt', () => {
+ const prompt = 'A cat jumps over a fence';
+
+ const result = chainRewriteGenerationPrompt({ mode: 'video', prompt });
+
+ expect(result.messages![0].content).toContain('expert video prompt engineer');
+ expect(result.messages![0].content).toContain('Temporal progression');
+ expect(result.messages![1].content).toBe(prompt);
+ });
+
+ it('should build text rewrite payload with text-specific system prompt', () => {
+ const prompt = '帮我优化这个 JavaScript 函数';
+
+ const result = chainRewriteGenerationPrompt({ mode: 'text', prompt });
+
+ expect(result.messages![0].content).toContain('expert prompt optimizer');
+ expect(result.messages![0].content).toContain('Do NOT add new requirements');
+ expect(result.messages![1].content).toBe(prompt);
+ });
+});
diff --git a/packages/prompts/src/chains/index.ts b/packages/prompts/src/chains/index.ts
index 8efe8751161..78ea7c3ad8b 100644
--- a/packages/prompts/src/chains/index.ts
+++ b/packages/prompts/src/chains/index.ts
@@ -4,6 +4,7 @@ export * from './compressContext';
export * from './inputCompletion';
export * from './langDetect';
export * from './pickEmoji';
+export * from './rewriteGenerationPrompt';
export * from './rewriteQuery';
export * from './summaryAgentName';
export * from './summaryDescription';
diff --git a/packages/prompts/src/chains/rewriteGenerationPrompt.ts b/packages/prompts/src/chains/rewriteGenerationPrompt.ts
new file mode 100644
index 00000000000..2739d14e81b
--- /dev/null
+++ b/packages/prompts/src/chains/rewriteGenerationPrompt.ts
@@ -0,0 +1,98 @@
+import type { ChatStreamPayload } from '@lobechat/types';
+
+interface RewriteGenerationPromptParams {
+ mode: 'image' | 'video' | 'text';
+ prompt: string;
+}
+
+const IMAGE_REWRITE_SYSTEM_PROMPT = () => `You are an expert image prompt engineer.
+
+Rewrite the user prompt into a production-ready image-generation prompt that is also easy for beginners to use.
+
+Use a concise, natural description that is ready for image generation. When the input is short or vague, infer reasonable visual details and complete the scene.
+
+Include these dimensions when relevant:
+1) Main subject and scene
+2) Visual style, medium, and overall quality
+3) Composition and viewpoint
+4) Lighting, atmosphere, and color mood
+5) Technical details such as lens or depth of field when helpful
+
+Rules:
+- Keep important entities, quantities, and constraints unchanged.
+- Add concrete visual details that make the image easier to generate.
+- Prefer clear, practical wording over jargon or overly complex wording.
+- Avoid verbosity, contradictions, and impossible details.
+- Preserve the original input language.
+- Output ONLY the final rewritten prompt.`;
+
+const VIDEO_REWRITE_SYSTEM_PROMPT = () => `You are an expert video prompt engineer.
+
+Rewrite the user prompt into a production-ready video-generation prompt that is also easy for beginners to use.
+
+Use a concise, natural description that is ready for video generation. When the input is short or vague, infer a simple continuous action, a stable camera plan, and a clear time progression.
+
+Include these dimensions when relevant:
+1) Subject, scene, and action
+2) Shot framing and camera movement (pan, tilt, dolly, handheld, static)
+3) Temporal progression (start -> middle -> end)
+4) Lighting, mood, and color style
+5) Motion characteristics (speed, rhythm, realism) and quality constraints
+
+Rules:
+- Keep important entities, quantities, and constraints unchanged.
+- Prioritize temporal clarity, camera language, and a single easy-to-follow action.
+- Add practical motion details that make the video easier to generate.
+- Avoid impossible or contradictory motion and physics descriptions.
+- Preserve the original input language.
+- Output ONLY the final rewritten prompt.`;
+
+const TEXT_REWRITE_SYSTEM_PROMPT = () => `You are an expert prompt optimizer.
+
+Rewrite the user prompt into a production-ready text prompt that is also easy for beginners to use.
+
+Use a concise, natural request that is ready for direct model input. When the input is short or vague, preserve the original intent and make only the minimum necessary expansion.
+
+Rules:
+- Do NOT add new requirements, expand the scope, or change the task meaning.
+- Do NOT generate role prompts, system prompts, persona instructions, or meta commentary.
+- Do NOT convert the request into instructions for the assistant to "be" something.
+- Keep the prompt concise and practical for direct model input.
+- If the user input is already clear, make only minimal improvements.
+- Preserve entity names, numbers, formatting requirements, and visible text exactly.
+- Preserve the original input language.
+- Output ONLY the final optimized user prompt.
+`;
+
+const getSystemPromptByMode = (mode: RewriteGenerationPromptParams['mode']) => {
+ switch (mode) {
+ case 'image': {
+ return IMAGE_REWRITE_SYSTEM_PROMPT();
+ }
+ case 'video': {
+ return VIDEO_REWRITE_SYSTEM_PROMPT();
+ }
+ case 'text': {
+ return TEXT_REWRITE_SYSTEM_PROMPT();
+ }
+ default: {
+ return TEXT_REWRITE_SYSTEM_PROMPT();
+ }
+ }
+};
+
+export const chainRewriteGenerationPrompt = ({
+ mode,
+ prompt,
+}: RewriteGenerationPromptParams): Partial<ChatStreamPayload> => ({
+ messages: [
+ {
+ content: getSystemPromptByMode(mode),
+ role: 'system',
+ },
+ {
+ content: prompt,
+ role: 'user',
+ },
+ ],
+});
diff --git a/packages/types/src/user/settings/systemAgent.ts b/packages/types/src/user/settings/systemAgent.ts
index b95bbe47888..174069b9eff 100644
--- a/packages/types/src/user/settings/systemAgent.ts
+++ b/packages/types/src/user/settings/systemAgent.ts
@@ -9,11 +9,16 @@ export interface QueryRewriteSystemAgent extends Omit<SystemAgentItem, 'enabled'
enabled: boolean;
}
+export interface PromptRewriteSystemAgent extends Omit<SystemAgentItem, 'enabled'> {
+ enabled: boolean;
+}
+
export interface UserSystemAgentConfig {
agentMeta: SystemAgentItem;
generationTopic: SystemAgentItem;
historyCompress: SystemAgentItem;
inputCompletion: SystemAgentItem;
+ promptRewrite: PromptRewriteSystemAgent;
queryRewrite: QueryRewriteSystemAgent;
thread: SystemAgentItem;
topic: SystemAgentItem;
diff --git a/src/features/ChatInput/ActionBar/PromptTransform/index.tsx b/src/features/ChatInput/ActionBar/PromptTransform/index.tsx
new file mode 100644
index 00000000000..95dae016d5d
--- /dev/null
+++ b/src/features/ChatInput/ActionBar/PromptTransform/index.tsx
@@ -0,0 +1,27 @@
+'use client';
+
+import { memo, useCallback } from 'react';
+
+import PromptTransformAction from '@/features/PromptTransform/PromptTransformAction';
+
+import { useChatInputStore } from '../../store';
+
+const PromptTransform = memo(() => {
+ const [editor, markdownContent] = useChatInputStore((s) => [s.editor, s.markdownContent]);
+
+ const onPromptChange = useCallback(
+ (prompt: string) => {
+ if (!editor) return;
+ editor.setDocument('markdown', prompt);
+ },
+ [editor],
+ );
+
+ return (
+ <PromptTransformAction mode={'text'} prompt={markdownContent} onPromptChange={onPromptChange} />
+ );
+});
+
+PromptTransform.displayName = 'PromptTransform';
+
+export default PromptTransform;
diff --git a/src/features/ChatInput/ActionBar/components/Action.tsx b/src/features/ChatInput/ActionBar/components/Action.tsx
index 8a515d28e55..25e786ad351 100644
--- a/src/features/ChatInput/ActionBar/components/Action.tsx
+++ b/src/features/ChatInput/ActionBar/components/Action.tsx
@@ -56,6 +56,7 @@ const Action = memo<ActionProps>(
placement: 'bottom',
}}
onClick={(e) => {
+ if (disabled || loading) return;
if (onClick) return onClick(e);
setShow(true);
}}
@@ -69,7 +70,7 @@ const Action = memo<ActionProps>(
/>
);
- if (disabled) return iconNode;
+ if (disabled || loading) return iconNode;
if (dropdown)
return (
diff --git a/src/features/ChatInput/ActionBar/config.ts b/src/features/ChatInput/ActionBar/config.ts
index 71ad5ae18b4..17cd095da3f 100644
--- a/src/features/ChatInput/ActionBar/config.ts
+++ b/src/features/ChatInput/ActionBar/config.ts
@@ -5,6 +5,7 @@ import Memory from './Memory';
import Mention from './Mention';
import Model from './Model';
import Params from './Params';
+import PromptTransform from './PromptTransform';
import SaveTopic from './SaveTopic';
import Search from './Search';
import STT from './STT';
@@ -24,6 +25,7 @@ export const actionMap = {
model: Model,
params: Params,
portalToken: PortalToken,
+ promptTransform: PromptTransform,
saveTopic: SaveTopic,
search: Search,
stt: STT,
diff --git a/src/features/Conversation/ChatInput/index.tsx b/src/features/Conversation/ChatInput/index.tsx
index fc71ea75fa7..508278952a3 100644
--- a/src/features/Conversation/ChatInput/index.tsx
+++ b/src/features/Conversation/ChatInput/index.tsx
@@ -119,7 +119,7 @@ const ChatInput = memo<ChatInputProps>(
allowExpand,
leftActions = [],
leftContent,
- rightActions = [],
+ rightActions = ['promptTransform'],
children,
extraActionItems,
mentionItems,
diff --git a/src/features/PromptTransform/PromptTransformAction.tsx b/src/features/PromptTransform/PromptTransformAction.tsx
new file mode 100644
index 00000000000..2b309a8c5f9
--- /dev/null
+++ b/src/features/PromptTransform/PromptTransformAction.tsx
@@ -0,0 +1,92 @@
+'use client';
+
+import { Languages, Lightbulb, Sparkles } from 'lucide-react';
+import { memo, useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import Action from '@/features/ChatInput/ActionBar/components/Action';
+
+import { usePromptTransform } from './usePromptTransform';
+
+interface PromptTransformActionProps {
+ mode: 'image' | 'video' | 'text';
+ onPromptChange: (prompt: string) => void;
+ prompt?: string | null;
+}
+
+const PromptTransformAction = memo<PromptTransformActionProps>(
+ ({ mode, onPromptChange, prompt }) => {
+ const { t } = useTranslation('common');
+
+ const {
+ isTransformDisabled,
+ isTransforming,
+ transformAction,
+ isRewriteEnabled,
+ rewritePrompt,
+ translatePrompt,
+ } = usePromptTransform({
+ mode,
+ onPromptChange,
+ prompt,
+ });
+
+ const menuItems = useMemo(
+ () => [
+ {
+ icon: <Sparkles size={16} />,
+ key: 'rewrite',
+ label: t('promptTransform.actions.rewrite'),
+ onClick: rewritePrompt,
+ },
+ {
+ icon: <Languages size={16} />,
+ key: 'translate',
+ label: t('promptTransform.actions.translate'),
+ onClick: translatePrompt,
+ },
+ ],
+ [rewritePrompt, t, translatePrompt],
+ );
+
+ const handlePrimaryAction = useMemo(
+ () => (isRewriteEnabled ? rewritePrompt : translatePrompt),
+ [isRewriteEnabled, rewritePrompt, translatePrompt],
+ );
+
+ const dropdown = useMemo(() => {
+ if (!isRewriteEnabled) return undefined;
+
+ return {
+ menu: { items: menuItems },
+ trigger: 'hover' as const,
+ };
+ }, [isRewriteEnabled, menuItems]);
+
+ const primaryIcon = isRewriteEnabled ? Lightbulb : Languages;
+ const isActionDisabled = isTransformDisabled || isTransforming;
+
+ return (
+ <Action
+ disabled={isActionDisabled}
+ dropdown={dropdown}
+ icon={primaryIcon}
+ loading={isTransforming}
+ title={
+ isTransforming
+ ? t(
+ transformAction === 'translate'
+ ? 'promptTransform.status.translate'
+ : 'promptTransform.status.rewrite',
+ )
+ : t(isRewriteEnabled ? 'promptTransform.action' : 'promptTransform.actions.translate')
+ }
+ onClick={handlePrimaryAction}
+ />
+ );
+ },
+);
+
+PromptTransformAction.displayName = 'PromptTransformAction';
+
+export default PromptTransformAction;
diff --git a/src/features/PromptTransform/usePromptTransform.ts b/src/features/PromptTransform/usePromptTransform.ts
new file mode 100644
index 00000000000..52b0acedee9
--- /dev/null
+++ b/src/features/PromptTransform/usePromptTransform.ts
@@ -0,0 +1,86 @@
+import { chainRewriteGenerationPrompt, chainTranslate } from '@lobechat/prompts';
+import { useCallback, useState } from 'react';
+
+import { chatService } from '@/services/chat';
+import { useUserStore } from '@/store/user';
+import { systemAgentSelectors } from '@/store/user/selectors';
+import { merge } from '@/utils/merge';
+
+interface UsePromptTransformParams {
+ mode: 'image' | 'video' | 'text';
+ onPromptChange: (prompt: string) => void;
+ prompt?: string | null;
+}
+
+type PromptTransformAction = 'rewrite' | 'translate';
+
+export const usePromptTransform = ({ mode, prompt, onPromptChange }: UsePromptTransformParams) => {
+ const [isTransforming, setIsTransforming] = useState(false);
+ const [transformAction, setTransformAction] = useState<PromptTransformAction>('rewrite');
+
+ const rewriteConfig = useUserStore(systemAgentSelectors.promptRewrite);
+ const translateConfig = useUserStore(systemAgentSelectors.translation);
+ const isRewriteActionEnabled = rewriteConfig?.enabled ?? false;
+
+ const getConfigByAction = useCallback(
+ (action: PromptTransformAction) =>
+ action === 'rewrite' ? (rewriteConfig ?? {}) : (translateConfig ?? {}),
+ [rewriteConfig, translateConfig],
+ );
+
+ const runTransform = useCallback(
+ async (action: PromptTransformAction) => {
+ if (isTransforming || !prompt?.trim()) return;
+ if (action === 'rewrite' && !isRewriteActionEnabled) return;
+
+ let transformedPrompt = '';
+ setTransformAction(action);
+
+ try {
+ await chatService.fetchPresetTaskResult({
+ onError: () => {
+ setIsTransforming(false);
+ },
+ onFinish: async (text) => {
+ const nextPrompt = text.trim() || transformedPrompt.trim();
+ if (nextPrompt) onPromptChange(nextPrompt);
+ },
+ onLoadingChange: setIsTransforming,
+ onMessageHandle: (chunk) => {
+ if (chunk.type === 'text') transformedPrompt += chunk.text;
+ },
+ params: merge(
+ getConfigByAction(action),
+ action === 'rewrite'
+ ? chainRewriteGenerationPrompt({
+ mode,
+ prompt,
+ })
+ : chainTranslate(prompt, 'English'),
+ ),
+ });
+ } finally {
+ setIsTransforming(false);
+ setTransformAction('rewrite');
+ }
+ },
+ [getConfigByAction, isRewriteActionEnabled, isTransforming, mode, onPromptChange, prompt],
+ );
+
+ const rewritePrompt = useCallback(async () => {
+ await runTransform('rewrite');
+ }, [runTransform]);
+
+ const translatePrompt = useCallback(async () => {
+ await runTransform('translate');
+ }, [runTransform]);
+
+ return {
+ isRewriteEnabled: isRewriteActionEnabled,
+ isTransformDisabled: !prompt?.trim(),
+ isTransforming,
+ rewritePrompt,
+ transformAction,
+ translatePrompt,
+ };
+};
diff --git a/src/locales/default/common.ts b/src/locales/default/common.ts
index 1797f37c2f7..12f1c00bd54 100644
--- a/src/locales/default/common.ts
+++ b/src/locales/default/common.ts
@@ -279,6 +279,11 @@ export default {
'copy': 'Copy',
'copyFail': 'Copy failed',
'copySuccess': 'Copied',
+ 'promptTransform.action': 'Refine Idea',
+ 'promptTransform.actions.rewrite': 'Expand Details',
+ 'promptTransform.actions.translate': 'Translate',
+ 'promptTransform.status.rewrite': 'Expanding details...',
+ 'promptTransform.status.translate': 'Translating...',
'dataStatistics.messages': 'Messages',
'dataStatistics.sessions': 'Agents',
'dataStatistics.today': "Today's New",
diff --git a/src/locales/default/setting.ts b/src/locales/default/setting.ts
index 7e6d90858a2..0e8c87465df 100644
--- a/src/locales/default/setting.ts
+++ b/src/locales/default/setting.ts
@@ -901,6 +901,9 @@ When I am ___, I need ___
'systemAgent.inputCompletion.modelDesc':
'Model used for input auto-completion suggestions (like GitHub Copilot ghost text)',
'systemAgent.inputCompletion.title': 'Input Auto-Completion Agent',
+ 'systemAgent.promptRewrite.label': 'Model',
+ 'systemAgent.promptRewrite.modelDesc': 'Specify the model used to rewrite prompts',
+ 'systemAgent.promptRewrite.title': 'Prompt Rewrite Agent',
'systemAgent.queryRewrite.label': 'Model',
'systemAgent.queryRewrite.modelDesc': 'Specify the model used to optimize user inquiries',
'systemAgent.queryRewrite.title': 'Library query rewrite Agent',
diff --git a/src/routes/(main)/(create)/image/features/PromptInput/index.tsx b/src/routes/(main)/(create)/image/features/PromptInput/index.tsx
index 5b585f07768..31ddb910722 100644
--- a/src/routes/(main)/(create)/image/features/PromptInput/index.tsx
+++ b/src/routes/(main)/(create)/image/features/PromptInput/index.tsx
@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';
import { loginRequired } from '@/components/Error/loginRequiredNotification';
import Action from '@/features/ChatInput/ActionBar/components/Action';
import ModelSwitchPanel from '@/features/ModelSwitchPanel';
+import PromptTransformAction from '@/features/PromptTransform/PromptTransformAction';
import { useFetchAiImageConfig } from '@/hooks/useFetchAiImageConfig';
import { useIsDark } from '@/hooks/useIsDark';
import { useQueryState } from '@/hooks/useQueryParam';
@@ -348,6 +349,9 @@ const PromptInput = ({ showTitle = false }: PromptInputProps) => {
placeholder={
hasRefImages ? t('config.prompt.placeholderWithRef') : t('config.prompt.placeholder')
}
+ rightActions={
+ <PromptTransformAction mode={'image'} prompt={value} onPromptChange={setValue as any} />
+ }
onGenerate={handleGenerate}
onValueChange={setValue}
/>
diff --git a/src/routes/(main)/(create)/video/features/PromptInput/index.tsx b/src/routes/(main)/(create)/video/features/PromptInput/index.tsx
index 69b40c402a9..bc7659c45db 100644
--- a/src/routes/(main)/(create)/video/features/PromptInput/index.tsx
+++ b/src/routes/(main)/(create)/video/features/PromptInput/index.tsx
@@ -11,6 +11,7 @@ import VideoFreeQuotaInfo from '@/business/client/features/VideoFreeQuotaInfo';
import { loginRequired } from '@/components/Error/loginRequiredNotification';
import Action from '@/features/ChatInput/ActionBar/components/Action';
import ModelSwitchPanel from '@/features/ModelSwitchPanel';
+import PromptTransformAction from '@/features/PromptTransform/PromptTransformAction';
import { useFetchAiVideoConfig } from '@/hooks/useFetchAiVideoConfig';
import { useIsDark } from '@/hooks/useIsDark';
import { useQueryState } from '@/hooks/useQueryParam';
@@ -477,6 +478,9 @@ const PromptInput = ({ showTitle = false }: PromptInputProps) => {
placeholder={
hasRefImages ? t('config.prompt.placeholderWithRef') : t('config.prompt.placeholder')
}
+ rightActions={
+ <PromptTransformAction mode={'video'} prompt={value} onPromptChange={setValue as any} />
+ }
onGenerate={handleGenerate}
onValueChange={setValue}
/>
diff --git a/src/routes/(main)/agent/features/Conversation/MainChatInput/index.tsx b/src/routes/(main)/agent/features/Conversation/MainChatInput/index.tsx
index accae74a5bb..2cf149a7bc5 100644
--- a/src/routes/(main)/agent/features/Conversation/MainChatInput/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/MainChatInput/index.tsx
@@ -10,7 +10,7 @@ import { userGeneralSettingsSelectors } from '@/store/user/selectors';
import { useSendMenuItems } from './useSendMenuItems';
-const rightActions: ActionKeys[] = [];
+const rightActions: ActionKeys[] = ['promptTransform'];
/**
* MainChatInput
diff --git a/src/routes/(main)/settings/agent/index.tsx b/src/routes/(main)/settings/agent/index.tsx
index b03151d727c..7954a8c252c 100644
--- a/src/routes/(main)/settings/agent/index.tsx
+++ b/src/routes/(main)/settings/agent/index.tsx
@@ -20,6 +20,7 @@ const Page = () => {
<SystemAgentForm systemAgentKey="historyCompress" />
<SystemAgentForm systemAgentKey="agentMeta" />
<SystemAgentForm allowDisable systemAgentKey="inputCompletion" />
+ <SystemAgentForm allowDisable systemAgentKey="promptRewrite" />
{enableKnowledgeBase && (
<SystemAgentForm
allowCustomPrompt
diff --git a/src/routes/(main)/settings/service-model/index.tsx b/src/routes/(main)/settings/service-model/index.tsx
index ef4e73620a2..4940843bd25 100644
--- a/src/routes/(main)/settings/service-model/index.tsx
+++ b/src/routes/(main)/settings/service-model/index.tsx
@@ -24,6 +24,7 @@ const Page = () => {
<SystemAgentForm systemAgentKey="historyCompress" />
<SystemAgentForm systemAgentKey="agentMeta" />
<SystemAgentForm allowDisable systemAgentKey="inputCompletion" />
+ <SystemAgentForm allowDisable systemAgentKey="promptRewrite" />
{enableKnowledgeBase && (
<SystemAgentForm
allowCustomPrompt
diff --git a/src/server/globalConfig/parseSystemAgent.ts b/src/server/globalConfig/parseSystemAgent.ts
index ea0d9e3bfb5..33d903f04c3 100644
--- a/src/server/globalConfig/parseSystemAgent.ts
+++ b/src/server/globalConfig/parseSystemAgent.ts
@@ -3,7 +3,7 @@ import { type UserSystemAgentConfig } from '@/types/user/settings';
const protectedKeys = Object.keys(DEFAULT_SYSTEM_AGENT_CONFIG);
-const defaultTrueLey = new Set(['queryRewrite', 'autoSuggestion']);
+const defaultTrueLey = new Set(['queryRewrite', 'promptRewrite', 'autoSuggestion']);
export const parseSystemAgent = (envString: string = ''): Partial<UserSystemAgentConfig> => {
if (!envString) return {};
diff --git a/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap b/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap
index 3941f5ae6a4..b2036757896 100644
--- a/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap
+++ b/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap
@@ -68,6 +68,11 @@ exports[`settingsSelectors > currentSystemAgent > should merge DEFAULT_SYSTEM_AG
"model": "gpt-5.4-mini",
"provider": "openai",
},
+ "promptRewrite": {
+ "enabled": true,
+ "model": "gpt-5.4-mini",
+ "provider": "openai",
+ },
"queryRewrite": {
"enabled": true,
"model": "gpt-5.4-mini",
diff --git a/src/store/user/slices/settings/selectors/systemAgent.ts b/src/store/user/slices/settings/selectors/systemAgent.ts
index 2ae8943c4ed..52948031769 100644
--- a/src/store/user/slices/settings/selectors/systemAgent.ts
+++ b/src/store/user/slices/settings/selectors/systemAgent.ts
@@ -12,6 +12,7 @@ const topic = (s: UserStore) => currentSystemAgent(s).topic;
const thread = (s: UserStore) => currentSystemAgent(s).thread;
const agentMeta = (s: UserStore) => currentSystemAgent(s).agentMeta;
const queryRewrite = (s: UserStore) => currentSystemAgent(s).queryRewrite;
+const promptRewrite = (s: UserStore) => currentSystemAgent(s).promptRewrite;
const historyCompress = (s: UserStore) => currentSystemAgent(s).historyCompress;
const generationTopic = (s: UserStore) => currentSystemAgent(s).generationTopic;
const inputCompletion = (s: UserStore) => currentSystemAgent(s).inputCompletion;
@@ -21,6 +22,7 @@ export const systemAgentSelectors = {
generationTopic,
historyCompress,
inputCompletion,
+ promptRewrite,
queryRewrite,
thread,
topic,