diff --git a/src/renderer/src/assets/images/search/tavily-dark.svg b/src/renderer/src/assets/images/search/tavily-dark.svg new file mode 100644 index 0000000000..bd1995a91f --- /dev/null +++ b/src/renderer/src/assets/images/search/tavily-dark.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 38bd198d52..93f1fe2396 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -808,7 +808,7 @@ "tray.title": "启用系统托盘图标", "websearch": { "title": "网络搜索", - "get_api_key": "点击这里获取 API 密钥", + "get_api_key": "点击这里获取密钥", "tavily": { "title": "Tavily", "description": "Tavily 是一个集成了多个搜索引擎的网络搜索工具,支持多种语言和多种搜索引擎。", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index 6652737d7d..45f3bef7d7 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -799,7 +799,7 @@ "tray.title": "啟用系統托盤圖標", "websearch": { "title": "網路搜索", - "get_api_key": "點擊這裡獲取 API 密鑰", + "get_api_key": "點擊這裡獲取密鑰", "tavily": { "title": "Tavily", "description": "Tavily 是一個集成了多個搜索引擎的網路搜索工具,支持多種語言和多種搜索引擎。", diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index 7c9ddd133c..fd6476af95 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -9,7 +9,7 @@ import { } from '@ant-design/icons' import { PicCenterOutlined } from '@ant-design/icons' import TranslateButton from '@renderer/components/TranslateButton' -import { isVisionModel } from '@renderer/config/models' +import { isVisionModel, isWebSearchModel } from '@renderer/config/models' import db from '@renderer/databases' import { useAssistant } from '@renderer/hooks/useAssistant' import { modelGenerating, useRuntime } from '@renderer/hooks/useRuntime' @@ -501,22 +501,30 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic }) => { } const onEnableWebSearch = () => { - if (!WebSearchService.isWebSearchEnabled()) { - window.modal.confirm({ - title: t('chat.input.web_search.enable'), - content: t('chat.input.web_search.enable_content'), - centered: true, - okText: t('chat.input.web_search.button.ok'), - onOk: () => { - navigate('/settings/web-search') - } - }) - return + if (!isWebSearchModel(model)) { + if (!WebSearchService.isWebSearchEnabled()) { + window.modal.confirm({ + title: t('chat.input.web_search.enable'), + content: t('chat.input.web_search.enable_content'), + centered: true, + okText: t('chat.input.web_search.button.ok'), + onOk: () => { + navigate('/settings/web-search') + } + }) + return + } } updateAssistant({ ...assistant, enableWebSearch: !assistant.enableWebSearch }) } + useEffect(() => { + if (!isWebSearchModel(model) && !WebSearchService.isWebSearchEnabled() && assistant.enableWebSearch) { + updateAssistant({ ...assistant, enableWebSearch: false }) + } + }, [assistant, model, updateAssistant]) + return ( diff --git a/src/renderer/src/pages/home/Messages/MessageContent.tsx b/src/renderer/src/pages/home/Messages/MessageContent.tsx index 2a54ca53b6..58e71f46d0 100644 --- a/src/renderer/src/pages/home/Messages/MessageContent.tsx +++ b/src/renderer/src/pages/home/Messages/MessageContent.tsx @@ -218,6 +218,7 @@ const Favicon = styled.img` width: 16px; height: 16px; border-radius: 4px; + background-color: var(--color-background-mute); ` export default React.memo(MessageContent) diff --git a/src/renderer/src/pages/settings/ProviderSettings/index.tsx b/src/renderer/src/pages/settings/ProviderSettings/index.tsx index 5fe6853b0b..cda80f26d0 100644 --- a/src/renderer/src/pages/settings/ProviderSettings/index.tsx +++ b/src/renderer/src/pages/settings/ProviderSettings/index.tsx @@ -166,6 +166,7 @@ const Container = styled.div` display: flex; flex-direction: row; justify-content: space-between; + padding: 2px 0; ` const ProviderListContainer = styled.div` diff --git a/src/renderer/src/pages/settings/WebSearchSettings.tsx b/src/renderer/src/pages/settings/WebSearchSettings.tsx index 7cbbc520ed..1357c61324 100644 --- a/src/renderer/src/pages/settings/WebSearchSettings.tsx +++ b/src/renderer/src/pages/settings/WebSearchSettings.tsx @@ -1,4 +1,5 @@ import tavilyLogo from '@renderer/assets/images/search/tavily.svg' +import tavilyLogoDark from '@renderer/assets/images/search/tavily-dark.svg' import { HStack } from '@renderer/components/Layout' import { useTheme } from '@renderer/context/ThemeProvider' import { useWebSearchProvider } from '@renderer/hooks/useWebSearchProviders' @@ -7,7 +8,7 @@ import { FC, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' -import { SettingContainer, SettingGroup, SettingHelpLink, SettingHelpTextRow } from '.' +import { SettingContainer, SettingDivider, SettingGroup, SettingHelpLink, SettingHelpTextRow } from '.' const WebSearchSettings: FC = () => { const { t } = useTranslation() @@ -16,6 +17,8 @@ const WebSearchSettings: FC = () => { const { provider, updateProvider } = useWebSearchProvider('tavily') const [apiKey, setApiKey] = useState(provider.apiKey) + const logo = theme === 'dark' ? tavilyLogoDark : tavilyLogo + useEffect(() => { return () => { console.log('apiKey', apiKey, provider.apiKey) @@ -29,8 +32,9 @@ const WebSearchSettings: FC = () => { - + + {t('settings.websearch.tavily.description')} @@ -41,12 +45,10 @@ const WebSearchSettings: FC = () => { onChange={(e) => setApiKey(e.target.value)} onBlur={() => updateProvider({ ...provider, apiKey })} /> - - - - {t('settings.websearch.get_api_key')} - - + + + {t('settings.websearch.get_api_key')} +