You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

66 regels
2.2 KiB

  1. package service
  2. import (
  3. "strings"
  4. "github.com/QuantumNous/new-api/constant"
  5. "github.com/QuantumNous/new-api/model"
  6. )
  7. const DoubaoAssetChannelPageSize = 50
  8. const DoubaoAssetChannelType = constant.ChannelTypeDoubaoVideoCompatibleAiping
  9. var DoubaoAssetChannelTypes = VideoAssetChannelTypesForFamily(VideoAssetFamilySeedance)
  10. func ResolveDoubaoAssetChannel(userId int, tokenGroup string) (*model.Channel, error) {
  11. return ResolveDoubaoAssetChannelForModel(userId, tokenGroup, "")
  12. }
  13. func ResolveDoubaoAssetChannelForModel(userId int, tokenGroup string, modelName string) (*model.Channel, error) {
  14. return ResolveVideoAssetChannelForModel(userId, tokenGroup, modelName, VideoAssetFamilySeedance)
  15. }
  16. func GetBoundDoubaoAssetChannel(userId int, tokenGroup string) (*model.Channel, error) {
  17. return GetBoundDoubaoAssetChannelForModel(userId, tokenGroup, "")
  18. }
  19. func GetBoundDoubaoAssetChannelForModel(userId int, tokenGroup string, modelName string) (*model.Channel, error) {
  20. return GetBoundVideoAssetChannelForModel(userId, tokenGroup, modelName, VideoAssetFamilySeedance)
  21. }
  22. func HasDoubaoVideoChannelForGroupModel(tokenGroup string, modelName string) bool {
  23. return HasVideoAssetChannelForGroupModel(tokenGroup, modelName, VideoAssetFamilySeedance)
  24. }
  25. func AutoMatchDoubaoAssetChannel(tokenGroup string) (*model.Channel, error) {
  26. return autoMatchVideoAssetChannelForModel(tokenGroup, "", VideoAssetFamilySeedance)
  27. }
  28. func IsUsableDoubaoAssetChannel(channel *model.Channel, tokenGroup string) bool {
  29. return IsUsableVideoAssetChannelForFamily(channel, tokenGroup, "", VideoAssetFamilySeedance)
  30. }
  31. func IsDoubaoAssetChannelType(channelType int) bool {
  32. return channelTypeAllowed(channelType, DoubaoAssetChannelTypes)
  33. }
  34. func DoubaoAssetChannelTypeForModel(modelName string) int {
  35. if strings.HasPrefix(strings.ToLower(strings.TrimSpace(modelName)), "cdance") {
  36. return constant.ChannelTypeDoubaoVideoCompatibleTianyiYun
  37. }
  38. return DoubaoAssetChannelType
  39. }
  40. func MatchDoubaoAssetGroup(channelGroups []string, tokenGroup string) bool {
  41. tokenGroup = strings.TrimSpace(tokenGroup)
  42. if tokenGroup == "" {
  43. return false
  44. }
  45. for _, group := range channelGroups {
  46. if strings.TrimSpace(group) == tokenGroup {
  47. return true
  48. }
  49. }
  50. return false
  51. }