Merge pull request #1885 from RedwindA/fix/hide-unavailable-fetch-model-button
feat: `获取模型列表`按钮白名单
This commit is contained in:
commit
5b26120bb8
@ -188,6 +188,8 @@ func FetchUpstreamModels(c *gin.Context) {
|
|||||||
url = fmt.Sprintf("%s/v1beta/openai/models", baseURL) // Remove key in url since we need to use AuthHeader
|
url = fmt.Sprintf("%s/v1beta/openai/models", baseURL) // Remove key in url since we need to use AuthHeader
|
||||||
case constant.ChannelTypeAli:
|
case constant.ChannelTypeAli:
|
||||||
url = fmt.Sprintf("%s/compatible-mode/v1/models", baseURL)
|
url = fmt.Sprintf("%s/compatible-mode/v1/models", baseURL)
|
||||||
|
case constant.ChannelTypeZhipu_v4:
|
||||||
|
url = fmt.Sprintf("%s/api/paas/v4/models", baseURL)
|
||||||
default:
|
default:
|
||||||
url = fmt.Sprintf("%s/v1/models", baseURL)
|
url = fmt.Sprintf("%s/v1/models", baseURL)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,26 @@ const REGION_EXAMPLE = {
|
|||||||
'claude-3-5-sonnet-20240620': 'europe-west1',
|
'claude-3-5-sonnet-20240620': 'europe-west1',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 支持并且已适配通过接口获取模型列表的渠道类型
|
||||||
|
const MODEL_FETCHABLE_TYPES = new Set([
|
||||||
|
1,
|
||||||
|
4,
|
||||||
|
14,
|
||||||
|
34,
|
||||||
|
17,
|
||||||
|
26,
|
||||||
|
24,
|
||||||
|
47,
|
||||||
|
25,
|
||||||
|
20,
|
||||||
|
23,
|
||||||
|
31,
|
||||||
|
35,
|
||||||
|
40,
|
||||||
|
42,
|
||||||
|
48,
|
||||||
|
]);
|
||||||
|
|
||||||
function type2secretPrompt(type) {
|
function type2secretPrompt(type) {
|
||||||
// inputs.type === 15 ? '按照如下格式输入:APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入:APPID|APISecret|APIKey' : '请输入渠道对应的鉴权密钥')
|
// inputs.type === 15 ? '按照如下格式输入:APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入:APPID|APISecret|APIKey' : '请输入渠道对应的鉴权密钥')
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -1872,13 +1892,15 @@ const EditChannelModal = (props) => {
|
|||||||
>
|
>
|
||||||
{t('填入所有模型')}
|
{t('填入所有模型')}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
{MODEL_FETCHABLE_TYPES.has(inputs.type) && (
|
||||||
size='small'
|
<Button
|
||||||
type='tertiary'
|
size='small'
|
||||||
onClick={() => fetchUpstreamModelList('models')}
|
type='tertiary'
|
||||||
>
|
onClick={() => fetchUpstreamModelList('models')}
|
||||||
{t('获取模型列表')}
|
>
|
||||||
</Button>
|
{t('获取模型列表')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
size='small'
|
size='small'
|
||||||
type='warning'
|
type='warning'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user