Dinh Long Nguyen e1c8d98bf2
Backend Architecture Refactoring (#6094) (#6162)
* add llamacpp plugin

* Refactor llamacpp plugin

* add utils plugin

* remove utils folder

* add hardware implementation

* add utils folder + move utils function

* organize cargo files

* refactor utils src

* refactor util

* apply fmt

* fmt

* Update gguf + reformat

* add permission for gguf commands

* fix cargo test windows

* revert yarn lock

* remove cargo.lock for hardware plugin

* ignore cargo.lock file

* Fix hardware invoke + refactor hardware + refactor tests, constants

* use api wrapper in extension to invoke hardware call + api wrapper build integration

* add newline at EOF (per Akarshan)

* add vi mock for getSystemInfo
2025-08-15 08:59:01 +07:00

44 lines
1.2 KiB
Rust

use tauri::{
plugin::{Builder, TauriPlugin},
Manager, Runtime,
};
pub mod cleanup;
mod commands;
mod device;
mod error;
mod gguf;
mod path;
mod process;
pub mod state;
pub use cleanup::cleanup_llama_processes;
pub use state::LLamaBackendSession;
/// Initializes the plugin.
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("llamacpp")
.invoke_handler(tauri::generate_handler![
// Cleanup command
cleanup::cleanup_llama_processes,
// LlamaCpp server commands
commands::load_llama_model,
commands::unload_llama_model,
commands::get_devices,
commands::generate_api_key,
commands::is_process_running,
commands::get_random_port,
commands::find_session_by_model,
commands::get_loaded_models,
commands::get_all_sessions,
commands::get_session_by_model,
// GGUF commands
gguf::commands::read_gguf_metadata,
])
.setup(|app, _api| {
// Initialize and manage the plugin state
app.manage(state::LlamacppState::new());
Ok(())
})
.build()
}