mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-15 04:33:42 +08:00
🎨 Change the method of getting channel parameters
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"one-api/common"
|
||||
"one-api/model"
|
||||
"one-api/types"
|
||||
"strings"
|
||||
|
||||
@@ -28,17 +29,22 @@ type BaseProvider struct {
|
||||
ImagesVariations string
|
||||
Proxy string
|
||||
Context *gin.Context
|
||||
Channel *model.Channel
|
||||
}
|
||||
|
||||
// 获取基础URL
|
||||
func (p *BaseProvider) GetBaseURL() string {
|
||||
if p.Context.GetString("base_url") != "" {
|
||||
return p.Context.GetString("base_url")
|
||||
if p.Channel.GetBaseURL() != "" {
|
||||
return p.Channel.GetBaseURL()
|
||||
}
|
||||
|
||||
return p.BaseURL
|
||||
}
|
||||
|
||||
func (p *BaseProvider) SetChannel(channel *model.Channel) {
|
||||
p.Channel = channel
|
||||
}
|
||||
|
||||
// 获取完整请求URL
|
||||
func (p *BaseProvider) GetFullRequestURL(requestURL string, modelName string) string {
|
||||
baseURL := strings.TrimSuffix(p.GetBaseURL(), "/")
|
||||
|
||||
@@ -12,6 +12,7 @@ type ProviderInterface interface {
|
||||
GetFullRequestURL(requestURL string, modelName string) string
|
||||
GetRequestHeaders() (headers map[string]string)
|
||||
SupportAPI(relayMode int) bool
|
||||
SetChannel(channel *model.Channel)
|
||||
}
|
||||
|
||||
// 完成接口
|
||||
|
||||
Reference in New Issue
Block a user