| 1 | //! Tauri command: `chat_get_status` |
| 2 | //! |
| 3 | //! Returns the current status of the chat model and conversation. |
| 4 | |
| 5 | use super::ChatStatusResponse; |
| 6 | |
| 7 | #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android"))] |
| 8 | use {super::ENGINE, crate::constants::ChatStatus, onde::inference::EngineStatus}; |
| 9 | |
| 10 | /// Get the current status of the chat model and conversation. |
| 11 | #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android"))] |
| 12 | #[tauri::command] |
| 13 | pub async fn chat_get_status() -> ChatStatusResponse { |
| 14 | let info = ENGINE.info().await; |
| 15 | let status = match info.status { |
| 16 | EngineStatus::Ready => ChatStatus::Ready, |
| 17 | EngineStatus::Unloaded => ChatStatus::Unloaded, |
| 18 | EngineStatus::Loading => ChatStatus::Loading, |
| 19 | EngineStatus::Generating => ChatStatus::Ready, |
| 20 | EngineStatus::Error => ChatStatus::Error, |
| 21 | }; |
| 22 | ChatStatusResponse { |
| 23 | status, |
| 24 | model_name: info.model_name, |
| 25 | approx_memory: info.approx_memory, |
| 26 | history_length: info.history_length as usize, |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))] |
| 31 | #[tauri::command] |
| 32 | pub async fn chat_get_status() -> ChatStatusResponse { |
| 33 | use crate::constants::ChatStatus; |
| 34 | |
| 35 | ChatStatusResponse { |
| 36 | status: ChatStatus::Unloaded, |
| 37 | model_name: None, |
| 38 | approx_memory: None, |
| 39 | history_length: 0, |
| 40 | } |
| 41 | } |