summaryrefslogtreecommitdiff
path: root/internal/appconfig
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-08-18 09:11:20 +0300
committerPaul Buetow <paul@buetow.org>2025-08-18 09:11:20 +0300
commit3217d2738af345629e7da14c52fa4ee5cb288fe9 (patch)
tree29381af9217aabc8fb9029225bfd7650e8f20717 /internal/appconfig
parent041d1f140436c6fdd223844b04c6592c84951878 (diff)
feat(config): per-provider temperature defaults and docs\n\n- Add , , to config with coding-friendly default 0.2.\n- Wire defaults through providers (OpenAI, Copilot, Ollama).\n- Update CLI and LSP runners to pass configured temperatures.\n- Document temperature behavior and examples in README.\n- Update config.json.example to show new keys.
Diffstat (limited to 'internal/appconfig')
-rw-r--r--internal/appconfig/config.go37
1 files changed, 29 insertions, 8 deletions
diff --git a/internal/appconfig/config.go b/internal/appconfig/config.go
index 7027547..c377467 100644
--- a/internal/appconfig/config.go
+++ b/internal/appconfig/config.go
@@ -13,7 +13,7 @@ import (
// App holds user-configurable settings read from ~/.config/hexai/config.json.
type App struct {
- MaxTokens int `json:"max_tokens"`
+ MaxTokens int `json:"max_tokens"`
ContextMode string `json:"context_mode"`
ContextWindowLines int `json:"context_window_lines"`
MaxContextTokens int `json:"max_context_tokens"`
@@ -22,23 +22,35 @@ type App struct {
TriggerCharacters []string `json:"trigger_characters"`
Provider string `json:"provider"`
- // Provider-specific options
- OpenAIBaseURL string `json:"openai_base_url"`
- OpenAIModel string `json:"openai_model"`
- OllamaBaseURL string `json:"ollama_base_url"`
- OllamaModel string `json:"ollama_model"`
- CopilotBaseURL string `json:"copilot_base_url"`
- CopilotModel string `json:"copilot_model"`
+ // Provider-specific options
+ OpenAIBaseURL string `json:"openai_base_url"`
+ OpenAIModel string `json:"openai_model"`
+ // Default temperature for OpenAI requests (nil means use provider default)
+ OpenAITemperature *float64 `json:"openai_temperature"`
+ OllamaBaseURL string `json:"ollama_base_url"`
+ OllamaModel string `json:"ollama_model"`
+ // Default temperature for Ollama requests (nil means use provider default)
+ OllamaTemperature *float64 `json:"ollama_temperature"`
+ CopilotBaseURL string `json:"copilot_base_url"`
+ CopilotModel string `json:"copilot_model"`
+ // Default temperature for Copilot requests (nil means use provider default)
+ CopilotTemperature *float64 `json:"copilot_temperature"`
}
// Constructor: defaults for App (kept first among functions)
func newDefaultConfig() App {
+ // Coding-friendly default temperature across providers
+ // Users can override per provider in config.json (including 0.0).
+ t := 0.2
return App{
MaxTokens: 4000,
ContextMode: "always-full",
ContextWindowLines: 120,
MaxContextTokens: 4000,
LogPreviewLimit: 100,
+ OpenAITemperature: &t,
+ OllamaTemperature: &t,
+ CopilotTemperature: &t,
}
}
@@ -115,18 +127,27 @@ func (a *App) mergeWith(other *App) {
if strings.TrimSpace(other.OpenAIModel) != "" {
a.OpenAIModel = other.OpenAIModel
}
+ if other.OpenAITemperature != nil { // allow explicit 0.0
+ a.OpenAITemperature = other.OpenAITemperature
+ }
if strings.TrimSpace(other.OllamaBaseURL) != "" {
a.OllamaBaseURL = other.OllamaBaseURL
}
if strings.TrimSpace(other.OllamaModel) != "" {
a.OllamaModel = other.OllamaModel
}
+ if other.OllamaTemperature != nil { // allow explicit 0.0
+ a.OllamaTemperature = other.OllamaTemperature
+ }
if strings.TrimSpace(other.CopilotBaseURL) != "" {
a.CopilotBaseURL = other.CopilotBaseURL
}
if strings.TrimSpace(other.CopilotModel) != "" {
a.CopilotModel = other.CopilotModel
}
+ if other.CopilotTemperature != nil { // allow explicit 0.0
+ a.CopilotTemperature = other.CopilotTemperature
+ }
}
func getConfigPath() (string, error) {