//! Smoke test: load a GGUF model and exercise the high-level wrappers.
//!
//! Verified against llama-cpp-2 `0.1.144` using:
//! - `llama_backend::LlamaBackend`
//! - `model::LlamaModel`
//! - `context::params::LlamaContextParams`
//! - `sampling::LlamaSampler`
//!
//! The test is gated behind `LUMOTIA_LLM_TEST_MODEL`.

use std::env;
use std::path::PathBuf;

use lumotia_llm::LlmEngine;
use lumotia_llm::LlmModelId;

#[test]
fn llama_cpp_2_smoke_generates_and_wraps() {
    let model_path = match env::var("LUMOTIA_LLM_TEST_MODEL") {
        Ok(path) => PathBuf::from(path),
        Err(_) => {
            eprintln!("LUMOTIA_LLM_TEST_MODEL not set — skipping");
            return;
        }
    };

    let engine = LlmEngine::new();
    engine
        .load_model(LlmModelId::Qwen3_5_2B_Q4, &model_path, true)
        .expect("load model");

    let completion = engine
        .generate(
            "Write exactly one short greeting.",
            &lumotia_llm::GenerationConfig {
                max_tokens: 32,
                temperature: 0.0,
                stop_sequences: vec!["\n".to_string()],
                grammar: None,
            },
        )
        .expect("generate");
    assert!(!completion.trim().is_empty());

    let cleaned = engine
        .cleanup_text(
            "You are a transcript cleanup assistant. Remove fillers and output only cleaned text.",
            "um hello there like general kenobi",
        )
        .expect("cleanup_text");
    assert!(!cleaned.trim().is_empty());

    let tasks = engine
        .extract_tasks("I need to call the plumber tomorrow and buy milk.")
        .expect("extract_tasks");
    assert!(!tasks.is_empty());

    let steps = engine
        .decompose_task("Plan a weekend trip to the coast")
        .expect("decompose_task");
    assert!((3..=7).contains(&steps.len()));
}
