config

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefault

func SetDefault(v *Configuration)

SetDefault makes v the default Configuration.

func Setup

func Setup(v *Configuration) error

func WebListenAndServe added in v0.3.2

func WebListenAndServe(handler http.Handler,
	cfg *WebServerConfig,
	wg *sync.WaitGroup,
	logger *slog.Logger) (*http.Server, error)

func WebShutdown added in v0.3.2

func WebShutdown(svr *http.Server, logger *slog.Logger)

Types

type AppConfig

type AppConfig struct {
	Path string `json:"path"` // C:\opt\_test\option.test.exe
	Dir  string `json:"dir"`  // C:\opt\_test
}

AppConfig app config

type Configuration added in v0.3.2

type Configuration struct {
	App    *AppConfig       `json:"app"`    // 程序运行目录
	Log    *LogConfig       `json:"log"`    // 日志
	Web    *WebServerConfig `json:"web"`    // web server
	OpenAI *OpenAIConfig    `json:"openai"` // openai
}

Configuration 配置

func Default

func Default() *Configuration

Default returns the default Configuration.

func New

func New(appDirIn string) *Configuration

New init config

func (*Configuration) Print added in v0.3.2

func (p *Configuration) Print()

Print 打印配置

type LogConfig

type LogConfig struct {
	Caller bool   `yaml:"caller,omitempty"` // true=打印代码名称和行号
	Level  string `yaml:"level,omitempty"`  // 输出日志level
	Format string `yaml:"format,omitempty"` // 日志输出格式 text, json
}

LogConfig 日志配置

type OpenAIConfig

type OpenAIConfig struct {
	ApiType    string `json:"api_type,omitempty"`     // api类型
	ApiKey     string `json:"api_key"`                // api key
	ApiBaseUrl string `json:"api_base_url,omitempty"` // base url
	Proxy      string `json:"proxy,omitempty"`        // 代理
	Model      string `json:"model"`                  // 运行模式
	System     string `json:"system,omitempty"`       // 系统提示信息
	SystemRaw  bool   `json:"system_raw,omitempty"`   // 系统提示信息不支持“\”转义
	Stream     bool   `json:"stream"`                 // 流模式
	MaxTokens  uint   `json:"max_tokens"`             // 最大tokens
	History    uint   `json:"history"`                // 历史记录
}

OpenAIConfig chatGPT配置

type WebServerConfig added in v0.3.2

type WebServerConfig struct {
	Port uint `json:"port"` // 服务端口
}

WebServerConfig web server配置

Jump to

Keyboard shortcuts

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