From 095c3c0c56a921b99914fd5dd0548ac70015986a Mon Sep 17 00:00:00 2001 From: Aminu Oluwaseun Joshua Date: Mon, 13 Apr 2026 04:09:10 +0100 Subject: [PATCH 1/2] ollama build more customizable Signed-off-by: Aminu Oluwaseun Joshua --- src/providers/ollama.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/providers/ollama.rs b/src/providers/ollama.rs index 4771050..1da2d37 100644 --- a/src/providers/ollama.rs +++ b/src/providers/ollama.rs @@ -2,7 +2,7 @@ use rig::{ agent::{Agent, AgentBuilder, WithBuilderTools}, client::{CompletionClient as _, Nothing}, completion::Prompt as _, - providers::ollama::{self, CompletionModel}, + providers::ollama::{Client, CompletionModel}, tool::Tool, }; use schemars::JsonSchema; @@ -105,7 +105,13 @@ pub fn builder( temperature: Option, max_tokens: Option, ) -> Result, Error> { - let ollama_client = ollama::Client::new(Nothing)?; + let base_url = + std::env::var("OLLAMA_API_BASE_URL").unwrap_or("http://localhost:11434".to_string()); + + let ollama_client = Client::builder() + .api_key(Nothing) + .base_url(&base_url) + .build()?; let builder = ollama_client .agent(model) From 9388c68379bfbe499de4afc5c2d49300191faa3e Mon Sep 17 00:00:00 2001 From: Aminu Oluwaseun Joshua Date: Mon, 13 Apr 2026 04:18:36 +0100 Subject: [PATCH 2/2] proper handling of var fallback error Signed-off-by: Aminu Oluwaseun Joshua --- src/providers/ollama.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/providers/ollama.rs b/src/providers/ollama.rs index 1da2d37..a3fa779 100644 --- a/src/providers/ollama.rs +++ b/src/providers/ollama.rs @@ -105,8 +105,11 @@ pub fn builder( temperature: Option, max_tokens: Option, ) -> Result, Error> { - 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(|_| { + #[cfg(feature = "tracing")] + tracing::warn!("OLLAMA_API_BASE_URL not set, using default: http://localhost:11434"); + "http://localhost:11434".to_string() + }); let ollama_client = Client::builder() .api_key(Nothing)