Revert "feat(model-mapper): 新增 modelToHeader 配置项并优化 header 更新逻辑 || feat(model-mapper): Added modelToHeader configuration item and optimized header update logic (#3689)"

This reverts commit 60ce07d297.
This commit is contained in:
johnlanni
2026-04-11 07:57:38 +08:00
parent 899633ea5e
commit e2beb6cd45
2 changed files with 0 additions and 216 deletions

View File

@@ -42,7 +42,6 @@ type Config struct {
prefixModelMapping []ModelMapping
defaultModel string
enableOnPathSuffix []string
modelToHeader string
}
func parseConfig(json gjson.Result, config *Config) error {
@@ -50,10 +49,6 @@ func parseConfig(json gjson.Result, config *Config) error {
if config.modelKey == "" {
config.modelKey = "model"
}
config.modelToHeader = json.Get("modelToHeader").String()
if config.modelToHeader == "" {
config.modelToHeader = "x-higress-llm-model"
}
modelMapping := json.Get("modelMapping")
if modelMapping.Exists() && !modelMapping.IsObject() {
@@ -149,8 +144,6 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config) types.Action {
return types.ActionContinue
}
// Disable re-route since the plugin may modify some headers related to the chosen route.
ctx.DisableReroute()
// Prepare for body processing
proxywasm.RemoveHttpRequestHeader("content-length")
// 100MB buffer limit
@@ -190,12 +183,6 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config Config, body []byte) type
}
if newModel != "" && newModel != oldModel {
// if x-higress-llm-model header is set, and it is not the same as the new model, update it
// this is to support fallback and token rate limit
model, _ := proxywasm.GetHttpRequestHeader(config.modelToHeader)
if model != "" && model != newModel {
proxywasm.ReplaceHttpRequestHeader(config.modelToHeader, newModel)
}
newBody, err := sjson.SetBytes(body, config.modelKey, newModel)
if err != nil {
log.Errorf("failed to update model: %v", err)