mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(model-registry): models.dev updater + admin endpoints
This commit is contained in:
@@ -10,11 +10,12 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Server ServerConfig
|
||||
Postgres PostgresConfig
|
||||
Redis RedisConfig
|
||||
Log LogConfig
|
||||
Auth AuthConfig
|
||||
Server ServerConfig
|
||||
Postgres PostgresConfig
|
||||
Redis RedisConfig
|
||||
Log LogConfig
|
||||
Auth AuthConfig
|
||||
ModelRegistry ModelRegistryConfig
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@@ -41,6 +42,15 @@ type LogConfig struct {
|
||||
QueueCapacity int
|
||||
}
|
||||
|
||||
type ModelRegistryConfig struct {
|
||||
Enabled bool
|
||||
RefreshSeconds int
|
||||
ModelsDevBaseURL string
|
||||
ModelsDevRef string
|
||||
CacheDir string
|
||||
TimeoutSeconds int
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
v := viper.New()
|
||||
|
||||
@@ -53,6 +63,12 @@ func Load() (*Config, error) {
|
||||
v.SetDefault("log.flush_ms", 1000)
|
||||
v.SetDefault("log.queue_capacity", 10000)
|
||||
v.SetDefault("auth.jwt_secret", "change_me_in_production")
|
||||
v.SetDefault("model_registry.enabled", false)
|
||||
v.SetDefault("model_registry.refresh_seconds", 1800)
|
||||
v.SetDefault("model_registry.models_dev_base_url", "https://codeload.github.com/sst/models.dev/tar.gz")
|
||||
v.SetDefault("model_registry.models_dev_ref", "dev")
|
||||
v.SetDefault("model_registry.cache_dir", "./data/model-registry")
|
||||
v.SetDefault("model_registry.timeout_seconds", 30)
|
||||
|
||||
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
v.AutomaticEnv()
|
||||
@@ -66,6 +82,12 @@ func Load() (*Config, error) {
|
||||
_ = v.BindEnv("log.flush_ms", "EZ_LOG_FLUSH_MS")
|
||||
_ = v.BindEnv("log.queue_capacity", "EZ_LOG_QUEUE")
|
||||
_ = v.BindEnv("auth.jwt_secret", "EZ_JWT_SECRET")
|
||||
_ = v.BindEnv("model_registry.enabled", "EZ_MODEL_REGISTRY_ENABLED")
|
||||
_ = v.BindEnv("model_registry.refresh_seconds", "EZ_MODEL_REGISTRY_REFRESH_SECONDS")
|
||||
_ = v.BindEnv("model_registry.models_dev_base_url", "EZ_MODEL_REGISTRY_MODELS_DEV_BASE_URL")
|
||||
_ = v.BindEnv("model_registry.models_dev_ref", "EZ_MODEL_REGISTRY_MODELS_DEV_REF")
|
||||
_ = v.BindEnv("model_registry.cache_dir", "EZ_MODEL_REGISTRY_CACHE_DIR")
|
||||
_ = v.BindEnv("model_registry.timeout_seconds", "EZ_MODEL_REGISTRY_TIMEOUT_SECONDS")
|
||||
|
||||
if configFile := os.Getenv("EZ_CONFIG_FILE"); configFile != "" {
|
||||
v.SetConfigFile(configFile)
|
||||
@@ -102,6 +124,14 @@ func Load() (*Config, error) {
|
||||
Auth: AuthConfig{
|
||||
JWTSecret: v.GetString("auth.jwt_secret"),
|
||||
},
|
||||
ModelRegistry: ModelRegistryConfig{
|
||||
Enabled: v.GetBool("model_registry.enabled"),
|
||||
RefreshSeconds: v.GetInt("model_registry.refresh_seconds"),
|
||||
ModelsDevBaseURL: v.GetString("model_registry.models_dev_base_url"),
|
||||
ModelsDevRef: v.GetString("model_registry.models_dev_ref"),
|
||||
CacheDir: v.GetString("model_registry.cache_dir"),
|
||||
TimeoutSeconds: v.GetInt("model_registry.timeout_seconds"),
|
||||
},
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
|
||||
Reference in New Issue
Block a user