fix: support vertex multi-key task fetch in content proxy

This commit is contained in:
Seefs
2026-02-27 17:07:10 +08:00
parent 5ed997905c
commit 985189af23
2 changed files with 27 additions and 2 deletions

View File

@@ -166,7 +166,12 @@ func getVertexVideoURL(channel *model.Channel, task *model.Task) (string, error)
return "", fmt.Errorf("vertex task adaptor not found")
}
resp, err := adaptor.FetchTask(baseURL, channel.Key, map[string]any{
key := getVertexTaskKey(channel, task)
if key == "" {
return "", fmt.Errorf("vertex key not available for task")
}
resp, err := adaptor.FetchTask(baseURL, key, map[string]any{
"task_id": task.GetUpstreamTaskID(),
"action": task.Action,
}, channel.GetSetting().Proxy)
@@ -193,6 +198,25 @@ func getVertexVideoURL(channel *model.Channel, task *model.Task) (string, error)
return "", fmt.Errorf("vertex video url not found")
}
func getVertexTaskKey(channel *model.Channel, task *model.Task) string {
if task != nil {
if key := strings.TrimSpace(task.PrivateData.Key); key != "" {
return key
}
}
if channel == nil {
return ""
}
keys := channel.GetKeys()
for _, key := range keys {
key = strings.TrimSpace(key)
if key != "" {
return key
}
}
return strings.TrimSpace(channel.Key)
}
func extractVertexVideoURLFromTaskData(task *model.Task) string {
if task == nil || len(task.Data) == 0 {
return ""

View File

@@ -173,7 +173,8 @@ func InitTask(platform constant.TaskPlatform, relayInfo *commonRelay.RelayInfo)
properties := Properties{}
privateData := TaskPrivateData{}
if relayInfo != nil && relayInfo.ChannelMeta != nil {
if relayInfo.ChannelMeta.ChannelType == constant.ChannelTypeGemini {
if relayInfo.ChannelMeta.ChannelType == constant.ChannelTypeGemini ||
relayInfo.ChannelMeta.ChannelType == constant.ChannelTypeVertexAi {
privateData.Key = relayInfo.ChannelMeta.ApiKey
}
if relayInfo.UpstreamModelName != "" {