mod llm;
mod commands;

use llm::AppState;
use std::sync::Mutex;

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_log::Builder::default().build())
        .plugin(tauri_plugin_store::Builder::default().build())
        .plugin(tauri_plugin_fs::init())
        .manage(AppState {
            config: Mutex::new(llm::LlmConfig::default()),
        })
        .invoke_handler(tauri::generate_handler![
            greet,
            commands::llm_commands::generate,
            commands::llm_commands::generate_stream,
            commands::llm_commands::get_llm_config,
            commands::llm_commands::set_llm_config,
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! Welcome to DM-Pal ⚔", name)
}