config

package
v0.0.0-...-9f73af6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// model status
	MODEL_REGISTERING = "registering"
	MODEL_LOADING     = "loading"
	MODEL_LOADED      = "loaded"
	MODEL_UNLOADED    = "unloaded"
	MODEL_DELETE      = "deleted"

	// task status
	TASK_INPROGRESS = "running"
	TASK_FAILED     = "failed"
	TASK_QUEUE      = "waiting"
	TASK_FINISH     = "succeeded"

	HTTPTIMEOUT = 10 * 60 * time.Second

	// cancel val
	CANCEL_INIT  = 0
	CANCEL_VALID = 1

	PROGRESS_INTERVAL = 500
)
View Source
const (
	OTSPUTERROR        = "put ots error"
	OTSGETERROR        = "get ots error"
	INTERNALERROR      = "an internal error"
	BADREQUEST         = "bad request body"
	NOTFOUND           = "not found"
	NOFOUNDENDPOINT    = "not found sd endpoint, please retry"
	MODELUPDATEFCERROR = "model update fc error"
)

error message

View Source
const (
	SD_MODEL         = "stableDiffusion"
	SD_VAE           = "sdVae"
	LORA_MODEL       = "lora"
	CONTORLNET_MODEL = "controlNet"
)

model type

View Source
const (
	//REFRESH_LORAS      = "/sdapi/v1/refresh-loras"
	//GET_LORAS          = "/sdapi/v1/loras"
	GET_SD_MODEL       = "/sdapi/v1/sd-models"
	REFRESH_SD_MODEL   = "/sdapi/v1/refresh-checkpoints"
	GET_SD_VAE         = "/sdapi/v1/sd-vae"
	REFRESH_VAE        = "/sdapi/v1/refresh-vae"
	REFRESH_CONTROLNET = "/controlnet/model_list"
	CANCEL             = "/sdapi/v1/interrupt"
	TXT2IMG            = "/sdapi/v1/txt2img"
	IMG2IMG            = "/sdapi/v1/img2img"
	PROGRESS           = "/sdapi/v1/progress"
	EXTRAIMAGES        = "/sdapi/v1/extra-single-image"
)

sd api path

View Source
const (
	ACCOUNT_ID              = "FC_ACCOUNT_ID"
	ACCESS_KEY_ID           = "ALIBABA_CLOUD_ACCESS_KEY_ID"
	ACCESS_KEY_SECRET       = "ALIBABA_CLOUD_ACCESS_KEY_SECRET"
	ACCESS_KET_TOKEN        = "ALIBABA_CLOUD_SECURITY_TOKEN"
	REGION                  = "FC_REGION"
	SERVICE_NAME            = "FC_SERVICE_NAME"
	OTS_ENDPOINT            = "OTS_ENDPOINT"
	OTS_INSTANCE            = "OTS_INSTANCE"
	OSS_ENDPOINT            = "OSS_ENDPOINT"
	OSS_BUCKET              = "OSS_BUCKET"
	OSS_PATH                = "OSS_PATH"
	OSS_MODE                = "OSS_MODE"
	LOGINSWITCH             = "LOGIN_SWITCH"
	USER_LOCAL_MODEL        = "USE_LOCAL_MODEL"
	SD_IMAGE                = "SD_IMAGE"
	FLEX_MODE               = "FLEX_MODE"
	EXPOSE_TO_USER          = "EXPOSE_TO_USER"
	SERVER_NAME             = "SERVER_NAME"
	DOWNSTREAM              = "DOWNSTREAM"
	GPU_MEMORY_SIZE         = "GPU_MEMORY_SIZE"
	COLD_START_CONCURRENCY  = "COLD_START_CONCURRENCY"
	MODEL_COLD_START_SERIAL = "MODEL_COLD_START_SERIAL"
	LOG_REMOTE_SERVICE      = "LOG_REMOTE_SERVICE"
	FC_ACCOUNT_ID           = "FC_ACCOUNT_ID"
	FC_FUNCTION_NAME        = "FC_FUNCTION_NAME"
	ENABLE_COLLECT          = "ENABLE_COLLECT"
	DISABLE_HF_CHECK        = "DISABLE_HF_CHECK"
	CHECK_MODEL_LOAD        = "CHECK_MODEL_LOAD"
)

env

View Source
const (
	DefaultSdPort              = "7861"
	DefaultSdPath              = "/stable-diffusion-webui"
	DefaultSdPathProxy         = "/mnt/auto/sd"
	DefaultExtraArgs           = "--api"
	DefaultSessionExpire       = 3600
	DefaultLoginSwitch         = "off"       // value: off|on
	DefaultUseLocalModel       = "yes"       // value: yes|no
	DefaultFlexMode            = "multiFunc" // value: singleFunc|multiFunc
	DefaultOssPath             = "/mnt/oss"
	DefaultLogService          = "http://server-ai-backend-agwwspzdwb.cn-hangzhou.devsapp.net"
	DefaultCaPort              = 7860
	DefaultCpu                 = 8
	DefaultDisk                = 512
	DefaultInstanceConcurrency = 1
	DefaultInstanceType        = "fc.gpu.tesla.1"
	DefaultMemorySize          = 32768
	DefaultGpuMemorySize       = 16384
	DefaultTimeout             = 600
	DefaultOssMode             = REMOTE
)

