Documentation
¶
Index ¶
- Constants
- func ActionFileCheck(conf *ActionFile) error
- func CalcReqUsedQuota(req *bfe_basic.Request, promptTokens, completionTokens int64) int64
- func GetApiKey(req *bfe_basic.Request) string
- func GetPromptToken(req *bfe_basic.Request) int64
- func GetUUID() string
- func ProductRuleConfLoad(filename string) (productRuleConf, error)
- func SetApiKey(req *bfe_http.Request, apiKey string)
- func SetTokenAuthContext(req *bfe_basic.Request, tokenCtx *TokenAuthContext)
- type Action
- type ActionFile
- type ConfModAITokenAuth
- type ModuleAITokenAuth
- func (m *ModuleAITokenAuth) GetTokenUsedQuota(t *Token) int64
- func (m *ModuleAITokenAuth) IncrTokenUsedQuotaBy(t *Token, delta int64) int64
- func (m *ModuleAITokenAuth) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHandlers, cr string) error
- func (m *ModuleAITokenAuth) Name() string
- func (m *ModuleAITokenAuth) ValidateUserTokenByReq(req *bfe_basic.Request) (token *Token, err error)
- type ModuleAITokenAuthState
- type ProductRules
- type ProductRulesFile
- type ProductTokenFiles
- type ProductTokens
- type Token
- type TokenAuthContext
- type TokenFile
- type TokenRuleTable
- func (t *TokenRuleTable) GetToken(product, key string) (*Token, bool)
- func (t *TokenRuleTable) Search(product string) (*tokenRuleList, bool)
- func (t *TokenRuleTable) Update(conf productRuleConf) (oldtokens []*Token)
- func (t *TokenRuleTable) ValidateUserToken(product, key string) (token *Token, err error)
Constants ¶
View Source
const ( TokenStatusEnabled = 1 TokenStatusDisabled = 2 TokenStatusExpired = 3 TokenStatusExhausted = 4 )
View Source
const (
ActionCheckToken = "CHECK_TOKEN"
)
View Source
const (
ModAITokenAuth = "mod_ai_token_auth"
)
View Source
const REQ_TOKEN_AUTH_CONTEXT = "tokenauth_ctx"
Variables ¶
This section is empty.
Functions ¶
func ActionFileCheck ¶
func ActionFileCheck(conf *ActionFile) error
func CalcReqUsedQuota ¶
func GetPromptToken ¶
func ProductRuleConfLoad ¶
func SetTokenAuthContext ¶
func SetTokenAuthContext(req *bfe_basic.Request, tokenCtx *TokenAuthContext)
SetTokenAuthContext sets the token authentication context in the request
Types ¶
type Action ¶
type Action ActionFile
type ActionFile ¶
type ActionFile struct {
Cmd string
}
type ConfModAITokenAuth ¶
type ConfModAITokenAuth struct {
Basic struct {
ProductRulePath string
}
// redis conf
Redis struct {
Bns string // bns name for redis proxy
ConnectTimeout int // connect timeout (ms)
ReadTimeout int // read timeout (ms)
WriteTimeout int // write timeout(ms)
// max idle connections in pool
MaxIdle int
// redis password,ignore if not set
Password string
// max active connections in pool,
// when set 0, there is no connection num limit
MaxActive int
}
Log struct {
OpenDebug bool
}
}
func (*ConfModAITokenAuth) Check ¶
func (cfg *ConfModAITokenAuth) Check(confRoot string) error
type ModuleAITokenAuth ¶
type ModuleAITokenAuth struct {
// contains filtered or unexported fields
}
func NewModuleAITokenAuth ¶
func NewModuleAITokenAuth() *ModuleAITokenAuth
func (*ModuleAITokenAuth) GetTokenUsedQuota ¶
func (m *ModuleAITokenAuth) GetTokenUsedQuota(t *Token) int64
func (*ModuleAITokenAuth) IncrTokenUsedQuotaBy ¶
func (m *ModuleAITokenAuth) IncrTokenUsedQuotaBy(t *Token, delta int64) int64
func (*ModuleAITokenAuth) Init ¶
func (m *ModuleAITokenAuth) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHandlers, cr string) error
func (*ModuleAITokenAuth) Name ¶
func (m *ModuleAITokenAuth) Name() string
func (*ModuleAITokenAuth) ValidateUserTokenByReq ¶
func (m *ModuleAITokenAuth) ValidateUserTokenByReq(req *bfe_basic.Request) (token *Token, err error)
type ModuleAITokenAuthState ¶
type ProductRules ¶
type ProductRules map[string]*tokenRuleList
type ProductRulesFile ¶
type ProductRulesFile map[string]*tokenRuleFileList
type ProductTokenFiles ¶
type ProductTokenFiles map[string]*tokenFileMap
type ProductTokens ¶
type ProductTokens map[string]*tokenMap
type TokenAuthContext ¶
type TokenAuthContext struct {
Token *Token
PromptTokens int64 // number of tokens in the prompt
CompletionTokens int64 // number of tokens in the completion
UsedQuota int64 // used quota for this request
}
func GetTokenAuthContext ¶
func GetTokenAuthContext(req *bfe_basic.Request) *TokenAuthContext
type TokenFile ¶
type TokenFile struct {
Key string `json:"key"`
Status int `json:"status"`
Name string `json:"name"`
UpdateTime int64 `json:"update_time"`
ExpiredTime int64 `json:"expired_time"` // -1 means never expired
RemainQuota int64 `json:"remain_quota"`
UnlimitedQuota bool `json:"unlimited_quota"`
Models *string `json:"models"` // allowed models
Subnet *string `json:"subnet"` // allowed subnet
// contains filtered or unexported fields
}
type TokenRuleTable ¶
type TokenRuleTable struct {
// contains filtered or unexported fields
}
func NewTokenRuleTable ¶
func NewTokenRuleTable() *TokenRuleTable
func (*TokenRuleTable) GetToken ¶
func (t *TokenRuleTable) GetToken(product, key string) (*Token, bool)
func (*TokenRuleTable) Search ¶
func (t *TokenRuleTable) Search(product string) (*tokenRuleList, bool)
func (*TokenRuleTable) Update ¶
func (t *TokenRuleTable) Update(conf productRuleConf) (oldtokens []*Token)
func (*TokenRuleTable) ValidateUserToken ¶
func (t *TokenRuleTable) ValidateUserToken(product, key string) (token *Token, err error)
Click to show internal directories.
Click to hide internal directories.