This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/agent/models.go

42 lines
1007 B
Go

package agent
import (
"os"
"path/filepath"
"gopkg.in/yaml.v3"
)
// modelsConfig holds the parsed contents of ~/.config/ollie/models.yaml.
type modelsConfig struct {
Compaction map[string]string `yaml:"compaction"`
Completion struct {
Model string `yaml:"model"`
Backend string `yaml:"backend"`
} `yaml:"completion"`
}
// loadModelsConfig reads and parses the models config file.
// Returns zero value if the file doesn't exist or is invalid.
func loadModelsConfig() modelsConfig {
path := filepath.Join(cfgDir(), "models.yaml")
data, err := os.ReadFile(path)
if err != nil {
return modelsConfig{}
}
var cfg modelsConfig
if err := yaml.Unmarshal(data, &cfg); err != nil {
return modelsConfig{}
}
return cfg
}
// cfgDir returns the ollie config directory, respecting XDG_CONFIG_HOME.
func cfgDir() string {
if xdg := os.Getenv("XDG_CONFIG_HOME"); xdg != "" {
return filepath.Join(xdg, "ollie")
}
home, _ := os.UserHomeDir()
return filepath.Join(home, ".config", "ollie")
}