constants.go 3.5 KB

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