model_extra.go 745 B

123456789101112131415161718192021222324
  1. package model
  2. // GetModelEnableGroups 返回指定模型名称可用的用户分组列表。
  3. // 复用缓存的定价映射,避免额外的数据库查询。
  4. func GetModelEnableGroups(modelName string) []string {
  5. for _, p := range GetPricing() {
  6. if p.ModelName == modelName {
  7. return p.EnableGroup
  8. }
  9. }
  10. return make([]string, 0)
  11. }
  12. // GetModelQuotaType 返回指定模型的计费类型(quota_type)。
  13. // 复用缓存的定价映射,避免额外数据库查询。
  14. // 如果未找到对应模型,默认返回 0。
  15. func GetModelQuotaType(modelName string) int {
  16. for _, p := range GetPricing() {
  17. if p.ModelName == modelName {
  18. return p.QuotaType
  19. }
  20. }
  21. return 0
  22. }