(&self)
| 312 | } |
| 313 | |
| 314 | fn resolve_server_binary(&self) -> Result<PathBuf, AppError> { |
| 315 | if let Ok(path) = std::env::var("OPENLLM_LLAMA_SERVER_PATH") { |
| 316 | let binary = PathBuf::from(path); |
| 317 | if binary.exists() { |
| 318 | return Ok(binary); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | let binary_name = if cfg!(target_os = "windows") { |
| 323 | "llama-server.exe" |
| 324 | } else { |
| 325 | "llama-server" |
| 326 | }; |
| 327 | |
| 328 | let candidates = if cfg!(target_os = "windows") { |
| 329 | self.windows_binary_candidates(binary_name) |
| 330 | } else { |
| 331 | vec![self.runtime_root.join(binary_name)] |
| 332 | }; |
| 333 | |
| 334 | for candidate in &candidates { |
| 335 | println!("[RuntimeManager] Checking binary candidate: {} -> exists: {}", candidate.display(), candidate.exists()); |
| 336 | if candidate.exists() { |
| 337 | println!("[RuntimeManager] Found binary at: {}", candidate.display()); |
| 338 | return Ok(candidate.clone()); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | Err(AppError::RuntimeError(format!( |
| 343 | "Could not find a usable llama.cpp server binary. Checked: {}. Put your binaries under '{}'", |
| 344 | candidates |
| 345 | .iter() |
| 346 | .map(|path| format!("'{}'", path.display())) |
| 347 | .collect::<Vec<_>>() |
| 348 | .join(", "), |
| 349 | self.runtime_root.display() |
| 350 | ))) |
| 351 | } |
| 352 | |
| 353 | fn windows_binary_candidates(&self, binary_name: &str) -> Vec<PathBuf> { |
| 354 | let has_nvidia = Self::has_command("nvidia-smi"); |
no test coverage detected