feat(ai-proxy): 新增 providerBasePath 配置并优化 providerDomain 处理方式 (#3686)

This commit is contained in:
rinfx
2026-04-08 15:23:15 +08:00
committed by GitHub
parent 1c9e981bf2
commit 228eb27e6a
7 changed files with 428 additions and 42 deletions

View File

@@ -10,11 +10,11 @@ import (
"time"
"github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util"
"github.com/higress-group/wasm-go/pkg/log"
"github.com/higress-group/wasm-go/pkg/wrapper"
"github.com/google/uuid"
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm"
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types"
"github.com/higress-group/wasm-go/pkg/log"
"github.com/higress-group/wasm-go/pkg/wrapper"
"github.com/tidwall/gjson"
)
@@ -198,6 +198,11 @@ func (c *ProviderConfig) transformRequestHeadersAndBody(ctx wrapper.HttpContext,
handler.TransformRequestHeaders(ctx, ApiNameChatCompletion, modifiedHeaders)
}
// Apply providerBasePath if configured
if c.providerBasePath != "" {
modifiedHeaders.Set(":path", c.applyProviderBasePath(modifiedHeaders.Get(":path")))
}
var err error
if handler, ok := activeProvider.(TransformRequestBodyHandler); ok {
body, err = handler.TransformRequestBody(ctx, ApiNameChatCompletion, body)