model_extra.go 632 B

12345678910111213141516171819202122232425262728293031
  1. package model
  2. func GetModelEnableGroups(modelName string) []string {
  3. // 确保缓存最新
  4. GetPricing()
  5. if modelName == "" {
  6. return make([]string, 0)
  7. }
  8. modelEnableGroupsLock.RLock()
  9. groups, ok := modelEnableGroups[modelName]
  10. modelEnableGroupsLock.RUnlock()
  11. if !ok {
  12. return make([]string, 0)
  13. }
  14. return groups
  15. }
  16. // GetModelQuotaTypes 返回指定模型的计费类型集合(来自缓存)
  17. func GetModelQuotaTypes(modelName string) []int {
  18. GetPricing()
  19. modelEnableGroupsLock.RLock()
  20. quota, ok := modelQuotaTypeMap[modelName]
  21. modelEnableGroupsLock.RUnlock()
  22. if !ok {
  23. return []int{}
  24. }
  25. return []int{quota}
  26. }