feat(admin): 渠道管理 - 支持渠道级出站代理
This commit is contained in:
commit
524d2910ca
16 files changed
+144
-12
No files matched your search
@@ -93,6 +93,7 @@ type ChannelRequest struct {
|
||||
Models []string `json:"models"`
|
||||
Headers []OutboundHeader `json:"headers"`
|
||||
Enabled *bool `json:"enabled"`
|
||||
ProxyURL string `json:"proxyUrl"`
|
||||
}
|
||||
|
||||
type PublicModelChannel struct {
|
||||
@@ -106,6 +107,7 @@ type PublicModelChannel struct {
|
||||
APIKey string `json:"apiKey"`
|
||||
APIFormat string `json:"apiFormat"`
|
||||
ConcurrencyLimit int `json:"concurrencyLimit"`
|
||||
ProxyURL string `json:"proxyUrl"`
|
||||
Models []string `json:"models"`
|
||||
ModelCosts []PublicChannelModelPrice `json:"modelCosts"`
|
||||
Headers []OutboundHeader `json:"headers,omitempty"`
|
||||
@@ -187,6 +189,7 @@ func (s *Service) channelFromRequest(req ChannelRequest, channel model.ModelChan
|
||||
}
|
||||
channel.ModelsJSON = string(modelsJSON)
|
||||
channel.HeadersJSON = headersJSON
|
||||
channel.ProxyURL = strings.TrimSpace(req.ProxyURL)
|
||||
if req.Enabled != nil {
|
||||
channel.Enabled = *req.Enabled
|
||||
}
|
||||
@@ -206,6 +209,9 @@ func mergeChannelRequest(req ChannelRequest, channel model.ModelChannel) Channel
|
||||
if req.Headers == nil {
|
||||
req.Headers, _ = ParseOutboundHeadersJSON(channel.HeadersJSON)
|
||||
}
|
||||
if strings.TrimSpace(req.ProxyURL) == "" {
|
||||
req.ProxyURL = channel.ProxyURL
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
@@ -232,6 +238,7 @@ func publicChannel(channel model.ModelChannel, admin bool, channelModels []model
|
||||
}
|
||||
apiKey := ""
|
||||
baseURL := channel.BaseURL
|
||||
proxyURL := ""
|
||||
var headers []OutboundHeader
|
||||
if channel.Scope == model.ChannelScopeSystem {
|
||||
if !admin {
|
||||
@@ -244,6 +251,9 @@ func publicChannel(channel model.ModelChannel, admin bool, channelModels []model
|
||||
} else if admin {
|
||||
apiKey = channel.APIKey
|
||||
}
|
||||
if admin {
|
||||
proxyURL = channel.ProxyURL
|
||||
}
|
||||
return PublicModelChannel{
|
||||
ID: channel.ID,
|
||||
UserID: channel.UserID,
|
||||
@@ -255,6 +265,7 @@ func publicChannel(channel model.ModelChannel, admin bool, channelModels []model
|
||||
APIKey: apiKey,
|
||||
APIFormat: channel.APIFormat,
|
||||
ConcurrencyLimit: channel.ConcurrencyLimit,
|
||||
ProxyURL: proxyURL,
|
||||
Models: models,
|
||||
ModelCosts: modelCosts,
|
||||
Headers: headers,
|
||||
|
||||
Reference in new issue
Block a user