|
@@ -120,7 +120,11 @@ func (a *TaskAdaptor) BuildRequestHeader(c *gin.Context, req *http.Request, info
|
|
|
return fmt.Errorf("failed to decode credentials: %w", err)
|
|
return fmt.Errorf("failed to decode credentials: %w", err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- token, err := vertexcore.AcquireAccessToken(*adc, "")
|
|
|
|
|
|
|
+ proxy := ""
|
|
|
|
|
+ if info != nil {
|
|
|
|
|
+ proxy = info.ChannelSetting.Proxy
|
|
|
|
|
+ }
|
|
|
|
|
+ token, err := vertexcore.AcquireAccessToken(*adc, proxy)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return fmt.Errorf("failed to acquire access token: %w", err)
|
|
return fmt.Errorf("failed to acquire access token: %w", err)
|
|
|
}
|
|
}
|
|
@@ -216,7 +220,7 @@ func (a *TaskAdaptor) GetModelList() []string { return []string{"veo-3.0-generat
|
|
|
func (a *TaskAdaptor) GetChannelName() string { return "vertex" }
|
|
func (a *TaskAdaptor) GetChannelName() string { return "vertex" }
|
|
|
|
|
|
|
|
// FetchTask fetch task status
|
|
// FetchTask fetch task status
|
|
|
-func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any) (*http.Response, error) {
|
|
|
|
|
|
|
+func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any, proxy string) (*http.Response, error) {
|
|
|
taskID, ok := body["task_id"].(string)
|
|
taskID, ok := body["task_id"].(string)
|
|
|
if !ok {
|
|
if !ok {
|
|
|
return nil, fmt.Errorf("invalid task_id")
|
|
return nil, fmt.Errorf("invalid task_id")
|
|
@@ -249,7 +253,7 @@ func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any) (*http
|
|
|
if err := json.Unmarshal([]byte(key), adc); err != nil {
|
|
if err := json.Unmarshal([]byte(key), adc); err != nil {
|
|
|
return nil, fmt.Errorf("failed to decode credentials: %w", err)
|
|
return nil, fmt.Errorf("failed to decode credentials: %w", err)
|
|
|
}
|
|
}
|
|
|
- token, err := vertexcore.AcquireAccessToken(*adc, "")
|
|
|
|
|
|
|
+ token, err := vertexcore.AcquireAccessToken(*adc, proxy)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, fmt.Errorf("failed to acquire access token: %w", err)
|
|
return nil, fmt.Errorf("failed to acquire access token: %w", err)
|
|
|
}
|
|
}
|
|
@@ -261,7 +265,11 @@ func (a *TaskAdaptor) FetchTask(baseUrl, key string, body map[string]any) (*http
|
|
|
req.Header.Set("Accept", "application/json")
|
|
req.Header.Set("Accept", "application/json")
|
|
|
req.Header.Set("Authorization", "Bearer "+token)
|
|
req.Header.Set("Authorization", "Bearer "+token)
|
|
|
req.Header.Set("x-goog-user-project", adc.ProjectID)
|
|
req.Header.Set("x-goog-user-project", adc.ProjectID)
|
|
|
- return service.GetHttpClient().Do(req)
|
|
|
|
|
|
|
+ client, err := service.GetHttpClientWithProxy(proxy)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return nil, fmt.Errorf("new proxy http client failed: %w", err)
|
|
|
|
|
+ }
|
|
|
|
|
+ return client.Do(req)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (a *TaskAdaptor) ParseTaskResult(respBody []byte) (*relaycommon.TaskInfo, error) {
|
|
func (a *TaskAdaptor) ParseTaskResult(respBody []byte) (*relaycommon.TaskInfo, error) {
|