Commit 621006d1 by 我秦始皇 Committed by GitHub

fix: make the 'openai_organization' parameter actually work.

parent d6672489
......@@ -156,7 +156,7 @@ func Distribute() func(c *gin.Context) {
ban = false
}
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("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)
return nil
}
if info.ChannelType == common.ChannelTypeOpenAI {
orgId := c.GetHeader("OpenAI-Organization")
if "" != orgId {
req.Header.Set("OpenAI-Organization", orgId)
}
if info.ChannelType == common.ChannelTypeOpenAI && "" != info.Organization {
req.Header.Set("OpenAI-Organization", info.Organization)
}
req.Header.Set("Authorization", "Bearer "+info.ApiKey)
//if info.ChannelType == common.ChannelTypeOpenRouter {
......
......@@ -24,6 +24,7 @@ type RelayInfo struct {
ApiVersion string
PromptTokens int
ApiKey string
Organization string
BaseUrl string
}
......@@ -52,6 +53,7 @@ func GenRelayInfo(c *gin.Context) *RelayInfo {
ApiType: apiType,
ApiVersion: c.GetString("api_version"),
ApiKey: strings.TrimPrefix(c.Request.Header.Get("Authorization"), "Bearer "),
Organization: c.GetString("channel_organization"),
}
if info.BaseUrl == "" {
info.BaseUrl = common.ChannelBaseURLs[channelType]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment