From d8db728c331d781f48d0a62c9240285e5724ffa7 Mon Sep 17 00:00:00 2001 From: KVOJJJin Date: Mon, 8 Apr 2024 21:36:27 +0800 Subject: [PATCH] Fix: prompt of expert mode (#3168) --- web/app/components/app/configuration/index.tsx | 5 ++++- web/config/index.ts | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/web/app/components/app/configuration/index.tsx b/web/app/components/app/configuration/index.tsx index fc37de33a2..c9edf498f0 100644 --- a/web/app/components/app/configuration/index.tsx +++ b/web/app/components/app/configuration/index.tsx @@ -388,7 +388,10 @@ const Configuration: FC = () => { const promptMode = modelConfig.prompt_type === PromptMode.advanced ? PromptMode.advanced : PromptMode.simple doSetPromptMode(promptMode) if (promptMode === PromptMode.advanced) { - setChatPromptConfig(modelConfig.chat_prompt_config || clone(DEFAULT_CHAT_PROMPT_CONFIG) as any) + if (modelConfig.chat_prompt_config && modelConfig.chat_prompt_config.prompt.length > 0) + setChatPromptConfig(modelConfig.chat_prompt_config) + else + setChatPromptConfig(clone(DEFAULT_CHAT_PROMPT_CONFIG) as any) setCompletionPromptConfig(modelConfig.completion_prompt_config || clone(DEFAULT_COMPLETION_PROMPT_CONFIG) as any) setCanReturnToSimpleMode(false) } diff --git a/web/config/index.ts b/web/config/index.ts index cfd1d9294d..eefe1f8aba 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -1,6 +1,7 @@ /* eslint-disable import/no-mutable-exports */ import { InputVarType } from '@/app/components/workflow/types' import { AgentStrategy } from '@/types/app' +import { PromptRole } from '@/models/debug' export let apiPrefix = '' export let publicApiPrefix = '' @@ -70,7 +71,12 @@ export const TONE_LIST = [ ] export const DEFAULT_CHAT_PROMPT_CONFIG = { - prompt: [], + prompt: [ + { + role: PromptRole.system, + text: '', + }, + ], } export const DEFAULT_COMPLETION_PROMPT_CONFIG = {