use tauri::State; use crate::AppState; use crate::ai::{AuthMethod, GeminiClient}; #[tauri::command] pub async fn set_gemini_auth(auth: AuthMethod, model: Option, state: State<'_, AppState>) -> Result<(), String> { let client = GeminiClient::new(auth, model.unwrap_or_else(|| "gemini-2.0-flash".to_string())); *state.gemini.lock().unwrap() = Some(client); Ok(()) } #[tauri::command] pub async fn gemini_chat(message: String, state: State<'_, AppState>) -> Result { let client = { let client_opt = state.gemini.lock().unwrap(); client_opt.as_ref().cloned().ok_or("Gemini not authenticated")? }; client.chat(&message).await.map_err(|e| e.to_string()) } #[tauri::command] pub fn is_gemini_authenticated(state: State<'_, AppState>) -> bool { state.gemini.lock().unwrap().is_some() }