diff --git a/providers/openai/base.go b/providers/openai/base.go index 0a3eebbc..aff6d962 100644 --- a/providers/openai/base.go +++ b/providers/openai/base.go @@ -102,6 +102,8 @@ func (p *OpenAIProvider) GetFullRequestURL(requestURL string, modelName string) requestURL = fmt.Sprintf("/openai%s?api-version=%s", requestURL, apiVersion) } + } else if p.Channel.Type == common.ChannelTypeCustom && p.Channel.Other != "" { + requestURL = strings.Replace(requestURL, "v1", p.Channel.Other, 1) } if strings.HasPrefix(baseURL, "https://gateway.ai.cloudflare.com") { diff --git a/web/src/views/Channel/component/EditModal.js b/web/src/views/Channel/component/EditModal.js index ed4b1f3c..82bc132c 100644 --- a/web/src/views/Channel/component/EditModal.js +++ b/web/src/views/Channel/component/EditModal.js @@ -153,7 +153,8 @@ const EditModal = ({ open, channelId, onCancel, onOk, groupOptions }) => { const res = await API.post(`/api/channel/provider_models_list`, { ...values, models: '' }); const { success, message, data } = res.data; if (success && data) { - let modelList = data.map((model) => { + let uniqueModels = Array.from(new Set(data)); + let modelList = uniqueModels.map((model) => { return { id: model, group: '自定义:点击或回车输入' diff --git a/web/src/views/Channel/type/Config.js b/web/src/views/Channel/type/Config.js index 46b36cc5..5d6c8057 100644 --- a/web/src/views/Channel/type/Config.js +++ b/web/src/views/Channel/type/Config.js @@ -54,7 +54,11 @@ const typeConfig = { }, 8: { inputLabel: { - provider_models_list: '从渠道获取模型列表' + provider_models_list: '从渠道获取模型列表', + other: '替换 API 版本' + }, + prompt: { + other: '输入后,会替换请求地址中的v1,例如:freeapi,则请求chat时会变成https://xxx.com/freeapi/chat/completions' } }, 3: {