blob: 7b6cfc0e5f60b6717aa131d1c359269b7db7f2ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package config
import (
"fmt"
"github.com/BurntSushi/toml"
)
type Config struct {
APIURL string `toml:"APIURL"`
ShowSys bool `toml:"ShowSys"`
LogFile string `toml:"LogFile"`
UserRole string `toml:"UserRole"`
ToolRole string `toml:"ToolRole"`
AssistantRole string `toml:"AssistantRole"`
AssistantIcon string `toml:"AssistantIcon"`
UserIcon string `toml:"UserIcon"`
ToolIcon string `toml:"ToolIcon"`
ChunkLimit uint32 `toml:"ChunkLimit"`
}
func LoadConfigOrDefault(fn string) *Config {
if fn == "" {
fn = "config.toml"
}
config := &Config{}
_, err := toml.DecodeFile(fn, &config)
if err != nil {
fmt.Println("failed to read config from file, loading default")
config.APIURL = "http://localhost:8080/v1/chat/completions"
config.ShowSys = true
config.LogFile = "log.txt"
config.UserRole = "user"
config.ToolRole = "tool"
config.AssistantRole = "assistant"
config.ChunkLimit = 8192
}
return config
}
|