healthapp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

79 lines
2.0 KiB

package config
import (
"github.com/spf13/viper"
)
type Config struct {
Server ServerConfig `mapstructure:"server"`
Database DatabaseConfig `mapstructure:"database"`
JWT JWTConfig `mapstructure:"jwt"`
AI AIConfig `mapstructure:"ai"`
}
type ServerConfig struct {
Port int `mapstructure:"port"`
Mode string `mapstructure:"mode"`
}
type DatabaseConfig struct {
Driver string `mapstructure:"driver"`
SQLite SQLiteConfig `mapstructure:"sqlite"`
Postgres PostgresConfig `mapstructure:"postgres"`
MySQL MySQLConfig `mapstructure:"mysql"`
}
type SQLiteConfig struct {
Path string `mapstructure:"path"`
}
type PostgresConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
DBName string `mapstructure:"dbname"`
}
type MySQLConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
User string `mapstructure:"user"`
Password string `mapstructure:"password"`
DBName string `mapstructure:"dbname"`
}
type JWTConfig struct {
Secret string `mapstructure:"secret"`
ExpireHours int `mapstructure:"expire_hours"`
}
type AIConfig struct {
Provider string `mapstructure:"provider"`
MaxHistoryMessages int `mapstructure:"max_history_messages"`
MaxTokens int `mapstructure:"max_tokens"`
OpenAI OpenAIConfig `mapstructure:"openai"`
Aliyun AliyunConfig `mapstructure:"aliyun"`
}
type OpenAIConfig struct {
APIKey string `mapstructure:"api_key"`
BaseURL string `mapstructure:"base_url"`
Model string `mapstructure:"model"`
}
type AliyunConfig struct {
APIKey string `mapstructure:"api_key"`
Model string `mapstructure:"model"`
}
var AppConfig *Config
func LoadConfig(path string) error {
viper.SetConfigFile(path)
if err := viper.ReadInConfig(); err != nil {
return err
}
AppConfig = &Config{}
return viper.Unmarshal(AppConfig)
}