-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
39 lines (33 loc) · 788 Bytes
/
config.go
File metadata and controls
39 lines (33 loc) · 788 Bytes
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 main
import (
"encoding/json"
"io/ioutil"
"os"
)
type Config struct {
ProxyOption string `json:"PROXY_OPTION"`
APIKey string `json:"APIKEY"`
APIURL string `json:"API_URL"`
Model string `json:"API_MODEL"`
MaxTokens int `json:"API_MAX_TOKENS"`
Temperature int `json:"API_TEMPERATURE"`
Stream bool `json:"API_STREAM"`
APITimeout int `json:"API_TIMEOUT"`
}
func LoadConfig(filename string) (Config, error) {
configFile, err := os.Open(filename)
if err != nil {
return Config{}, err
}
defer configFile.Close()
configData, err := ioutil.ReadAll(configFile)
if err != nil {
return Config{}, err
}
var config Config
err = json.Unmarshal(configData, &config)
if err != nil {
return Config{}, err
}
return config, nil
}