mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-20 19:01:02 +00:00
refactor: use adaptor to do relay & test
This commit is contained in:
@@ -8,35 +8,41 @@ import (
|
||||
)
|
||||
|
||||
type RelayMeta struct {
|
||||
Mode int
|
||||
ChannelType int
|
||||
ChannelId int
|
||||
TokenId int
|
||||
TokenName string
|
||||
UserId int
|
||||
Group string
|
||||
ModelMapping map[string]string
|
||||
BaseURL string
|
||||
APIVersion string
|
||||
APIKey string
|
||||
APIType int
|
||||
Config map[string]string
|
||||
Mode int
|
||||
ChannelType int
|
||||
ChannelId int
|
||||
TokenId int
|
||||
TokenName string
|
||||
UserId int
|
||||
Group string
|
||||
ModelMapping map[string]string
|
||||
BaseURL string
|
||||
APIVersion string
|
||||
APIKey string
|
||||
APIType int
|
||||
Config map[string]string
|
||||
IsStream bool
|
||||
OriginModelName string
|
||||
ActualModelName string
|
||||
RequestURLPath string
|
||||
PromptTokens int // only for DoResponse
|
||||
}
|
||||
|
||||
func GetRelayMeta(c *gin.Context) *RelayMeta {
|
||||
meta := RelayMeta{
|
||||
Mode: constant.Path2RelayMode(c.Request.URL.Path),
|
||||
ChannelType: c.GetInt("channel"),
|
||||
ChannelId: c.GetInt("channel_id"),
|
||||
TokenId: c.GetInt("token_id"),
|
||||
TokenName: c.GetString("token_name"),
|
||||
UserId: c.GetInt("id"),
|
||||
Group: c.GetString("group"),
|
||||
ModelMapping: c.GetStringMapString("model_mapping"),
|
||||
BaseURL: c.GetString("base_url"),
|
||||
APIVersion: c.GetString("api_version"),
|
||||
APIKey: strings.TrimPrefix(c.Request.Header.Get("Authorization"), "Bearer "),
|
||||
Config: nil,
|
||||
Mode: constant.Path2RelayMode(c.Request.URL.Path),
|
||||
ChannelType: c.GetInt("channel"),
|
||||
ChannelId: c.GetInt("channel_id"),
|
||||
TokenId: c.GetInt("token_id"),
|
||||
TokenName: c.GetString("token_name"),
|
||||
UserId: c.GetInt("id"),
|
||||
Group: c.GetString("group"),
|
||||
ModelMapping: c.GetStringMapString("model_mapping"),
|
||||
BaseURL: c.GetString("base_url"),
|
||||
APIVersion: c.GetString("api_version"),
|
||||
APIKey: strings.TrimPrefix(c.Request.Header.Get("Authorization"), "Bearer "),
|
||||
Config: nil,
|
||||
RequestURLPath: c.Request.URL.String(),
|
||||
}
|
||||
if meta.ChannelType == common.ChannelTypeAzure {
|
||||
meta.APIVersion = GetAzureAPIVersion(c)
|
||||
|
Reference in New Issue
Block a user