default value

View Source
const (
	TRIGGER_TYPE         = "http"
	TRIGGER_NAME         = "defaultTrigger"
	HTTP_GET             = "GET"
	HTTP_POST            = "POST"
	HTTP_PUT             = "PUT"
	AUTH_TYPE            = "anonymous"
	MODEL_REFRESH_SIGNAL = "MODEL_REFRESH_SIGNAL"
	MODEL_SD             = "SD_MODEL"
	MODEL_SD_VAE         = "SD_VAE"
	SD_START_PARAMS      = "EXTRA_ARGS"
)

function http trigger

View Source
const (
	LOCAL  = "local"
	REMOTE = "remote"
)

oss mode

View Source
const (
	PROXY   = "proxy"
	AGENT   = "agent"
	CONTROL = "control"
)
View Source
const (
	ColdStartConcurrency = 10
	ModelColdStartSerial = false
)
View Source
const (
	TrackerKeyStableDiffusionStartup = "stable_diffusion_startup"
	FcRequestID                      = "x-fc-request-id"
)
View Source
const (
	COLPK = "PK"
)

ots

Variables

This section is empty.

Functions

func InitConfig

func InitConfig(fn string) error

Types

type Config

type Config struct {
	ConfigYaml
	ConfigEnv
}
var ConfigGlobal *Config

func (*Config) EnableLogin

func (c *Config) EnableLogin() bool

func (*Config) EnableProgressImg

func (c *Config) EnableProgressImg() bool

func (*Config) ExposeToUser

func (c *Config) ExposeToUser() bool

func (*Config) GetDisableHealthCheck

func (c *Config) GetDisableHealthCheck() bool

func (*Config) GetFlexMode

func (c *Config) GetFlexMode() FlexMode

GetFlexMode flex mode

func (*Config) GetSDPort

func (c *Config) GetSDPort() string

func (*Config) IsServerTypeMatch

func (c *Config) IsServerTypeMatch(name string) bool

IsServerTypeMatch Identify whether serverName == name

func (*Config) SendLogToRemote

func (c *Config) SendLogToRemote() bool

func (*Config) UseLocalModel

func (c *Config) UseLocalModel() bool

type ConfigEnv

type ConfigEnv struct {
	// account
	AccountId            string
	AccessKeyId          string
	AccessKeySecret      string
	AccessKeyToken       string
	Region               string
	ServiceName          string
	FunctionName         string
	ColdStartConcurrency int32
	ModelColdStartSerial bool
}

type ConfigYaml

type ConfigYaml struct {
	// ots
	OtsEndpoint     string `yaml:"otsEndpoint"`
	OtsTimeToAlive  int    `yaml:"otsTimeToAlive"`
	OtsInstanceName string `yaml:"otsInstanceName"`
	OtsMaxVersion   int    `yaml:"otsMaxVersion"`
	// oss
	OssEndpoint string `yaml:"ossEndpoint"`
	Bucket      string `yaml:"bucket"`
	OssPath     string `yaml:"ossPath""`
	OssMode     string `yaml:"ossMode"`

	// db
	DbSqlite string `yaml:"dbSqlite"`

	// listen
	ListenInterval int32 `yaml:"listenInterval"`

	// function
	Image               string  `yaml:"image"`
	CAPort              int32   `yaml:"caPort"`
	Timeout             int32   `yaml:"timeout"`
	CPU                 float32 `yaml:"CPU"`
	GpuMemorySize       int32   `yaml:"gpuMemorySize"`
	ExtraArgs           string  `yaml:"extraArgs"`
	DiskSize            int32   `yaml:"diskSize"`
	MemorySize          int32   `yaml:"memorySize"`
	InstanceConcurrency int32   `yaml:"instanceConcurrency"`
	InstanceType        string  `yaml:"instanceType"`

	// user
	SessionExpire             int64  `yaml:"sessionExpire"`
	LoginSwitch               string `yaml:"loginSwitch"`
	ProgressImageOutputSwitch string `yaml:"progressImageOutputSwitch"`

	// sd
	SdUrlPrefix string `yaml:"sdUrlPrefix"`
	SdPath      string `yaml:"sdPath"`
	SdShell     string `yaml:"sdShell"`

	// model
	UseLocalModels string `yaml:"useLocalModel"`

	// flex mode
	FlexMode string `yaml:"flexMode"`

	// agent expose to user or not
	LogRemoteService   string `yaml:"logRemoteService"`
	EnableCollect      string `yaml:"enableCollect"`
	DisableHealthCheck string `yaml:"disableHealthCheck"`

	// proxy or control or agent
	ServerName string `yaml:"serverName"`
	Downstream string `yaml:"downstream"`
}

type FlexMode

type FlexMode int32
const (
	SingleFunc FlexMode = iota
	MultiFunc
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL