fix: fetch model add header passthrough rule key check
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/QuantumNous/new-api/constant"
|
"github.com/QuantumNous/new-api/constant"
|
||||||
"github.com/QuantumNous/new-api/dto"
|
"github.com/QuantumNous/new-api/dto"
|
||||||
"github.com/QuantumNous/new-api/model"
|
"github.com/QuantumNous/new-api/model"
|
||||||
|
relaychannel "github.com/QuantumNous/new-api/relay/channel"
|
||||||
"github.com/QuantumNous/new-api/relay/channel/gemini"
|
"github.com/QuantumNous/new-api/relay/channel/gemini"
|
||||||
"github.com/QuantumNous/new-api/relay/channel/ollama"
|
"github.com/QuantumNous/new-api/relay/channel/ollama"
|
||||||
"github.com/QuantumNous/new-api/service"
|
"github.com/QuantumNous/new-api/service"
|
||||||
@@ -183,6 +184,9 @@ func buildFetchModelsHeaders(channel *model.Channel, key string) (http.Header, e
|
|||||||
|
|
||||||
headerOverride := channel.GetHeaderOverride()
|
headerOverride := channel.GetHeaderOverride()
|
||||||
for k, v := range headerOverride {
|
for k, v := range headerOverride {
|
||||||
|
if relaychannel.IsHeaderPassthroughRuleKey(k) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
str, ok := v.(string)
|
str, ok := v.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("invalid header override for key %s", k)
|
return nil, fmt.Errorf("invalid header override for key %s", k)
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ func getHeaderPassthroughRegex(pattern string) (*regexp.Regexp, error) {
|
|||||||
return compiled, nil
|
return compiled, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsHeaderPassthroughRuleKey(key string) bool {
|
||||||
|
return isHeaderPassthroughRuleKey(key)
|
||||||
|
}
|
||||||
func isHeaderPassthroughRuleKey(key string) bool {
|
func isHeaderPassthroughRuleKey(key string) bool {
|
||||||
key = strings.TrimSpace(key)
|
key = strings.TrimSpace(key)
|
||||||
if key == "" {
|
if key == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user