update config to file

This commit is contained in:
2023-11-29 14:31:11 +08:00
parent 0a2a7376f1
commit 7b74818676
3 changed files with 32 additions and 12 deletions

View File

@@ -8,6 +8,9 @@ import (
)
type Config struct {
Address string `yaml:"address"`
DBType string `yaml:"dbtype"`
DBAddr string `yaml:"dbaddr"`
Authorization string `yaml:"authorization"`
Upstreams []OPENAI_UPSTREAM `yaml:"upstreams"`
}
@@ -32,5 +35,16 @@ func readConfig(filepath string) Config {
log.Fatalf("Error unmarshaling YAML: %s", err)
}
// set default value
if config.Address == "" {
config.Address = ":8888"
}
if config.DBType == "" {
config.DBType = "sqlite"
}
if config.DBAddr == "" {
config.DBAddr = "./db.sqlite"
}
return config
}