diff --git a/README.md b/README.md index c4d6a655..08532b97 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ _✨ All in one 的 OpenAI 接口,整合各种 API 访问方式,开箱即用 ## 功能 1. 支持多种 API 访问渠道,欢迎 PR 或提 issue 添加更多渠道: - + [x] OpenAI 官方通道 + + [x] OpenAI 官方通道(支持配置代理) + [x] **Azure OpenAI API** + [x] [API2D](https://api2d.com/r/197971) + [x] [OhMyGPT](https://aigptx.top?aff=uFpUl2Kf) @@ -59,7 +59,7 @@ _✨ All in one 的 OpenAI 接口,整合各种 API 访问方式,开箱即用 + [x] [OpenAI Max](https://openaimax.com) + [x] [OpenAI-SB](https://openai-sb.com) + [x] [CloseAI](https://console.openai-asia.com/r/2412) - + [x] 自定义渠道:例如使用自行搭建的 OpenAI 代理 + + [x] 自定义渠道:例如各种未收录的第三方代理服务 2. 支持通过**负载均衡**的方式访问多个渠道。 3. 支持 **stream 模式**,可以通过流式传输实现打字机效果。 4. 支持**多机部署**,[详见此处](#多机部署)。 diff --git a/controller/channel-test.go b/controller/channel-test.go index b1a43eff..838a2738 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -27,6 +27,8 @@ func testChannel(channel *model.Channel, request *ChatRequest) error { } else { if channel.Type == common.ChannelTypeCustom { requestURL = channel.BaseURL + } else if channel.Type == common.ChannelTypeOpenAI && channel.BaseURL != "" { + requestURL = channel.BaseURL } requestURL += "/v1/chat/completions" } diff --git a/controller/relay.go b/controller/relay.go index f2fa2dd4..ef279e3a 100644 --- a/controller/relay.go +++ b/controller/relay.go @@ -147,6 +147,10 @@ func relayHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode { requestURL := c.Request.URL.String() if channelType == common.ChannelTypeCustom { baseURL = c.GetString("base_url") + } else if channelType == common.ChannelTypeOpenAI { + if c.GetString("base_url") != "" { + baseURL = c.GetString("base_url") + } } fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL) if channelType == common.ChannelTypeAzure { diff --git a/middleware/distributor.go b/middleware/distributor.go index 624cf3b1..6fa2bc28 100644 --- a/middleware/distributor.go +++ b/middleware/distributor.go @@ -82,11 +82,9 @@ func Distribute() func(c *gin.Context) { c.Set("channel_id", channel.Id) c.Set("channel_name", channel.Name) c.Request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", channel.Key)) - if channel.Type == common.ChannelTypeCustom || channel.Type == common.ChannelTypeAzure { - c.Set("base_url", channel.BaseURL) - if channel.Type == common.ChannelTypeAzure { - c.Set("api_version", channel.Other) - } + c.Set("base_url", channel.BaseURL) + if channel.Type == common.ChannelTypeAzure { + c.Set("api_version", channel.Other) } c.Next() } diff --git a/web/src/pages/Channel/EditChannel.js b/web/src/pages/Channel/EditChannel.js index 022a9fe4..798442ac 100644 --- a/web/src/pages/Channel/EditChannel.js +++ b/web/src/pages/Channel/EditChannel.js @@ -198,6 +198,20 @@ const EditChannel = () => { handleInputChange(null, { name: 'models', value: fullModels }); }}>填入所有模型 + { + inputs.type === 1 && ( +