]> git.giacomolli.uk - onechat/blobdiff - config.go
Order model and chat declarations
[onechat] / config.go
index 6e2da84bee797abf2e913a380fa9e92463d7fb35..fb24c20111448c3baac9597ae2c7e2b6eab98307 100644 (file)
--- a/config.go
+++ b/config.go
@@ -19,6 +19,19 @@ const (
        configEndpointAPI = "api"
 )
 
+// Config holds the settings of config.json in the data directory.
+type Config struct {
+       Endpoint  string      `json:"endpoint"`
+       Voice     VoiceConfig `json:"voice"`
+       Compactor ModelConfig `json:"compactor"`
+}
+
+// ModelConfig names a model and its reasoning effort.
+type ModelConfig struct {
+       Model  string `json:"model"`
+       Effort string `json:"effort"`
+}
+
 // loadConfig reads config.json in dir over the defaults. A missing file gives
 // the defaults. An unknown field is an error, so a typo does not become a
 // silent default.
@@ -35,6 +48,7 @@ func loadConfig(dir string) (Config, error) {
 
        decoder := json.NewDecoder(bytes.NewReader(data))
        decoder.DisallowUnknownFields()
+
        err = decoder.Decode(&config)
        if err == nil && !errors.Is(decoder.Decode(&struct{}{}), io.EOF) {
                err = errors.New("data after the JSON object")
@@ -51,12 +65,6 @@ func loadConfig(dir string) (Config, error) {
        return config, nil
 }
 
-// Config holds the settings of config.json in the data directory.
-type Config struct {
-       Endpoint  string      `json:"endpoint"`
-       Compactor ModelConfig `json:"compactor"`
-}
-
 // validate makes sure that each setting has a valid value.
 func (c Config) validate() error {
        if c.Endpoint != configEndpointChatGPT && c.Endpoint != configEndpointAPI {
@@ -70,12 +78,6 @@ func (c Config) validate() error {
        return nil
 }
 
-// ModelConfig names a model and its reasoning effort.
-type ModelConfig struct {
-       Model  string `json:"model"`
-       Effort string `json:"effort"`
-}
-
 // defaultConfig returns the settings that apply when config.json does not
 // set them.
 func defaultConfig() Config {