@@ -234,6 +234,22 @@ var (
234234 }
235235 errSelectionCancelled = errors .New ("selection cancelled" )
236236)
237+ // resolveOllamaConfig returns the URL and model for Ollama, using environment variables as fallbacks
238+ func resolveOllamaConfig (apiKey string ) (url , model string ) {
239+ url = apiKey
240+ if strings .TrimSpace (url ) == "" {
241+ url = os .Getenv ("OLLAMA_URL" )
242+ if url == "" {
243+ url = "http://localhost:11434/api/generate"
244+ }
245+ }
246+ model = os .Getenv ("OLLAMA_MODEL" )
247+ if model == "" {
248+ model = "llama3.1"
249+ }
250+ return url , model
251+ }
252+
237253
238254func generateMessage (provider types.LLMProvider , config * types.Config , changes string , apiKey string , opts * types.GenerationOptions ) (string , error ) {
239255 switch provider {
@@ -246,17 +262,7 @@ func generateMessage(provider types.LLMProvider, config *types.Config, changes s
246262 case types .ProviderGroq :
247263 return groq .GenerateCommitMessage (config , changes , apiKey , opts )
248264 case types .ProviderOllama :
249- url := apiKey
250- if strings .TrimSpace (url ) == "" {
251- url = os .Getenv ("OLLAMA_URL" )
252- if url == "" {
253- url = "http://localhost:11434/api/generate"
254- }
255- }
256- model := os .Getenv ("OLLAMA_MODEL" )
257- if model == "" {
258- model = "llama3.1"
259- }
265+ url , model := resolveOllamaConfig (apiKey )
260266 return ollama .GenerateCommitMessage (config , changes , url , model , opts )
261267 default :
262268 return grok .GenerateCommitMessage (config , changes , apiKey , opts )
@@ -454,17 +460,7 @@ func displayDryRunInfo(provider types.LLMProvider, config *types.Config, changes
454460 // Add provider-specific info
455461 switch provider {
456462 case types .ProviderOllama :
457- url := apiKey
458- if strings .TrimSpace (url ) == "" {
459- url = os .Getenv ("OLLAMA_URL" )
460- if url == "" {
461- url = "http://localhost:11434/api/generate"
462- }
463- }
464- model := os .Getenv ("OLLAMA_MODEL" )
465- if model == "" {
466- model = "llama3.1"
467- }
463+ url , model := resolveOllamaConfig (apiKey )
468464 providerInfo = append (providerInfo , []string {"Ollama URL" , url })
469465 providerInfo = append (providerInfo , []string {"Model" , model })
470466 case types .ProviderGrok :
@@ -515,6 +511,10 @@ func maskAPIKey(apiKey string) string {
515511 if len (apiKey ) == 0 {
516512 return "[NOT SET]"
517513 }
514+ // Don't mask URLs (used by Ollama)
515+ if strings .HasPrefix (apiKey , "http://" ) || strings .HasPrefix (apiKey , "https://" ) {
516+ return apiKey
517+ }
518518 if len (apiKey ) <= 8 {
519519 return strings .Repeat ("*" , len (apiKey ))
520520 }
0 commit comments