fix: Corrected deletions and added API host reset for editable providers.

- Corrected deletions of the 'editable' property for multiple providers.
- Added ability to reset API host for editable providers when not empty.
This commit is contained in:
kangfenmao 2024-09-11 15:25:44 +08:00
parent 14180b8c06
commit 0e4b3c730b
2 changed files with 22 additions and 40 deletions

View File

@ -121,8 +121,7 @@ export function getModelLogo(modelId: string) {
export const PROVIDER_CONFIG = { export const PROVIDER_CONFIG = {
openai: { openai: {
api: { api: {
url: 'https://api.openai.com', url: 'https://api.openai.com'
editable: true
}, },
websites: { websites: {
official: 'https://openai.com/', official: 'https://openai.com/',
@ -138,8 +137,7 @@ export const PROVIDER_CONFIG = {
}, },
gemini: { gemini: {
api: { api: {
url: 'https://generativelanguage.googleapis.com', url: 'https://generativelanguage.googleapis.com'
editable: false
}, },
websites: { websites: {
official: 'https://gemini.google.com/', official: 'https://gemini.google.com/',
@ -155,8 +153,7 @@ export const PROVIDER_CONFIG = {
}, },
silicon: { silicon: {
api: { api: {
url: 'https://cloud.siliconflow.cn', url: 'https://cloud.siliconflow.cn'
editable: false
}, },
websites: { websites: {
official: 'https://www.siliconflow.cn/', official: 'https://www.siliconflow.cn/',
@ -172,8 +169,7 @@ export const PROVIDER_CONFIG = {
}, },
deepseek: { deepseek: {
api: { api: {
url: 'https://api.deepseek.com', url: 'https://api.deepseek.com'
editable: false
}, },
websites: { websites: {
official: 'https://deepseek.com/', official: 'https://deepseek.com/',
@ -189,8 +185,7 @@ export const PROVIDER_CONFIG = {
}, },
yi: { yi: {
api: { api: {
url: 'https://api.lingyiwanwu.com', url: 'https://api.lingyiwanwu.com'
editable: false
}, },
websites: { websites: {
official: 'https://platform.lingyiwanwu.com/', official: 'https://platform.lingyiwanwu.com/',
@ -206,8 +201,7 @@ export const PROVIDER_CONFIG = {
}, },
zhipu: { zhipu: {
api: { api: {
url: 'https://open.bigmodel.cn/api/paas/v4/', url: 'https://open.bigmodel.cn/api/paas/v4/'
editable: false
}, },
websites: { websites: {
official: 'https://open.bigmodel.cn/', official: 'https://open.bigmodel.cn/',
@ -223,8 +217,7 @@ export const PROVIDER_CONFIG = {
}, },
moonshot: { moonshot: {
api: { api: {
url: 'https://api.moonshot.cn', url: 'https://api.moonshot.cn'
editable: false
}, },
websites: { websites: {
official: 'https://moonshot.ai/', official: 'https://moonshot.ai/',
@ -240,8 +233,7 @@ export const PROVIDER_CONFIG = {
}, },
baichuan: { baichuan: {
api: { api: {
url: 'https://api.baichuan-ai.com', url: 'https://api.baichuan-ai.com'
editable: false
}, },
websites: { websites: {
official: 'https://www.baichuan-ai.com/', official: 'https://www.baichuan-ai.com/',
@ -257,8 +249,7 @@ export const PROVIDER_CONFIG = {
}, },
dashscope: { dashscope: {
api: { api: {
url: 'https://dashscope.aliyuncs.com/compatible-mode/v1/', url: 'https://dashscope.aliyuncs.com/compatible-mode/v1/'
editable: false
}, },
websites: { websites: {
official: 'https://dashscope.aliyun.com/', official: 'https://dashscope.aliyun.com/',
@ -274,8 +265,7 @@ export const PROVIDER_CONFIG = {
}, },
stepfun: { stepfun: {
api: { api: {
url: 'https://api.stepfun.com', url: 'https://api.stepfun.com'
editable: false
}, },
websites: { websites: {
official: 'https://platform.stepfun.com/', official: 'https://platform.stepfun.com/',
@ -291,8 +281,7 @@ export const PROVIDER_CONFIG = {
}, },
doubao: { doubao: {
api: { api: {
url: 'https://ark.cn-beijing.volces.com/api/v3/', url: 'https://ark.cn-beijing.volces.com/api/v3/'
editable: true
}, },
websites: { websites: {
official: 'https://console.volcengine.com/ark/', official: 'https://console.volcengine.com/ark/',
@ -308,8 +297,7 @@ export const PROVIDER_CONFIG = {
}, },
minimax: { minimax: {
api: { api: {
url: 'https://api.minimax.chat/v1/', url: 'https://api.minimax.chat/v1/'
editable: true
}, },
websites: { websites: {
official: 'https://platform.minimaxi.com/', official: 'https://platform.minimaxi.com/',
@ -325,14 +313,12 @@ export const PROVIDER_CONFIG = {
}, },
'graphrag-kylin-mountain': { 'graphrag-kylin-mountain': {
api: { api: {
url: '', url: ''
editable: true
} }
}, },
openrouter: { openrouter: {
api: { api: {
url: 'https://openrouter.ai/api/v1/', url: 'https://openrouter.ai/api/v1/'
editable: false
}, },
websites: { websites: {
official: 'https://openrouter.ai/', official: 'https://openrouter.ai/',
@ -343,8 +329,7 @@ export const PROVIDER_CONFIG = {
}, },
groq: { groq: {
api: { api: {
url: 'https://api.groq.com/openai', url: 'https://api.groq.com/openai'
editable: false
}, },
websites: { websites: {
official: 'https://groq.com/', official: 'https://groq.com/',
@ -360,8 +345,7 @@ export const PROVIDER_CONFIG = {
}, },
ollama: { ollama: {
api: { api: {
url: 'http://localhost:11434/v1/', url: 'http://localhost:11434/v1/'
editable: true
}, },
websites: { websites: {
official: 'https://ollama.com/', official: 'https://ollama.com/',
@ -371,8 +355,7 @@ export const PROVIDER_CONFIG = {
}, },
anthropic: { anthropic: {
api: { api: {
url: 'https://api.anthropic.com/', url: 'https://api.anthropic.com/'
editable: true
}, },
websites: { websites: {
official: 'https://anthropic.com/', official: 'https://anthropic.com/',
@ -388,8 +371,7 @@ export const PROVIDER_CONFIG = {
}, },
aihubmix: { aihubmix: {
api: { api: {
url: 'https://aihubmix.com', url: 'https://aihubmix.com'
editable: false
}, },
websites: { websites: {
official: 'https://aihubmix.com/', official: 'https://aihubmix.com/',

View File

@ -14,7 +14,7 @@ import { checkApi } from '@renderer/services/api'
import { Provider } from '@renderer/types' import { Provider } from '@renderer/types'
import { Avatar, Button, Card, Divider, Flex, Input, Space, Switch } from 'antd' import { Avatar, Button, Card, Divider, Flex, Input, Space, Switch } from 'antd'
import Link from 'antd/es/typography/Link' import Link from 'antd/es/typography/Link'
import { groupBy } from 'lodash' import { groupBy, isEmpty } from 'lodash'
import { FC, useEffect, useState } from 'react' import { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import styled from 'styled-components' import styled from 'styled-components'
@ -72,7 +72,6 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
const docsWebsite = providerConfig?.websites?.docs const docsWebsite = providerConfig?.websites?.docs
const modelsWebsite = providerConfig?.websites?.models const modelsWebsite = providerConfig?.websites?.models
const configedApiHost = providerConfig?.api?.url const configedApiHost = providerConfig?.api?.url
const apiEditable = provider.isSystem ? providerConfig?.api?.editable : true
const onReset = () => { const onReset = () => {
setApiHost(configedApiHost) setApiHost(configedApiHost)
@ -131,9 +130,10 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
placeholder={t('settings.provider.api_host')} placeholder={t('settings.provider.api_host')}
onChange={(e) => setApiHost(e.target.value)} onChange={(e) => setApiHost(e.target.value)}
onBlur={onUpdateApiHost} onBlur={onUpdateApiHost}
disabled={!apiEditable}
/> />
{apiEditable && <Button onClick={onReset}>{t('settings.provider.api.url.reset')}</Button>} {!isEmpty(configedApiHost) && apiHost !== configedApiHost && (
<Button onClick={onReset}>{t('settings.provider.api.url.reset')}</Button>
)}
</Space.Compact> </Space.Compact>
{provider.id === 'ollama' && <OllamSettings />} {provider.id === 'ollama' && <OllamSettings />}
{provider.id === 'graphrag-kylin-mountain' && provider.models.length > 0 && ( {provider.id === 'graphrag-kylin-mountain' && provider.models.length > 0 && (