From b879f3a99e35ad1451a94b5e2ccaed6d2c47cc42 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 24 Sep 2025 18:57:07 +0800 Subject: [PATCH] perf: prompt --- .../generate-related-dialog/index.vue | 11 ++- ui/src/locales/lang/en-US/common.ts | 4 ++ .../lang/en-US/views/application-workflow.ts | 18 +++-- .../locales/lang/en-US/views/application.ts | 13 ++-- ui/src/locales/lang/zh-CN/common.ts | 4 ++ .../lang/zh-CN/views/application-workflow.ts | 18 +++-- .../locales/lang/zh-CN/views/application.ts | 15 ++-- ui/src/locales/lang/zh-Hant/common.ts | 4 ++ .../zh-Hant/views/application-workflow.ts | 18 +++-- .../locales/lang/zh-Hant/views/application.ts | 13 ++-- .../views/application/ApplicationSetting.vue | 70 ++++++++++++------- .../component/CreateApplicationDialog.vue | 4 +- .../component/ParamSettingDialog.vue | 4 +- ui/src/workflow/nodes/ai-chat-node/index.vue | 35 ++++++---- .../workflow/nodes/image-generate/index.vue | 4 +- .../workflow/nodes/image-to-video/index.vue | 4 +- .../workflow/nodes/image-understand/index.vue | 19 ++++- ui/src/workflow/nodes/question-node/index.vue | 27 +++++-- ui/src/workflow/nodes/text-to-video/index.vue | 4 +- 19 files changed, 197 insertions(+), 92 deletions(-) diff --git a/ui/src/components/generate-related-dialog/index.vue b/ui/src/components/generate-related-dialog/index.vue index b22d38f89..3b5d0b962 100644 --- a/ui/src/components/generate-related-dialog/index.vue +++ b/ui/src/components/generate-related-dialog/index.vue @@ -57,20 +57,17 @@ @change="modelChange" > - + @@ -150,7 +147,7 @@ const rules = reactive({ prompt: [ { required: true, - message: t('views.application.form.prompt.placeholder'), + message: t('common.prompt.placeholder'), trigger: 'blur', }, ], diff --git a/ui/src/locales/lang/en-US/common.ts b/ui/src/locales/lang/en-US/common.ts index b36a4d71c..50876e5a3 100644 --- a/ui/src/locales/lang/en-US/common.ts +++ b/ui/src/locales/lang/en-US/common.ts @@ -110,4 +110,8 @@ export default { copyTitle: 'Copy', professional: 'Purchase the Professional Edition', sync: 'Sync', + prompt: { + label: 'Prompt', + placeholder: 'Please enter prompt', + }, } diff --git a/ui/src/locales/lang/en-US/views/application-workflow.ts b/ui/src/locales/lang/en-US/views/application-workflow.ts index 2e871629d..4288f0802 100644 --- a/ui/src/locales/lang/en-US/views/application-workflow.ts +++ b/ui/src/locales/lang/en-US/views/application-workflow.ts @@ -142,9 +142,18 @@ export default { label: 'Question Optimization', text: 'Optimize and improve the current question based on historical chat records to better match knowledge segments', result: 'Optimized Question Result', - defaultPrompt1: `Optimize and improve the user's question based on context:`, - defaultPrompt2: `Please output an optimized question.`, - systemDefault: 'You are a question optimization expert', + systemDefault: `#Role +You are a master of problem optimization, adept at accurately inferring user intentions based on context and optimizing the questions raised by users. + +##Skills +###Skill 1: Optimizing Problems +2. Receive user input questions. +3. Carefully analyze the meaning of the problem based on the context. +4. Output optimized problems. + +##Limitations: +-Only return the optimized problem without any additional explanation or clarification. +-Ensure that the optimized problem accurately reflects the original problem intent and does not alter the original intention.`, }, conditionNode: { label: 'Conditional Branch', @@ -403,5 +412,6 @@ export default { len_le: 'Length less than or equal to', len_lt: 'Length less than', }, - FileUploadSetting: {}, + SystemPromptPlaceholder: 'System Prompt, can reference variables in the system, such as', + UserPromptPlaceholder: 'User Prompt, can reference variables in the system, such as', } diff --git a/ui/src/locales/lang/en-US/views/application.ts b/ui/src/locales/lang/en-US/views/application.ts index 29615b933..3b8d06277 100644 --- a/ui/src/locales/lang/en-US/views/application.ts +++ b/ui/src/locales/lang/en-US/views/application.ts @@ -67,17 +67,20 @@ export default { }, roleSettings: { label: 'System Prompt', - placeholder: 'You are xxx assistant', + placeholder: + 'System prompt, you can reference variables in the system: {data} is the segment hit in the knowledge base; {question} is the question asked by the user.', + tooltip: 'Set the role or instructions for the model to follow', }, prompt: { - label: 'Prompt', + label: 'User Prompt', noReferences: '(No references Knowledge)', references: ' (References Knowledge)', - placeholder: 'Please enter prompt', - requiredMessage: 'Please enter prompt', + placeholder: + 'User prompt, you can reference variables in the system: {data} is the segment hit in the knowledge base; {question} is the question asked by the user', + requiredMessage: 'Please enter User prompt', tooltip: - 'By adjusting the content of the prompt, you can guide the direction of the large model chat.', + 'The question or command that the user poses to the model', noReferencesTooltip: 'By adjusting the content of the prompt, you can guide the direction of the large model chat. This prompt will be fixed at the beginning of the context. Variables used: {question} is the question posed by the user.', diff --git a/ui/src/locales/lang/zh-CN/common.ts b/ui/src/locales/lang/zh-CN/common.ts index d4aed6690..065a91ea2 100644 --- a/ui/src/locales/lang/zh-CN/common.ts +++ b/ui/src/locales/lang/zh-CN/common.ts @@ -113,4 +113,8 @@ export default { copyTitle: '副本', professional: '购买专业版', sync: '同步', + prompt: { + label: '提示词', + placeholder: '请输入提示词', + }, } diff --git a/ui/src/locales/lang/zh-CN/views/application-workflow.ts b/ui/src/locales/lang/zh-CN/views/application-workflow.ts index fd6765ae8..6c5bcb0da 100644 --- a/ui/src/locales/lang/zh-CN/views/application-workflow.ts +++ b/ui/src/locales/lang/zh-CN/views/application-workflow.ts @@ -150,9 +150,18 @@ export default { label: '问题优化', text: '根据历史聊天记录优化完善当前问题,更利于匹配知识库分段', result: '问题优化结果', - defaultPrompt1: `根据上下文优化和完善用户问题`, - defaultPrompt2: `请输出一个优化后的问题。`, - systemDefault: '你是一个问题优化大师', + systemDefault: `# 角色 +你是一位问题优化大师,擅长根据上下文精准揣测用户意图,并对用户提出的问题进行优化。 + +## 技能 +### 技能 1: 优化问题 +2. 接收用户输入的问题。 +3. 依据上下文仔细分析问题含义。 +4. 输出优化后的问题。 + +## 限制: +- 仅返回优化后的问题,不进行额外解释或说明。 +- 确保优化后的问题准确反映原始问题意图,不得改变原意。`, }, conditionNode: { label: '判断器', @@ -405,5 +414,6 @@ export default { is_true: '为真', is_not_true: '不为真', }, - FileUploadSetting: {}, + SystemPromptPlaceholder: '系统提示词,可以引用系统中的变量:如', + UserPromptPlaceholder: '用户提示词,可以引用系统中的变量:如', } diff --git a/ui/src/locales/lang/zh-CN/views/application.ts b/ui/src/locales/lang/zh-CN/views/application.ts index 4e692921e..80d5d5fdc 100644 --- a/ui/src/locales/lang/zh-CN/views/application.ts +++ b/ui/src/locales/lang/zh-CN/views/application.ts @@ -1,3 +1,5 @@ +import tool from '@/api/tool/tool' + export default { title: '应用', createApplication: '创建简易应用', @@ -63,17 +65,20 @@ export default { }, roleSettings: { label: '系统提示词', - placeholder: '你是 xxx 小助手', + placeholder: + '系统提示词,可以引用系统中的变量:{data} 是命中知识库中的分段;{question} 是用户提出的问题。', + tooltip: '设定模型扮演的角色或遵循的指令', }, prompt: { - label: '提示词', + label: '用户提示词', noReferences: ' (无引用知识库)', references: ' (引用知识库)', - placeholder: '请输入提示词', - requiredMessage: '请输入提示词', + placeholder: + '用户提示词,可以引用系统中的变量:{data} 是命中知识库中的分段;{question} 是用户提出的问题。', + requiredMessage: '请输入用户提示词', tooltip: - '通过调整提示词内容,可以引导大模型聊天方向,该提示词会被固定在上下文的开头,可以使用变量。', + '用户向模型提出的问题或输入的指令', noReferencesTooltip: '通过调整提示词内容,可以引导大模型聊天方向,该提示词会被固定在上下文的开头。可以使用变量:{question} 是用户提出问题的占位符。', referencesTooltip: diff --git a/ui/src/locales/lang/zh-Hant/common.ts b/ui/src/locales/lang/zh-Hant/common.ts index 1352ebc19..01e866b9a 100644 --- a/ui/src/locales/lang/zh-Hant/common.ts +++ b/ui/src/locales/lang/zh-Hant/common.ts @@ -109,4 +109,8 @@ export default { copyTitle: '副本', professional: '購買專業版', sync: '同步', + prompt: { + label: '提示詞', + placeholder: '請輸入提示詞', + }, } diff --git a/ui/src/locales/lang/zh-Hant/views/application-workflow.ts b/ui/src/locales/lang/zh-Hant/views/application-workflow.ts index 1486a7f8c..632369cad 100644 --- a/ui/src/locales/lang/zh-Hant/views/application-workflow.ts +++ b/ui/src/locales/lang/zh-Hant/views/application-workflow.ts @@ -143,9 +143,18 @@ export default { label: '問題優化', text: '根據歷史聊天記錄優化完善當前問題,更利於匹配知識庫分段', result: '問題優化結果', - defaultPrompt1: `根據上下文優化和完善用戶問題:`, - defaultPrompt2: `請輸出一個優化後的問題。`, - systemDefault: '你是一個問題優化大師', + systemDefault: `# 角色 +妳是壹位問題優化大師,擅長根據上下文精準揣測用戶意圖,並對用戶提出的問題進行優化。 + +## 技能 +### 技能 1: 優化問題 +2. 接收用戶輸入的問題。 +3. 依據上下文仔細分析問題含義。 +4. 輸出優化後的問題。 + +## 限制: +- 僅返回優化後的問題,不進行額外解釋或說明。 +- 確保優化後的問題準確反映原始問題意圖,不得改變原意。`, }, conditionNode: { label: '判斷器', @@ -389,5 +398,6 @@ export default { len_le: '長度小於等於', len_lt: '長度小於', }, - FileUploadSetting: {}, + SystemPromptPlaceholder: '系統提示詞,可以引用系統中的變量:如', + UserPromptPlaceholder: '用戶提示詞,可以引用系統中的變量:如', } diff --git a/ui/src/locales/lang/zh-Hant/views/application.ts b/ui/src/locales/lang/zh-Hant/views/application.ts index 220500868..28b95eb6e 100644 --- a/ui/src/locales/lang/zh-Hant/views/application.ts +++ b/ui/src/locales/lang/zh-Hant/views/application.ts @@ -63,15 +63,18 @@ export default { }, roleSettings: { label: '系統提示詞', - placeholder: '你是 xxx 小助手', + placeholder: + '系統提示詞,可以引用系統中的變數:{data} 是命中知識庫中的分段;{question} 是用戶提出的問題。', + tooltip: '設定模型扮演的角色或遵循的指令', }, prompt: { - label: '提示詞', + label: '用戶提示詞', noReferences: ' (無引用知識庫)', references: ' (引用知識庫)', - placeholder: '請輸入提示詞', - requiredMessage: '請輸入提示詞', - tooltip: '透過調整提示詞內容,可以引導大模型對話方向,該提示詞會被固定在上下文的開頭。', + placeholder: + '用戶提示詞,可以引用系統中的變數:{data} 是命中知識庫中的分段;{question} 是用戶提出的問題。', + requiredMessage: '請輸入用戶提示詞', + tooltip: '用戶向模型提出的問題或輸入的指令', noReferencesTooltip: '透過調整提示詞內容,可以引導大模型對話方向,該提示詞會被固定在上下文的開頭。可以使用變數:{question} 是用戶提出問題的佔位符。', diff --git a/ui/src/views/application/ApplicationSetting.vue b/ui/src/views/application/ApplicationSetting.vue index e4f623632..1907fdc89 100644 --- a/ui/src/views/application/ApplicationSetting.vue +++ b/ui/src/views/application/ApplicationSetting.vue @@ -102,7 +102,17 @@ - +
@@ -698,7 +717,7 @@ const applicationForm = ref({ }, model_setting: { prompt: defaultPrompt, - system: t('views.application.form.roleSettings.placeholder'), + system: '', no_references_prompt: '{question}', reasoning_content_enable: false, }, @@ -834,7 +853,6 @@ const openSTTParamSettingDialog = () => { } } - const openParamSettingDialog = () => { ParamSettingDialogRef.value?.open(applicationForm.value) } @@ -847,7 +865,9 @@ function removeTool(id: any) { function removeMcpTool(id: any) { if (applicationForm.value.mcp_tool_ids) { - applicationForm.value.mcp_tool_ids = applicationForm.value.mcp_tool_ids.filter((v: any) => v !== id) + applicationForm.value.mcp_tool_ids = applicationForm.value.mcp_tool_ids.filter( + (v: any) => v !== id, + ) } } diff --git a/ui/src/views/application/component/CreateApplicationDialog.vue b/ui/src/views/application/component/CreateApplicationDialog.vue index f373ef1d9..23d551c25 100644 --- a/ui/src/views/application/component/CreateApplicationDialog.vue +++ b/ui/src/views/application/component/CreateApplicationDialog.vue @@ -151,7 +151,7 @@ const applicationForm = ref({ }, model_setting: { prompt: defaultPrompt, - system: t('views.application.form.roleSettings.placeholder'), + system: '', no_references_prompt: '{question}', }, model_params_setting: {}, @@ -205,7 +205,7 @@ watch(dialogVisible, (bool) => { }, model_setting: { prompt: defaultPrompt, - system: t('views.application.form.roleSettings.placeholder'), + system: '', no_references_prompt: '{question}', }, model_params_setting: {}, diff --git a/ui/src/views/application/component/ParamSettingDialog.vue b/ui/src/views/application/component/ParamSettingDialog.vue index 48f93d9bb..c935bafb4 100644 --- a/ui/src/views/application/component/ParamSettingDialog.vue +++ b/ui/src/views/application/component/ParamSettingDialog.vue @@ -168,7 +168,7 @@ >({ designated_answer: [ { required: true, - message: t('views.application.form.prompt.requiredMessage'), + message: t('common.prompt.placeholder'), trigger: 'blur', }, ], diff --git a/ui/src/workflow/nodes/ai-chat-node/index.vue b/ui/src/workflow/nodes/ai-chat-node/index.vue index 973b95943..2aea49b7e 100644 --- a/ui/src/workflow/nodes/ai-chat-node/index.vue +++ b/ui/src/workflow/nodes/ai-chat-node/index.vue @@ -56,7 +56,17 @@