diff options
| author | Paul Buetow <paul@buetow.org> | 2025-08-19 23:12:56 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-08-19 23:12:56 +0300 |
| commit | fd8e2fe8177305c9271d12c90cc6ad2ed73a1673 (patch) | |
| tree | 362e20bb2ddc20821b1666c207cf073b1ff13f34 /internal/hexaicli | |
| parent | 7abb7c9177d34f3b2a1773624f0da7daa8c8e2de (diff) | |
config: add HEXAI_* env overrides with precedence; prefer HEXAI_OPENAI_API_KEY over OPENAI_API_KEY; update docs
Diffstat (limited to 'internal/hexaicli')
| -rw-r--r-- | internal/hexaicli/run.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/hexaicli/run.go b/internal/hexaicli/run.go index cfc70ec..8cd5c82 100644 --- a/internal/hexaicli/run.go +++ b/internal/hexaicli/run.go @@ -83,9 +83,13 @@ func newClientFromConfig(cfg appconfig.App) (llm.Client, error) { CopilotModel: cfg.CopilotModel, CopilotTemperature: cfg.CopilotTemperature, } - oaKey := os.Getenv("OPENAI_API_KEY") - cpKey := os.Getenv("COPILOT_API_KEY") - return llm.NewFromConfig(llmCfg, oaKey, cpKey) + // Prefer HEXAI_OPENAI_API_KEY; fall back to OPENAI_API_KEY + oaKey := os.Getenv("HEXAI_OPENAI_API_KEY") + if strings.TrimSpace(oaKey) == "" { + oaKey = os.Getenv("OPENAI_API_KEY") + } + cpKey := os.Getenv("COPILOT_API_KEY") + return llm.NewFromConfig(llmCfg, oaKey, cpKey) } // buildMessages creates system and user messages based on input content. |
