global.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package model_setting
  2. import (
  3. "strings"
  4. "github.com/QuantumNous/new-api/setting/config"
  5. )
  6. type GlobalSettings struct {
  7. PassThroughRequestEnabled bool `json:"pass_through_request_enabled"`
  8. ThinkingModelBlacklist []string `json:"thinking_model_blacklist"`
  9. }
  10. // 默认配置
  11. var defaultOpenaiSettings = GlobalSettings{
  12. PassThroughRequestEnabled: false,
  13. ThinkingModelBlacklist: []string{
  14. "moonshotai/kimi-k2-thinking",
  15. "kimi-k2-thinking",
  16. },
  17. }
  18. // 全局实例
  19. var globalSettings = defaultOpenaiSettings
  20. func init() {
  21. // 注册到全局配置管理器
  22. config.GlobalConfig.Register("global", &globalSettings)
  23. }
  24. func GetGlobalSettings() *GlobalSettings {
  25. return &globalSettings
  26. }
  27. // ShouldPreserveThinkingSuffix 判断模型是否配置为保留 thinking/-nothinking/-low/-high/-medium 后缀
  28. func ShouldPreserveThinkingSuffix(modelName string) bool {
  29. target := strings.TrimSpace(modelName)
  30. if target == "" {
  31. return false
  32. }
  33. for _, entry := range globalSettings.ThinkingModelBlacklist {
  34. if strings.TrimSpace(entry) == target {
  35. return true
  36. }
  37. }
  38. return false
  39. }