fix(relay): wrong URL for claude model in GCP Vertex AI
This commit is contained in:
@@ -90,7 +90,43 @@ func (a *Adaptor) getRequestUrl(info *relaycommon.RelayInfo, modelName, suffix s
|
|||||||
}
|
}
|
||||||
a.AccountCredentials = *adc
|
a.AccountCredentials = *adc
|
||||||
|
|
||||||
if a.RequestMode == RequestModeLlama {
|
if a.RequestMode == RequestModeGemini {
|
||||||
|
if region == "global" {
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"https://aiplatform.googleapis.com/v1/projects/%s/locations/global/publishers/google/models/%s:%s",
|
||||||
|
adc.ProjectID,
|
||||||
|
modelName,
|
||||||
|
suffix,
|
||||||
|
), nil
|
||||||
|
} else {
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:%s",
|
||||||
|
region,
|
||||||
|
adc.ProjectID,
|
||||||
|
region,
|
||||||
|
modelName,
|
||||||
|
suffix,
|
||||||
|
), nil
|
||||||
|
}
|
||||||
|
} else if a.RequestMode == RequestModeClaude {
|
||||||
|
if region == "global" {
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"https://aiplatform.googleapis.com/v1/projects/%s/locations/global/publishers/anthropic/models/%s:%s",
|
||||||
|
adc.ProjectID,
|
||||||
|
modelName,
|
||||||
|
suffix,
|
||||||
|
), nil
|
||||||
|
} else {
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/anthropic/models/%s:%s",
|
||||||
|
region,
|
||||||
|
adc.ProjectID,
|
||||||
|
region,
|
||||||
|
modelName,
|
||||||
|
suffix,
|
||||||
|
), nil
|
||||||
|
}
|
||||||
|
} else if a.RequestMode == RequestModeLlama {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"https://%s-aiplatform.googleapis.com/v1beta1/projects/%s/locations/%s/endpoints/openapi/chat/completions",
|
"https://%s-aiplatform.googleapis.com/v1beta1/projects/%s/locations/%s/endpoints/openapi/chat/completions",
|
||||||
region,
|
region,
|
||||||
@@ -98,24 +134,6 @@ func (a *Adaptor) getRequestUrl(info *relaycommon.RelayInfo, modelName, suffix s
|
|||||||
region,
|
region,
|
||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if region == "global" {
|
|
||||||
return fmt.Sprintf(
|
|
||||||
"https://aiplatform.googleapis.com/v1/projects/%s/locations/global/publishers/google/models/%s:%s",
|
|
||||||
adc.ProjectID,
|
|
||||||
modelName,
|
|
||||||
suffix,
|
|
||||||
), nil
|
|
||||||
} else {
|
|
||||||
return fmt.Sprintf(
|
|
||||||
"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:%s",
|
|
||||||
region,
|
|
||||||
adc.ProjectID,
|
|
||||||
region,
|
|
||||||
modelName,
|
|
||||||
suffix,
|
|
||||||
), nil
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if region == "global" {
|
if region == "global" {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
@@ -134,6 +152,7 @@ func (a *Adaptor) getRequestUrl(info *relaycommon.RelayInfo, modelName, suffix s
|
|||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return "", errors.New("unsupported request mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
||||||
@@ -187,7 +206,7 @@ func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Header, info *rel
|
|||||||
}
|
}
|
||||||
req.Set("Authorization", "Bearer "+accessToken)
|
req.Set("Authorization", "Bearer "+accessToken)
|
||||||
}
|
}
|
||||||
if a.AccountCredentials.ProjectID != "" {
|
if a.AccountCredentials.ProjectID != "" {
|
||||||
req.Set("x-goog-user-project", a.AccountCredentials.ProjectID)
|
req.Set("x-goog-user-project", a.AccountCredentials.ProjectID)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user