mirror of
https://github.com/alibaba/higress.git
synced 2026-05-08 04:17:27 +08:00
vertex support global region (#3213)
This commit is contained in:
@@ -25,12 +25,13 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
vertexAuthDomain = "oauth2.googleapis.com"
|
vertexAuthDomain = "oauth2.googleapis.com"
|
||||||
vertexDomain = "{REGION}-aiplatform.googleapis.com"
|
vertexDomain = "aiplatform.googleapis.com"
|
||||||
// /v1/projects/{PROJECT_ID}/locations/{REGION}/publishers/google/models/{MODEL_ID}:{ACTION}
|
// /v1/projects/{PROJECT_ID}/locations/{REGION}/publishers/google/models/{MODEL_ID}:{ACTION}
|
||||||
vertexPathTemplate = "/v1/projects/%s/locations/%s/publishers/google/models/%s:%s"
|
vertexPathTemplate = "/v1/projects/%s/locations/%s/publishers/google/models/%s:%s"
|
||||||
vertexChatCompletionAction = "generateContent"
|
vertexChatCompletionAction = "generateContent"
|
||||||
vertexChatCompletionStreamAction = "streamGenerateContent?alt=sse"
|
vertexChatCompletionStreamAction = "streamGenerateContent?alt=sse"
|
||||||
vertexEmbeddingAction = "predict"
|
vertexEmbeddingAction = "predict"
|
||||||
|
vertexGlobalRegion = "global"
|
||||||
)
|
)
|
||||||
|
|
||||||
type vertexProviderInitializer struct{}
|
type vertexProviderInitializer struct{}
|
||||||
@@ -94,8 +95,13 @@ func (v *vertexProvider) OnRequestHeaders(ctx wrapper.HttpContext, apiName ApiNa
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *vertexProvider) TransformRequestHeaders(ctx wrapper.HttpContext, apiName ApiName, headers http.Header) {
|
func (v *vertexProvider) TransformRequestHeaders(ctx wrapper.HttpContext, apiName ApiName, headers http.Header) {
|
||||||
vertexRegionDomain := strings.Replace(vertexDomain, "{REGION}", v.config.vertexRegion, 1)
|
var finalVertexDomain string
|
||||||
util.OverwriteRequestHostHeader(headers, vertexRegionDomain)
|
if v.config.vertexRegion != vertexGlobalRegion {
|
||||||
|
finalVertexDomain = fmt.Sprintf("%s-%s", v.config.vertexRegion, vertexDomain)
|
||||||
|
} else {
|
||||||
|
finalVertexDomain = vertexDomain
|
||||||
|
}
|
||||||
|
util.OverwriteRequestHostHeader(headers, finalVertexDomain)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *vertexProvider) getToken() (cached bool, err error) {
|
func (v *vertexProvider) getToken() (cached bool, err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user