constants.go 3.7 KB

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