diff options
| author | Paul Buetow <paul@buetow.org> | 2025-08-16 23:16:54 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-08-16 23:16:54 +0300 |
| commit | 765eda955eb811d08d867ff4d3914fc6d60c22dd (patch) | |
| tree | fdc87da6af9d86dbda2ea9ab08244e93fd167188 /internal/llm/ollama.go | |
| parent | 1b01e35c34b953cbf51298f4650dc3215c382a4f (diff) | |
refactor(config): drop env-based config (except OPENAI_API_KEY)
- Switch to config-file-only; only OPENAI_API_KEY read from env.\n- llm: replace env autodetect with Config + NewFromConfig; add newOpenAI/newOllama.\n- lsp: NewServer now accepts injected llm.Client.\n- cli: remove env overrides; extend appConfig with provider-specific fields; build client from config + OPENAI_API_KEY.\n- docs: update README (config-only, defaults to OpenAI, minimal example); simplify flags table.\n- add config.json.example.\n- prompts: enforce ;text; (no spaces) and add ;;text; to remove entire line; tests added.
Diffstat (limited to 'internal/llm/ollama.go')
| -rw-r--r-- | internal/llm/ollama.go | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/internal/llm/ollama.go b/internal/llm/ollama.go index 495b5c2..db3e06b 100644 --- a/internal/llm/ollama.go +++ b/internal/llm/ollama.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "net/http" - "os" "strings" "time" @@ -21,22 +20,16 @@ type ollamaClient struct { defaultModel string } -func newOllamaFromEnv() Client { - // Prefer OLLAMA_BASE_URL, fall back to OLLAMA_HOST, then default. - base := strings.TrimSpace(os.Getenv("OLLAMA_BASE_URL")) - if base == "" { - base = strings.TrimSpace(os.Getenv("OLLAMA_HOST")) +func newOllama(baseURL, model string) Client { + if strings.TrimSpace(baseURL) == "" { + baseURL = "http://localhost:11434" } - if base == "" { - base = "http://localhost:11434" - } - model := strings.TrimSpace(os.Getenv("OLLAMA_MODEL")) - if model == "" { + if strings.TrimSpace(model) == "" { model = "qwen2.5-coder:latest" } return &ollamaClient{ httpClient: &http.Client{Timeout: 30 * time.Second}, - baseURL: strings.TrimRight(base, "/"), + baseURL: strings.TrimRight(baseURL, "/"), defaultModel: model, } } |
