Skip to content
7 changes: 5 additions & 2 deletions extensions/llamacpp-extension/src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ export async function downloadBackend(
// Get proxy configuration from localStorage
const proxyConfig = getProxyConfig()

const sysInfo = await window.core.api.getSystemInfo()
const platformName = sysInfo.os_type === 'windows' ? 'win' : 'linux'

const downloadItems = [
{
url: `https://github.com/menloresearch/llama.cpp/releases/download/${version}/llama-${version}-bin-${backend}.tar.gz`,
Expand All @@ -147,13 +150,13 @@ export async function downloadBackend(
// also download CUDA runtime + cuBLAS + cuBLASLt if needed
if (backend.includes('cu11.7') && !(await _isCudaInstalled('11.7'))) {
downloadItems.push({
url: `https://github.com/menloresearch/llama.cpp/releases/download/${version}/cudart-llama-bin-linux-cu11.7-x64.tar.gz`,
url: `https://github.com/menloresearch/llama.cpp/releases/download/${version}/cudart-llama-bin-${platformName}-cu11.7-x64.tar.gz`,
save_path: await joinPath([libDir, 'cuda11.tar.gz']),
proxy: proxyConfig,
})
} else if (backend.includes('cu12.0') && !(await _isCudaInstalled('12.0'))) {
downloadItems.push({
url: `https://github.com/menloresearch/llama.cpp/releases/download/${version}/cudart-llama-bin-linux-cu12.0-x64.tar.gz`,
url: `https://github.com/menloresearch/llama.cpp/releases/download/${version}/cudart-llama-bin-${platformName}-cu12.0-x64.tar.gz`,
save_path: await joinPath([libDir, 'cuda12.tar.gz']),
proxy: proxyConfig,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,25 @@ pub async fn load_llama_model(
Err(_) => lib_path.to_string(),
};
command.env("PATH", new_path);

// Normalize the path by removing UNC prefix if present
let normalized_path = lib_path.trim_start_matches(r"\\?\").to_string();
log::info!("Library path:\n{}", &normalized_path);

// Only set current_dir if the normalized path exists and is a directory
let path = std::path::Path::new(&normalized_path);
if path.exists() && path.is_dir() {
command.current_dir(&normalized_path);
} else {
log::warn!(
"Library path '{}' does not exist or is not a directory",
normalized_path
);
}
} else {
log::warn!("Library path setting is not supported on this OS");
}
}

command.stdout(Stdio::piped());
command.stderr(Stdio::piped());
#[cfg(all(windows, target_arch = "x86_64"))]
Expand Down
Loading