Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/providers/ollama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,7 +105,16 @@ pub fn builder(
temperature: Option<f64>,
max_tokens: Option<u64>,
) -> Result<AgentBuilder<CompletionModel>, Error> {
let ollama_client = ollama::Client::new(Nothing)?;
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)
.base_url(&base_url)
.build()?;

let builder = ollama_client
.agent(model)
Expand Down
Loading