diff --git a/web/app/components/app/chat/thought/index.tsx b/web/app/components/app/chat/thought/index.tsx index b4732c1dff..e8079f3d03 100644 --- a/web/app/components/app/chat/thought/index.tsx +++ b/web/app/components/app/chat/thought/index.tsx @@ -45,8 +45,12 @@ const Thought: FC = ({ return t('explore.universalChat.thought.res.dataset').replace('{datasetName}', `${datasetName}`) case 'web_reader': return t(`explore.universalChat.thought.res.webReader.${!input.cursor ? 'normal' : 'hasPageInfo'}`).replace('{url}', `${input.url}`) - default: // google, wikipedia - return t('explore.universalChat.thought.res.search', { query: input.query }) + case 'google_search': + return t('explore.universalChat.thought.res.google', { query: input.query }) + case 'wikipedia': + return t('explore.universalChat.thought.res.wikipedia', { query: input.query }) + default: + return `Unknown tool: ${item.tool}` } } catch (error) { diff --git a/web/app/components/explore/universal-chat/index.tsx b/web/app/components/explore/universal-chat/index.tsx index 0b8598a9a9..9a66fdcfb0 100644 --- a/web/app/components/explore/universal-chat/index.tsx +++ b/web/app/components/explore/universal-chat/index.tsx @@ -47,6 +47,28 @@ const DEFAULT_PLUGIN = { web_reader: true, wikipedia: true, } +const CONFIG_KEY = 'universal-chat-config' +type CONFIG = { + modelId: string + plugin: { + google_search: boolean + web_reader: boolean + wikipedia: boolean + } +} +let prevConfig: null | CONFIG = localStorage.getItem(CONFIG_KEY) ? JSON.parse(localStorage.getItem(CONFIG_KEY) as string) as CONFIG : null +const setPrevConfig = (config: CONFIG) => { + prevConfig = config + localStorage.setItem(CONFIG_KEY, JSON.stringify(prevConfig)) +} +const getInitConfig = (type: 'model' | 'plugin') => { + if (type === 'model') + return prevConfig?.modelId || DEFAULT_MODEL_ID + + if (type === 'plugin') + return prevConfig?.plugin || DEFAULT_PLUGIN +} + export type IMainProps = {} const Main: FC = () => { @@ -415,6 +437,13 @@ const Main: FC = () => { const [errorHappened, setErrorHappened] = useState(false) const [isResponsingConIsCurrCon, setIsResponsingConCurrCon, getIsResponsingConIsCurrCon] = useGetState(true) const handleSend = async (message: string) => { + if (isNewConversation) { + setPrevConfig({ + modelId, + plugin: plugins as any, + }) + } + if (isResponsing) { notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') }) return @@ -598,10 +627,10 @@ const Main: FC = () => { ) } - const [modelId, setModeId] = useState(DEFAULT_MODEL_ID) + const [modelId, setModeId] = useState(getInitConfig('model') as string) // const currModel = MODEL_LIST.find(item => item.id === modelId) - const [plugins, setPlugins] = useState>(DEFAULT_PLUGIN) + const [plugins, setPlugins] = useState>(getInitConfig('plugin') as Record) const handlePluginsChange = (key: string, value: boolean) => { setPlugins({ ...plugins, @@ -610,8 +639,8 @@ const Main: FC = () => { } const [dataSets, setDateSets] = useState([]) const configSetDefaultValue = () => { - setModeId(DEFAULT_MODEL_ID) - setPlugins(DEFAULT_PLUGIN) + setModeId(getInitConfig('model') as string) + setPlugins(getInitConfig('plugin') as any) setDateSets([]) } const isCurrConversationPinned = !!pinnedConversationList.find(item => item.id === currConversationId) diff --git a/web/i18n/lang/explore.en.ts b/web/i18n/lang/explore.en.ts index 6a3d444e6b..85221b3228 100644 --- a/web/i18n/lang/explore.en.ts +++ b/web/i18n/lang/explore.en.ts @@ -66,7 +66,8 @@ const translation = { normal: 'Reading {url}', hasPageInfo: 'Reading next page of {url}', }, - search: 'Searching {{query}}', + google: 'Searching Google {{query}}', + wikipedia: 'Searching Wikipedia {{query}}', dataset: 'Retrieving dataset {datasetName}', }, }, diff --git a/web/i18n/lang/explore.zh.ts b/web/i18n/lang/explore.zh.ts index 5c99dca065..6d8591e587 100644 --- a/web/i18n/lang/explore.zh.ts +++ b/web/i18n/lang/explore.zh.ts @@ -66,7 +66,8 @@ const translation = { normal: '解析链接 {url}', hasPageInfo: '解析链接 {url} 的下一页', }, - search: '搜索 {{query}}', + google: '搜索谷歌 {{query}}', + wikipedia: '搜索维基百科 {{query}}', dataset: '检索数据集 {datasetName}', }, },