Skip to content

Commit 40ba520

Browse files
committed
feat: vertexai support proxy url(example: cloudflare ai gateway)
1 parent cf9b5f0 commit 40ba520

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

relay/adaptor/vertexai/adaptor.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var _ adaptor.Adaptor = new(Adaptor)
1919

2020
const channelName = "vertexai"
2121

22-
type Adaptor struct {}
22+
type Adaptor struct{}
2323

2424
func (a *Adaptor) Init(meta *meta.Meta) {
2525
}
@@ -75,8 +75,24 @@ func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error) {
7575
}
7676
}
7777

78-
baseUrl := fmt.Sprintf("https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:%s", meta.Config.Region, meta.Config.VertexAIProjectID, meta.Config.Region, meta.ActualModelName, suffix)
79-
return baseUrl, nil
78+
if meta.BaseURL != "" {
79+
return fmt.Sprintf(
80+
"%s/v1/projects/%s/locations/%s/publishers/google/models/%s:%s",
81+
meta.BaseURL,
82+
meta.Config.VertexAIProjectID,
83+
meta.Config.Region,
84+
meta.ActualModelName,
85+
suffix,
86+
), nil
87+
}
88+
return fmt.Sprintf(
89+
"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:%s",
90+
meta.Config.Region,
91+
meta.Config.VertexAIProjectID,
92+
meta.Config.Region,
93+
meta.ActualModelName,
94+
suffix,
95+
), nil
8096
}
8197

8298
func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error {

0 commit comments

Comments
 (0)