| | package common |
| |
|
| | import ( |
| | |
| | |
| | "sync" |
| | "time" |
| |
|
| | "github.com/google/uuid" |
| | ) |
| |
|
| | var StartTime = time.Now().Unix() |
| | var Version = "v0.0.0" |
| | var SystemName = "New API" |
| | var Footer = "" |
| | var Logo = "" |
| | var TopUpLink = "" |
| |
|
| | |
| | |
| | var QuotaPerUnit = 500 * 1000.0 |
| | var DisplayInCurrencyEnabled = true |
| | var DisplayTokenStatEnabled = true |
| | var DrawingEnabled = true |
| | var TaskEnabled = true |
| | var DataExportEnabled = true |
| | var DataExportInterval = 5 |
| | var DataExportDefaultTime = "hour" |
| | var DefaultCollapseSidebar = false |
| |
|
| | |
| |
|
| | var SessionSecret = uuid.New().String() |
| | var CryptoSecret = uuid.New().String() |
| |
|
| | var OptionMap map[string]string |
| | var OptionMapRWMutex sync.RWMutex |
| |
|
| | var ItemsPerPage = 10 |
| | var MaxRecentItems = 100 |
| |
|
| | var PasswordLoginEnabled = true |
| | var PasswordRegisterEnabled = true |
| | var EmailVerificationEnabled = false |
| | var GitHubOAuthEnabled = false |
| | var LinuxDOOAuthEnabled = false |
| | var WeChatAuthEnabled = false |
| | var TelegramOAuthEnabled = false |
| | var TurnstileCheckEnabled = false |
| | var RegisterEnabled = true |
| |
|
| | var EmailDomainRestrictionEnabled = false |
| | var EmailAliasRestrictionEnabled = false |
| | var EmailDomainWhitelist = []string{ |
| | "gmail.com", |
| | "163.com", |
| | "126.com", |
| | "qq.com", |
| | "outlook.com", |
| | "hotmail.com", |
| | "icloud.com", |
| | "yahoo.com", |
| | "foxmail.com", |
| | } |
| | var EmailLoginAuthServerList = []string{ |
| | "smtp.sendcloud.net", |
| | "smtp.azurecomm.net", |
| | } |
| |
|
| | var DebugEnabled bool |
| | var MemoryCacheEnabled bool |
| |
|
| | var LogConsumeEnabled = true |
| |
|
| | var SMTPServer = "" |
| | var SMTPPort = 587 |
| | var SMTPSSLEnabled = false |
| | var SMTPAccount = "" |
| | var SMTPFrom = "" |
| | var SMTPToken = "" |
| |
|
| | var GitHubClientId = "" |
| | var GitHubClientSecret = "" |
| | var LinuxDOClientId = "" |
| | var LinuxDOClientSecret = "" |
| |
|
| | var WeChatServerAddress = "" |
| | var WeChatServerToken = "" |
| | var WeChatAccountQRCodeImageURL = "" |
| |
|
| | var TurnstileSiteKey = "" |
| | var TurnstileSecretKey = "" |
| |
|
| | var TelegramBotToken = "" |
| | var TelegramBotName = "" |
| |
|
| | var QuotaForNewUser = 0 |
| | var QuotaForInviter = 0 |
| | var QuotaForInvitee = 0 |
| | var ChannelDisableThreshold = 5.0 |
| | var AutomaticDisableChannelEnabled = false |
| | var AutomaticEnableChannelEnabled = false |
| | var QuotaRemindThreshold = 1000 |
| | var PreConsumedQuota = 500 |
| |
|
| | var RetryTimes = 0 |
| |
|
| | |
| |
|
| | var IsMasterNode bool |
| |
|
| | var requestInterval int |
| | var RequestInterval time.Duration |
| |
|
| | var SyncFrequency int |
| |
|
| | var BatchUpdateEnabled = false |
| | var BatchUpdateInterval int |
| |
|
| | var RelayTimeout int |
| |
|
| | var GeminiSafetySetting string |
| |
|
| | |
| | var CohereSafetySetting string |
| |
|
| | const ( |
| | RequestIdKey = "X-Oneapi-Request-Id" |
| | ) |
| |
|
| | const ( |
| | RoleGuestUser = 0 |
| | RoleCommonUser = 1 |
| | RoleAdminUser = 10 |
| | RoleRootUser = 100 |
| | ) |
| |
|
| | func IsValidateRole(role int) bool { |
| | return role == RoleGuestUser || role == RoleCommonUser || role == RoleAdminUser || role == RoleRootUser |
| | } |
| |
|
| | var ( |
| | FileUploadPermission = RoleGuestUser |
| | FileDownloadPermission = RoleGuestUser |
| | ImageUploadPermission = RoleGuestUser |
| | ImageDownloadPermission = RoleGuestUser |
| | ) |
| |
|
| | |
| | |
| | var ( |
| | GlobalApiRateLimitEnable bool |
| | GlobalApiRateLimitNum int |
| | GlobalApiRateLimitDuration int64 |
| |
|
| | GlobalWebRateLimitEnable bool |
| | GlobalWebRateLimitNum int |
| | GlobalWebRateLimitDuration int64 |
| |
|
| | UploadRateLimitNum = 10 |
| | UploadRateLimitDuration int64 = 60 |
| |
|
| | DownloadRateLimitNum = 10 |
| | DownloadRateLimitDuration int64 = 60 |
| |
|
| | CriticalRateLimitNum = 20 |
| | CriticalRateLimitDuration int64 = 20 * 60 |
| | ) |
| |
|
| | var RateLimitKeyExpirationDuration = 20 * time.Minute |
| |
|
| | const ( |
| | UserStatusEnabled = 1 |
| | UserStatusDisabled = 2 |
| | ) |
| |
|
| | const ( |
| | TokenStatusEnabled = 1 |
| | TokenStatusDisabled = 2 |
| | TokenStatusExpired = 3 |
| | TokenStatusExhausted = 4 |
| | ) |
| |
|
| | const ( |
| | RedemptionCodeStatusEnabled = 1 |
| | RedemptionCodeStatusDisabled = 2 |
| | RedemptionCodeStatusUsed = 3 |
| | ) |
| |
|
| | const ( |
| | ChannelStatusUnknown = 0 |
| | ChannelStatusEnabled = 1 |
| | ChannelStatusManuallyDisabled = 2 |
| | ChannelStatusAutoDisabled = 3 |
| | ) |
| |
|
| | const ( |
| | ChannelTypeUnknown = 0 |
| | ChannelTypeOpenAI = 1 |
| | ChannelTypeMidjourney = 2 |
| | ChannelTypeAzure = 3 |
| | ChannelTypeOllama = 4 |
| | ChannelTypeMidjourneyPlus = 5 |
| | ChannelTypeOpenAIMax = 6 |
| | ChannelTypeOhMyGPT = 7 |
| | ChannelTypeCustom = 8 |
| | ChannelTypeAILS = 9 |
| | ChannelTypeAIProxy = 10 |
| | ChannelTypePaLM = 11 |
| | ChannelTypeAPI2GPT = 12 |
| | ChannelTypeAIGC2D = 13 |
| | ChannelTypeAnthropic = 14 |
| | ChannelTypeBaidu = 15 |
| | ChannelTypeZhipu = 16 |
| | ChannelTypeAli = 17 |
| | ChannelTypeXunfei = 18 |
| | ChannelType360 = 19 |
| | ChannelTypeOpenRouter = 20 |
| | ChannelTypeAIProxyLibrary = 21 |
| | ChannelTypeFastGPT = 22 |
| | ChannelTypeTencent = 23 |
| | ChannelTypeGemini = 24 |
| | ChannelTypeMoonshot = 25 |
| | ChannelTypeZhipu_v4 = 26 |
| | ChannelTypePerplexity = 27 |
| | ChannelTypeLingYiWanWu = 31 |
| | ChannelTypeAws = 33 |
| | ChannelTypeCohere = 34 |
| | ChannelTypeMiniMax = 35 |
| | ChannelTypeSunoAPI = 36 |
| | ChannelTypeDify = 37 |
| | ChannelTypeJina = 38 |
| | ChannelCloudflare = 39 |
| | ChannelTypeSiliconFlow = 40 |
| | ChannelTypeVertexAi = 41 |
| | ChannelTypeMistral = 42 |
| | ChannelTypeDeepSeek = 43 |
| | ChannelTypeMokaAI = 44 |
| | ChannelTypeVolcEngine = 45 |
| | ChannelTypeBaiduV2 = 46 |
| | ChannelTypeXinference = 47 |
| | ChannelTypeXai = 48 |
| | ChannelTypeCoze = 49 |
| | ChannelTypeDummy |
| |
|
| | ) |
| |
|
| | var ChannelBaseURLs = []string{ |
| | "", |
| | "https://api.openai.com", |
| | "https://oa.api2d.net", |
| | "", |
| | "http://localhost:11434", |
| | "https://api.openai-sb.com", |
| | "https://api.openaimax.com", |
| | "https://api.ohmygpt.com", |
| | "", |
| | "https://api.caipacity.com", |
| | "https://api.aiproxy.io", |
| | "", |
| | "https://api.api2gpt.com", |
| | "https://api.aigc2d.com", |
| | "https://api.anthropic.com", |
| | "https://aip.baidubce.com", |
| | "https://open.bigmodel.cn", |
| | "https://dashscope.aliyuncs.com", |
| | "", |
| | "https://api.360.cn", |
| | "https://openrouter.ai/api", |
| | "https://api.aiproxy.io", |
| | "https://fastgpt.run/api/openapi", |
| | "https://hunyuan.tencentcloudapi.com", |
| | "https://generativelanguage.googleapis.com", |
| | "https://api.moonshot.cn", |
| | "https://open.bigmodel.cn", |
| | "https://api.perplexity.ai", |
| | "", |
| | "", |
| | "", |
| | "https://api.lingyiwanwu.com", |
| | "", |
| | "", |
| | "https://api.cohere.ai", |
| | "https://api.minimax.chat", |
| | "", |
| | "https://api.dify.ai", |
| | "https://api.jina.ai", |
| | "https://api.cloudflare.com", |
| | "https://api.siliconflow.cn", |
| | "", |
| | "https://api.mistral.ai", |
| | "https://api.deepseek.com", |
| | "https://api.moka.ai", |
| | "https://ark.cn-beijing.volces.com", |
| | "https://qianfan.baidubce.com", |
| | "", |
| | "https://api.x.ai", |
| | "https://api.coze.cn", |
| | } |
| |
|