feat: 支持vertex ai渠道多个部署地区

This commit is contained in:
CalciumIon
2024-08-28 18:43:40 +08:00
parent c41820541d
commit e60f200192
6 changed files with 75 additions and 17 deletions

View File

@@ -199,6 +199,25 @@ func AddChannel(c *gin.Context) {
channel.CreatedTime = common.GetTimestamp()
keys := strings.Split(channel.Key, "\n")
if channel.Type == common.ChannelTypeVertexAi {
if channel.Other == "" {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": "部署地区不能为空",
})
return
} else {
if common.IsJsonStr(channel.Other) {
// must have default
regionMap := common.StrToMap(channel.Other)
if regionMap["default"] == nil {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": "必须包含default字段",
})
return
}
}
}
keys = []string{channel.Key}
}
channels := make([]model.Channel, 0, len(keys))