add Jan's library path to path
This commit is contained in:
parent
65d6f34878
commit
95944fa081
@ -457,6 +457,7 @@ export default class llamacpp_extension extends AIEngine {
|
|||||||
// TODO: add LIBRARY_PATH
|
// TODO: add LIBRARY_PATH
|
||||||
const sInfo = await invoke<sessionInfo>('load_llama_model', {
|
const sInfo = await invoke<sessionInfo>('load_llama_model', {
|
||||||
backendPath: await getBackendExePath(backend, version),
|
backendPath: await getBackendExePath(backend, version),
|
||||||
|
libraryPath: await joinPath([this.providerPath, 'lib']),
|
||||||
args,
|
args,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use hmac::{Hmac, Mac};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tauri::{AppHandle, State}; // Import Manager trait
|
use tauri::State; // Import Manager trait
|
||||||
use thiserror;
|
use thiserror;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
@ -56,9 +56,9 @@ pub struct unloadResult {
|
|||||||
// --- Load Command ---
|
// --- Load Command ---
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn load_llama_model(
|
pub async fn load_llama_model(
|
||||||
_app_handle: AppHandle, // Get the AppHandle
|
|
||||||
state: State<'_, AppState>, // Access the shared state
|
state: State<'_, AppState>, // Access the shared state
|
||||||
backend_path: &str,
|
backend_path: &str,
|
||||||
|
library_path: Option<&str>,
|
||||||
args: Vec<String>, // Arguments from the frontend
|
args: Vec<String>, // Arguments from the frontend
|
||||||
) -> ServerResult<sessionInfo> {
|
) -> ServerResult<sessionInfo> {
|
||||||
let mut process_lock = state.llama_server_process.lock().await;
|
let mut process_lock = state.llama_server_process.lock().await;
|
||||||
@ -115,6 +115,24 @@ pub async fn load_llama_model(
|
|||||||
let mut command = Command::new(backend_path);
|
let mut command = Command::new(backend_path);
|
||||||
command.args(args);
|
command.args(args);
|
||||||
|
|
||||||
|
if let Some(lib_path) = library_path {
|
||||||
|
if cfg!(target_os = "linux") {
|
||||||
|
let new_lib_path = match std::env::var("LD_LIBRARY_PATH") {
|
||||||
|
Ok(path) => format!("{}:{}", path, lib_path),
|
||||||
|
Err(_) => lib_path.to_string(),
|
||||||
|
};
|
||||||
|
command.env("LD_LIBRARY_PATH", new_lib_path);
|
||||||
|
} else if cfg!(target_os = "windows") {
|
||||||
|
let new_path = match std::env::var("PATH") {
|
||||||
|
Ok(path) => format!("{};{}", path, lib_path),
|
||||||
|
Err(_) => lib_path.to_string(),
|
||||||
|
};
|
||||||
|
command.env("PATH", new_path);
|
||||||
|
} else {
|
||||||
|
log::warn!("Library path setting is not supported on this OS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Optional: Redirect stdio if needed (e.g., for logging within Jan)
|
// Optional: Redirect stdio if needed (e.g., for logging within Jan)
|
||||||
// command.stdout(Stdio::piped());
|
// command.stdout(Stdio::piped());
|
||||||
// command.stderr(Stdio::piped());
|
// command.stderr(Stdio::piped());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user