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.
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")
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 {
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 {