mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
fix: make the 'openai_organization' parameter actually work.
This commit is contained in:
parent
0fb98e44a7
commit
f63ad9c03c
@ -156,7 +156,7 @@ func Distribute() func(c *gin.Context) {
|
|||||||
ban = false
|
ban = false
|
||||||
}
|
}
|
||||||
if nil != channel.OpenAIOrganization {
|
if nil != channel.OpenAIOrganization {
|
||||||
c.Request.Header.Set("OpenAI-Organization", *channel.OpenAIOrganization)
|
c.Set("channel_organization", *channel.OpenAIOrganization)
|
||||||
}
|
}
|
||||||
c.Set("auto_ban", ban)
|
c.Set("auto_ban", ban)
|
||||||
c.Set("model_mapping", channel.GetModelMapping())
|
c.Set("model_mapping", channel.GetModelMapping())
|
||||||
|
@ -49,11 +49,8 @@ func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, info *re
|
|||||||
req.Header.Set("api-key", info.ApiKey)
|
req.Header.Set("api-key", info.ApiKey)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if info.ChannelType == common.ChannelTypeOpenAI {
|
if info.ChannelType == common.ChannelTypeOpenAI && "" != info.Organization {
|
||||||
orgId := c.GetHeader("OpenAI-Organization")
|
req.Header.Set("OpenAI-Organization", info.Organization)
|
||||||
if "" != orgId {
|
|
||||||
req.Header.Set("OpenAI-Organization", orgId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
req.Header.Set("Authorization", "Bearer "+info.ApiKey)
|
req.Header.Set("Authorization", "Bearer "+info.ApiKey)
|
||||||
//if info.ChannelType == common.ChannelTypeOpenRouter {
|
//if info.ChannelType == common.ChannelTypeOpenRouter {
|
||||||
|
@ -24,6 +24,7 @@ type RelayInfo struct {
|
|||||||
ApiVersion string
|
ApiVersion string
|
||||||
PromptTokens int
|
PromptTokens int
|
||||||
ApiKey string
|
ApiKey string
|
||||||
|
Organization string
|
||||||
BaseUrl string
|
BaseUrl string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
|
|||||||
ApiType: apiType,
|
ApiType: apiType,
|
||||||
ApiVersion: c.GetString("api_version"),
|
ApiVersion: c.GetString("api_version"),
|
||||||
ApiKey: strings.TrimPrefix(c.Request.Header.Get("Authorization"), "Bearer "),
|
ApiKey: strings.TrimPrefix(c.Request.Header.Get("Authorization"), "Bearer "),
|
||||||
|
Organization: c.GetString("channel_organization"),
|
||||||
}
|
}
|
||||||
if info.BaseUrl == "" {
|
if info.BaseUrl == "" {
|
||||||
info.BaseUrl = common.ChannelBaseURLs[channelType]
|
info.BaseUrl = common.ChannelBaseURLs[channelType]
|
||||||
|
Loading…
Reference in New Issue
Block a user