constants.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package common
  2. import (
  3. "github.com/google/uuid"
  4. "sync"
  5. "time"
  6. )
  7. var StartTime = time.Now().Unix() // unit: second
  8. var Version = "v0.0.0" // this hard coding will be replaced automatically when building, no need to manually change
  9. var SystemName = "One API"
  10. var ServerAddress = "http://localhost:3000"
  11. var Footer = ""
  12. var Logo = ""
  13. var TopUpLink = ""
  14. var UsingSQLite = false
  15. // Any options with "Secret", "Token" in its key won't be return by GetOptions
  16. var SessionSecret = uuid.New().String()
  17. var SQLitePath = "one-api.db"
  18. var OptionMap map[string]string
  19. var OptionMapRWMutex sync.RWMutex
  20. var ItemsPerPage = 10
  21. var MaxRecentItems = 100
  22. var PasswordLoginEnabled = true
  23. var PasswordRegisterEnabled = true
  24. var EmailVerificationEnabled = false
  25. var GitHubOAuthEnabled = false
  26. var WeChatAuthEnabled = false
  27. var TurnstileCheckEnabled = false
  28. var RegisterEnabled = true
  29. var SMTPServer = ""
  30. var SMTPPort = 587
  31. var SMTPAccount = ""
  32. var SMTPFrom = ""
  33. var SMTPToken = ""
  34. var GitHubClientId = ""
  35. var GitHubClientSecret = ""
  36. var WeChatServerAddress = ""
  37. var WeChatServerToken = ""
  38. var WeChatAccountQRCodeImageURL = ""
  39. var TurnstileSiteKey = ""
  40. var TurnstileSecretKey = ""
  41. var QuotaForNewUser = 0
  42. var ChannelDisableThreshold = 5.0
  43. var AutomaticDisableChannelEnabled = false
  44. var QuotaRemindThreshold = 1000
  45. var PreConsumedQuota = 500
  46. var RootUserEmail = ""
  47. const (
  48. RoleGuestUser = 0
  49. RoleCommonUser = 1
  50. RoleAdminUser = 10
  51. RoleRootUser = 100
  52. )
  53. var (
  54. FileUploadPermission = RoleGuestUser
  55. FileDownloadPermission = RoleGuestUser
  56. ImageUploadPermission = RoleGuestUser
  57. ImageDownloadPermission = RoleGuestUser
  58. )
  59. // All duration's unit is seconds
  60. // Shouldn't larger then RateLimitKeyExpirationDuration
  61. var (
  62. GlobalApiRateLimitNum = 180
  63. GlobalApiRateLimitDuration int64 = 3 * 60
  64. GlobalWebRateLimitNum = 60
  65. GlobalWebRateLimitDuration int64 = 3 * 60
  66. UploadRateLimitNum = 10
  67. UploadRateLimitDuration int64 = 60
  68. DownloadRateLimitNum = 10
  69. DownloadRateLimitDuration int64 = 60
  70. CriticalRateLimitNum = 20
  71. CriticalRateLimitDuration int64 = 20 * 60
  72. )
  73. var RateLimitKeyExpirationDuration = 20 * time.Minute
  74. const (
  75. UserStatusEnabled = 1 // don't use 0, 0 is the default value!
  76. UserStatusDisabled = 2 // also don't use 0
  77. )
  78. const (
  79. TokenStatusEnabled = 1 // don't use 0, 0 is the default value!
  80. TokenStatusDisabled = 2 // also don't use 0
  81. TokenStatusExpired = 3
  82. TokenStatusExhausted = 4
  83. )
  84. const (
  85. RedemptionCodeStatusEnabled = 1 // don't use 0, 0 is the default value!
  86. RedemptionCodeStatusDisabled = 2 // also don't use 0
  87. RedemptionCodeStatusUsed = 3 // also don't use 0
  88. )
  89. const (
  90. ChannelStatusUnknown = 0
  91. ChannelStatusEnabled = 1 // don't use 0, 0 is the default value!
  92. ChannelStatusDisabled = 2 // also don't use 0
  93. )
  94. const (
  95. ChannelTypeUnknown = 0
  96. ChannelTypeOpenAI = 1
  97. ChannelTypeAPI2D = 2
  98. ChannelTypeAzure = 3
  99. ChannelTypeCloseAI = 4
  100. ChannelTypeOpenAISB = 5
  101. ChannelTypeOpenAIMax = 6
  102. ChannelTypeOhMyGPT = 7
  103. ChannelTypeCustom = 8
  104. ChannelTypeAILS = 9
  105. ChannelTypeAIProxy = 10
  106. ChannelTypePaLM = 11
  107. )
  108. var ChannelBaseURLs = []string{
  109. "", // 0
  110. "https://api.openai.com", // 1
  111. "https://oa.api2d.net", // 2
  112. "", // 3
  113. "https://api.openai-asia.com", // 4
  114. "https://api.openai-sb.com", // 5
  115. "https://api.openaimax.com", // 6
  116. "https://api.ohmygpt.com", // 7
  117. "", // 8
  118. "https://api.caipacity.com", // 9
  119. "https://api.aiproxy.io", // 10
  120. "", // 11
  121. }