Documentation ¶
Overview ¶
Package config implements config.
Index ¶
Constants ¶
View Source
const (
// FreetierUserToken freetier user token
FreetierUserToken = "DEFAULT_PROXY_TOKEN"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ImageTokenType ¶
type ImageTokenType string
ImageTokenType image token type
const ( // ImageTokenAzure azure image token ImageTokenAzure ImageTokenType = "azure" // ImageTokenOpenai openai image token ImageTokenOpenai ImageTokenType = "openai" )
func (ImageTokenType) String ¶
func (t ImageTokenType) String() string
type OpenAI ¶
type OpenAI struct { // Gateway (optional) gateway url, default to https://chat.laisky.com Gateway string `json:"gateway" mapstructure:"gateway"` // API (optional) openai api base url, default is https://api.openai.com API string `json:"api" mapstructure:"api"` // Token (required) openai api request token Token string `json:"-" mapstructure:"token"` // DefaultOpenaiToken (optional) default openai token, default equals to token // // Dangerous: will escape paying wall, use it carefully // DefaultOpenaiToken string `json:"-" mapstructure:"default_openai_token"` // DefaultImageToken (optional) default image token, default equals to token DefaultImageToken string `json:"-" mapstructure:"default_image_token"` // DefaultImageUrl (optional) default image url // // default to https://{{API}}/v1/images/generations DefaultImageUrl string `json:"-" mapstructure:"default_image_url"` // RateLimitExpensiveModelsIntervalSeconds (optional) rate limit interval seconds for expensive models, default is 60 RateLimitExpensiveModelsIntervalSeconds int `json:"rate_limit_expensive_models_interval_secs" mapstructure:"rate_limit_expensive_models_interval_secs"` // RateLimitImageModelsIntervalSeconds (optional) rate limit interval seconds for image models, default is 600 RateLimitImageModelsIntervalSeconds int `json:"rate_limit_image_models_interval_secs" mapstructure:"rate_limit_image_models_interval_secs"` // Proxy (optional) proxy url to send request Proxy string `json:"-" mapstructure:"proxy"` // UserTokens (optional) paid user's tenant tokens UserTokens []*UserConfig `json:"user_tokens" mapstructure:"user_tokens"` // GoogleAnalytics (optional) google analytics id GoogleAnalytics string `json:"ga" mapstructure:"ga"` // StaticLibs (optional) replace default static libs' url StaticLibs map[string]string `json:"static_libs" mapstructure:"static_libs"` // QAChatModels (optional) qa chat models QAChatModels []qaChatModel `json:"qa_chat_models" mapstructure:"qa_chat_models"` // ExternalBillingAPI (optional) default billing api, default is https://oneapi.laisky.com ExternalBillingAPI string `json:"external_billing_api" mapstructure:"external_billing_api"` // ExternalBillingToken (optional) default billing token // ExternalBillingToken string `json:"external_billing_token" mapstructure:"external_billing_token"` // RamjetURL (optional) ramjet url RamjetURL string `json:"ramjet_url" mapstructure:"ramjet_url"` // S3 (optional) s3 config S3 s3Config `json:"s3" mapstructure:"s3"` NvidiaApikey string `json:"-" mapstructure:"nvidia_apikey"` // ReplicateApikey is the api key for flux pro // // https://replicate.com/account/api-tokens ReplicateApikey string `json:"-" mapstructure:"replicate_apikey"` // SegmindApikey is the api key for segmind // // https://cloud.segmind.com/console/api-keys SegmindApikey string `json:"-" mapstructure:"segmind_apikey"` // PaymentStripeKey (optional) stripe key PaymentStripeKey string `json:"payment_stripe_key" mapstructure:"payment_stripe_key"` // LcmBasicAuthUsername (optional) lcm basic auth username LcmBasicAuthUsername string `json:"lcm_basic_auth_username" mapstructure:"lcm_basic_auth_username"` // LcmBasicAuthPassword (optional) lcm basic auth password LcmBasicAuthPassword string `json:"lcm_basic_auth_password" mapstructure:"lcm_basic_auth_password"` // LimitUploadFileBytes (optional) limit upload file bytes, default is 20MB LimitUploadFileBytes int `json:"limit_upload_file_bytes" mapstructure:"limit_upload_file_bytes"` // Azure (optional) azure config Azure azureConfig `json:"azure" mapstructure:"azure"` }
OpenAI openai config
nolint: lll
var ( // Config global shared config instance Config *OpenAI )
type UserConfig ¶
type UserConfig struct { UserName string `json:"username" mapstructure:"username"` // Token (required) client's tenant token, not the openai token Token string `json:"-" mapstructure:"token"` // OpenaiToken (optional) openai token, default is global default token OpenaiToken string `json:"-" mapstructure:"openai_token"` // ImageToken (optional) token be used to generate image, // default is global default image token ImageToken string `json:"-" mapstructure:"image_token"` // ImageUrl (optional) image url, default is global default image url ImageUrl string `json:"-" mapstructure:"image_url"` // APIBase (optional) api base url, default is global default api base APIBase string `json:"api_base" mapstructure:"api_base"` // IsFree (optional) is free user, default is false IsFree bool `json:"is_free" mapstructure:"is_free"` // BYOK (optional) user's bring his own token, default is false BYOK bool `json:"byok" mapstructure:"byok"` // AllowedModels (required) allowed models AllowedModels []string `json:"allowed_models" mapstructure:"allowed_models"` // NoLimitExpensiveModels (optional) skip rate limiter for expensive models NoLimitExpensiveModels bool `json:"no_limit_expensive_models" mapstructure:"no_limit_expensive_models"` // NoLimitImageModels (optional) skip rate limiter for image models NoLimitImageModels bool `json:"no_limit_image_models" mapstructure:"no_limit_image_models"` // NoLimitOpenaiModels (optional) skip rate limiter for models that only supported by openai NoLimitOpenaiModels bool `json:"no_limit_openai_models" mapstructure:"no_limit_openai_models"` // LimitPromptTokenLength (optional) set limit for prompt token length, <=0 means no limit LimitPromptTokenLength int `json:"limit_prompt_token_length" mapstructure:"limit_prompt_token_length"` // EnableExternalImageBilling (optional) enable external image billing EnableExternalImageBilling bool `json:"enable_external_image_billing" mapstructure:"enable_external_image_billing"` }
UserConfig user config
func (*UserConfig) IsModelAllowed ¶
IsModelAllowed check if model is allowed
Args ¶
- model: model name
- nPromptTokens: the length of prompt tokens, 0 means no limit
Click to show internal directories.
Click to hide internal directories.