Documentation
¶
Index ¶
- Constants
- Variables
- func InitConf()
- type BoolOptionHandler
- type ClaudeSettings
- type ContextKey
- type CustomOptionHandler
- type FloatOptionHandler
- type GeminiSettings
- type IntOptionHandler
- type OptionHandler
- type OptionManager
- func (cm *OptionManager) Get(key string) string
- func (cm *OptionManager) GetAll() map[string]string
- func (cm *OptionManager) Register(key string, handler OptionHandler, defaultValue string)
- func (cm *OptionManager) RegisterBool(key string, value *bool)
- func (cm *OptionManager) RegisterCustom(key string, getter func() string, setter func(string) error, ...)
- func (cm *OptionManager) RegisterFloat(key string, value *float64)
- func (cm *OptionManager) RegisterInt(key string, value *int)
- func (cm *OptionManager) RegisterString(key string, value *string)
- func (cm *OptionManager) RegisterValue(key string)
- func (cm *OptionManager) Set(key string, value string) error
- type StringOptionHandler
- type ValueOptionHandler
Constants ¶
View Source
const ( RoleGuestUser = 0 RoleCommonUser = 1 RoleReliableUser = 3 // 可信的内部员工 RoleAdminUser = 10 RoleRootUser = 100 )
View Source
const ( UserStatusEnabled = 1 // don't use 0, 0 is the default value! UserStatusDisabled = 2 // also don't use 0 )
View Source
const ( TokenStatusEnabled = 1 // don't use 0, 0 is the default value! TokenStatusDisabled = 2 // also don't use 0 TokenStatusExpired = 3 TokenStatusExhausted = 4 )
View Source
const ( RedemptionCodeStatusEnabled = 1 // don't use 0, 0 is the default value! RedemptionCodeStatusDisabled = 2 // also don't use 0 RedemptionCodeStatusUsed = 3 // also don't use 0 )
View Source
const ( ChannelStatusUnknown = 0 ChannelStatusEnabled = 1 // don't use 0, 0 is the default value! ChannelStatusManuallyDisabled = 2 // also don't use 0 ChannelStatusAutoDisabled = 3 )
View Source
const ( ChannelTypeUnknown = 0 ChannelTypeOpenAI = 1 // ChannelTypeAPI2D = 2 ChannelTypeAzure = 3 // ChannelTypeCloseAI = 4 // ChannelTypeOpenAISB = 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 ChannelTypeAzureSpeech = 24 ChannelTypeGemini = 25 ChannelTypeBaichuan = 26 ChannelTypeMiniMax = 27 ChannelTypeDeepseek = 28 ChannelTypeMoonshot = 29 ChannelTypeMistral = 30 ChannelTypeGroq = 31 ChannelTypeBedrock = 32 ChannelTypeLingyi = 33 ChannelTypeMidjourney = 34 ChannelTypeCloudflareAI = 35 ChannelTypeCohere = 36 ChannelTypeStabilityAI = 37 ChannelTypeCoze = 38 ChannelTypeOllama = 39 ChannelTypeHunyuan = 40 ChannelTypeSuno = 41 ChannelTypeVertexAI = 42 ChannelTypeLLAMA = 43 ChannelTypeIdeogram = 44 ChannelTypeSiliconflow = 45 ChannelTypeFlux = 46 ChannelTypeJina = 47 ChannelTypeRerank = 48 ChannelTypeGithub = 49 ChannelTypeRecraft = 51 ChannelTypeReplicate = 52 ChannelTypeKling = 53 ChannelTypeAzureDatabricks = 54 ChannelTypeAzureV1 = 55 ChannelTypeXAI = 56 ChannelTypeTokiame = 100 )
View Source
const ( RelayModeUnknown = iota RelayModeChatCompletions RelayModeCompletions RelayModeEmbeddings RelayModeModerations RelayModeImagesGenerations RelayModeImagesEdits RelayModeImagesVariations RelayModeEdits RelayModeAudioSpeech RelayModeAudioTranscription RelayModeAudioTranslation RelayModeSuno RelayModeRerank RelayModeChatRealtime RelayModeKling RelayModeResponses RelayModeVideos )
View Source
const ( PreCostDefault = 1 PreCostNotImage = 2 PreContNotAll = 3 )
View Source
const ( UsageExtraCache = "cached_tokens" // 缓存 UsageExtraCachedWrite = "cached_write_tokens" // 缓存写入 UsageExtraCachedRead = "cached_read_tokens" // 缓存读取 UsageExtraInputAudio = "input_audio_tokens" // 输入音频 UsageExtraOutputAudio = "output_audio_tokens" // 输出音频 UsageExtraReasoning = "reasoning_tokens" // 推理 UsageExtraInputTextTokens = "input_text_tokens" // 输入文本 UsageExtraOutputTextTokens = "output_text_tokens" // 输出文本 UsageExtraInputImageTokens = "input_image_tokens" // 输入图像 UsageExtraOutputImageTokens = "output_image_tokens" // 输出图像 )
View Source
const (
GinRequestBodyKey = "cached_request_body"
)
Variables ¶
View Source
var AnalyticsCode = ""
View Source
var ApproximateTokenEnabled = false
View Source
var AutomaticDisableChannelEnabled = false
View Source
var AutomaticEnableChannelEnabled = false
View Source
var BatchUpdateEnabled = false
View Source
var BatchUpdateInterval = 5
View Source
var BuildTime = "unknown"
View Source
var CFWorkerImageKey = ""
View Source
var CFWorkerImageUrl = ""
View Source
var ChannelDisableThreshold = 5.0
View Source
var ChatImageRequestProxy = ""
View Source
var ChatLink = ""
View Source
var ChatLinks = ""
View Source
var ClaudeAPIEnabled = true
Claude
View Source
var ClaudeSettingsInstance = ClaudeSettings{ DefaultMaxTokens: map[string]int{ "default": 8192, }, BudgetTokensPercentage: 0.8, }
View Source
var Commit = "unknown"
View Source
var Debug = false
View Source
var DefaultChannelWeight = uint(1)
View Source
var DisableTokenEncoders = false
View Source
var DisplayInCurrencyEnabled = true
View Source
var EmailDomainRestrictionEnabled = false
View Source
var EmailDomainWhitelist = []string{
"gmail.com",
"163.com",
"126.com",
"qq.com",
"outlook.com",
"hotmail.com",
"icloud.com",
"yahoo.com",
"foxmail.com",
}
View Source
var EmailVerificationEnabled = false
View Source
var EnableSafe = false
是否开启内容审查
View Source
var GeminiAPIEnabled = true
Gemini
View Source
var GeminiSettingsInstance = GeminiSettings{ OpenThink: map[string]bool{}, }
View Source
var GitHubClientId = ""
View Source
var GitHubClientSecret = ""
View Source
var GitHubOAuthEnabled = false
View Source
var GitHubOldIdCloseEnabled = false
View Source
var GitHubProxy = ""
View Source
var GlobalOption = NewOptionManager()
View Source
var GoogleClientId = ""
View Source
var GoogleClientSecret = ""
View Source
var GoogleOAuthEnabled = false
View Source
var GoogleOnlyRegisterEnabled = false
View Source
var IsMasterNode = true
View Source
var ItemsPerPage = 10
View Source
var Language = ""
View Source
var LarkAuthEnabled = false
View Source
var LarkClientId = ""
View Source
var LarkClientSecret = ""
View Source
var LogConsumeEnabled = true
View Source
var Logo = ""
View Source
var MCP_ENABLE = false
View Source
var MaxRecentItems = 100
View Source
var MemoryCacheEnabled = false
View Source
var MjNotifyEnabled = false
mj
View Source
var OIDCAuthEnabled = false
View Source
var OIDCClientId = ""
View Source
var OIDCClientSecret = ""
View Source
var OIDCIssuer = ""
View Source
var OIDCScopes = ""
View Source
var OIDCUsernameClaims = ""
View Source
var OldTokenMaxId = 0
View Source
var PasswordLoginEnabled = true
View Source
var PasswordRegisterEnabled = true
View Source
var PaymentMinAmount = 1
View Source
var PaymentUSDRate = 7.3
View Source
var PreConsumedQuota = 500
View Source
var QuotaForInvitee = 0
View Source
var QuotaForInviter = 0
View Source
var QuotaForNewUser = 0
View Source
var QuotaPerUnit = 500 * 1000.0 // $0.002 / 1K tokens
View Source
var QuotaRemindThreshold = 1000
View Source
var RateLimitKeyExpirationDuration = 20 * time.Minute
View Source
var RechargeDiscount = ""
View Source
var RedisEnabled = false
View Source
var RegisterEnabled = true
View Source
var RequestInterval time.Duration
View Source
var RetryCooldownSeconds = 5
View Source
var RetryTimeOut = 10
View Source
var RetryTimes = 0
View Source
var RootUserEmail = ""
View Source
var SMTPAccount = ""
View Source
var SMTPFrom = ""
View Source
var SMTPPort = 587
View Source
var SMTPServer = ""
View Source
var SMTPToken = ""
View Source
var SafeKeyWords = []string{
"fuck",
"shit",
"bitch",
"pussy",
"cunt",
"dick",
"asshole",
"bastard",
"slut",
"whore",
"nigger",
"nigga",
"nazi",
"gay",
"lesbian",
"transgender",
"queer",
"homosexual",
"incest",
"rape",
"rapist",
"raped",
"raping",
"raped",
"raping",
"rapist",
"rape",
"sex",
"sexual",
"sexually",
"sexualize",
"sexualized",
"sexualizes",
"sexualizing",
"sexually",
"sex",
"porn",
"pornography",
"prostitute",
"prostitution",
"masturbate",
"masturbation",
"pedophile",
"pedophilia",
"hentai",
"explicit",
"obscene",
"obscenity",
"erotic",
"erotica",
"fetish",
"NSFW",
"nude",
"nudity",
"harassment",
"abuse",
"violent",
"violence",
"suicide",
"racist",
"racism",
"discrimination",
"hate",
"terrorism",
"terrorist",
"drugs",
"cocaine",
"heroin",
"methamphetamine",
}
系统自带关键词审查默认字典
View Source
var SafeToolName = "Keyword"
默认使用系统自带关键词审查工具
View Source
var ServerAddress = "http://localhost:3000"
View Source
var SessionSecret = uuid.New().String()
View Source
var StartTime = time.Now().Unix() // unit: second
View Source
var SystemName = "Tokilake"
View Source
var TopUpLink = ""
View Source
var TurnstileCheckEnabled = false
View Source
var TurnstileSecretKey = ""
View Source
var TurnstileSiteKey = ""
View Source
var UPTIMEKUMA_DOMAIN = ""
View Source
var UPTIMEKUMA_ENABLE = false
View Source
var UPTIMEKUMA_STATUS_PAGE_NAME = ""
View Source
var UserInvoiceMonth = false
是否开启用户月账单功能
View Source
var Version = "v0.0.0" // this hard coding will be replaced automatically when building, no need to manually change
View Source
var WeChatAccountQRCodeImageURL = ""
View Source
var WeChatAuthEnabled = false
View Source
var WeChatServerAddress = ""
View Source
var WeChatServerToken = ""
View Source
var WebAuthnAuthEnabled = true
Functions ¶
Types ¶
type BoolOptionHandler ¶
type BoolOptionHandler struct {
// contains filtered or unexported fields
}
func (*BoolOptionHandler) GetValue ¶
func (h *BoolOptionHandler) GetValue() string
func (*BoolOptionHandler) SetValue ¶
func (h *BoolOptionHandler) SetValue(value string) error
type ClaudeSettings ¶
func (*ClaudeSettings) GetBudgetTokensPercentage ¶
func (c *ClaudeSettings) GetBudgetTokensPercentage() float64
func (*ClaudeSettings) GetDefaultMaxTokens ¶
func (c *ClaudeSettings) GetDefaultMaxTokens(model string) int
func (*ClaudeSettings) GetDefaultMaxTokensJSONString ¶
func (c *ClaudeSettings) GetDefaultMaxTokensJSONString() string
func (*ClaudeSettings) SetDefaultMaxTokens ¶
func (c *ClaudeSettings) SetDefaultMaxTokens(data string)
type ContextKey ¶
type ContextKey string
type CustomOptionHandler ¶
type CustomOptionHandler struct {
// contains filtered or unexported fields
}
func (*CustomOptionHandler) GetValue ¶
func (h *CustomOptionHandler) GetValue() string
func (*CustomOptionHandler) SetValue ¶
func (h *CustomOptionHandler) SetValue(value string) error
type FloatOptionHandler ¶
type FloatOptionHandler struct {
// contains filtered or unexported fields
}
func (*FloatOptionHandler) GetValue ¶
func (h *FloatOptionHandler) GetValue() string
func (*FloatOptionHandler) SetValue ¶
func (h *FloatOptionHandler) SetValue(value string) error
type GeminiSettings ¶
func (*GeminiSettings) GetOpenThink ¶
func (c *GeminiSettings) GetOpenThink(model string) bool
func (*GeminiSettings) GetOpenThinkJSONString ¶
func (c *GeminiSettings) GetOpenThinkJSONString() string
func (*GeminiSettings) SetOpenThink ¶
func (c *GeminiSettings) SetOpenThink(data string)
type IntOptionHandler ¶
type IntOptionHandler struct {
// contains filtered or unexported fields
}
func (*IntOptionHandler) GetValue ¶
func (h *IntOptionHandler) GetValue() string
func (*IntOptionHandler) SetValue ¶
func (h *IntOptionHandler) SetValue(value string) error
type OptionHandler ¶
type OptionHandler interface {
// SetValue 设置配置值
SetValue(value string) error
// GetValue 获取配置字符串值
GetValue() string
}
OptionHandler 定义配置项处理器接口
type OptionManager ¶
type OptionManager struct {
// contains filtered or unexported fields
}
OptionManager 配置管理器
func (*OptionManager) GetAll ¶
func (cm *OptionManager) GetAll() map[string]string
func (*OptionManager) Register ¶
func (cm *OptionManager) Register(key string, handler OptionHandler, defaultValue string)
Register 注册配置项
func (*OptionManager) RegisterBool ¶
func (cm *OptionManager) RegisterBool(key string, value *bool)
RegisterBool 快速注册布尔配置
func (*OptionManager) RegisterCustom ¶
func (cm *OptionManager) RegisterCustom(key string, getter func() string, setter func(string) error, defaultValue string)
RegisterCustom 注册自定义处理函数的配置
func (*OptionManager) RegisterFloat ¶
func (cm *OptionManager) RegisterFloat(key string, value *float64)
RegisterFloat 快速注册浮点数配置
func (*OptionManager) RegisterInt ¶
func (cm *OptionManager) RegisterInt(key string, value *int)
RegisterInt 快速注册整数配置
func (*OptionManager) RegisterString ¶
func (cm *OptionManager) RegisterString(key string, value *string)
RegisterString 快速注册字符串配置
func (*OptionManager) RegisterValue ¶
func (cm *OptionManager) RegisterValue(key string)
RegisterValue 注册一个值类型的配置项
type StringOptionHandler ¶
type StringOptionHandler struct {
// contains filtered or unexported fields
}
以下是各种配置处理器的实现
func (*StringOptionHandler) GetValue ¶
func (h *StringOptionHandler) GetValue() string
func (*StringOptionHandler) SetValue ¶
func (h *StringOptionHandler) SetValue(value string) error
type ValueOptionHandler ¶
type ValueOptionHandler struct {
// contains filtered or unexported fields
}
ValueOptionHandler 用于存储非全局变量的字符串值
func (*ValueOptionHandler) GetValue ¶
func (h *ValueOptionHandler) GetValue() string
func (*ValueOptionHandler) SetValue ¶
func (h *ValueOptionHandler) SetValue(value string) error
Click to show internal directories.
Click to hide internal directories.