Allows use of a port number for a custom OpenAI provider (#4312)

Signed-off-by: V. Lascik <vlascik@users.noreply.github.com>
This commit is contained in:
vlascik
2025-08-25 20:49:31 +02:00
committed by GitHub
parent e7ee5fc2f1
commit 21c0bb00cc
+10 -1
View File
@@ -121,7 +121,16 @@ impl OpenAiProvider {
let url = url::Url::parse(&config.base_url)
.map_err(|e| anyhow::anyhow!("Invalid base URL '{}': {}", config.base_url, e))?;
let host = format!("{}://{}", url.scheme(), url.host_str().unwrap_or(""));
let host = if let Some(port) = url.port() {
format!(
"{}://{}:{}",
url.scheme(),
url.host_str().unwrap_or(""),
port
)
} else {
format!("{}://{}", url.scheme(), url.host_str().unwrap_or(""))
};
let base_path = url.path().trim_start_matches('/').to_string();
let base_path = if base_path.is_empty() {
"v1/chat/completions".to_string()