Просмотр исходного кода

Merge pull request #1113 from tbphp/tbphp_vertex_gemini_global_region

fix: Vertex channel global region format
IcedTangerine 9 месяцев назад
Родитель
Сommit
bf016543c3
1 измененных файлов с 17 добавлено и 8 удалено
  1. 17 8
      relay/channel/vertex/adaptor.go

+ 17 - 8
relay/channel/vertex/adaptor.go

@@ -95,14 +95,23 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
 		} else {
 		} else {
 			suffix = "generateContent"
 			suffix = "generateContent"
 		}
 		}
-		return fmt.Sprintf(
-			"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:%s",
-			region,
-			adc.ProjectID,
-			region,
-			info.UpstreamModelName,
-			suffix,
-		), nil
+		if region == "global" {
+			return fmt.Sprintf(
+				"https://aiplatform.googleapis.com/v1/projects/%s/locations/global/publishers/google/models/%s:%s",
+				adc.ProjectID,
+				info.UpstreamModelName,
+				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,
+				info.UpstreamModelName,
+				suffix,
+			), nil
+		}
 	} else if a.RequestMode == RequestModeClaude {
 	} else if a.RequestMode == RequestModeClaude {
 		if info.IsStream {
 		if info.IsStream {
 			suffix = "streamRawPredict?alt=sse"
 			suffix = "streamRawPredict?alt=sse"