| 1 | //! Tauri command: `chat_get_history` |
| 2 | //! |
| 3 | //! Returns the full conversation history from the cached chat state. |
| 4 | |
| 5 | use super::ChatMessagePayload; |
| 6 | |
| 7 | #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android"))] |
| 8 | use {super::ENGINE, onde::inference::ChatRole}; |
| 9 | |
| 10 | /// Return the full conversation history. |
| 11 | #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android"))] |
| 12 | #[tauri::command] |
| 13 | pub async fn chat_get_history() -> Vec<ChatMessagePayload> { |
| 14 | ENGINE |
| 15 | .history() |
| 16 | .await |
| 17 | .into_iter() |
| 18 | .map(|msg| ChatMessagePayload { |
| 19 | role: match msg.role { |
| 20 | ChatRole::User => "user".to_string(), |
| 21 | ChatRole::Assistant => "assistant".to_string(), |
| 22 | ChatRole::System => "system".to_string(), |
| 23 | }, |
| 24 | content: msg.content, |
| 25 | }) |
| 26 | .collect() |
| 27 | } |
| 28 | |
| 29 | #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))] |
| 30 | #[tauri::command] |
| 31 | pub async fn chat_get_history() -> Vec<ChatMessagePayload> { |
| 32 | Vec::new() |
| 33 | } |