config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const AppName = "X-Ally"

Real constants and can not be changed

View Source
const PROXY_TOKEN_NAME = "X-ALLY-TOKEN"

const MaxTokens = 4096

View Source
const ServerName = "X-Ally-Server"

Real constants and can not be changed

View Source
const ServerVersion = "0.2.1"
View Source
const Version = "0.2.1"

Variables

This section is empty.

Functions

func FindHomeDir

func FindHomeDir(verbose bool) (string, error)

func GetAcceptLanguage

func GetAcceptLanguage() string

func GetPageActivate

func GetPageActivate(activate_url string, msg string, title string, tips string) string

func GetPageActiviated

func GetPageActiviated(msg string, title string, tips string) string

func GetRealFullPath

func GetRealFullPath(path string) (string, error)

func GetServerDSN

func GetServerDSN() string

func IsMySQL added in v0.2.0

func IsMySQL() bool

func IsSQLite added in v0.2.0

func IsSQLite() bool

func IsWritable

func IsWritable(path string, verbose bool) (isWritable bool, err error)

/////////////////////////////////////////////////////////////////////////////

func SetupPeferenceLanguage

func SetupPeferenceLanguage(language string)

func Text

func Text(str_key string) string

Types

type ProxyRoute

type ProxyRoute struct {
	Name    string `yaml:"name"`
	Context string `yaml:"context"`
	Target  string `yaml:"target"`
}

type ServerConfig

type ServerConfig struct {
	Server *ServerConfigItems `yaml:"server"`
}
var SvrConfig *ServerConfig

func LoadServerConfig

func LoadServerConfig(config_file string, verbose bool) (*ServerConfig, error)

func (*ServerConfig) DebugMode added in v0.1.6

func (cfg *ServerConfig) DebugMode() bool

func (*ServerConfig) DumpIntoYAML

func (cfg *ServerConfig) DumpIntoYAML(cfg_file string) (string, error)

func (*ServerConfig) LoadFromYAML

func (cfg *ServerConfig) LoadFromYAML(cfg_file string) error

type ServerConfigItems

type ServerConfigItems struct {
	DBDriver                 string       `yaml:"db_driver"`
	DBHost                   string       `yaml:"db_host"`
	DBPort                   string       `yaml:"db_port"`
	DBUser                   string       `yaml:"db_user"`
	DBPassword               string       `yaml:"db_password"`
	SentryDSN                string       `yaml:"sentry_dsn,omitempty"`
	OpenaiApiKey             string       `yaml:"openai_api_key"`
	OpenaiOrgID              string       `yaml:"openai_org_id"`
	AppToken                 string       `yaml:"app_token"`
	AppTokenLifespan         uint32       `yaml:"app_token_lifespan"`
	ListenAddr               string       `yaml:"listen_addr"`
	WhiteListRefreshInterval int64        `yaml:"white_list_refresh_interval,omitempty"`
	Routes                   []ProxyRoute `yaml:"routes,omitempty"`

	ExternalEndpoint    string `yaml:"external_endpoint"`
	SMTPServer          string `yaml:"smtp_server"`
	SMTPPort            int    `yaml:"smtp_port"`
	SMTPUsername        string `yaml:"smtp_username"`
	SMTPPassword        string `yaml:"smtp_password"`
	DirectEmailNotify   bool   `yaml:"direct_email_notify"`
	EmailRestrictDomain string `yaml:"email_restrict_domain"`

	DebugMode bool `yaml:"debug_mode,omitempty"`
}

type SysConfig

type SysConfig struct {
	System SysSystem `yaml:"system"`

	Roles map[string]SysRole `yaml:"roles"`
}
var MyConfig *SysConfig

func LoadClientConfig

func LoadClientConfig(config_file string, verbose bool) (*SysConfig, error)

func NewSysConfig

func NewSysConfig(cfg_file string) *SysConfig

func (*SysConfig) DebugMode added in v0.1.5

func (cfg *SysConfig) DebugMode() bool

func (*SysConfig) DumpIntoYAML

func (cfg *SysConfig) DumpIntoYAML(cfg_file string) (string, error)

func (*SysConfig) FindRole

func (cfg *SysConfig) FindRole(role_name string) (*SysRole, error)

func (*SysConfig) GetCurrentMode

func (cfg *SysConfig) GetCurrentMode(connected bool) string

func (*SysConfig) IsSharedMode

func (cfg *SysConfig) IsSharedMode() bool

func (*SysConfig) LoadFromYAML

func (cfg *SysConfig) LoadFromYAML(cfg_file string) error

func (*SysConfig) UsingOriginalService

func (cfg *SysConfig) UsingOriginalService() bool

type SysRole

type SysRole struct {
	Name        string  `yaml:"name,omitempty"`
	Model       string  `yaml:"model,omitempty"`
	Avatar      string  `yaml:"avatar,omitempty"`
	Temperature float32 `yaml:"temperature,omitempty"`
	TopP        int     `yaml:"top_p,omitempty"`
	Prompt      string  `yaml:"prompt,omitempty"`
	Opening     string  `yaml:"opening,omitempty"`
}

type SysSystem

type SysSystem struct {
	SentryDSN         string `yaml:"sentry_dsn,omitempty"`
	ChatHistoryPath   string `yaml:"chat_history_path,omitempty"`
	LogPath           string `yaml:"log_path,omitempty"`
	LogLevel          string `yaml:"log_level,omitempty"`
	PeferenceLanguage string `yaml:"peference_language,omitempty"`
	DefaultRole       string `yaml:"default_role,omitempty"`
	APIEndpointOpenai string `yaml:"api_endpoint_openai,omitempty"`
	APIEndpointDeepl  string `yaml:"api_endpoint_deepl,omitempty"`
	// APIKeyOpenai      string `yaml:"api_key_openai,omitempty"`
	OpenaiApiKey string `yaml:"openai_api_key"`
	OpenaiOrgID  string `yaml:"openai_org_id"`
	DeeplApiKey  string `yaml:"deepl_api_key,omitempty"`

	// APIOrgIDOpenai string `yaml:"api_orgid_openai,omitempty"`
	UseSharedMode uint32 `yaml:"use_shared_mode,omitempty"`
	AppToken      string `yaml:"app_token,omitempty"`
	Email         string `yaml:"email,omitempty"`

	DebugMode bool `yaml:"debug_mode,omitempty"`
}

Jump to

Keyboard shortcuts

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