Skip to content

Commit 63fdf3c

Browse files
committed
fixed reading config
1 parent ed9a7cc commit 63fdf3c

2 files changed

Lines changed: 33 additions & 11 deletions

File tree

internal/config/config.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,27 @@ func ApplyToAppConfig(jcfg *JSONConfig, appCfg *types.AppConfig) {
5959
if jcfg.Agent != "" {
6060
appCfg.Provider = jcfg.Agent
6161
}
62-
// Use gmodel for gemini, model for ollama
63-
switch jcfg.Agent {
64-
case "gemini":
65-
if jcfg.GModel != "" {
66-
appCfg.DefaultModel = jcfg.GModel
62+
63+
// Update stored models if present in config
64+
if jcfg.GModel != "" {
65+
appCfg.GeminiModel = jcfg.GModel
66+
}
67+
if jcfg.Model != "" {
68+
appCfg.OllamaModel = jcfg.Model
69+
}
70+
71+
// Set active model based on provider
72+
if appCfg.Provider == "gemini" {
73+
if appCfg.GeminiModel != "" {
74+
appCfg.DefaultModel = appCfg.GeminiModel
6775
}
68-
default:
69-
if jcfg.Model != "" {
70-
appCfg.DefaultModel = jcfg.Model
76+
} else {
77+
// Default to ollama
78+
if appCfg.OllamaModel != "" {
79+
appCfg.DefaultModel = appCfg.OllamaModel
7180
}
7281
}
82+
7383
if jcfg.OllamaURL != "" {
7484
appCfg.OllamaURL = jcfg.OllamaURL
7585
}
@@ -88,11 +98,19 @@ func AppConfigToJSONConfig(appCfg *types.AppConfig) *JSONConfig {
8898
OllamaURL: appCfg.OllamaURL,
8999
GeminiAPI: appCfg.GeminiAPIKey,
90100
Workspace: appCfg.WorkspaceDir,
101+
Model: appCfg.OllamaModel,
102+
GModel: appCfg.GeminiModel,
91103
}
104+
105+
// Ensure active model is synced to the correct field if stored model is empty
92106
if appCfg.Provider == "gemini" {
93-
jcfg.GModel = appCfg.DefaultModel
107+
if jcfg.GModel == "" {
108+
jcfg.GModel = appCfg.DefaultModel
109+
}
94110
} else {
95-
jcfg.Model = appCfg.DefaultModel
111+
if jcfg.Model == "" {
112+
jcfg.Model = appCfg.DefaultModel
113+
}
96114
}
97115
return jcfg
98116
}

internal/types/types.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ const (
1717

1818
// AppConfig holds application configuration
1919
type AppConfig struct {
20-
Provider string `yaml:"provider"` // "ollama" or "gemini"
20+
Provider string `yaml:"provider"` // "ollama" or "gemini"
2121
OllamaURL string `yaml:"ollama_url"`
2222
GeminiAPIKey string `yaml:"gemini_api_key"`
2323
DefaultModel string `yaml:"default_model"`
24+
OllamaModel string `yaml:"ollama_model"`
25+
GeminiModel string `yaml:"gemini_model"`
2426
EditorTheme string `yaml:"editor_theme"`
2527
WorkspaceDir string `yaml:"workspace_dir"`
2628
AutoSave bool `yaml:"auto_save"`
@@ -35,6 +37,8 @@ func DefaultConfig() *AppConfig {
3537
OllamaURL: "http://localhost:11434",
3638
GeminiAPIKey: "",
3739
DefaultModel: "llama2",
40+
OllamaModel: "llama2",
41+
GeminiModel: "gemini-2.0-flash-exp",
3842
EditorTheme: "monokai",
3943
WorkspaceDir: filepath.Join(homeDir, "ti-workspace"),
4044
AutoSave: false,

0 commit comments

Comments
 (0)