* initial specta commands * refactor to use the bindings in the ui * merge fixes * remove unused commands * add clamshell to lib * Remove Invoke from everything. * fix settings not being loaded properly * fix settings being overwritten due to deserialization failure + remove provider kind * fix model loading text bug
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use crate::managers::transcription::TranscriptionManager;
|
|
use crate::settings::{get_settings, write_settings, ModelUnloadTimeout};
|
|
use serde::Serialize;
|
|
use specta::Type;
|
|
use tauri::{AppHandle, State};
|
|
|
|
#[derive(Serialize, Type)]
|
|
pub struct ModelLoadStatus {
|
|
is_loaded: bool,
|
|
current_model: Option<String>,
|
|
}
|
|
|
|
#[tauri::command]
|
|
#[specta::specta]
|
|
pub fn set_model_unload_timeout(app: AppHandle, timeout: ModelUnloadTimeout) {
|
|
let mut settings = get_settings(&app);
|
|
settings.model_unload_timeout = timeout;
|
|
write_settings(&app, settings);
|
|
}
|
|
|
|
#[tauri::command]
|
|
#[specta::specta]
|
|
pub fn get_model_load_status(
|
|
transcription_manager: State<TranscriptionManager>,
|
|
) -> Result<ModelLoadStatus, String> {
|
|
Ok(ModelLoadStatus {
|
|
is_loaded: transcription_manager.is_model_loaded(),
|
|
current_model: transcription_manager.get_current_model(),
|
|
})
|
|
}
|
|
|
|
#[tauri::command]
|
|
#[specta::specta]
|
|
pub fn unload_model_manually(
|
|
transcription_manager: State<TranscriptionManager>,
|
|
) -> Result<(), String> {
|
|
transcription_manager
|
|
.unload_model()
|
|
.map_err(|e| format!("Failed to unload model: {}", e))
|
|
}
|