Skip to content

ollama build more customizable#9

Merged
seun-ja merged 2 commits into
mainfrom
initiate-ollama-with-env-var
Apr 13, 2026
Merged

ollama build more customizable#9
seun-ja merged 2 commits into
mainfrom
initiate-ollama-with-env-var

Conversation

@seun-ja

@seun-ja seun-ja commented Apr 13, 2026

Copy link
Copy Markdown
Owner

Makes Ollama build more configurable, can get base_url via env

Signed-off-by: Aminu Oluwaseun Joshua <seun.aminujoshua@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the Ollama provider client configuration more flexible by allowing the Ollama API base URL to be configured via an environment variable, rather than always using the default client settings.

Changes:

  • Switch Ollama client initialization to use Client::builder() instead of Client::new(...).
  • Read OLLAMA_API_BASE_URL from the environment with a localhost default.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/providers/ollama.rs Outdated
Comment on lines +108 to +109
let base_url =
std::env::var("OLLAMA_API_BASE_URL").unwrap_or("http://localhost:11434".to_string());

Copilot AI Apr 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::env::var(...).unwrap_or("http://localhost:11434".to_string()) eagerly allocates the default String even when the env var is set. Prefer unwrap_or_else (or a const/Cow) so the default allocation only happens on the error path.

Suggested change
let base_url =
std::env::var("OLLAMA_API_BASE_URL").unwrap_or("http://localhost:11434".to_string());
let base_url = std::env::var("OLLAMA_API_BASE_URL")
.unwrap_or_else(|_| "http://localhost:11434".to_string());

Copilot uses AI. Check for mistakes.
Comment thread src/providers/ollama.rs Outdated
Comment on lines +108 to +109
let base_url =
std::env::var("OLLAMA_API_BASE_URL").unwrap_or("http://localhost:11434".to_string());

Copilot AI Apr 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::env::var("OLLAMA_API_BASE_URL").unwrap_or(...) falls back to localhost for any VarError, including NotUnicode. That can silently ignore a misconfigured env var and be hard to diagnose. Consider only defaulting on VarError::NotPresent and returning an error for other cases.

Suggested change
let base_url =
std::env::var("OLLAMA_API_BASE_URL").unwrap_or("http://localhost:11434".to_string());
let base_url = match std::env::var("OLLAMA_API_BASE_URL") {
Ok(base_url) => base_url,
Err(std::env::VarError::NotPresent) => "http://localhost:11434".to_string(),
Err(err) => return Err(err.into()),
};

Copilot uses AI. Check for mistakes.
Signed-off-by: Aminu Oluwaseun Joshua <seun.aminujoshua@gmail.com>
@seun-ja
seun-ja merged commit 0e3b105 into main Apr 13, 2026
1 check passed
@seun-ja
seun-ja deleted the initiate-ollama-with-env-var branch April 13, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants