fix(ollama): respect ollama URL and port (#2004)
This commit is contained in:
@@ -65,8 +65,13 @@ impl OllamaProvider {
|
||||
.map_err(|e| ProviderError::RequestFailed(format!("Invalid base URL: {e}")))?;
|
||||
|
||||
// Set the default port if missing
|
||||
// Don't add default port if:
|
||||
// 1. URL explicitly ends with standard ports (:80 or :443)
|
||||
// 2. URL uses HTTPS (which implicitly uses port 443)
|
||||
let explicit_default_port = self.host.ends_with(":80") || self.host.ends_with(":443");
|
||||
if base_url.port().is_none() && !explicit_default_port {
|
||||
let is_https = base_url.scheme() == "https";
|
||||
|
||||
if base_url.port().is_none() && !explicit_default_port && !is_https {
|
||||
base_url.set_port(Some(OLLAMA_DEFAULT_PORT)).map_err(|_| {
|
||||
ProviderError::RequestFailed("Failed to set default port".to_string())
|
||||
})?;
|
||||
|
||||
@@ -96,8 +96,13 @@ impl OllamaInterpreter {
|
||||
.map_err(|e| ProviderError::RequestFailed(format!("Invalid base URL: {e}")))?;
|
||||
|
||||
// Set the default port if missing
|
||||
// Don't add default port if:
|
||||
// 1. URL explicitly ends with standard ports (:80 or :443)
|
||||
// 2. URL uses HTTPS (which implicitly uses port 443)
|
||||
let explicit_default_port = host.ends_with(":80") || host.ends_with(":443");
|
||||
if base_url.port().is_none() && !explicit_default_port {
|
||||
let is_https = base_url.scheme() == "https";
|
||||
|
||||
if base_url.port().is_none() && !explicit_default_port && !is_https {
|
||||
base_url.set_port(Some(OLLAMA_DEFAULT_PORT)).map_err(|_| {
|
||||
ProviderError::RequestFailed("Failed to set default port".to_string())
|
||||
})?;
|
||||
|
||||
Reference in New Issue
Block a user