feat: Add Tavily dark mode logo and improve web search settings UI
This commit is contained in:
parent
fb6b0b0c97
commit
c354537f30
14
src/renderer/src/assets/images/search/tavily-dark.svg
Normal file
14
src/renderer/src/assets/images/search/tavily-dark.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<svg width="778" height="257" viewBox="0 0 778 257" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M97.1853 5.35901L127.346 53.1064C132.19 60.7745 126.68 70.7725 117.61 70.7725H105.279V142.278H87.4492V-0.00683594C91.1876 -0.00683594 94.926 1.78179 97.1853 5.35901Z" fill="#8FBCFA"/>
|
||||
<path d="M47.5482 53.1064L77.7098 5.35901C79.9691 1.78179 83.7075 -0.00683594 87.4459 -0.00683594V142.279C81.0587 141.981 74.8755 143.829 69.616 147.544V70.7725H57.2849C48.2149 70.7725 42.7047 60.7745 47.5482 53.1064Z" fill="#468BFF"/>
|
||||
<path d="M182.003 189.445L107.34 189.445C111.648 184.622 114.201 178.481 114.476 171.615H252.782C252.782 175.353 250.993 179.092 247.416 181.351L199.669 211.512C192.001 216.356 182.003 210.846 182.003 201.776V189.445Z" fill="#FDBB11"/>
|
||||
<path d="M199.668 131.718L247.415 161.879C250.993 164.138 252.781 167.877 252.781 171.615H114.471C114.72 165.212 112.733 158.898 108.957 153.785H182.002V141.454C182.002 132.384 192 126.874 199.668 131.718Z" fill="#F6D785"/>
|
||||
<path d="M46.9409 209.797L3.37891 253.359C6.02226 256.003 9.93035 257.381 14.0576 256.45L69.1472 244.014C77.9944 242.017 81.1678 231.051 74.7545 224.638L66.035 215.918L98.7916 183.055C105.771 176.075 105.462 164.899 98.6758 158.113L46.9409 209.797Z" fill="#FF9A9D"/>
|
||||
<path d="M40.8221 190.708L73.6898 157.963C80.6694 150.983 91.8931 151.328 98.679 158.113L46.9436 209.802L3.38131 253.364C0.737954 250.721 -0.640662 246.812 0.291 242.685L12.7265 187.596C14.7236 178.748 25.6895 175.575 32.1028 181.988L40.8221 190.708Z" fill="#FE363B"/>
|
||||
<path d="M777.344 93.6689L718.337 234.049H692.704L713.348 186.567L675.156 93.6689H702.166L726.766 160.246L751.711 93.6689H777.344Z" fill="#FFFFFF"/>
|
||||
<path d="M664.096 70.1191V188.976H640.012V70.1191H664.096Z" fill="#FFFFFF"/>
|
||||
<path d="M606.041 82.2736C601.797 82.2736 598.242 80.9547 595.375 78.3168C592.622 75.5643 591.246 72.181 591.246 68.1668C591.246 64.1527 592.622 60.8267 595.375 58.1889C598.242 55.4363 601.797 54.0601 606.041 54.0601C610.284 54.0601 613.783 55.4363 616.535 58.1889C619.402 60.8267 620.836 63.6942 620.836 67.7084C620.836 71.7225 619.402 75.5643 616.535 78.3168C613.783 80.9547 610.284 82.2736 606.041 82.2736ZM617.911 93.6279V188.978H593.827V93.6279H617.911Z" fill="#FFFFFF"/>
|
||||
<path d="M532.3 166.783L556.385 93.6689H582.018L546.751 188.976H517.505L482.41 93.6689H508.215L532.3 166.783Z" fill="#FFFFFF"/>
|
||||
<path d="M371.52 140.972C371.52 131.338 373.412 122.794 377.197 115.339C381.096 107.884 386.314 102.15 392.852 98.1355C399.504 94.1213 406.901 92.1143 415.044 92.1143C422.155 92.1143 428.348 93.5479 433.624 96.4151C439.014 99.2823 443.315 102.895 446.526 107.253V93.6626H470.783V188.969H446.526V175.035C443.43 179.507 439.129 183.235 433.624 186.217C428.233 189.084 421.983 190.518 414.872 190.518C406.844 190.518 399.504 188.453 392.852 184.324C386.314 180.196 381.096 174.404 377.197 166.949C373.412 159.38 371.52 150.72 371.52 140.972ZM446.526 141.316C446.526 135.467 445.379 130.478 443.086 126.349C440.792 122.105 437.695 118.894 433.796 116.715C429.896 114.421 425.71 113.274 421.237 113.274C416.764 113.274 412.636 114.364 408.851 116.543C405.066 118.722 401.97 121.933 399.561 126.177C397.267 130.306 396.12 135.237 396.12 140.972C396.12 146.706 397.267 151.753 399.561 156.111C401.97 160.354 405.066 163.623 408.851 165.917C412.75 168.211 416.879 169.357 421.237 169.357C425.71 169.357 429.896 168.268 433.796 166.089C437.695 163.795 440.792 160.584 443.086 156.455C445.379 152.211 446.526 147.165 446.526 141.316Z" fill="#FFFFFF"/>
|
||||
<path d="M340.767 113.445V159.55C340.767 162.762 341.513 165.113 343.004 166.604C344.609 167.98 347.247 168.668 350.917 168.668H362.099V188.968H346.96C326.66 188.968 316.51 179.105 316.51 159.378V113.445H305.156V93.6614H316.51V70.0928H340.767V93.6614H362.099V113.445H340.767Z" fill="#FFFFFF"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
@ -808,7 +808,7 @@
|
||||
"tray.title": "启用系统托盘图标",
|
||||
"websearch": {
|
||||
"title": "网络搜索",
|
||||
"get_api_key": "点击这里获取 API 密钥",
|
||||
"get_api_key": "点击这里获取密钥",
|
||||
"tavily": {
|
||||
"title": "Tavily",
|
||||
"description": "Tavily 是一个集成了多个搜索引擎的网络搜索工具,支持多种语言和多种搜索引擎。",
|
||||
|
||||
@ -799,7 +799,7 @@
|
||||
"tray.title": "啟用系統托盤圖標",
|
||||
"websearch": {
|
||||
"title": "網路搜索",
|
||||
"get_api_key": "點擊這裡獲取 API 密鑰",
|
||||
"get_api_key": "點擊這裡獲取密鑰",
|
||||
"tavily": {
|
||||
"title": "Tavily",
|
||||
"description": "Tavily 是一個集成了多個搜索引擎的網路搜索工具,支持多種語言和多種搜索引擎。",
|
||||
|
||||
@ -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,6 +501,7 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic }) => {
|
||||
}
|
||||
|
||||
const onEnableWebSearch = () => {
|
||||
if (!isWebSearchModel(model)) {
|
||||
if (!WebSearchService.isWebSearchEnabled()) {
|
||||
window.modal.confirm({
|
||||
title: t('chat.input.web_search.enable'),
|
||||
@ -513,10 +514,17 @@ const Inputbar: FC<Props> = ({ assistant: _assistant, setActiveTopic }) => {
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
updateAssistant({ ...assistant, enableWebSearch: !assistant.enableWebSearch })
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!isWebSearchModel(model) && !WebSearchService.isWebSearchEnabled() && assistant.enableWebSearch) {
|
||||
updateAssistant({ ...assistant, enableWebSearch: false })
|
||||
}
|
||||
}, [assistant, model, updateAssistant])
|
||||
|
||||
return (
|
||||
<Container onDragOver={handleDragOver} onDrop={handleDrop} className="inputbar">
|
||||
<NarrowLayout style={{ width: '100%' }}>
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -166,6 +166,7 @@ const Container = styled.div`
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
padding: 2px 0;
|
||||
`
|
||||
|
||||
const ProviderListContainer = styled.div`
|
||||
|
||||
@ -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 = () => {
|
||||
<SettingContainer theme={theme}>
|
||||
<SettingGroup theme={theme}>
|
||||
<HStack alignItems="center" gap={10}>
|
||||
<TavilyLogo src={tavilyLogo} alt="web-search" style={{ width: '60px' }} />
|
||||
<TavilyLogo src={logo} alt="web-search" style={{ width: '60px' }} />
|
||||
</HStack>
|
||||
<SettingDivider />
|
||||
<Paragraph type="secondary" style={{ margin: '10px 0' }}>
|
||||
{t('settings.websearch.tavily.description')}
|
||||
</Paragraph>
|
||||
@ -41,12 +45,10 @@ const WebSearchSettings: FC = () => {
|
||||
onChange={(e) => setApiKey(e.target.value)}
|
||||
onBlur={() => updateProvider({ ...provider, apiKey })}
|
||||
/>
|
||||
<SettingHelpTextRow style={{ justifyContent: 'space-between' }}>
|
||||
<HStack gap={5}>
|
||||
<SettingHelpTextRow style={{ justifyContent: 'space-between', marginTop: 5 }}>
|
||||
<SettingHelpLink target="_blank" href="https://app.tavily.com/home">
|
||||
{t('settings.websearch.get_api_key')}
|
||||
</SettingHelpLink>
|
||||
</HStack>
|
||||
</SettingHelpTextRow>
|
||||
</SettingGroup>
|
||||
</SettingContainer>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user