feat(provider.ts): add API endpoint configuration for each provider with editable status
This commit is contained in:
parent
f961accd86
commit
8c80cc00b3
@ -85,6 +85,10 @@ export function getModelLogo(modelId: string) {
|
|||||||
|
|
||||||
export const PROVIDER_CONFIG = {
|
export const PROVIDER_CONFIG = {
|
||||||
openai: {
|
openai: {
|
||||||
|
api: {
|
||||||
|
url: 'https://api.openai.com',
|
||||||
|
editable: true
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://openai.com/',
|
official: 'https://openai.com/',
|
||||||
apiKey: 'https://platform.openai.com/api-keys',
|
apiKey: 'https://platform.openai.com/api-keys',
|
||||||
@ -93,6 +97,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
silicon: {
|
silicon: {
|
||||||
|
api: {
|
||||||
|
url: 'https://cloud.siliconflow.cn',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://www.siliconflow.cn/',
|
official: 'https://www.siliconflow.cn/',
|
||||||
apiKey: 'https://cloud.siliconflow.cn/account/ak',
|
apiKey: 'https://cloud.siliconflow.cn/account/ak',
|
||||||
@ -101,6 +109,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
deepseek: {
|
deepseek: {
|
||||||
|
api: {
|
||||||
|
url: 'https://api.deepseek.com',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://deepseek.com/',
|
official: 'https://deepseek.com/',
|
||||||
apiKey: 'https://platform.deepseek.com/api_keys',
|
apiKey: 'https://platform.deepseek.com/api_keys',
|
||||||
@ -109,6 +121,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
yi: {
|
yi: {
|
||||||
|
api: {
|
||||||
|
url: 'https://api.lingyiwanwu.com',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://platform.lingyiwanwu.com/',
|
official: 'https://platform.lingyiwanwu.com/',
|
||||||
apiKey: 'https://platform.lingyiwanwu.com/apikeys',
|
apiKey: 'https://platform.lingyiwanwu.com/apikeys',
|
||||||
@ -117,6 +133,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
zhipu: {
|
zhipu: {
|
||||||
|
api: {
|
||||||
|
url: 'https://open.bigmodel.cn/api/paas/v4/',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://open.bigmodel.cn/',
|
official: 'https://open.bigmodel.cn/',
|
||||||
apiKey: 'https://open.bigmodel.cn/usercenter/apikeys',
|
apiKey: 'https://open.bigmodel.cn/usercenter/apikeys',
|
||||||
@ -125,6 +145,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
moonshot: {
|
moonshot: {
|
||||||
|
api: {
|
||||||
|
url: 'https://api.moonshot.cn',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://moonshot.ai/',
|
official: 'https://moonshot.ai/',
|
||||||
apiKey: 'https://platform.moonshot.cn/console/api-keys',
|
apiKey: 'https://platform.moonshot.cn/console/api-keys',
|
||||||
@ -133,6 +157,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
baichuan: {
|
baichuan: {
|
||||||
|
api: {
|
||||||
|
url: 'https://api.baichuan-ai.com',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://www.baichuan-ai.com/',
|
official: 'https://www.baichuan-ai.com/',
|
||||||
apiKey: 'https://platform.baichuan-ai.com/console/apikey',
|
apiKey: 'https://platform.baichuan-ai.com/console/apikey',
|
||||||
@ -141,6 +169,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
dashscope: {
|
dashscope: {
|
||||||
|
api: {
|
||||||
|
url: 'https://dashscope.aliyuncs.com/compatible-mode/v1/',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://dashscope.aliyun.com/',
|
official: 'https://dashscope.aliyun.com/',
|
||||||
apiKey: 'https://help.aliyun.com/zh/dashscope/developer-reference/acquisition-and-configuration-of-api-key',
|
apiKey: 'https://help.aliyun.com/zh/dashscope/developer-reference/acquisition-and-configuration-of-api-key',
|
||||||
@ -149,6 +181,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
openrouter: {
|
openrouter: {
|
||||||
|
api: {
|
||||||
|
url: 'https://openrouter.ai/api/v1/',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://openrouter.ai/',
|
official: 'https://openrouter.ai/',
|
||||||
apiKey: 'https://openrouter.ai/settings/keys',
|
apiKey: 'https://openrouter.ai/settings/keys',
|
||||||
@ -157,6 +193,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
groq: {
|
groq: {
|
||||||
|
api: {
|
||||||
|
url: 'https://api.groq.com/openai',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://groq.com/',
|
official: 'https://groq.com/',
|
||||||
apiKey: 'https://console.groq.com/keys',
|
apiKey: 'https://console.groq.com/keys',
|
||||||
@ -165,6 +205,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ollama: {
|
ollama: {
|
||||||
|
api: {
|
||||||
|
url: 'http://localhost:11434/v1/',
|
||||||
|
editable: true
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://ollama.com/',
|
official: 'https://ollama.com/',
|
||||||
docs: 'https://github.com/ollama/ollama/tree/main/docs',
|
docs: 'https://github.com/ollama/ollama/tree/main/docs',
|
||||||
@ -172,6 +216,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
anthropic: {
|
anthropic: {
|
||||||
|
api: {
|
||||||
|
url: 'https://api.anthropic.com/',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://anthropic.com/',
|
official: 'https://anthropic.com/',
|
||||||
apiKey: 'https://console.anthropic.com/settings/keys',
|
apiKey: 'https://console.anthropic.com/settings/keys',
|
||||||
@ -180,6 +228,10 @@ export const PROVIDER_CONFIG = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
aihubmix: {
|
aihubmix: {
|
||||||
|
api: {
|
||||||
|
url: 'https://aihubmix.com',
|
||||||
|
editable: false
|
||||||
|
},
|
||||||
websites: {
|
websites: {
|
||||||
official: 'https://aihubmix.com/',
|
official: 'https://aihubmix.com/',
|
||||||
apiKey: 'https://aihubmix.com/token',
|
apiKey: 'https://aihubmix.com/token',
|
||||||
|
|||||||
@ -121,6 +121,7 @@ const resources = {
|
|||||||
'provider.docs_check': 'Check',
|
'provider.docs_check': 'Check',
|
||||||
'provider.docs_more_details': 'for more details',
|
'provider.docs_more_details': 'for more details',
|
||||||
'provider.search_placeholder': 'Search model id or name',
|
'provider.search_placeholder': 'Search model id or name',
|
||||||
|
'provider.api.url.reset': 'Reset',
|
||||||
'models.default_assistant_model': 'Default Assistant Model',
|
'models.default_assistant_model': 'Default Assistant Model',
|
||||||
'models.topic_naming_model': 'Topic Naming Model',
|
'models.topic_naming_model': 'Topic Naming Model',
|
||||||
'models.add.add_model': 'Add Model',
|
'models.add.add_model': 'Add Model',
|
||||||
@ -276,6 +277,7 @@ const resources = {
|
|||||||
'provider.docs_check': '查看',
|
'provider.docs_check': '查看',
|
||||||
'provider.docs_more_details': '获取更多详情',
|
'provider.docs_more_details': '获取更多详情',
|
||||||
'provider.search_placeholder': '搜索模型 ID 或名称',
|
'provider.search_placeholder': '搜索模型 ID 或名称',
|
||||||
|
'provider.api.url.reset': '重置',
|
||||||
'models.default_assistant_model': '默认助手模型',
|
'models.default_assistant_model': '默认助手模型',
|
||||||
'models.topic_naming_model': '话题命名模型',
|
'models.topic_naming_model': '话题命名模型',
|
||||||
'models.add.add_model': '添加模型',
|
'models.add.add_model': '添加模型',
|
||||||
|
|||||||
@ -52,8 +52,13 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
|||||||
const apiKeyWebsite = providerConfig?.websites?.apiKey
|
const apiKeyWebsite = providerConfig?.websites?.apiKey
|
||||||
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 apiEditable = provider.isSystem ? providerConfig?.api?.editable : true
|
||||||
|
|
||||||
const apiKeyDisabled = provider.id === 'ollama'
|
const onReset = () => {
|
||||||
|
setApiHost(configedApiHost)
|
||||||
|
updateProvider({ ...provider, apiHost: configedApiHost })
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingContainer>
|
<SettingContainer>
|
||||||
@ -81,15 +86,12 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
|||||||
onChange={(e) => setApiKey(e.target.value)}
|
onChange={(e) => setApiKey(e.target.value)}
|
||||||
onBlur={onUpdateApiKey}
|
onBlur={onUpdateApiKey}
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
disabled={apiKeyDisabled}
|
|
||||||
type="password"
|
type="password"
|
||||||
autoFocus={provider.enabled && apiKey === ''}
|
autoFocus={provider.enabled && apiKey === ''}
|
||||||
/>
|
/>
|
||||||
{!apiKeyDisabled && (
|
|
||||||
<Button type={apiValid ? 'primary' : 'default'} ghost={apiValid} onClick={onCheckApi}>
|
<Button type={apiValid ? 'primary' : 'default'} ghost={apiValid} onClick={onCheckApi}>
|
||||||
{apiChecking ? <LoadingOutlined spin /> : apiValid ? <CheckOutlined /> : t('settings.provider.check')}
|
{apiChecking ? <LoadingOutlined spin /> : apiValid ? <CheckOutlined /> : t('settings.provider.check')}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
|
||||||
</Space.Compact>
|
</Space.Compact>
|
||||||
{apiKeyWebsite && (
|
{apiKeyWebsite && (
|
||||||
<HelpTextRow>
|
<HelpTextRow>
|
||||||
@ -99,13 +101,16 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
|||||||
</HelpTextRow>
|
</HelpTextRow>
|
||||||
)}
|
)}
|
||||||
<SettingSubtitle>{t('settings.provider.api_host')}</SettingSubtitle>
|
<SettingSubtitle>{t('settings.provider.api_host')}</SettingSubtitle>
|
||||||
|
<Space.Compact style={{ width: '100%' }}>
|
||||||
<Input
|
<Input
|
||||||
value={apiHost}
|
value={apiHost}
|
||||||
placeholder={t('settings.provider.api_host')}
|
placeholder={t('settings.provider.api_host')}
|
||||||
disabled={provider.isSystem}
|
|
||||||
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>}
|
||||||
|
</Space.Compact>
|
||||||
<SettingSubtitle>{t('common.models')}</SettingSubtitle>
|
<SettingSubtitle>{t('common.models')}</SettingSubtitle>
|
||||||
{Object.keys(modelGroups).map((group) => (
|
{Object.keys(modelGroups).map((group) => (
|
||||||
<Card key={group} type="inner" title={group} style={{ marginBottom: '10px' }} size="small">
|
<Card key={group} type="inner" title={group} style={{ marginBottom: '10px' }} size="small">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user