mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 02:44:40 +00:00
fix: support vertex multi-key task fetch in content proxy
This commit is contained in:
@@ -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 ""
|
||||
|
||||
@@ -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 != "" {
|
||||
|
||||
Reference in New Issue
Block a user